aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/00-INDEX3
-rw-r--r--Documentation/ABI/testing/sysfs-profiling13
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/procfs-guide.tmpl29
-rw-r--r--Documentation/DocBook/procfs_example.c20
-rw-r--r--Documentation/DocBook/videobook.tmpl1654
-rw-r--r--Documentation/HOWTO4
-rw-r--r--Documentation/SAK.txt2
-rw-r--r--Documentation/SubmitChecklist3
-rw-r--r--Documentation/SubmittingDrivers2
-rw-r--r--Documentation/SubmittingPatches11
-rw-r--r--Documentation/block/data-integrity.txt4
-rw-r--r--Documentation/cris/README2
-rw-r--r--Documentation/development-process/1.Intro274
-rw-r--r--Documentation/development-process/2.Process459
-rw-r--r--Documentation/development-process/3.Early-stage195
-rw-r--r--Documentation/development-process/4.Coding384
-rw-r--r--Documentation/development-process/5.Posting278
-rw-r--r--Documentation/development-process/6.Followthrough202
-rw-r--r--Documentation/development-process/7.AdvancedTopics173
-rw-r--r--Documentation/development-process/8.Conclusion74
-rw-r--r--Documentation/dontdiff59
-rw-r--r--Documentation/fb/intelfb.txt1
-rw-r--r--Documentation/fb/uvesafb.txt4
-rw-r--r--Documentation/fb/viafb.modes870
-rw-r--r--Documentation/fb/viafb.txt214
-rw-r--r--Documentation/feature-removal-schedule.txt9
-rw-r--r--Documentation/filesystems/autofs4-mount-control.txt393
-rw-r--r--Documentation/filesystems/ext3.txt3
-rw-r--r--Documentation/filesystems/nfsroot.txt2
-rw-r--r--Documentation/filesystems/proc.txt12
-rw-r--r--Documentation/filesystems/ramfs-rootfs-initramfs.txt2
-rw-r--r--Documentation/gpio.txt9
-rw-r--r--Documentation/ia64/kvm.txt9
-rw-r--r--Documentation/kernel-parameters.txt6
-rw-r--r--Documentation/kobject.txt4
-rw-r--r--Documentation/networking/cs89x0.txt4
-rw-r--r--Documentation/networking/phonet.txt4
-rw-r--r--Documentation/networking/vortex.txt9
-rw-r--r--Documentation/power/s2ram.txt18
-rw-r--r--Documentation/scsi/ChangeLog.megaraid6
-rw-r--r--Documentation/spi/pxa2xx34
-rw-r--r--Documentation/w1/00-INDEX2
-rw-r--r--Documentation/w1/masters/ds249052
-rw-r--r--Documentation/w1/slaves/00-INDEX4
-rw-r--r--Documentation/w1/slaves/w1_therm41
-rw-r--r--Documentation/w1/w1.generic11
-rw-r--r--MAINTAINERS33
-rw-r--r--arch/Kconfig18
-rw-r--r--arch/alpha/Kconfig3
-rw-r--r--arch/alpha/include/asm/a.out.h2
-rw-r--r--arch/alpha/include/asm/elf.h4
-rw-r--r--arch/alpha/kernel/pci_iommu.c17
-rw-r--r--arch/alpha/kernel/smp.c1
-rw-r--r--arch/arm/Kconfig2
-rw-r--r--arch/arm/Makefile3
-rw-r--r--arch/arm/common/Kconfig2
-rw-r--r--arch/arm/common/sa1111.c2
-rw-r--r--arch/arm/configs/omap3_beagle_defconfig1321
-rw-r--r--arch/arm/configs/omap_ldp_defconfig1044
-rw-r--r--arch/arm/configs/overo_defconfig1885
-rw-r--r--arch/arm/include/asm/elf.h2
-rw-r--r--arch/arm/mach-integrator/cpu.c1
-rw-r--r--arch/arm/mach-ixp4xx/Kconfig5
-rw-r--r--arch/arm/mach-omap1/clock.c10
-rw-r--r--arch/arm/mach-omap1/clock.h6
-rw-r--r--arch/arm/mach-omap1/devices.c2
-rw-r--r--arch/arm/mach-omap1/mcbsp.c45
-rw-r--r--arch/arm/mach-omap1/serial.c12
-rw-r--r--arch/arm/mach-omap2/Kconfig22
-rw-r--r--arch/arm/mach-omap2/Makefile12
-rw-r--r--arch/arm/mach-omap2/board-ldp.c86
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c244
-rw-r--r--arch/arm/mach-omap2/board-overo.c242
-rw-r--r--arch/arm/mach-omap2/clock.c64
-rw-r--r--arch/arm/mach-omap2/clock.h2
-rw-r--r--arch/arm/mach-omap2/clock24xx.h238
-rw-r--r--arch/arm/mach-omap2/clock34xx.c31
-rw-r--r--arch/arm/mach-omap2/clock34xx.h248
-rw-r--r--arch/arm/mach-omap2/clockdomain.c623
-rw-r--r--arch/arm/mach-omap2/clockdomains.h305
-rw-r--r--arch/arm/mach-omap2/cm-regbits-24xx.h24
-rw-r--r--arch/arm/mach-omap2/cm-regbits-34xx.h42
-rw-r--r--arch/arm/mach-omap2/cm.h2
-rw-r--r--arch/arm/mach-omap2/devices.c225
-rw-r--r--arch/arm/mach-omap2/gpmc.c88
-rw-r--r--arch/arm/mach-omap2/id.c39
-rw-r--r--arch/arm/mach-omap2/io.c152
-rw-r--r--arch/arm/mach-omap2/irq.c81
-rw-r--r--arch/arm/mach-omap2/mcbsp.c151
-rw-r--r--arch/arm/mach-omap2/memory.c14
-rw-r--r--arch/arm/mach-omap2/memory.h7
-rw-r--r--arch/arm/mach-omap2/mux.c245
-rw-r--r--arch/arm/mach-omap2/powerdomain.c1113
-rw-r--r--arch/arm/mach-omap2/powerdomains.h187
-rw-r--r--arch/arm/mach-omap2/powerdomains24xx.h200
-rw-r--r--arch/arm/mach-omap2/powerdomains34xx.h327
-rw-r--r--arch/arm/mach-omap2/prcm-common.h3
-rw-r--r--arch/arm/mach-omap2/prm-regbits-24xx.h12
-rw-r--r--arch/arm/mach-omap2/prm-regbits-34xx.h11
-rw-r--r--arch/arm/mach-omap2/prm.h5
-rw-r--r--arch/arm/mach-omap2/serial.c116
-rw-r--r--arch/arm/mach-omap2/sleep24xx.S (renamed from arch/arm/mach-omap2/sleep.S)32
-rw-r--r--arch/arm/mach-omap2/sram34xx.S179
-rw-r--r--arch/arm/mach-pxa/Kconfig1
-rw-r--r--arch/arm/mach-pxa/cm-x270.c2
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa2xx.c3
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa3xx.c1
-rw-r--r--arch/arm/mach-pxa/include/mach/irqs.h5
-rw-r--r--arch/arm/mach-pxa/pwm.c2
-rw-r--r--arch/arm/mach-pxa/viper.c54
-rw-r--r--arch/arm/mach-s3c2410/bast-irq.c2
-rw-r--r--arch/arm/mach-s3c2410/clock.c8
-rw-r--r--arch/arm/mach-s3c2410/dma.c6
-rw-r--r--arch/arm/mach-s3c2410/include/mach/debug-macro.S4
-rw-r--r--arch/arm/mach-s3c2410/include/mach/map.h2
-rw-r--r--arch/arm/mach-s3c2410/include/mach/spi.h1
-rw-r--r--arch/arm/mach-s3c2410/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-s3c2410/irq.c4
-rw-r--r--arch/arm/mach-s3c2410/mach-amlm5900.c6
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c8
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c10
-rw-r--r--arch/arm/mach-s3c2410/mach-n30.c10
-rw-r--r--arch/arm/mach-s3c2410/mach-otom.c10
-rw-r--r--arch/arm/mach-s3c2410/mach-qt2410.c10
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2410.c8
-rw-r--r--arch/arm/mach-s3c2410/mach-tct_hammer.c6
-rw-r--r--arch/arm/mach-s3c2410/mach-vr1000.c8
-rw-r--r--arch/arm/mach-s3c2410/pm.c4
-rw-r--r--arch/arm/mach-s3c2410/s3c2410.c10
-rw-r--r--arch/arm/mach-s3c2410/sleep.S2
-rw-r--r--arch/arm/mach-s3c2410/usb-simtec.c2
-rw-r--r--arch/arm/mach-s3c2412/clock.c8
-rw-r--r--arch/arm/mach-s3c2412/dma.c6
-rw-r--r--arch/arm/mach-s3c2412/irq.c6
-rw-r--r--arch/arm/mach-s3c2412/mach-jive.c10
-rw-r--r--arch/arm/mach-s3c2412/mach-smdk2413.c14
-rw-r--r--arch/arm/mach-s3c2412/mach-vstms.c12
-rw-r--r--arch/arm/mach-s3c2412/pm.c6
-rw-r--r--arch/arm/mach-s3c2412/s3c2412.c12
-rw-r--r--arch/arm/mach-s3c2440/clock.c4
-rw-r--r--arch/arm/mach-s3c2440/dma.c6
-rw-r--r--arch/arm/mach-s3c2440/dsc.c4
-rw-r--r--arch/arm/mach-s3c2440/irq.c6
-rw-r--r--arch/arm/mach-s3c2440/mach-anubis.c8
-rw-r--r--arch/arm/mach-s3c2440/mach-at2440evb.c8
-rw-r--r--arch/arm/mach-s3c2440/mach-nexcoder.c12
-rw-r--r--arch/arm/mach-s3c2440/mach-osiris.c8
-rw-r--r--arch/arm/mach-s3c2440/mach-rx3715.c10
-rw-r--r--arch/arm/mach-s3c2440/mach-smdk2440.c14
-rw-r--r--arch/arm/mach-s3c2440/s3c2440.c6
-rw-r--r--arch/arm/mach-s3c2442/clock.c4
-rw-r--r--arch/arm/mach-s3c2442/s3c2442.c4
-rw-r--r--arch/arm/mach-s3c2443/clock.c6
-rw-r--r--arch/arm/mach-s3c2443/dma.c6
-rw-r--r--arch/arm/mach-s3c2443/irq.c6
-rw-r--r--arch/arm/mach-s3c2443/mach-smdk2443.c14
-rw-r--r--arch/arm/mach-s3c2443/s3c2443.c6
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c1
-rw-r--r--arch/arm/mm/Kconfig2
-rw-r--r--arch/arm/mm/cache-v4.S6
-rw-r--r--arch/arm/plat-omap/Kconfig33
-rw-r--r--arch/arm/plat-omap/Makefile2
-rw-r--r--arch/arm/plat-omap/common.c40
-rw-r--r--arch/arm/plat-omap/devices.c22
-rw-r--r--arch/arm/plat-omap/dma.c8
-rw-r--r--arch/arm/plat-omap/dmtimer.c2
-rw-r--r--arch/arm/plat-omap/gpio.c70
-rw-r--r--arch/arm/plat-omap/include/mach/board-2430sdp.h6
-rw-r--r--arch/arm/plat-omap/include/mach/board-apollon.h6
-rw-r--r--arch/arm/plat-omap/include/mach/board-h4.h5
-rw-r--r--arch/arm/plat-omap/include/mach/board-ldp.h36
-rw-r--r--arch/arm/plat-omap/include/mach/board-omap3beagle.h33
-rw-r--r--arch/arm/plat-omap/include/mach/board-overo.h26
-rw-r--r--arch/arm/plat-omap/include/mach/board.h2
-rw-r--r--arch/arm/plat-omap/include/mach/clock.h3
-rw-r--r--arch/arm/plat-omap/include/mach/clockdomain.h106
-rw-r--r--arch/arm/plat-omap/include/mach/common.h3
-rw-r--r--arch/arm/plat-omap/include/mach/control.h23
-rw-r--r--arch/arm/plat-omap/include/mach/cpu.h5
-rw-r--r--arch/arm/plat-omap/include/mach/debug-macro.S12
-rw-r--r--arch/arm/plat-omap/include/mach/entry-macro.S12
-rw-r--r--arch/arm/plat-omap/include/mach/fpga.h12
-rw-r--r--arch/arm/plat-omap/include/mach/gpio.h4
-rw-r--r--arch/arm/plat-omap/include/mach/gpmc.h12
-rw-r--r--arch/arm/plat-omap/include/mach/hardware.h12
-rw-r--r--arch/arm/plat-omap/include/mach/io.h59
-rw-r--r--arch/arm/plat-omap/include/mach/irqs.h59
-rw-r--r--arch/arm/plat-omap/include/mach/mcbsp.h44
-rw-r--r--arch/arm/plat-omap/include/mach/memory.h2
-rw-r--r--arch/arm/plat-omap/include/mach/mux.h180
-rw-r--r--arch/arm/plat-omap/include/mach/omap1510.h2
-rw-r--r--arch/arm/plat-omap/include/mach/omap16xx.h7
-rw-r--r--arch/arm/plat-omap/include/mach/omap24xx.h2
-rw-r--r--arch/arm/plat-omap/include/mach/omapfb.h3
-rw-r--r--arch/arm/plat-omap/include/mach/pm.h7
-rw-r--r--arch/arm/plat-omap/include/mach/powerdomain.h166
-rw-r--r--arch/arm/plat-omap/include/mach/sdrc.h8
-rw-r--r--arch/arm/plat-omap/include/mach/serial.h18
-rw-r--r--arch/arm/plat-omap/include/mach/sram.h10
-rw-r--r--arch/arm/plat-omap/include/mach/system.h2
-rw-r--r--arch/arm/plat-omap/io.c107
-rw-r--r--arch/arm/plat-omap/mcbsp.c431
-rw-r--r--arch/arm/plat-omap/sram.c53
-rw-r--r--arch/arm/plat-s3c/Makefile3
-rw-r--r--arch/arm/plat-s3c/include/plat/debug-macro.S (renamed from include/asm-arm/plat-s3c/debug-macro.S)2
-rw-r--r--arch/arm/plat-s3c/include/plat/map.h (renamed from include/asm-arm/plat-s3c/map.h)0
-rw-r--r--arch/arm/plat-s3c/include/plat/regs-adc.h (renamed from include/asm-arm/plat-s3c/regs-adc.h)0
-rw-r--r--arch/arm/plat-s3c/include/plat/regs-serial.h (renamed from include/asm-arm/plat-s3c/regs-serial.h)0
-rw-r--r--arch/arm/plat-s3c/include/plat/regs-timer.h (renamed from include/asm-arm/plat-s3c/regs-timer.h)0
-rw-r--r--arch/arm/plat-s3c/include/plat/uncompress.h (renamed from include/asm-arm/plat-s3c/uncompress.h)2
-rw-r--r--arch/arm/plat-s3c24xx/clock.c4
-rw-r--r--arch/arm/plat-s3c24xx/common-smdk.c6
-rw-r--r--arch/arm/plat-s3c24xx/cpu.c22
-rw-r--r--arch/arm/plat-s3c24xx/devs.c6
-rw-r--r--arch/arm/plat-s3c24xx/dma.c2
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/clock.h (renamed from include/asm-arm/plat-s3c24xx/clock.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/common-smdk.h (renamed from include/asm-arm/plat-s3c24xx/common-smdk.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/cpu.h (renamed from include/asm-arm/plat-s3c24xx/cpu.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/devs.h (renamed from include/asm-arm/plat-s3c24xx/devs.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/dma.h (renamed from include/asm-arm/plat-s3c24xx/dma.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/irq.h (renamed from include/asm-arm/plat-s3c24xx/irq.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/pm.h (renamed from include/asm-arm/plat-s3c24xx/pm.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2400.h (renamed from include/asm-arm/plat-s3c24xx/s3c2400.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2410.h (renamed from include/asm-arm/plat-s3c24xx/s3c2410.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2412.h (renamed from include/asm-arm/plat-s3c24xx/s3c2412.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2440.h (renamed from include/asm-arm/plat-s3c24xx/s3c2440.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2442.h (renamed from include/asm-arm/plat-s3c24xx/s3c2442.h)0
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2443.h (renamed from include/asm-arm/plat-s3c24xx/s3c2443.h)0
-rw-r--r--arch/arm/plat-s3c24xx/irq.c6
-rw-r--r--arch/arm/plat-s3c24xx/pm-simtec.c2
-rw-r--r--arch/arm/plat-s3c24xx/pm.c4
-rw-r--r--arch/arm/plat-s3c24xx/pwm-clock.c6
-rw-r--r--arch/arm/plat-s3c24xx/pwm.c4
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x-clock.c4
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x-irq.c6
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x.c14
-rw-r--r--arch/arm/plat-s3c24xx/sleep.S2
-rw-r--r--arch/arm/plat-s3c24xx/time.c6
-rw-r--r--arch/avr32/include/asm/elf.h2
-rw-r--r--arch/avr32/mach-at32ap/cpufreq.c1
-rw-r--r--arch/blackfin/configs/BF526-EZBRD_defconfig2
-rw-r--r--arch/blackfin/configs/BF527-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF533-EZKIT_defconfig4
-rw-r--r--arch/blackfin/configs/BF533-STAMP_defconfig2
-rw-r--r--arch/blackfin/configs/BF537-STAMP_defconfig4
-rw-r--r--arch/blackfin/configs/BF548-EZKIT_defconfig4
-rw-r--r--arch/blackfin/configs/BF561-EZKIT_defconfig4
-rw-r--r--arch/blackfin/configs/CM-BF527_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF533_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF537E_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF537U_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF548_defconfig4
-rw-r--r--arch/blackfin/configs/CM-BF561_defconfig2
-rw-r--r--arch/blackfin/include/asm/cacheflush.h27
-rw-r--r--arch/blackfin/include/asm/cplbinit.h17
-rw-r--r--arch/blackfin/include/asm/elf.h2
-rw-r--r--arch/blackfin/include/asm/io.h30
-rw-r--r--arch/blackfin/include/asm/timex.h2
-rw-r--r--arch/blackfin/kernel/cplb-mpu/cplbmgr.c5
-rw-r--r--arch/blackfin/kernel/cplb-nompu/cplbinit.c1
-rw-r--r--arch/blackfin/mach-bf527/head.S2
-rw-r--r--arch/blackfin/mach-bf533/head.S2
-rw-r--r--arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h2
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c25
-rw-r--r--arch/blackfin/mach-bf537/head.S2
-rw-r--r--arch/blackfin/mach-bf548/head.S2
-rw-r--r--arch/blackfin/mach-bf561/head.S2
-rw-r--r--arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h2
-rw-r--r--arch/blackfin/mach-common/cache.S173
-rw-r--r--arch/blackfin/mach-common/cpufreq.c2
-rw-r--r--arch/blackfin/mach-common/head.S54
-rw-r--r--arch/cris/arch-v32/mach-a3/cpufreq.c1
-rw-r--r--arch/cris/arch-v32/mach-fs/cpufreq.c1
-rw-r--r--arch/frv/kernel/pm.c6
-rw-r--r--arch/frv/mb93090-mb00/pci-dma-nommu.c23
-rw-r--r--arch/frv/mb93090-mb00/pci-dma.c11
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.c32
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.h1
-rw-r--r--arch/frv/mb93090-mb00/pci-vdk.c2
-rw-r--r--arch/frv/mm/init.c2
-rw-r--r--arch/h8300/Kconfig4
-rw-r--r--arch/h8300/Kconfig.cpu115
-rw-r--r--arch/h8300/include/asm/bug.h4
-rw-r--r--arch/h8300/include/asm/elf.h2
-rw-r--r--arch/h8300/include/asm/io.h34
-rw-r--r--arch/h8300/include/asm/md.h2
-rw-r--r--arch/h8300/include/asm/system.h2
-rw-r--r--arch/h8300/kernel/Makefile2
-rw-r--r--arch/h8300/kernel/module.c3
-rw-r--r--arch/h8300/kernel/time.c29
-rw-r--r--arch/h8300/kernel/timer/Makefile6
-rw-r--r--arch/h8300/kernel/timer/itu.c83
-rw-r--r--arch/h8300/kernel/timer/timer16.c78
-rw-r--r--arch/h8300/kernel/timer/timer8.c103
-rw-r--r--arch/h8300/kernel/timer/tpu.c102
-rw-r--r--arch/h8300/kernel/traps.c17
-rw-r--r--arch/h8300/mm/fault.c5
-rw-r--r--arch/h8300/platform/h8300h/aki3068net/Makefile1
-rw-r--r--arch/h8300/platform/h8300h/aki3068net/timer.c51
-rw-r--r--arch/h8300/platform/h8300h/generic/Makefile1
-rw-r--r--arch/h8300/platform/h8300h/generic/timer.c95
-rw-r--r--arch/h8300/platform/h8300h/h8max/Makefile1
-rw-r--r--arch/h8300/platform/h8300h/h8max/timer.c52
-rw-r--r--arch/h8300/platform/h8s/edosk2674/Makefile1
-rw-r--r--arch/h8300/platform/h8s/edosk2674/timer.c54
-rw-r--r--arch/h8300/platform/h8s/generic/Makefile1
-rw-r--r--arch/h8300/platform/h8s/generic/timer.c53
-rw-r--r--arch/ia64/Kconfig8
-rw-r--r--arch/ia64/ia32/binfmt_elf32.c2
-rw-r--r--arch/ia64/ia32/ia32_entry.S4
-rw-r--r--arch/ia64/ia32/ia32priv.h4
-rw-r--r--arch/ia64/ia32/sys_ia32.c91
-rw-r--r--arch/ia64/include/asm/elf.h2
-rw-r--r--arch/ia64/include/asm/kvm_host.h6
-rw-r--r--arch/ia64/kvm/Kconfig2
-rw-r--r--arch/ia64/kvm/Makefile6
-rw-r--r--arch/ia64/kvm/irq.h31
-rw-r--r--arch/ia64/kvm/kvm-ia64.c66
-rw-r--r--arch/ia64/kvm/kvm_minstate.h23
-rw-r--r--arch/ia64/kvm/optvfault.S181
-rw-r--r--arch/ia64/kvm/process.c4
-rw-r--r--arch/ia64/kvm/vcpu.h26
-rw-r--r--arch/ia64/kvm/vmm_ivt.S39
-rw-r--r--arch/ia64/kvm/vtlb.c23
-rw-r--r--arch/m32r/kernel/process.c2
-rw-r--r--arch/m32r/mm/discontig.c4
-rw-r--r--arch/m68knommu/include/asm/elf.h2
-rw-r--r--arch/mips/include/asm/elf.h10
-rw-r--r--arch/mips/kernel/linux32.c101
-rw-r--r--arch/mips/kernel/rtlx.c4
-rw-r--r--arch/mips/kernel/scall64-n32.S4
-rw-r--r--arch/mips/kernel/scall64-o32.S4
-rw-r--r--arch/mips/lasat/sysctl.c17
-rw-r--r--arch/mips/sibyte/common/sb_tbprof.c3
-rw-r--r--arch/parisc/kernel/binfmt_elf32.c2
-rw-r--r--arch/parisc/kernel/sys_parisc32.c105
-rw-r--r--arch/parisc/kernel/syscall_table.S4
-rw-r--r--arch/powerpc/Kconfig3
-rw-r--r--arch/powerpc/include/asm/elf.h4
-rw-r--r--arch/powerpc/include/asm/kvm_host.h14
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h12
-rw-r--r--arch/powerpc/include/asm/types.h7
-rw-r--r--arch/powerpc/kernel/asm-offsets.c4
-rw-r--r--arch/powerpc/kernel/iommu.c23
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c99
-rw-r--r--arch/powerpc/kvm/44x_tlb.c53
-rw-r--r--arch/powerpc/kvm/Kconfig11
-rw-r--r--arch/powerpc/kvm/Makefile6
-rw-r--r--arch/powerpc/kvm/booke_guest.c17
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S79
-rw-r--r--arch/powerpc/kvm/emulate.c8
-rw-r--r--arch/powerpc/kvm/powerpc.c99
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype1
-rw-r--r--arch/powerpc/sysdev/ppc4xx_pci.c16
-rw-r--r--arch/s390/Kconfig7
-rw-r--r--arch/s390/include/asm/elf.h8
-rw-r--r--arch/s390/kernel/compat_linux.c102
-rw-r--r--arch/s390/kernel/compat_linux.h4
-rw-r--r--arch/s390/kernel/compat_wrapper.S12
-rw-r--r--arch/s390/kernel/syscalls.S4
-rw-r--r--arch/s390/kvm/priv.c4
-rw-r--r--arch/sh/include/asm/elf.h2
-rw-r--r--arch/sparc/include/asm/elf_32.h2
-rw-r--r--arch/sparc/include/asm/elf_64.h6
-rw-r--r--arch/sparc64/kernel/iommu.c7
-rw-r--r--arch/sparc64/kernel/iommu_common.h14
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c7
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c97
-rw-r--r--arch/sparc64/kernel/systbls.S4
-rw-r--r--arch/sparc64/kernel/us3_cpufreq.c1
-rw-r--r--arch/um/kernel/exec.c12
-rw-r--r--arch/um/os-Linux/Makefile3
-rw-r--r--arch/um/os-Linux/tty_log.c217
-rw-r--r--arch/x86/Kconfig27
-rw-r--r--arch/x86/boot/video-vesa.c9
-rw-r--r--arch/x86/ia32/ia32entry.S4
-rw-r--r--arch/x86/ia32/sys_ia32.c99
-rw-r--r--arch/x86/kernel/amd_iommu.c9
-rw-r--r--arch/x86/kernel/cpuid.c4
-rw-r--r--arch/x86/kernel/dumpstack_32.c2
-rw-r--r--arch/x86/kernel/dumpstack_64.c2
-rw-r--r--arch/x86/kernel/e820.c4
-rw-r--r--arch/x86/kernel/kvmclock.c30
-rw-r--r--arch/x86/kernel/msr.c4
-rw-r--r--arch/x86/kernel/pci-calgary_64.c18
-rw-r--r--arch/x86/kernel/pci-dma.c4
-rw-r--r--arch/x86/kernel/pci-gart_64.c8
-rw-r--r--arch/x86/kernel/pvclock.c12
-rw-r--r--arch/x86/kernel/smpboot.c14
-rw-r--r--arch/x86/kvm/Makefile5
-rw-r--r--arch/x86/kvm/i8254.c81
-rw-r--r--arch/x86/kvm/i8254.h7
-rw-r--r--arch/x86/kvm/i8259.c53
-rw-r--r--arch/x86/kvm/irq.c3
-rw-r--r--arch/x86/kvm/irq.h6
-rw-r--r--arch/x86/kvm/kvm_cache_regs.h32
-rw-r--r--arch/x86/kvm/lapic.c43
-rw-r--r--arch/x86/kvm/mmu.c680
-rw-r--r--arch/x86/kvm/paging_tmpl.h249
-rw-r--r--arch/x86/kvm/svm.c156
-rw-r--r--arch/x86/kvm/vmx.c712
-rw-r--r--arch/x86/kvm/vmx.h3
-rw-r--r--arch/x86/kvm/x86.c554
-rw-r--r--arch/x86/kvm/x86.h22
-rw-r--r--arch/x86/kvm/x86_emulate.c170
-rw-r--r--arch/x86/mm/fault.c45
-rw-r--r--arch/x86/mm/ioremap.c6
-rw-r--r--arch/x86/xen/time.c11
-rw-r--r--block/bsg.c3
-rw-r--r--drivers/base/Kconfig2
-rw-r--r--drivers/base/bus.c54
-rw-r--r--drivers/base/core.c30
-rw-r--r--drivers/base/dd.c3
-rw-r--r--drivers/base/firmware_class.c24
-rw-r--r--drivers/base/platform.c80
-rw-r--r--drivers/base/power/main.c9
-rw-r--r--drivers/block/aoe/aoechr.c6
-rw-r--r--drivers/block/paride/pg.c5
-rw-r--r--drivers/block/paride/pt.c10
-rw-r--r--drivers/block/pktcdvd.c5
-rw-r--r--drivers/char/Kconfig9
-rw-r--r--drivers/char/agp/amd-k7-agp.c38
-rw-r--r--drivers/char/agp/intel-agp.c18
-rw-r--r--drivers/char/agp/nvidia-agp.c22
-rw-r--r--drivers/char/applicom.c2
-rw-r--r--drivers/char/bsr.c5
-rw-r--r--drivers/char/ds1286.c4
-rw-r--r--drivers/char/dsp56k.c4
-rw-r--r--drivers/char/hw_random/omap-rng.c33
-rw-r--r--drivers/char/ip2/ip2main.c12
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c2
-rw-r--r--drivers/char/istallion.c5
-rw-r--r--drivers/char/keyboard.c2
-rw-r--r--drivers/char/lp.c4
-rw-r--r--drivers/char/mem.c6
-rw-r--r--drivers/char/misc.c4
-rw-r--r--drivers/char/moxa.c2
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c3
-rw-r--r--drivers/char/ppdev.c5
-rw-r--r--drivers/char/random.c2
-rw-r--r--drivers/char/raw.c7
-rw-r--r--drivers/char/rtc.c2
-rw-r--r--drivers/char/snsc.c4
-rw-r--r--drivers/char/stallion.c4
-rw-r--r--drivers/char/sysrq.c31
-rw-r--r--drivers/char/tpm/tpm.c36
-rw-r--r--drivers/char/tty_io.c2
-rw-r--r--drivers/char/vc_screen.c12
-rw-r--r--drivers/char/viotape.c8
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c3
-rw-r--r--drivers/dca/dca-sysfs.c8
-rw-r--r--drivers/edac/i5000_edac.c196
-rw-r--r--drivers/edac/i82443bxgx_edac.c63
-rw-r--r--drivers/edac/mpc85xx_edac.c33
-rw-r--r--drivers/firewire/fw-card.c56
-rw-r--r--drivers/firewire/fw-cdev.c6
-rw-r--r--drivers/firewire/fw-device.c37
-rw-r--r--drivers/firewire/fw-sbp2.c116
-rw-r--r--drivers/firewire/fw-transaction.c48
-rw-r--r--drivers/firewire/fw-transaction.h9
-rw-r--r--drivers/firmware/dmi_scan.c22
-rw-r--r--drivers/firmware/iscsi_ibft.c18
-rw-r--r--drivers/gpio/gpiolib.c111
-rw-r--r--drivers/gpio/max7301.c24
-rw-r--r--drivers/gpio/max732x.c5
-rw-r--r--drivers/gpio/mcp23s08.c5
-rw-r--r--drivers/gpio/pca953x.c5
-rw-r--r--drivers/gpio/pcf857x.c5
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c4
-rw-r--r--drivers/hid/Kconfig122
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hidraw.c5
-rw-r--r--drivers/hwmon/hwmon.c4
-rw-r--r--drivers/i2c/busses/i2c-omap.c12
-rw-r--r--drivers/i2c/i2c-dev.c6
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/ide/ide-probe.c4
-rw-r--r--drivers/ide/ide-tape.c11
-rw-r--r--drivers/ieee1394/csr1212.c2
-rw-r--r--drivers/ieee1394/dv1394.c10
-rw-r--r--drivers/ieee1394/eth1394.c2
-rw-r--r--drivers/ieee1394/nodemgr.c279
-rw-r--r--drivers/ieee1394/nodemgr.h2
-rw-r--r--drivers/ieee1394/raw1394-private.h1
-rw-r--r--drivers/ieee1394/raw1394.c238
-rw-r--r--drivers/ieee1394/sbp2.c218
-rw-r--r--drivers/ieee1394/sbp2.h33
-rw-r--r--drivers/ieee1394/video1394.c13
-rw-r--r--drivers/infiniband/core/cm.c6
-rw-r--r--drivers/infiniband/core/user_mad.c12
-rw-r--r--drivers/infiniband/core/uverbs_main.c9
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c2
-rw-r--r--drivers/input/gameport/gameport.c88
-rw-r--r--drivers/input/joystick/a3d.c3
-rw-r--r--drivers/input/joystick/adi.c3
-rw-r--r--drivers/input/joystick/analog.c4
-rw-r--r--drivers/input/joystick/cobra.c3
-rw-r--r--drivers/input/joystick/gf2k.c3
-rw-r--r--drivers/input/joystick/grip.c3
-rw-r--r--drivers/input/joystick/grip_mp.c3
-rw-r--r--drivers/input/joystick/guillemot.c3
-rw-r--r--drivers/input/joystick/interact.c3
-rw-r--r--drivers/input/joystick/joydump.c3
-rw-r--r--drivers/input/joystick/sidewinder.c3
-rw-r--r--drivers/input/joystick/tmdc.c3
-rw-r--r--drivers/input/joystick/xpad.c4
-rw-r--r--drivers/input/keyboard/atkbd.c30
-rw-r--r--drivers/input/keyboard/bf54x-keys.c13
-rw-r--r--drivers/input/keyboard/gpio_keys.c42
-rw-r--r--drivers/input/keyboard/omap-keypad.c29
-rw-r--r--drivers/input/misc/Kconfig13
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ati_remote2.c263
-rw-r--r--drivers/input/misc/cm109.c882
-rw-r--r--drivers/input/misc/wistron_btns.c19
-rw-r--r--drivers/input/misc/yealink.c2
-rw-r--r--drivers/input/mouse/Kconfig10
-rw-r--r--drivers/input/mouse/Makefile1
-rw-r--r--drivers/input/mouse/alps.c1
-rw-r--r--drivers/input/mouse/appletouch.c299
-rw-r--r--drivers/input/mouse/hgpk.c477
-rw-r--r--drivers/input/mouse/hgpk.h49
-rw-r--r--drivers/input/mouse/logips2pp.c4
-rw-r--r--drivers/input/mouse/psmouse-base.c81
-rw-r--r--drivers/input/mouse/psmouse.h14
-rw-r--r--drivers/input/mouse/trackpoint.c8
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h7
-rw-r--r--drivers/input/serio/serio_raw.c6
-rw-r--r--drivers/input/tablet/aiptek.c53
-rw-r--r--drivers/input/touchscreen/ads7846.c94
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c37
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c5
-rw-r--r--drivers/input/touchscreen/wm9705.c5
-rw-r--r--drivers/input/touchscreen/wm9712.c5
-rw-r--r--drivers/input/touchscreen/wm9713.c5
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c5
-rw-r--r--drivers/isdn/capi/capi.c3
-rw-r--r--drivers/leds/led-class.c4
-rw-r--r--drivers/macintosh/adb.c3
-rw-r--r--drivers/md/faulty.c2
-rw-r--r--drivers/md/linear.c133
-rw-r--r--drivers/md/md.c81
-rw-r--r--drivers/md/multipath.c9
-rw-r--r--drivers/md/raid0.c5
-rw-r--r--drivers/md/raid1.c1
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c42
-rw-r--r--drivers/md/raid6.h9
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c2
-rw-r--r--drivers/media/video/cpia.c4
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c4
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c4
-rw-r--r--drivers/media/video/v4l1-compat.c4
-rw-r--r--drivers/media/video/v4l2-common.c4
-rw-r--r--drivers/media/video/vino.c5
-rw-r--r--drivers/media/video/w9968cf.c4
-rw-r--r--drivers/message/i2o/Makefile2
-rw-r--r--drivers/message/i2o/device.c2
-rw-r--r--drivers/message/i2o/exec-osm.c4
-rw-r--r--drivers/message/i2o/i2o_config.c31
-rw-r--r--drivers/message/i2o/iop.c2
-rw-r--r--drivers/message/i2o/memory.c313
-rw-r--r--drivers/message/i2o/pci.c16
-rw-r--r--drivers/misc/Kconfig3
-rw-r--r--drivers/misc/hp-wmi.c2
-rw-r--r--drivers/misc/phantom.c6
-rw-r--r--drivers/misc/sgi-gru/gru.h4
-rw-r--r--drivers/misc/sgi-gru/gru_instructions.h10
-rw-r--r--drivers/misc/sgi-gru/grufault.c11
-rw-r--r--drivers/misc/sgi-gru/grufile.c8
-rw-r--r--drivers/misc/sgi-gru/gruhandles.h5
-rw-r--r--drivers/misc/sgi-gru/grukservices.c3
-rw-r--r--drivers/misc/sgi-gru/grumain.c29
-rw-r--r--drivers/mmc/host/omap.c11
-rw-r--r--drivers/mtd/mtdchar.c10
-rw-r--r--drivers/mtd/mtdpart.c2
-rw-r--r--drivers/mtd/nand/ams-delta.c4
-rw-r--r--drivers/net/3c509.c2
-rw-r--r--drivers/net/cs89x0.c13
-rw-r--r--drivers/net/irda/sir_dongle.c2
-rw-r--r--drivers/net/phy/phy_device.c8
-rw-r--r--drivers/net/ppp_generic.c14
-rw-r--r--drivers/net/pppox.c9
-rw-r--r--drivers/net/wan/cosa.c4
-rw-r--r--drivers/net/wireless/ath9k/main.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c2
-rw-r--r--drivers/net/wireless/libertas/cmd.c2
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c6
-rw-r--r--drivers/net/wireless/orinoco_cs.c5
-rw-r--r--drivers/net/wireless/p54/p54common.c1
-rw-r--r--drivers/net/wireless/p54/p54usb.c3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c9
-rw-r--r--drivers/net/wireless/rtl8187_dev.c3
-rw-r--r--drivers/net/wireless/spectrum_cs.c5
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/nubus/nubus.c2
-rw-r--r--drivers/parport/ChangeLog2
-rw-r--r--drivers/parport/ieee1284.c2
-rw-r--r--drivers/parport/probe.c2
-rw-r--r--drivers/parport/share.c2
-rw-r--r--drivers/pci/dmar.c4
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c2
-rw-r--r--drivers/pci/intel-iommu.c116
-rw-r--r--drivers/pci/intr_remapping.c2
-rw-r--r--drivers/pci/intr_remapping.h2
-rw-r--r--drivers/pci/iova.c2
-rw-r--r--drivers/pci/probe.c50
-rw-r--r--drivers/pci/quirks.c3
-rw-r--r--drivers/pci/setup-bus.c9
-rw-r--r--drivers/pcmcia/Makefile3
-rw-r--r--drivers/pnp/base.h4
-rw-r--r--drivers/pnp/core.c11
-rw-r--r--drivers/pnp/driver.c1
-rw-r--r--drivers/pnp/interface.c37
-rw-r--r--drivers/pnp/quirks.c5
-rw-r--r--drivers/pnp/resource.c4
-rw-r--r--drivers/power/olpc_battery.c20
-rw-r--r--drivers/power/power_supply_core.c4
-rw-r--r--drivers/rtc/Kconfig25
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-at91rm9200.c4
-rw-r--r--drivers/rtc/rtc-dev.c12
-rw-r--r--drivers/rtc/rtc-ds1286.c1
-rw-r--r--drivers/rtc/rtc-ds1307.c308
-rw-r--r--drivers/rtc/rtc-ds1374.c21
-rw-r--r--drivers/rtc/rtc-ds1511.c13
-rw-r--r--drivers/rtc/rtc-ds1553.c12
-rw-r--r--drivers/rtc/rtc-ds1672.c114
-rw-r--r--drivers/rtc/rtc-ds3234.c290
-rw-r--r--drivers/rtc/rtc-m41t80.c43
-rw-r--r--drivers/rtc/rtc-m48t35.c1
-rw-r--r--drivers/rtc/rtc-max6900.c223
-rw-r--r--drivers/rtc/rtc-pcf8563.c58
-rw-r--r--drivers/rtc/rtc-pl030.c11
-rw-r--r--drivers/rtc/rtc-pl031.c14
-rw-r--r--drivers/rtc/rtc-rs5c372.c228
-rw-r--r--drivers/rtc/rtc-sh.c7
-rw-r--r--drivers/rtc/rtc-stk17ta8.c12
-rw-r--r--drivers/s390/char/raw3270.c14
-rw-r--r--drivers/s390/char/tape_class.c6
-rw-r--r--drivers/s390/char/vmlogrdr.c8
-rw-r--r--drivers/s390/char/vmur.c5
-rw-r--r--drivers/s390/net/ctcm_mpc.c2
-rw-r--r--drivers/scsi/ch.c6
-rw-r--r--drivers/scsi/dpt_i2o.c2
-rw-r--r--drivers/scsi/osst.c3
-rw-r--r--drivers/scsi/sg.c10
-rw-r--r--drivers/scsi/st.c11
-rw-r--r--drivers/serial/8250.c23
-rw-r--r--drivers/serial/s3c2400.c2
-rw-r--r--drivers/serial/s3c2410.c2
-rw-r--r--drivers/serial/s3c2412.c2
-rw-r--r--drivers/serial/s3c2440.c2
-rw-r--r--drivers/serial/samsung.c2
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c55
-rw-r--r--drivers/spi/omap2_mcspi.c18
-rw-r--r--drivers/spi/omap_uwire.c23
-rw-r--r--drivers/spi/orion_spi.c5
-rw-r--r--drivers/spi/pxa2xx_spi.c54
-rw-r--r--drivers/spi/spi.c24
-rw-r--r--drivers/spi/spi_s3c24xx.c6
-rw-r--r--drivers/spi/spidev.c7
-rw-r--r--drivers/telephony/ixj.c2
-rw-r--r--drivers/uio/Kconfig13
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio.c26
-rw-r--r--drivers/uio/uio_pdrv.c2
-rw-r--r--drivers/uio/uio_sercos3.c243
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/core/file.c6
-rw-r--r--drivers/usb/core/hcd.c5
-rw-r--r--drivers/usb/gadget/Makefile23
-rw-r--r--drivers/usb/gadget/cdc2.c25
-rw-r--r--drivers/usb/gadget/ether.c28
-rw-r--r--drivers/usb/gadget/f_ecm.c108
-rw-r--r--drivers/usb/gadget/f_loopback.c34
-rw-r--r--drivers/usb/gadget/f_subset.c44
-rw-r--r--drivers/usb/gadget/file_storage.c12
-rw-r--r--drivers/usb/gadget/gmidi.c15
-rw-r--r--drivers/usb/gadget/printer.c18
-rw-r--r--drivers/usb/gadget/rndis.c115
-rw-r--r--drivers/usb/gadget/serial.c18
-rw-r--r--drivers/usb/gadget/u_ether.c4
-rw-r--r--drivers/usb/gadget/zero.c17
-rw-r--r--drivers/usb/host/ohci-omap.c14
-rw-r--r--drivers/usb/host/uhci-q.c24
-rw-r--r--drivers/usb/misc/phidgetkit.c5
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c5
-rw-r--r--drivers/usb/misc/phidgetservo.c5
-rw-r--r--drivers/usb/mon/mon_bin.c6
-rw-r--r--drivers/video/Kconfig109
-rw-r--r--drivers/video/Makefile3
-rw-r--r--drivers/video/atmel_lcdfb.c7
-rw-r--r--drivers/video/aty/radeon_accel.c313
-rw-r--r--drivers/video/aty/radeon_backlight.c2
-rw-r--r--drivers/video/aty/radeon_base.c35
-rw-r--r--drivers/video/aty/radeon_i2c.c4
-rw-r--r--drivers/video/aty/radeon_pm.c6
-rw-r--r--drivers/video/aty/radeonfb.h53
-rw-r--r--drivers/video/carminefb.c2
-rw-r--r--drivers/video/cirrusfb.c577
-rw-r--r--drivers/video/console/fbcon.c8
-rw-r--r--drivers/video/console/vgacon.c39
-rw-r--r--drivers/video/display/display-sysfs.c9
-rw-r--r--drivers/video/efifb.c191
-rw-r--r--drivers/video/fbmem.c22
-rw-r--r--drivers/video/fbmon.c8
-rw-r--r--drivers/video/imacfb.c376
-rw-r--r--drivers/video/intelfb/intelfb.h7
-rw-r--r--drivers/video/intelfb/intelfb_i2c.c1
-rw-r--r--drivers/video/intelfb/intelfbdrv.c7
-rw-r--r--drivers/video/intelfb/intelfbhw.c7
-rw-r--r--drivers/video/matrox/matroxfb_base.c9
-rw-r--r--drivers/video/neofb.c60
-rw-r--r--drivers/video/omap/dispc.c21
-rw-r--r--drivers/video/omap/dispc.h2
-rw-r--r--drivers/video/omap/lcd_h4.c4
-rw-r--r--drivers/video/omap/lcd_inn1610.c22
-rw-r--r--drivers/video/omap/lcd_osk.c10
-rw-r--r--drivers/video/omap/lcd_sx1.c99
-rw-r--r--drivers/video/omap/lcdc.c2
-rw-r--r--drivers/video/omap/lcdc.h2
-rw-r--r--drivers/video/omap/omapfb_main.c15
-rw-r--r--drivers/video/omap/rfbi.c9
-rw-r--r--drivers/video/omap/sossi.c8
-rw-r--r--drivers/video/s1d13xxxfb.c23
-rw-r--r--drivers/video/tdfxfb.c48
-rw-r--r--drivers/video/tmiofb.c1050
-rw-r--r--drivers/video/uvesafb.c11
-rw-r--r--drivers/video/vga16fb.c11
-rw-r--r--drivers/video/via/Makefile7
-rw-r--r--drivers/video/via/accel.c279
-rw-r--r--drivers/video/via/accel.h169
-rw-r--r--drivers/video/via/chip.h190
-rw-r--r--drivers/video/via/debug.h41
-rw-r--r--drivers/video/via/dvi.c682
-rw-r--r--drivers/video/via/dvi.h64
-rw-r--r--drivers/video/via/global.c60
-rw-r--r--drivers/video/via/global.h90
-rw-r--r--drivers/video/via/hw.c2865
-rw-r--r--drivers/video/via/hw.h933
-rw-r--r--drivers/video/via/iface.c78
-rw-r--r--drivers/video/via/iface.h38
-rw-r--r--drivers/video/via/ioctl.c112
-rw-r--r--drivers/video/via/ioctl.h210
-rw-r--r--drivers/video/via/lcd.c1821
-rw-r--r--drivers/video/via/lcd.h94
-rw-r--r--drivers/video/via/lcdtbl.h591
-rw-r--r--drivers/video/via/share.h1105
-rw-r--r--drivers/video/via/tbl1636.c71
-rw-r--r--drivers/video/via/tbl1636.h34
-rw-r--r--drivers/video/via/tblDPASetting.c109
-rw-r--r--drivers/video/via/tblDPASetting.h47
-rw-r--r--drivers/video/via/via_i2c.c177
-rw-r--r--drivers/video/via/via_i2c.h46
-rw-r--r--drivers/video/via/via_utility.c253
-rw-r--r--drivers/video/via/via_utility.h35
-rw-r--r--drivers/video/via/viafbdev.c2571
-rw-r--r--drivers/video/via/viafbdev.h112
-rw-r--r--drivers/video/via/viamode.c1086
-rw-r--r--drivers/video/via/viamode.h177
-rw-r--r--drivers/video/via/vt1636.c306
-rw-r--r--drivers/video/via/vt1636.h44
-rw-r--r--drivers/w1/masters/ds1wm.c10
-rw-r--r--drivers/w1/masters/ds2490.c348
-rw-r--r--drivers/w1/slaves/w1_ds2431.c312
-rw-r--r--drivers/w1/slaves/w1_therm.c72
-rw-r--r--drivers/w1/w1.c423
-rw-r--r--drivers/w1/w1.h34
-rw-r--r--drivers/w1/w1_family.c13
-rw-r--r--drivers/w1/w1_family.h3
-rw-r--r--drivers/w1/w1_int.c88
-rw-r--r--drivers/w1/w1_io.c85
-rw-r--r--fs/Kconfig.binfmt2
-rw-r--r--fs/Makefile3
-rw-r--r--fs/afs/file.c4
-rw-r--r--fs/afs/internal.h8
-rw-r--r--fs/afs/write.c131
-rw-r--r--fs/autofs4/Makefile2
-rw-r--r--fs/autofs4/autofs_i.h44
-rw-r--r--fs/autofs4/dev-ioctl.c863
-rw-r--r--fs/autofs4/expire.c18
-rw-r--r--fs/autofs4/init.c11
-rw-r--r--fs/autofs4/inode.c8
-rw-r--r--fs/autofs4/waitq.c42
-rw-r--r--fs/befs/befs_fs_types.h4
-rw-r--r--fs/befs/linuxvfs.c4
-rw-r--r--fs/befs/super.c6
-rw-r--r--fs/binfmt_elf.c6
-rw-r--r--fs/binfmt_elf_fdpic.c85
-rw-r--r--fs/binfmt_em86.c2
-rw-r--r--fs/binfmt_flat.c6
-rw-r--r--fs/binfmt_misc.c4
-rw-r--r--fs/binfmt_script.c5
-rw-r--r--fs/binfmt_som.c2
-rw-r--r--fs/char_dev.c3
-rw-r--r--fs/coda/psdev.c5
-rw-r--r--fs/compat.c41
-rw-r--r--fs/direct-io.c4
-rw-r--r--fs/dquot.c2
-rw-r--r--fs/ecryptfs/Makefile2
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h28
-rw-r--r--fs/ecryptfs/file.c17
-rw-r--r--fs/ecryptfs/keystore.c32
-rw-r--r--fs/ecryptfs/main.c19
-rw-r--r--fs/ecryptfs/messaging.c118
-rw-r--r--fs/ecryptfs/mmap.c81
-rw-r--r--fs/ecryptfs/netlink.c249
-rw-r--r--fs/eventpoll.c9
-rw-r--r--fs/exec.c15
-rw-r--r--fs/ext2/balloc.c3
-rw-r--r--fs/ext2/dir.c60
-rw-r--r--fs/fs-writeback.c2
-rw-r--r--fs/hfs/catalog.c4
-rw-r--r--fs/hfsplus/bitmap.c12
-rw-r--r--fs/hfsplus/catalog.c5
-rw-r--r--fs/hfsplus/super.c2
-rw-r--r--fs/mpage.c2
-rw-r--r--fs/nfs/client.c5
-rw-r--r--fs/nfs/dir.c20
-rw-r--r--fs/nfs/file.c18
-rw-r--r--fs/nfs/inode.c183
-rw-r--r--fs/nfs/internal.h25
-rw-r--r--fs/nfs/mount_clnt.c3
-rw-r--r--fs/nfs/namespace.c7
-rw-r--r--fs/nfs/nfs3acl.c2
-rw-r--r--fs/nfs/nfs3proc.c20
-rw-r--r--fs/nfs/nfs4namespace.c105
-rw-r--r--fs/nfs/proc.c10
-rw-r--r--fs/nfs/super.c126
-rw-r--r--fs/nfs/unlink.c5
-rw-r--r--fs/nfs/write.c3
-rw-r--r--fs/nls/nls_base.c21
-rw-r--r--fs/partitions/acorn.c10
-rw-r--r--fs/partitions/check.c17
-rw-r--r--fs/proc/proc_misc.c26
-rw-r--r--fs/reiserfs/procfs.c3
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--fs/sysfs/bin.c42
-rw-r--r--fs/sysfs/dir.c24
-rw-r--r--fs/sysfs/file.c46
-rw-r--r--fs/sysfs/mount.c15
-rw-r--r--fs/sysfs/sysfs.h6
-rw-r--r--include/acpi/acmacros.h6
-rw-r--r--include/acpi/platform/acgcc.h2
-rw-r--r--include/asm-cris/elf.h2
-rw-r--r--include/asm-frv/elf.h2
-rw-r--r--include/asm-frv/unaligned.h2
-rw-r--r--include/asm-generic/bug.h2
-rw-r--r--include/asm-generic/gpio.h18
-rw-r--r--include/asm-generic/vmlinux.lds.h10
-rw-r--r--include/asm-h8300/timer.h25
-rw-r--r--include/asm-m32r/elf.h2
-rw-r--r--include/asm-m68k/elf.h2
-rw-r--r--include/asm-mn10300/elf.h2
-rw-r--r--include/asm-parisc/elf.h2
-rw-r--r--include/asm-um/elf-i386.h2
-rw-r--r--include/asm-um/elf-ppc.h2
-rw-r--r--include/asm-um/elf-x86_64.h2
-rw-r--r--include/asm-x86/elf.h4
-rw-r--r--include/asm-x86/es7000/apic.h2
-rw-r--r--include/asm-x86/iommu.h2
-rw-r--r--include/asm-x86/kvm.h22
-rw-r--r--include/asm-x86/kvm_host.h82
-rw-r--r--include/asm-x86/msr-index.h3
-rw-r--r--include/asm-x86/page_32.h2
-rw-r--r--include/asm-x86/page_64.h1
-rw-r--r--include/asm-x86/pgtable.h7
-rw-r--r--include/asm-x86/pvclock.h1
-rw-r--r--include/asm-x86/summit/apic.h2
-rw-r--r--include/asm-x86/xen/page.h4
-rw-r--r--include/asm-xtensa/elf.h2
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/aio.h9
-rw-r--r--include/linux/auto_dev-ioctl.h157
-rw-r--r--include/linux/auto_fs4.h7
-rw-r--r--include/linux/binfmts.h5
-rw-r--r--include/linux/cgroup.h3
-rw-r--r--include/linux/clk.h4
-rw-r--r--include/linux/compat.h6
-rw-r--r--include/linux/device.h18
-rw-r--r--include/linux/dma_remapping.h (renamed from drivers/pci/dma_remapping.h)0
-rw-r--r--include/linux/dynamic_printk.h93
-rw-r--r--include/linux/ext2_fs.h2
-rw-r--r--include/linux/ext3_fs.h4
-rw-r--r--include/linux/ext3_jbd.h14
-rw-r--r--include/linux/firewire-cdev.h9
-rw-r--r--include/linux/gameport.h7
-rw-r--r--include/linux/gpio.h3
-rw-r--r--include/linux/i2o.h292
-rw-r--r--include/linux/icmpv6.h6
-rw-r--r--include/linux/init.h4
-rw-r--r--include/linux/input.h15
-rw-r--r--include/linux/intel-iommu.h (renamed from drivers/pci/intel-iommu.h)24
-rw-r--r--include/linux/interrupt.h2
-rw-r--r--include/linux/iommu-helper.h3
-rw-r--r--include/linux/ioport.h8
-rw-r--r--include/linux/iova.h (renamed from drivers/pci/iova.h)0
-rw-r--r--include/linux/jbd.h4
-rw-r--r--include/linux/jbd2.h4
-rw-r--r--include/linux/journal-head.h2
-rw-r--r--include/linux/kallsyms.h8
-rw-r--r--include/linux/kernel.h35
-rw-r--r--include/linux/kmod.h3
-rw-r--r--include/linux/kvm.h72
-rw-r--r--include/linux/kvm_host.h82
-rw-r--r--include/linux/map_to_7segment.h (renamed from drivers/input/misc/map_to_7segment.h)4
-rw-r--r--include/linux/mfd/tmio.h19
-rw-r--r--include/linux/mod_devicetable.h2
-rw-r--r--include/linux/module.h1
-rw-r--r--include/linux/mount.h2
-rw-r--r--include/linux/netfilter/nfnetlink.h3
-rw-r--r--include/linux/nfs_fs.h19
-rw-r--r--include/linux/nfs_fs_sb.h1
-rw-r--r--include/linux/nfs_mount.h4
-rw-r--r--include/linux/nfs_xdr.h11
-rw-r--r--include/linux/parport.h2
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/pfn.h6
-rw-r--r--include/linux/pid_namespace.h6
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/pm.h2
-rw-r--r--include/linux/pnp.h6
-rw-r--r--include/linux/profile.h8
-rw-r--r--include/linux/quota.h2
-rw-r--r--include/linux/quotaops.h3
-rw-r--r--include/linux/raid/linear.h10
-rw-r--r--include/linux/raid/md.h32
-rw-r--r--include/linux/reiserfs_fs.h2
-rw-r--r--include/linux/rtmutex.h2
-rw-r--r--include/linux/spi/orion_spi.h1
-rw-r--r--include/linux/sunrpc/xprtrdma.h4
-rw-r--r--include/linux/swiotlb.h83
-rw-r--r--include/linux/sysctl.h2
-rw-r--r--include/linux/sysfs.h36
-rw-r--r--include/linux/task_io_accounting.h2
-rw-r--r--include/linux/telephony.h4
-rw-r--r--include/linux/time.h2
-rw-r--r--include/linux/types.h8
-rw-r--r--include/linux/wait.h9
-rw-r--r--include/media/saa7146.h2
-rw-r--r--include/net/9p/9p.h4
-rw-r--r--include/net/bluetooth/bluetooth.h4
-rw-r--r--include/net/ieee80211.h2
-rw-r--r--include/net/ip.h2
-rw-r--r--include/net/ip_vs.h4
-rw-r--r--include/net/irda/irda.h2
-rw-r--r--include/net/mac80211.h3
-rw-r--r--include/net/ndisc.h5
-rw-r--r--include/net/netfilter/nf_nat_core.h8
-rw-r--r--include/net/sctp/sctp.h2
-rw-r--r--include/video/cyblafb.h2
-rw-r--r--include/video/neomagic.h1
-rw-r--r--include/video/radeon.h23
-rw-r--r--include/video/s1d13xxxfb.h3
-rw-r--r--init/Kconfig8
-rw-r--r--init/do_mounts_md.c1
-rw-r--r--init/do_mounts_rd.c2
-rw-r--r--init/initramfs.c53
-rw-r--r--ipc/ipc_sysctl.c9
-rw-r--r--ipc/sem.c2
-rw-r--r--kernel/cgroup.c4
-rw-r--r--kernel/compat.c58
-rw-r--r--kernel/dma.c2
-rw-r--r--kernel/exit.c9
-rw-r--r--kernel/kallsyms.c1
-rw-r--r--kernel/kmod.c67
-rw-r--r--kernel/kprobes.c2
-rw-r--r--kernel/ksysfs.c35
-rw-r--r--kernel/module.c45
-rw-r--r--kernel/panic.c65
-rw-r--r--kernel/power/disk.c11
-rw-r--r--kernel/power/main.c7
-rw-r--r--kernel/power/user.c10
-rw-r--r--kernel/printk.c26
-rw-r--r--kernel/profile.c41
-rw-r--r--kernel/resource.c92
-rw-r--r--kernel/sched_clock.c6
-rw-r--r--kernel/softirq.c13
-rw-r--r--kernel/softlockup.c2
-rw-r--r--kernel/sys.c34
-rw-r--r--kernel/sys_ni.c5
-rw-r--r--kernel/sysctl.c98
-rw-r--r--kernel/time/Kconfig1
-rw-r--r--kernel/time/tick-sched.c2
-rw-r--r--kernel/timer.c1
-rw-r--r--kernel/utsname_sysctl.c5
-rw-r--r--kernel/wait.c14
-rw-r--r--kernel/workqueue.c2
-rw-r--r--lib/Kconfig4
-rw-r--r--lib/Kconfig.debug55
-rw-r--r--lib/Makefile2
-rw-r--r--lib/dynamic_printk.c418
-rw-r--r--lib/iommu-helper.c9
-rw-r--r--lib/kobject.c35
-rw-r--r--lib/vsprintf.c235
-rw-r--r--mm/Kconfig7
-rw-r--r--mm/bootmem.c2
-rw-r--r--mm/fadvise.c2
-rw-r--r--mm/filemap.c18
-rw-r--r--mm/hugetlb.c23
-rw-r--r--mm/page-writeback.c2
-rw-r--r--mm/page_alloc.c2
-rw-r--r--mm/pdflush.c2
-rw-r--r--mm/readahead.c2
-rw-r--r--mm/truncate.c2
-rw-r--r--net/802/fc.c2
-rw-r--r--net/bridge/netfilter/Kconfig1
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/decnet/dn_dev.c6
-rw-r--r--net/decnet/sysctl_net_decnet.c4
-rw-r--r--net/ipv4/devinet.c7
-rw-r--r--net/ipv4/netfilter/nf_defrag_ipv4.c3
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c97
-rw-r--r--net/ipv4/route.c7
-rw-r--r--net/ipv4/sysctl_net_ipv4.c18
-rw-r--r--net/ipv6/addrconf.c1
-rw-r--r--net/ipv6/ndisc.c13
-rw-r--r--net/ipv6/netfilter.c6
-rw-r--r--net/mac80211/debugfs_netdev.c6
-rw-r--r--net/mac80211/debugfs_sta.c11
-rw-r--r--net/mac80211/ieee80211_i.h6
-rw-r--r--net/mac80211/mlme.c3
-rw-r--r--net/mac80211/scan.c3
-rw-r--r--net/mac80211/sta_info.c7
-rw-r--r--net/mac80211/sta_info.h1
-rw-r--r--net/mac80211/util.c8
-rw-r--r--net/mac80211/wext.c2
-rw-r--r--net/netfilter/nf_conntrack_acct.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c7
-rw-r--r--net/netfilter/nf_conntrack_netlink.c151
-rw-r--r--net/netfilter/nf_conntrack_pptp.c2
-rw-r--r--net/netfilter/nfnetlink.c12
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/sunrpc/rpcb_clnt.c40
-rw-r--r--net/sunrpc/xprt.c12
-rw-r--r--net/sunrpc/xprtrdma/rpc_rdma.c29
-rw-r--r--net/sunrpc/xprtrdma/transport.c41
-rw-r--r--net/sunrpc/xprtrdma/verbs.c741
-rw-r--r--net/sunrpc/xprtrdma/xprt_rdma.h17
-rw-r--r--net/wireless/core.c5
-rw-r--r--scripts/Makefile.lib11
-rw-r--r--scripts/basic/Makefile2
-rw-r--r--scripts/basic/hash.c64
-rwxr-xr-xscripts/checkpatch.pl388
-rw-r--r--sound/arm/pxa2xx-ac97-lib.c12
-rw-r--r--sound/core/init.c6
-rw-r--r--sound/core/sound.c5
-rw-r--r--sound/oss/soundcard.c15
-rw-r--r--sound/pci/hda/patch_realtek.c88
-rw-r--r--sound/pci/hda/patch_sigmatel.c2
-rw-r--r--sound/soc/codecs/Kconfig2
-rw-r--r--sound/soc/codecs/tlv320aic23.c10
-rw-r--r--sound/sound_core.c5
-rw-r--r--sound/usb/usx2y/us122l.c13
-rw-r--r--virt/kvm/ioapic.c22
-rw-r--r--virt/kvm/ioapic.h10
-rw-r--r--virt/kvm/irq_comm.c60
-rw-r--r--virt/kvm/kvm_main.c382
-rw-r--r--virt/kvm/kvm_trace.c30
-rw-r--r--virt/kvm/vtd.c191
1066 files changed, 47280 insertions, 12484 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index 438277800103..7286ad090db7 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -21,6 +21,9 @@ Changes
21 - list of changes that break older software packages. 21 - list of changes that break older software packages.
22CodingStyle 22CodingStyle
23 - how the boss likes the C code in the kernel to look. 23 - how the boss likes the C code in the kernel to look.
24development-process/
25 - An extended tutorial on how to work with the kernel development
26 process.
24DMA-API.txt 27DMA-API.txt
25 - DMA API, pci_ API & extensions for non-consistent memory machines. 28 - DMA API, pci_ API & extensions for non-consistent memory machines.
26DMA-ISA-LPC.txt 29DMA-ISA-LPC.txt
diff --git a/Documentation/ABI/testing/sysfs-profiling b/Documentation/ABI/testing/sysfs-profiling
new file mode 100644
index 000000000000..b02d8b8c173a
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-profiling
@@ -0,0 +1,13 @@
1What: /sys/kernel/profile
2Date: September 2008
3Contact: Dave Hansen <dave@linux.vnet.ibm.com>
4Description:
5 /sys/kernel/profile is the runtime equivalent
6 of the boot-time profile= option.
7
8 You can get the same effect running:
9
10 echo 2 > /sys/kernel/profile
11
12 as you would by issuing profile=2 on the boot
13 command line.
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 1615350b7b53..fabc06466b93 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -6,7 +6,7 @@
6# To add a new book the only step required is to add the book to the 6# To add a new book the only step required is to add the book to the
7# list of DOCBOOKS. 7# list of DOCBOOKS.
8 8
9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ 9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 procfs-guide.xml writing_usb_driver.xml networking.xml \ 11 procfs-guide.xml writing_usb_driver.xml networking.xml \
12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \
diff --git a/Documentation/DocBook/procfs-guide.tmpl b/Documentation/DocBook/procfs-guide.tmpl
index 8a5dc6e021ff..9eba4b7af73d 100644
--- a/Documentation/DocBook/procfs-guide.tmpl
+++ b/Documentation/DocBook/procfs-guide.tmpl
@@ -14,17 +14,20 @@
14 <othername>(J.A.K.)</othername> 14 <othername>(J.A.K.)</othername>
15 <surname>Mouw</surname> 15 <surname>Mouw</surname>
16 <affiliation> 16 <affiliation>
17 <orgname>Delft University of Technology</orgname>
18 <orgdiv>Faculty of Information Technology and Systems</orgdiv>
19 <address> 17 <address>
20 <email>J.A.K.Mouw@its.tudelft.nl</email> 18 <email>mouw@nl.linux.org</email>
21 <pob>PO BOX 5031</pob>
22 <postcode>2600 GA</postcode>
23 <city>Delft</city>
24 <country>The Netherlands</country>
25 </address> 19 </address>
26 </affiliation> 20 </affiliation>
27 </author> 21 </author>
22 <othercredit>
23 <contrib>
24 This software and documentation were written while working on the
25 LART computing board
26 (<ulink url="http://www.lartmaker.nl/">http://www.lartmaker.nl/</ulink>),
27 which was sponsored by the Delt University of Technology projects
28 Mobile Multi-media Communications and Ubiquitous Communications.
29 </contrib>
30 </othercredit>
28 </authorgroup> 31 </authorgroup>
29 32
30 <revhistory> 33 <revhistory>
@@ -109,18 +112,6 @@
109 </para> 112 </para>
110 113
111 <para> 114 <para>
112 This documentation was written while working on the LART
113 computing board (<ulink
114 url="http://www.lart.tudelft.nl/">http://www.lart.tudelft.nl/</ulink>),
115 which is sponsored by the Mobile Multi-media Communications
116 (<ulink
117 url="http://www.mmc.tudelft.nl/">http://www.mmc.tudelft.nl/</ulink>)
118 and Ubiquitous Communications (<ulink
119 url="http://www.ubicom.tudelft.nl/">http://www.ubicom.tudelft.nl/</ulink>)
120 projects.
121 </para>
122
123 <para>
124 Erik 115 Erik
125 </para> 116 </para>
126 </preface> 117 </preface>
diff --git a/Documentation/DocBook/procfs_example.c b/Documentation/DocBook/procfs_example.c
index 2f3de0fb8365..8c6396e4bf31 100644
--- a/Documentation/DocBook/procfs_example.c
+++ b/Documentation/DocBook/procfs_example.c
@@ -1,28 +1,16 @@
1/* 1/*
2 * procfs_example.c: an example proc interface 2 * procfs_example.c: an example proc interface
3 * 3 *
4 * Copyright (C) 2001, Erik Mouw (J.A.K.Mouw@its.tudelft.nl) 4 * Copyright (C) 2001, Erik Mouw (mouw@nl.linux.org)
5 * 5 *
6 * This file accompanies the procfs-guide in the Linux kernel 6 * This file accompanies the procfs-guide in the Linux kernel
7 * source. Its main use is to demonstrate the concepts and 7 * source. Its main use is to demonstrate the concepts and
8 * functions described in the guide. 8 * functions described in the guide.
9 * 9 *
10 * This software has been developed while working on the LART 10 * This software has been developed while working on the LART
11 * computing board (http://www.lart.tudelft.nl/), which is 11 * computing board (http://www.lartmaker.nl), which was sponsored
12 * sponsored by the Mobile Multi-media Communications 12 * by the Delt University of Technology projects Mobile Multi-media
13 * (http://www.mmc.tudelft.nl/) and Ubiquitous Communications 13 * Communications and Ubiquitous Communications.
14 * (http://www.ubicom.tudelft.nl/) projects.
15 *
16 * The author can be reached at:
17 *
18 * Erik Mouw
19 * Information and Communication Theory Group
20 * Faculty of Information Technology and Systems
21 * Delft University of Technology
22 * P.O. Box 5031
23 * 2600 GA Delft
24 * The Netherlands
25 *
26 * 14 *
27 * This program is free software; you can redistribute 15 * This program is free software; you can redistribute
28 * it and/or modify it under the terms of the GNU General 16 * it and/or modify it under the terms of the GNU General
diff --git a/Documentation/DocBook/videobook.tmpl b/Documentation/DocBook/videobook.tmpl
deleted file mode 100644
index 0bc25949b668..000000000000
--- a/Documentation/DocBook/videobook.tmpl
+++ /dev/null
@@ -1,1654 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="V4LGuide">
6 <bookinfo>
7 <title>Video4Linux Programming</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Alan</firstname>
12 <surname>Cox</surname>
13 <affiliation>
14 <address>
15 <email>alan@redhat.com</email>
16 </address>
17 </affiliation>
18 </author>
19 </authorgroup>
20
21 <copyright>
22 <year>2000</year>
23 <holder>Alan Cox</holder>
24 </copyright>
25
26 <legalnotice>
27 <para>
28 This documentation is free software; you can redistribute
29 it and/or modify it under the terms of the GNU General Public
30 License as published by the Free Software Foundation; either
31 version 2 of the License, or (at your option) any later
32 version.
33 </para>
34
35 <para>
36 This program is distributed in the hope that it will be
37 useful, but WITHOUT ANY WARRANTY; without even the implied
38 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
39 See the GNU General Public License for more details.
40 </para>
41
42 <para>
43 You should have received a copy of the GNU General Public
44 License along with this program; if not, write to the Free
45 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
46 MA 02111-1307 USA
47 </para>
48
49 <para>
50 For more details see the file COPYING in the source
51 distribution of Linux.
52 </para>
53 </legalnotice>
54 </bookinfo>
55
56<toc></toc>
57
58 <chapter id="intro">
59 <title>Introduction</title>
60 <para>
61 Parts of this document first appeared in Linux Magazine under a
62 ninety day exclusivity.
63 </para>
64 <para>
65 Video4Linux is intended to provide a common programming interface
66 for the many TV and capture cards now on the market, as well as
67 parallel port and USB video cameras. Radio, teletext decoders and
68 vertical blanking data interfaces are also provided.
69 </para>
70 </chapter>
71 <chapter id="radio">
72 <title>Radio Devices</title>
73 <para>
74 There are a wide variety of radio interfaces available for PC's, and these
75 are generally very simple to program. The biggest problem with supporting
76 such devices is normally extracting documentation from the vendor.
77 </para>
78 <para>
79 The radio interface supports a simple set of control ioctls standardised
80 across all radio and tv interfaces. It does not support read or write, which
81 are used for video streams. The reason radio cards do not allow you to read
82 the audio stream into an application is that without exception they provide
83 a connection on to a soundcard. Soundcards can be used to read the radio
84 data just fine.
85 </para>
86 <sect1 id="registerradio">
87 <title>Registering Radio Devices</title>
88 <para>
89 The Video4linux core provides an interface for registering devices. The
90 first step in writing our radio card driver is to register it.
91 </para>
92 <programlisting>
93
94
95static struct video_device my_radio
96{
97 "My radio",
98 VID_TYPE_TUNER,
99 radio_open.
100 radio_close,
101 NULL, /* no read */
102 NULL, /* no write */
103 NULL, /* no poll */
104 radio_ioctl,
105 NULL, /* no special init function */
106 NULL /* no private data */
107};
108
109
110 </programlisting>
111 <para>
112 This declares our video4linux device driver interface. The VID_TYPE_ value
113 defines what kind of an interface we are, and defines basic capabilities.
114 </para>
115 <para>
116 The only defined value relevant for a radio card is VID_TYPE_TUNER which
117 indicates that the device can be tuned. Clearly our radio is going to have some
118 way to change channel so it is tuneable.
119 </para>
120 <para>
121 We declare an open and close routine, but we do not need read or write,
122 which are used to read and write video data to or from the card itself. As
123 we have no read or write there is no poll function.
124 </para>
125 <para>
126 The private initialise function is run when the device is registered. In
127 this driver we've already done all the work needed. The final pointer is a
128 private data pointer that can be used by the device driver to attach and
129 retrieve private data structures. We set this field "priv" to NULL for
130 the moment.
131 </para>
132 <para>
133 Having the structure defined is all very well but we now need to register it
134 with the kernel.
135 </para>
136 <programlisting>
137
138
139static int io = 0x320;
140
141int __init myradio_init(struct video_init *v)
142{
143 if(!request_region(io, MY_IO_SIZE, "myradio"))
144 {
145 printk(KERN_ERR
146 "myradio: port 0x%03X is in use.\n", io);
147 return -EBUSY;
148 }
149
150 if(video_device_register(&amp;my_radio, VFL_TYPE_RADIO)==-1) {
151 release_region(io, MY_IO_SIZE);
152 return -EINVAL;
153 }
154 return 0;
155}
156
157 </programlisting>
158 <para>
159 The first stage of the initialisation, as is normally the case, is to check
160 that the I/O space we are about to fiddle with doesn't belong to some other
161 driver. If it is we leave well alone. If the user gives the address of the
162 wrong device then we will spot this. These policies will generally avoid
163 crashing the machine.
164 </para>
165 <para>
166 Now we ask the Video4Linux layer to register the device for us. We hand it
167 our carefully designed video_device structure and also tell it which group
168 of devices we want it registered with. In this case VFL_TYPE_RADIO.
169 </para>
170 <para>
171 The types available are
172 </para>
173 <table frame="all" id="Device_Types"><title>Device Types</title>
174 <tgroup cols="3" align="left">
175 <tbody>
176 <row>
177 <entry>VFL_TYPE_RADIO</entry><entry>/dev/radio{n}</entry><entry>
178
179 Radio devices are assigned in this block. As with all of these
180 selections the actual number assignment is done by the video layer
181 accordijng to what is free.</entry>
182 </row><row>
183 <entry>VFL_TYPE_GRABBER</entry><entry>/dev/video{n}</entry><entry>
184 Video capture devices and also -- counter-intuitively for the name --
185 hardware video playback devices such as MPEG2 cards.</entry>
186 </row><row>
187 <entry>VFL_TYPE_VBI</entry><entry>/dev/vbi{n}</entry><entry>
188 The VBI devices capture the hidden lines on a television picture
189 that carry further information like closed caption data, teletext
190 (primarily in Europe) and now Intercast and the ATVEC internet
191 television encodings.</entry>
192 </row><row>
193 <entry>VFL_TYPE_VTX</entry><entry>/dev/vtx[n}</entry><entry>
194 VTX is 'Videotext' also known as 'Teletext'. This is a system for
195 sending numbered, 40x25, mostly textual page images over the hidden
196 lines. Unlike the /dev/vbi interfaces, this is for 'smart' decoder
197 chips. (The use of the word smart here has to be taken in context,
198 the smartest teletext chips are fairly dumb pieces of technology).
199 </entry>
200 </row>
201 </tbody>
202 </tgroup>
203 </table>
204 <para>
205 We are most definitely a radio.
206 </para>
207 <para>
208 Finally we allocate our I/O space so that nobody treads on us and return 0
209 to signify general happiness with the state of the universe.
210 </para>
211 </sect1>
212 <sect1 id="openradio">
213 <title>Opening And Closing The Radio</title>
214
215 <para>
216 The functions we declared in our video_device are mostly very simple.
217 Firstly we can drop in what is basically standard code for open and close.
218 </para>
219 <programlisting>
220
221
222static int users = 0;
223
224static int radio_open(struct video_device *dev, int flags)
225{
226 if(users)
227 return -EBUSY;
228 users++;
229 return 0;
230}
231
232 </programlisting>
233 <para>
234 At open time we need to do nothing but check if someone else is also using
235 the radio card. If nobody is using it we make a note that we are using it,
236 then we ensure that nobody unloads our driver on us.
237 </para>
238 <programlisting>
239
240
241static int radio_close(struct video_device *dev)
242{
243 users--;
244}
245
246 </programlisting>
247 <para>
248 At close time we simply need to reduce the user count and allow the module
249 to become unloadable.
250 </para>
251 <para>
252 If you are sharp you will have noticed neither the open nor the close
253 routines attempt to reset or change the radio settings. This is intentional.
254 It allows an application to set up the radio and exit. It avoids a user
255 having to leave an application running all the time just to listen to the
256 radio.
257 </para>
258 </sect1>
259 <sect1 id="ioctlradio">
260 <title>The Ioctl Interface</title>
261 <para>
262 This leaves the ioctl routine, without which the driver will not be
263 terribly useful to anyone.
264 </para>
265 <programlisting>
266
267
268static int radio_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
269{
270 switch(cmd)
271 {
272 case VIDIOCGCAP:
273 {
274 struct video_capability v;
275 v.type = VID_TYPE_TUNER;
276 v.channels = 1;
277 v.audios = 1;
278 v.maxwidth = 0;
279 v.minwidth = 0;
280 v.maxheight = 0;
281 v.minheight = 0;
282 strcpy(v.name, "My Radio");
283 if(copy_to_user(arg, &amp;v, sizeof(v)))
284 return -EFAULT;
285 return 0;
286 }
287
288 </programlisting>
289 <para>
290 VIDIOCGCAP is the first ioctl all video4linux devices must support. It
291 allows the applications to find out what sort of a card they have found and
292 to figure out what they want to do about it. The fields in the structure are
293 </para>
294 <table frame="all" id="video_capability_fields"><title>struct video_capability fields</title>
295 <tgroup cols="2" align="left">
296 <tbody>
297 <row>
298 <entry>name</entry><entry>The device text name. This is intended for the user.</entry>
299 </row><row>
300 <entry>channels</entry><entry>The number of different channels you can tune on
301 this card. It could even by zero for a card that has
302 no tuning capability. For our simple FM radio it is 1.
303 An AM/FM radio would report 2.</entry>
304 </row><row>
305 <entry>audios</entry><entry>The number of audio inputs on this device. For our
306 radio there is only one audio input.</entry>
307 </row><row>
308 <entry>minwidth,minheight</entry><entry>The smallest size the card is capable of capturing
309 images in. We set these to zero. Radios do not
310 capture pictures</entry>
311 </row><row>
312 <entry>maxwidth,maxheight</entry><entry>The largest image size the card is capable of
313 capturing. For our radio we report 0.
314 </entry>
315 </row><row>
316 <entry>type</entry><entry>This reports the capabilities of the device, and
317 matches the field we filled in in the struct
318 video_device when registering.</entry>
319 </row>
320 </tbody>
321 </tgroup>
322 </table>
323 <para>
324 Having filled in the fields, we use copy_to_user to copy the structure into
325 the users buffer. If the copy fails we return an EFAULT to the application
326 so that it knows it tried to feed us garbage.
327 </para>
328 <para>
329 The next pair of ioctl operations select which tuner is to be used and let
330 the application find the tuner properties. We have only a single FM band
331 tuner in our example device.
332 </para>
333 <programlisting>
334
335
336 case VIDIOCGTUNER:
337 {
338 struct video_tuner v;
339 if(copy_from_user(&amp;v, arg, sizeof(v))!=0)
340 return -EFAULT;
341 if(v.tuner)
342 return -EINVAL;
343 v.rangelow=(87*16000);
344 v.rangehigh=(108*16000);
345 v.flags = VIDEO_TUNER_LOW;
346 v.mode = VIDEO_MODE_AUTO;
347 v.signal = 0xFFFF;
348 strcpy(v.name, "FM");
349 if(copy_to_user(&amp;v, arg, sizeof(v))!=0)
350 return -EFAULT;
351 return 0;
352 }
353
354 </programlisting>
355 <para>
356 The VIDIOCGTUNER ioctl allows applications to query a tuner. The application
357 sets the tuner field to the tuner number it wishes to query. The query does
358 not change the tuner that is being used, it merely enquires about the tuner
359 in question.
360 </para>
361 <para>
362 We have exactly one tuner so after copying the user buffer to our temporary
363 structure we complain if they asked for a tuner other than tuner 0.
364 </para>
365 <para>
366 The video_tuner structure has the following fields
367 </para>
368 <table frame="all" id="video_tuner_fields"><title>struct video_tuner fields</title>
369 <tgroup cols="2" align="left">
370 <tbody>
371 <row>
372 <entry>int tuner</entry><entry>The number of the tuner in question</entry>
373 </row><row>
374 <entry>char name[32]</entry><entry>A text description of this tuner. "FM" will do fine.
375 This is intended for the application.</entry>
376 </row><row>
377 <entry>u32 flags</entry>
378 <entry>Tuner capability flags</entry>
379 </row>
380 <row>
381 <entry>u16 mode</entry><entry>The current reception mode</entry>
382
383 </row><row>
384 <entry>u16 signal</entry><entry>The signal strength scaled between 0 and 65535. If
385 a device cannot tell the signal strength it should
386 report 65535. Many simple cards contain only a
387 signal/no signal bit. Such cards will report either
388 0 or 65535.</entry>
389
390 </row><row>
391 <entry>u32 rangelow, rangehigh</entry><entry>
392 The range of frequencies supported by the radio
393 or TV. It is scaled according to the VIDEO_TUNER_LOW
394 flag.</entry>
395
396 </row>
397 </tbody>
398 </tgroup>
399 </table>
400
401 <table frame="all" id="video_tuner_flags"><title>struct video_tuner flags</title>
402 <tgroup cols="2" align="left">
403 <tbody>
404 <row>
405 <entry>VIDEO_TUNER_PAL</entry><entry>A PAL TV tuner</entry>
406 </row><row>
407 <entry>VIDEO_TUNER_NTSC</entry><entry>An NTSC (US) TV tuner</entry>
408 </row><row>
409 <entry>VIDEO_TUNER_SECAM</entry><entry>A SECAM (French) TV tuner</entry>
410 </row><row>
411 <entry>VIDEO_TUNER_LOW</entry><entry>
412 The tuner frequency is scaled in 1/16th of a KHz
413 steps. If not it is in 1/16th of a MHz steps
414 </entry>
415 </row><row>
416 <entry>VIDEO_TUNER_NORM</entry><entry>The tuner can set its format</entry>
417 </row><row>
418 <entry>VIDEO_TUNER_STEREO_ON</entry><entry>The tuner is currently receiving a stereo signal</entry>
419 </row>
420 </tbody>
421 </tgroup>
422 </table>
423
424 <table frame="all" id="video_tuner_modes"><title>struct video_tuner modes</title>
425 <tgroup cols="2" align="left">
426 <tbody>
427 <row>
428 <entry>VIDEO_MODE_PAL</entry><entry>PAL Format</entry>
429 </row><row>
430 <entry>VIDEO_MODE_NTSC</entry><entry>NTSC Format (USA)</entry>
431 </row><row>
432 <entry>VIDEO_MODE_SECAM</entry><entry>French Format</entry>
433 </row><row>
434 <entry>VIDEO_MODE_AUTO</entry><entry>A device that does not need to do
435 TV format switching</entry>
436 </row>
437 </tbody>
438 </tgroup>
439 </table>
440 <para>
441 The settings for the radio card are thus fairly simple. We report that we
442 are a tuner called "FM" for FM radio. In order to get the best tuning
443 resolution we report VIDEO_TUNER_LOW and select tuning to 1/16th of KHz. Its
444 unlikely our card can do that resolution but it is a fair bet the card can
445 do better than 1/16th of a MHz. VIDEO_TUNER_LOW is appropriate to almost all
446 radio usage.
447 </para>
448 <para>
449 We report that the tuner automatically handles deciding what format it is
450 receiving - true enough as it only handles FM radio. Our example card is
451 also incapable of detecting stereo or signal strengths so it reports a
452 strength of 0xFFFF (maximum) and no stereo detected.
453 </para>
454 <para>
455 To finish off we set the range that can be tuned to be 87-108Mhz, the normal
456 FM broadcast radio range. It is important to find out what the card is
457 actually capable of tuning. It is easy enough to simply use the FM broadcast
458 range. Unfortunately if you do this you will discover the FM broadcast
459 ranges in the USA, Europe and Japan are all subtly different and some users
460 cannot receive all the stations they wish.
461 </para>
462 <para>
463 The application also needs to be able to set the tuner it wishes to use. In
464 our case, with a single tuner this is rather simple to arrange.
465 </para>
466 <programlisting>
467
468 case VIDIOCSTUNER:
469 {
470 struct video_tuner v;
471 if(copy_from_user(&amp;v, arg, sizeof(v)))
472 return -EFAULT;
473 if(v.tuner != 0)
474 return -EINVAL;
475 return 0;
476 }
477
478 </programlisting>
479 <para>
480 We copy the user supplied structure into kernel memory so we can examine it.
481 If the user has selected a tuner other than zero we reject the request. If
482 they wanted tuner 0 then, surprisingly enough, that is the current tuner already.
483 </para>
484 <para>
485 The next two ioctls we need to provide are to get and set the frequency of
486 the radio. These both use an unsigned long argument which is the frequency.
487 The scale of the frequency depends on the VIDEO_TUNER_LOW flag as I
488 mentioned earlier on. Since we have VIDEO_TUNER_LOW set this will be in
489 1/16ths of a KHz.
490 </para>
491 <programlisting>
492
493static unsigned long current_freq;
494
495
496
497 case VIDIOCGFREQ:
498 if(copy_to_user(arg, &amp;current_freq,
499 sizeof(unsigned long))
500 return -EFAULT;
501 return 0;
502
503 </programlisting>
504 <para>
505 Querying the frequency in our case is relatively simple. Our radio card is
506 too dumb to let us query the signal strength so we remember our setting if
507 we know it. All we have to do is copy it to the user.
508 </para>
509 <programlisting>
510
511
512 case VIDIOCSFREQ:
513 {
514 u32 freq;
515 if(copy_from_user(arg, &amp;freq,
516 sizeof(unsigned long))!=0)
517 return -EFAULT;
518 if(hardware_set_freq(freq)&lt;0)
519 return -EINVAL;
520 current_freq = freq;
521 return 0;
522 }
523
524 </programlisting>
525 <para>
526 Setting the frequency is a little more complex. We begin by copying the
527 desired frequency into kernel space. Next we call a hardware specific routine
528 to set the radio up. This might be as simple as some scaling and a few
529 writes to an I/O port. For most radio cards it turns out a good deal more
530 complicated and may involve programming things like a phase locked loop on
531 the card. This is what documentation is for.
532 </para>
533 <para>
534 The final set of operations we need to provide for our radio are the
535 volume controls. Not all radio cards can even do volume control. After all
536 there is a perfectly good volume control on the sound card. We will assume
537 our radio card has a simple 4 step volume control.
538 </para>
539 <para>
540 There are two ioctls with audio we need to support
541 </para>
542 <programlisting>
543
544static int current_volume=0;
545
546 case VIDIOCGAUDIO:
547 {
548 struct video_audio v;
549 if(copy_from_user(&amp;v, arg, sizeof(v)))
550 return -EFAULT;
551 if(v.audio != 0)
552 return -EINVAL;
553 v.volume = 16384*current_volume;
554 v.step = 16384;
555 strcpy(v.name, "Radio");
556 v.mode = VIDEO_SOUND_MONO;
557 v.balance = 0;
558 v.base = 0;
559 v.treble = 0;
560
561 if(copy_to_user(arg. &amp;v, sizeof(v)))
562 return -EFAULT;
563 return 0;
564 }
565
566 </programlisting>
567 <para>
568 Much like the tuner we start by copying the user structure into kernel
569 space. Again we check if the user has asked for a valid audio input. We have
570 only input 0 and we punt if they ask for another input.
571 </para>
572 <para>
573 Then we fill in the video_audio structure. This has the following format
574 </para>
575 <table frame="all" id="video_audio_fields"><title>struct video_audio fields</title>
576 <tgroup cols="2" align="left">
577 <tbody>
578 <row>
579 <entry>audio</entry><entry>The input the user wishes to query</entry>
580 </row><row>
581 <entry>volume</entry><entry>The volume setting on a scale of 0-65535</entry>
582 </row><row>
583 <entry>base</entry><entry>The base level on a scale of 0-65535</entry>
584 </row><row>
585 <entry>treble</entry><entry>The treble level on a scale of 0-65535</entry>
586 </row><row>
587 <entry>flags</entry><entry>The features this audio device supports
588 </entry>
589 </row><row>
590 <entry>name</entry><entry>A text name to display to the user. We picked
591 "Radio" as it explains things quite nicely.</entry>
592 </row><row>
593 <entry>mode</entry><entry>The current reception mode for the audio
594
595 We report MONO because our card is too stupid to know if it is in
596 mono or stereo.
597 </entry>
598 </row><row>
599 <entry>balance</entry><entry>The stereo balance on a scale of 0-65535, 32768 is
600 middle.</entry>
601 </row><row>
602 <entry>step</entry><entry>The step by which the volume control jumps. This is
603 used to help make it easy for applications to set
604 slider behaviour.</entry>
605 </row>
606 </tbody>
607 </tgroup>
608 </table>
609
610 <table frame="all" id="video_audio_flags"><title>struct video_audio flags</title>
611 <tgroup cols="2" align="left">
612 <tbody>
613 <row>
614 <entry>VIDEO_AUDIO_MUTE</entry><entry>The audio is currently muted. We
615 could fake this in our driver but we
616 choose not to bother.</entry>
617 </row><row>
618 <entry>VIDEO_AUDIO_MUTABLE</entry><entry>The input has a mute option</entry>
619 </row><row>
620 <entry>VIDEO_AUDIO_TREBLE</entry><entry>The input has a treble control</entry>
621 </row><row>
622 <entry>VIDEO_AUDIO_BASS</entry><entry>The input has a base control</entry>
623 </row>
624 </tbody>
625 </tgroup>
626 </table>
627
628 <table frame="all" id="video_audio_modes"><title>struct video_audio modes</title>
629 <tgroup cols="2" align="left">
630 <tbody>
631 <row>
632 <entry>VIDEO_SOUND_MONO</entry><entry>Mono sound</entry>
633 </row><row>
634 <entry>VIDEO_SOUND_STEREO</entry><entry>Stereo sound</entry>
635 </row><row>
636 <entry>VIDEO_SOUND_LANG1</entry><entry>Alternative language 1 (TV specific)</entry>
637 </row><row>
638 <entry>VIDEO_SOUND_LANG2</entry><entry>Alternative language 2 (TV specific)</entry>
639 </row>
640 </tbody>
641 </tgroup>
642 </table>
643 <para>
644 Having filled in the structure we copy it back to user space.
645 </para>
646 <para>
647 The VIDIOCSAUDIO ioctl allows the user to set the audio parameters in the
648 video_audio structure. The driver does its best to honour the request.
649 </para>
650 <programlisting>
651
652 case VIDIOCSAUDIO:
653 {
654 struct video_audio v;
655 if(copy_from_user(&amp;v, arg, sizeof(v)))
656 return -EFAULT;
657 if(v.audio)
658 return -EINVAL;
659 current_volume = v/16384;
660 hardware_set_volume(current_volume);
661 return 0;
662 }
663
664 </programlisting>
665 <para>
666 In our case there is very little that the user can set. The volume is
667 basically the limit. Note that we could pretend to have a mute feature
668 by rewriting this to
669 </para>
670 <programlisting>
671
672 case VIDIOCSAUDIO:
673 {
674 struct video_audio v;
675 if(copy_from_user(&amp;v, arg, sizeof(v)))
676 return -EFAULT;
677 if(v.audio)
678 return -EINVAL;
679 current_volume = v/16384;
680 if(v.flags&amp;VIDEO_AUDIO_MUTE)
681 hardware_set_volume(0);
682 else
683 hardware_set_volume(current_volume);
684 current_muted = v.flags &amp;
685 VIDEO_AUDIO_MUTE;
686 return 0;
687 }
688
689 </programlisting>
690 <para>
691 This with the corresponding changes to the VIDIOCGAUDIO code to report the
692 state of the mute flag we save and to report the card has a mute function,
693 will allow applications to use a mute facility with this card. It is
694 questionable whether this is a good idea however. User applications can already
695 fake this themselves and kernel space is precious.
696 </para>
697 <para>
698 We now have a working radio ioctl handler. So we just wrap up the function
699 </para>
700 <programlisting>
701
702
703 }
704 return -ENOIOCTLCMD;
705}
706
707 </programlisting>
708 <para>
709 and pass the Video4Linux layer back an error so that it knows we did not
710 understand the request we got passed.
711 </para>
712 </sect1>
713 <sect1 id="modradio">
714 <title>Module Wrapper</title>
715 <para>
716 Finally we add in the usual module wrapping and the driver is done.
717 </para>
718 <programlisting>
719
720#ifndef MODULE
721
722static int io = 0x300;
723
724#else
725
726static int io = -1;
727
728#endif
729
730MODULE_AUTHOR("Alan Cox");
731MODULE_DESCRIPTION("A driver for an imaginary radio card.");
732module_param(io, int, 0444);
733MODULE_PARM_DESC(io, "I/O address of the card.");
734
735static int __init init(void)
736{
737 if(io==-1)
738 {
739 printk(KERN_ERR
740 "You must set an I/O address with io=0x???\n");
741 return -EINVAL;
742 }
743 return myradio_init(NULL);
744}
745
746static void __exit cleanup(void)
747{
748 video_unregister_device(&amp;my_radio);
749 release_region(io, MY_IO_SIZE);
750}
751
752module_init(init);
753module_exit(cleanup);
754
755 </programlisting>
756 <para>
757 In this example we set the IO base by default if the driver is compiled into
758 the kernel: you can still set it using "my_radio.irq" if this file is called <filename>my_radio.c</filename>. For the module we require the
759 user sets the parameter. We set io to a nonsense port (-1) so that we can
760 tell if the user supplied an io parameter or not.
761 </para>
762 <para>
763 We use MODULE_ defines to give an author for the card driver and a
764 description. We also use them to declare that io is an integer and it is the
765 address of the card, and can be read by anyone from sysfs.
766 </para>
767 <para>
768 The clean-up routine unregisters the video_device we registered, and frees
769 up the I/O space. Note that the unregister takes the actual video_device
770 structure as its argument. Unlike the file operations structure which can be
771 shared by all instances of a device a video_device structure as an actual
772 instance of the device. If you are registering multiple radio devices you
773 need to fill in one structure per device (most likely by setting up a
774 template and copying it to each of the actual device structures).
775 </para>
776 </sect1>
777 </chapter>
778 <chapter id="Video_Capture_Devices">
779 <title>Video Capture Devices</title>
780 <sect1 id="introvid">
781 <title>Video Capture Device Types</title>
782 <para>
783 The video capture devices share the same interfaces as radio devices. In
784 order to explain the video capture interface I will use the example of a
785 camera that has no tuners or audio input. This keeps the example relatively
786 clean. To get both combine the two driver examples.
787 </para>
788 <para>
789 Video capture devices divide into four categories. A little technology
790 backgrounder. Full motion video even at television resolution (which is
791 actually fairly low) is pretty resource-intensive. You are continually
792 passing megabytes of data every second from the capture card to the display.
793 several alternative approaches have emerged because copying this through the
794 processor and the user program is a particularly bad idea .
795 </para>
796 <para>
797 The first is to add the television image onto the video output directly.
798 This is also how some 3D cards work. These basic cards can generally drop the
799 video into any chosen rectangle of the display. Cards like this, which
800 include most mpeg1 cards that used the feature connector, aren't very
801 friendly in a windowing environment. They don't understand windows or
802 clipping. The video window is always on the top of the display.
803 </para>
804 <para>
805 Chroma keying is a technique used by cards to get around this. It is an old
806 television mixing trick where you mark all the areas you wish to replace
807 with a single clear colour that isn't used in the image - TV people use an
808 incredibly bright blue while computing people often use a particularly
809 virulent purple. Bright blue occurs on the desktop. Anyone with virulent
810 purple windows has another problem besides their TV overlay.
811 </para>
812 <para>
813 The third approach is to copy the data from the capture card to the video
814 card, but to do it directly across the PCI bus. This relieves the processor
815 from doing the work but does require some smartness on the part of the video
816 capture chip, as well as a suitable video card. Programming this kind of
817 card and more so debugging it can be extremely tricky. There are some quite
818 complicated interactions with the display and you may also have to cope with
819 various chipset bugs that show up when PCI cards start talking to each
820 other.
821 </para>
822 <para>
823 To keep our example fairly simple we will assume a card that supports
824 overlaying a flat rectangular image onto the frame buffer output, and which
825 can also capture stuff into processor memory.
826 </para>
827 </sect1>
828 <sect1 id="regvid">
829 <title>Registering Video Capture Devices</title>
830 <para>
831 This time we need to add more functions for our camera device.
832 </para>
833 <programlisting>
834static struct video_device my_camera
835{
836 "My Camera",
837 VID_TYPE_OVERLAY|VID_TYPE_SCALES|\
838 VID_TYPE_CAPTURE|VID_TYPE_CHROMAKEY,
839 camera_open.
840 camera_close,
841 camera_read, /* no read */
842 NULL, /* no write */
843 camera_poll, /* no poll */
844 camera_ioctl,
845 NULL, /* no special init function */
846 NULL /* no private data */
847};
848 </programlisting>
849 <para>
850 We need a read() function which is used for capturing data from
851 the card, and we need a poll function so that a driver can wait for the next
852 frame to be captured.
853 </para>
854 <para>
855 We use the extra video capability flags that did not apply to the
856 radio interface. The video related flags are
857 </para>
858 <table frame="all" id="Capture_Capabilities"><title>Capture Capabilities</title>
859 <tgroup cols="2" align="left">
860 <tbody>
861 <row>
862<entry>VID_TYPE_CAPTURE</entry><entry>We support image capture</entry>
863</row><row>
864<entry>VID_TYPE_TELETEXT</entry><entry>A teletext capture device (vbi{n])</entry>
865</row><row>
866<entry>VID_TYPE_OVERLAY</entry><entry>The image can be directly overlaid onto the
867 frame buffer</entry>
868</row><row>
869<entry>VID_TYPE_CHROMAKEY</entry><entry>Chromakey can be used to select which parts
870 of the image to display</entry>
871</row><row>
872<entry>VID_TYPE_CLIPPING</entry><entry>It is possible to give the board a list of
873 rectangles to draw around. </entry>
874</row><row>
875<entry>VID_TYPE_FRAMERAM</entry><entry>The video capture goes into the video memory
876 and actually changes it. Applications need
877 to know this so they can clean up after the
878 card</entry>
879</row><row>
880<entry>VID_TYPE_SCALES</entry><entry>The image can be scaled to various sizes,
881 rather than being a single fixed size.</entry>
882</row><row>
883<entry>VID_TYPE_MONOCHROME</entry><entry>The capture will be monochrome. This isn't a
884 complete answer to the question since a mono
885 camera on a colour capture card will still
886 produce mono output.</entry>
887</row><row>
888<entry>VID_TYPE_SUBCAPTURE</entry><entry>The card allows only part of its field of
889 view to be captured. This enables
890 applications to avoid copying all of a large
891 image into memory when only some section is
892 relevant.</entry>
893 </row>
894 </tbody>
895 </tgroup>
896 </table>
897 <para>
898 We set VID_TYPE_CAPTURE so that we are seen as a capture card,
899 VID_TYPE_CHROMAKEY so the application knows it is time to draw in virulent
900 purple, and VID_TYPE_SCALES because we can be resized.
901 </para>
902 <para>
903 Our setup is fairly similar. This time we also want an interrupt line
904 for the 'frame captured' signal. Not all cards have this so some of them
905 cannot handle poll().
906 </para>
907 <programlisting>
908
909
910static int io = 0x320;
911static int irq = 11;
912
913int __init mycamera_init(struct video_init *v)
914{
915 if(!request_region(io, MY_IO_SIZE, "mycamera"))
916 {
917 printk(KERN_ERR
918 "mycamera: port 0x%03X is in use.\n", io);
919 return -EBUSY;
920 }
921
922 if(video_device_register(&amp;my_camera,
923 VFL_TYPE_GRABBER)==-1) {
924 release_region(io, MY_IO_SIZE);
925 return -EINVAL;
926 }
927 return 0;
928}
929
930 </programlisting>
931 <para>
932 This is little changed from the needs of the radio card. We specify
933 VFL_TYPE_GRABBER this time as we want to be allocated a /dev/video name.
934 </para>
935 </sect1>
936 <sect1 id="opvid">
937 <title>Opening And Closing The Capture Device</title>
938 <programlisting>
939
940
941static int users = 0;
942
943static int camera_open(struct video_device *dev, int flags)
944{
945 if(users)
946 return -EBUSY;
947 if(request_irq(irq, camera_irq, 0, "camera", dev)&lt;0)
948 return -EBUSY;
949 users++;
950 return 0;
951}
952
953
954static int camera_close(struct video_device *dev)
955{
956 users--;
957 free_irq(irq, dev);
958}
959 </programlisting>
960 <para>
961 The open and close routines are also quite similar. The only real change is
962 that we now request an interrupt for the camera device interrupt line. If we
963 cannot get the interrupt we report EBUSY to the application and give up.
964 </para>
965 </sect1>
966 <sect1 id="irqvid">
967 <title>Interrupt Handling</title>
968 <para>
969 Our example handler is for an ISA bus device. If it was PCI you would be
970 able to share the interrupt and would have set IRQF_SHARED to indicate a
971 shared IRQ. We pass the device pointer as the interrupt routine argument. We
972 don't need to since we only support one card but doing this will make it
973 easier to upgrade the driver for multiple devices in the future.
974 </para>
975 <para>
976 Our interrupt routine needs to do little if we assume the card can simply
977 queue one frame to be read after it captures it.
978 </para>
979 <programlisting>
980
981
982static struct wait_queue *capture_wait;
983static int capture_ready = 0;
984
985static void camera_irq(int irq, void *dev_id,
986 struct pt_regs *regs)
987{
988 capture_ready=1;
989 wake_up_interruptible(&amp;capture_wait);
990}
991 </programlisting>
992 <para>
993 The interrupt handler is nice and simple for this card as we are assuming
994 the card is buffering the frame for us. This means we have little to do but
995 wake up anybody interested. We also set a capture_ready flag, as we may
996 capture a frame before an application needs it. In this case we need to know
997 that a frame is ready. If we had to collect the frame on the interrupt life
998 would be more complex.
999 </para>
1000 <para>
1001 The two new routines we need to supply are camera_read which returns a
1002 frame, and camera_poll which waits for a frame to become ready.
1003 </para>
1004 <programlisting>
1005
1006
1007static int camera_poll(struct video_device *dev,
1008 struct file *file, struct poll_table *wait)
1009{
1010 poll_wait(file, &amp;capture_wait, wait);
1011 if(capture_read)
1012 return POLLIN|POLLRDNORM;
1013 return 0;
1014}
1015
1016 </programlisting>
1017 <para>
1018 Our wait queue for polling is the capture_wait queue. This will cause the
1019 task to be woken up by our camera_irq routine. We check capture_read to see
1020 if there is an image present and if so report that it is readable.
1021 </para>
1022 </sect1>
1023 <sect1 id="rdvid">
1024 <title>Reading The Video Image</title>
1025 <programlisting>
1026
1027
1028static long camera_read(struct video_device *dev, char *buf,
1029 unsigned long count)
1030{
1031 struct wait_queue wait = { current, NULL };
1032 u8 *ptr;
1033 int len;
1034 int i;
1035
1036 add_wait_queue(&amp;capture_wait, &amp;wait);
1037
1038 while(!capture_ready)
1039 {
1040 if(file->flags&amp;O_NDELAY)
1041 {
1042 remove_wait_queue(&amp;capture_wait, &amp;wait);
1043 current->state = TASK_RUNNING;
1044 return -EWOULDBLOCK;
1045 }
1046 if(signal_pending(current))
1047 {
1048 remove_wait_queue(&amp;capture_wait, &amp;wait);
1049 current->state = TASK_RUNNING;
1050 return -ERESTARTSYS;
1051 }
1052 schedule();
1053 current->state = TASK_INTERRUPTIBLE;
1054 }
1055 remove_wait_queue(&amp;capture_wait, &amp;wait);
1056 current->state = TASK_RUNNING;
1057
1058 </programlisting>
1059 <para>
1060 The first thing we have to do is to ensure that the application waits until
1061 the next frame is ready. The code here is almost identical to the mouse code
1062 we used earlier in this chapter. It is one of the common building blocks of
1063 Linux device driver code and probably one which you will find occurs in any
1064 drivers you write.
1065 </para>
1066 <para>
1067 We wait for a frame to be ready, or for a signal to interrupt our waiting. If a
1068 signal occurs we need to return from the system call so that the signal can
1069 be sent to the application itself. We also check to see if the user actually
1070 wanted to avoid waiting - ie if they are using non-blocking I/O and have other things
1071 to get on with.
1072 </para>
1073 <para>
1074 Next we copy the data from the card to the user application. This is rarely
1075 as easy as our example makes out. We will add capture_w, and capture_h here
1076 to hold the width and height of the captured image. We assume the card only
1077 supports 24bit RGB for now.
1078 </para>
1079 <programlisting>
1080
1081
1082
1083 capture_ready = 0;
1084
1085 ptr=(u8 *)buf;
1086 len = capture_w * 3 * capture_h; /* 24bit RGB */
1087
1088 if(len>count)
1089 len=count; /* Doesn't all fit */
1090
1091 for(i=0; i&lt;len; i++)
1092 {
1093 put_user(inb(io+IMAGE_DATA), ptr);
1094 ptr++;
1095 }
1096
1097 hardware_restart_capture();
1098
1099 return i;
1100}
1101
1102 </programlisting>
1103 <para>
1104 For a real hardware device you would try to avoid the loop with put_user().
1105 Each call to put_user() has a time overhead checking whether the accesses to user
1106 space are allowed. It would be better to read a line into a temporary buffer
1107 then copy this to user space in one go.
1108 </para>
1109 <para>
1110 Having captured the image and put it into user space we can kick the card to
1111 get the next frame acquired.
1112 </para>
1113 </sect1>
1114 <sect1 id="iocvid">
1115 <title>Video Ioctl Handling</title>
1116 <para>
1117 As with the radio driver the major control interface is via the ioctl()
1118 function. Video capture devices support the same tuner calls as a radio
1119 device and also support additional calls to control how the video functions
1120 are handled. In this simple example the card has no tuners to avoid making
1121 the code complex.
1122 </para>
1123 <programlisting>
1124
1125
1126
1127static int camera_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1128{
1129 switch(cmd)
1130 {
1131 case VIDIOCGCAP:
1132 {
1133 struct video_capability v;
1134 v.type = VID_TYPE_CAPTURE|\
1135 VID_TYPE_CHROMAKEY|\
1136 VID_TYPE_SCALES|\
1137 VID_TYPE_OVERLAY;
1138 v.channels = 1;
1139 v.audios = 0;
1140 v.maxwidth = 640;
1141 v.minwidth = 16;
1142 v.maxheight = 480;
1143 v.minheight = 16;
1144 strcpy(v.name, "My Camera");
1145 if(copy_to_user(arg, &amp;v, sizeof(v)))
1146 return -EFAULT;
1147 return 0;
1148 }
1149
1150
1151 </programlisting>
1152 <para>
1153 The first ioctl we must support and which all video capture and radio
1154 devices are required to support is VIDIOCGCAP. This behaves exactly the same
1155 as with a radio device. This time, however, we report the extra capabilities
1156 we outlined earlier on when defining our video_dev structure.
1157 </para>
1158 <para>
1159 We now set the video flags saying that we support overlay, capture,
1160 scaling and chromakey. We also report size limits - our smallest image is
1161 16x16 pixels, our largest is 640x480.
1162 </para>
1163 <para>
1164 To keep things simple we report no audio and no tuning capabilities at all.
1165 </para>
1166 <programlisting>
1167
1168 case VIDIOCGCHAN:
1169 {
1170 struct video_channel v;
1171 if(copy_from_user(&amp;v, arg, sizeof(v)))
1172 return -EFAULT;
1173 if(v.channel != 0)
1174 return -EINVAL;
1175 v.flags = 0;
1176 v.tuners = 0;
1177 v.type = VIDEO_TYPE_CAMERA;
1178 v.norm = VIDEO_MODE_AUTO;
1179 strcpy(v.name, "Camera Input");break;
1180 if(copy_to_user(&amp;v, arg, sizeof(v)))
1181 return -EFAULT;
1182 return 0;
1183 }
1184
1185
1186 </programlisting>
1187 <para>
1188 This follows what is very much the standard way an ioctl handler looks
1189 in Linux. We copy the data into a kernel space variable and we check that the
1190 request is valid (in this case that the input is 0). Finally we copy the
1191 camera info back to the user.
1192 </para>
1193 <para>
1194 The VIDIOCGCHAN ioctl allows a user to ask about video channels (that is
1195 inputs to the video card). Our example card has a single camera input. The
1196 fields in the structure are
1197 </para>
1198 <table frame="all" id="video_channel_fields"><title>struct video_channel fields</title>
1199 <tgroup cols="2" align="left">
1200 <tbody>
1201 <row>
1202
1203 <entry>channel</entry><entry>The channel number we are selecting</entry>
1204 </row><row>
1205 <entry>name</entry><entry>The name for this channel. This is intended
1206 to describe the port to the user.
1207 Appropriate names are therefore things like
1208 "Camera" "SCART input"</entry>
1209 </row><row>
1210 <entry>flags</entry><entry>Channel properties</entry>
1211 </row><row>
1212 <entry>type</entry><entry>Input type</entry>
1213 </row><row>
1214 <entry>norm</entry><entry>The current television encoding being used
1215 if relevant for this channel.
1216 </entry>
1217 </row>
1218 </tbody>
1219 </tgroup>
1220 </table>
1221 <table frame="all" id="video_channel_flags"><title>struct video_channel flags</title>
1222 <tgroup cols="2" align="left">
1223 <tbody>
1224 <row>
1225 <entry>VIDEO_VC_TUNER</entry><entry>Channel has a tuner.</entry>
1226 </row><row>
1227 <entry>VIDEO_VC_AUDIO</entry><entry>Channel has audio.</entry>
1228 </row>
1229 </tbody>
1230 </tgroup>
1231 </table>
1232 <table frame="all" id="video_channel_types"><title>struct video_channel types</title>
1233 <tgroup cols="2" align="left">
1234 <tbody>
1235 <row>
1236 <entry>VIDEO_TYPE_TV</entry><entry>Television input.</entry>
1237 </row><row>
1238 <entry>VIDEO_TYPE_CAMERA</entry><entry>Fixed camera input.</entry>
1239 </row><row>
1240 <entry>0</entry><entry>Type is unknown.</entry>
1241 </row>
1242 </tbody>
1243 </tgroup>
1244 </table>
1245 <table frame="all" id="video_channel_norms"><title>struct video_channel norms</title>
1246 <tgroup cols="2" align="left">
1247 <tbody>
1248 <row>
1249 <entry>VIDEO_MODE_PAL</entry><entry>PAL encoded Television</entry>
1250 </row><row>
1251 <entry>VIDEO_MODE_NTSC</entry><entry>NTSC (US) encoded Television</entry>
1252 </row><row>
1253 <entry>VIDEO_MODE_SECAM</entry><entry>SECAM (French) Television </entry>
1254 </row><row>
1255 <entry>VIDEO_MODE_AUTO</entry><entry>Automatic switching, or format does not
1256 matter</entry>
1257 </row>
1258 </tbody>
1259 </tgroup>
1260 </table>
1261 <para>
1262 The corresponding VIDIOCSCHAN ioctl allows a user to change channel and to
1263 request the norm is changed - for example to switch between a PAL or an NTSC
1264 format camera.
1265 </para>
1266 <programlisting>
1267
1268
1269 case VIDIOCSCHAN:
1270 {
1271 struct video_channel v;
1272 if(copy_from_user(&amp;v, arg, sizeof(v)))
1273 return -EFAULT;
1274 if(v.channel != 0)
1275 return -EINVAL;
1276 if(v.norm != VIDEO_MODE_AUTO)
1277 return -EINVAL;
1278 return 0;
1279 }
1280
1281
1282 </programlisting>
1283 <para>
1284 The implementation of this call in our driver is remarkably easy. Because we
1285 are assuming fixed format hardware we need only check that the user has not
1286 tried to change anything.
1287 </para>
1288 <para>
1289 The user also needs to be able to configure and adjust the picture they are
1290 seeing. This is much like adjusting a television set. A user application
1291 also needs to know the palette being used so that it knows how to display
1292 the image that has been captured. The VIDIOCGPICT and VIDIOCSPICT ioctl
1293 calls provide this information.
1294 </para>
1295 <programlisting>
1296
1297
1298 case VIDIOCGPICT
1299 {
1300 struct video_picture v;
1301 v.brightness = hardware_brightness();
1302 v.hue = hardware_hue();
1303 v.colour = hardware_saturation();
1304 v.contrast = hardware_brightness();
1305 /* Not settable */
1306 v.whiteness = 32768;
1307 v.depth = 24; /* 24bit */
1308 v.palette = VIDEO_PALETTE_RGB24;
1309 if(copy_to_user(&amp;v, arg,
1310 sizeof(v)))
1311 return -EFAULT;
1312 return 0;
1313 }
1314
1315
1316 </programlisting>
1317 <para>
1318 The brightness, hue, color, and contrast provide the picture controls that
1319 are akin to a conventional television. Whiteness provides additional
1320 control for greyscale images. All of these values are scaled between 0-65535
1321 and have 32768 as the mid point setting. The scaling means that applications
1322 do not have to worry about the capability range of the hardware but can let
1323 it make a best effort attempt.
1324 </para>
1325 <para>
1326 Our depth is 24, as this is in bits. We will be returning RGB24 format. This
1327 has one byte of red, then one of green, then one of blue. This then repeats
1328 for every other pixel in the image. The other common formats the interface
1329 defines are
1330 </para>
1331 <table frame="all" id="Framebuffer_Encodings"><title>Framebuffer Encodings</title>
1332 <tgroup cols="2" align="left">
1333 <tbody>
1334 <row>
1335 <entry>GREY</entry><entry>Linear greyscale. This is for simple cameras and the
1336 like</entry>
1337 </row><row>
1338 <entry>RGB565</entry><entry>The top 5 bits hold 32 red levels, the next six bits
1339 hold green and the low 5 bits hold blue. </entry>
1340 </row><row>
1341 <entry>RGB555</entry><entry>The top bit is clear. The red green and blue levels
1342 each occupy five bits.</entry>
1343 </row>
1344 </tbody>
1345 </tgroup>
1346 </table>
1347 <para>
1348 Additional modes are support for YUV capture formats. These are common for
1349 TV and video conferencing applications.
1350 </para>
1351 <para>
1352 The VIDIOCSPICT ioctl allows a user to set some of the picture parameters.
1353 Exactly which ones are supported depends heavily on the card itself. It is
1354 possible to support many modes and effects in software. In general doing
1355 this in the kernel is a bad idea. Video capture is a performance-sensitive
1356 application and the programs can often do better if they aren't being
1357 'helped' by an overkeen driver writer. Thus for our device we will report
1358 RGB24 only and refuse to allow a change.
1359 </para>
1360 <programlisting>
1361
1362
1363 case VIDIOCSPICT:
1364 {
1365 struct video_picture v;
1366 if(copy_from_user(&amp;v, arg, sizeof(v)))
1367 return -EFAULT;
1368 if(v.depth!=24 ||
1369 v.palette != VIDEO_PALETTE_RGB24)
1370 return -EINVAL;
1371 set_hardware_brightness(v.brightness);
1372 set_hardware_hue(v.hue);
1373 set_hardware_saturation(v.colour);
1374 set_hardware_brightness(v.contrast);
1375 return 0;
1376 }
1377
1378
1379 </programlisting>
1380 <para>
1381 We check the user has not tried to change the palette or the depth. We do
1382 not want to carry out some of the changes and then return an error. This may
1383 confuse the application which will be assuming no change occurred.
1384 </para>
1385 <para>
1386 In much the same way as you need to be able to set the picture controls to
1387 get the right capture images, many cards need to know what they are
1388 displaying onto when generating overlay output. In some cases getting this
1389 wrong even makes a nasty mess or may crash the computer. For that reason
1390 the VIDIOCSBUF ioctl used to set up the frame buffer information may well
1391 only be usable by root.
1392 </para>
1393 <para>
1394 We will assume our card is one of the old ISA devices with feature connector
1395 and only supports a couple of standard video modes. Very common for older
1396 cards although the PCI devices are way smarter than this.
1397 </para>
1398 <programlisting>
1399
1400
1401static struct video_buffer capture_fb;
1402
1403 case VIDIOCGFBUF:
1404 {
1405 if(copy_to_user(arg, &amp;capture_fb,
1406 sizeof(capture_fb)))
1407 return -EFAULT;
1408 return 0;
1409
1410 }
1411
1412
1413 </programlisting>
1414 <para>
1415 We keep the frame buffer information in the format the ioctl uses. This
1416 makes it nice and easy to work with in the ioctl calls.
1417 </para>
1418 <programlisting>
1419
1420 case VIDIOCSFBUF:
1421 {
1422 struct video_buffer v;
1423
1424 if(!capable(CAP_SYS_ADMIN))
1425 return -EPERM;
1426
1427 if(copy_from_user(&amp;v, arg, sizeof(v)))
1428 return -EFAULT;
1429 if(v.width!=320 &amp;&amp; v.width!=640)
1430 return -EINVAL;
1431 if(v.height!=200 &amp;&amp; v.height!=240
1432 &amp;&amp; v.height!=400
1433 &amp;&amp; v.height !=480)
1434 return -EINVAL;
1435 memcpy(&amp;capture_fb, &amp;v, sizeof(v));
1436 hardware_set_fb(&amp;v);
1437 return 0;
1438 }
1439
1440
1441
1442 </programlisting>
1443 <para>
1444 The capable() function checks a user has the required capability. The Linux
1445 operating system has a set of about 30 capabilities indicating privileged
1446 access to services. The default set up gives the superuser (uid 0) all of
1447 them and nobody else has any.
1448 </para>
1449 <para>
1450 We check that the user has the SYS_ADMIN capability, that is they are
1451 allowed to operate as the machine administrator. We don't want anyone but
1452 the administrator making a mess of the display.
1453 </para>
1454 <para>
1455 Next we check for standard PC video modes (320 or 640 wide with either
1456 EGA or VGA depths). If the mode is not a standard video mode we reject it as
1457 not supported by our card. If the mode is acceptable we save it so that
1458 VIDIOCFBUF will give the right answer next time it is called. The
1459 hardware_set_fb() function is some undescribed card specific function to
1460 program the card for the desired mode.
1461 </para>
1462 <para>
1463 Before the driver can display an overlay window it needs to know where the
1464 window should be placed, and also how large it should be. If the card
1465 supports clipping it needs to know which rectangles to omit from the
1466 display. The video_window structure is used to describe the way the image
1467 should be displayed.
1468 </para>
1469 <table frame="all" id="video_window_fields"><title>struct video_window fields</title>
1470 <tgroup cols="2" align="left">
1471 <tbody>
1472 <row>
1473 <entry>width</entry><entry>The width in pixels of the desired image. The card
1474 may use a smaller size if this size is not available</entry>
1475 </row><row>
1476 <entry>height</entry><entry>The height of the image. The card may use a smaller
1477 size if this size is not available.</entry>
1478 </row><row>
1479 <entry>x</entry><entry> The X position of the top left of the window. This
1480 is in pixels relative to the left hand edge of the
1481 picture. Not all cards can display images aligned on
1482 any pixel boundary. If the position is unsuitable
1483 the card adjusts the image right and reduces the
1484 width.</entry>
1485 </row><row>
1486 <entry>y</entry><entry> The Y position of the top left of the window. This
1487 is counted in pixels relative to the top edge of the
1488 picture. As with the width if the card cannot
1489 display starting on this line it will adjust the
1490 values.</entry>
1491 </row><row>
1492 <entry>chromakey</entry><entry>The colour (expressed in RGB32 format) for the
1493 chromakey colour if chroma keying is being used. </entry>
1494 </row><row>
1495 <entry>clips</entry><entry>An array of rectangles that must not be drawn
1496 over.</entry>
1497 </row><row>
1498 <entry>clipcount</entry><entry>The number of clips in this array.</entry>
1499 </row>
1500 </tbody>
1501 </tgroup>
1502 </table>
1503 <para>
1504 Each clip is a struct video_clip which has the following fields
1505 </para>
1506 <table frame="all" id="video_clip_fields"><title>video_clip fields</title>
1507 <tgroup cols="2" align="left">
1508 <tbody>
1509 <row>
1510 <entry>x, y</entry><entry>Co-ordinates relative to the display</entry>
1511 </row><row>
1512 <entry>width, height</entry><entry>Width and height in pixels</entry>
1513 </row><row>
1514 <entry>next</entry><entry>A spare field for the application to use</entry>
1515 </row>
1516 </tbody>
1517 </tgroup>
1518 </table>
1519 <para>
1520 The driver is required to ensure it always draws in the area requested or a smaller area, and that it never draws in any of the areas that are clipped.
1521 This may well mean it has to leave alone. small areas the application wished to be
1522 drawn.
1523 </para>
1524 <para>
1525 Our example card uses chromakey so does not have to address most of the
1526 clipping. We will add a video_window structure to our global variables to
1527 remember our parameters, as we did with the frame buffer.
1528 </para>
1529 <programlisting>
1530
1531
1532 case VIDIOCGWIN:
1533 {
1534 if(copy_to_user(arg, &amp;capture_win,
1535 sizeof(capture_win)))
1536 return -EFAULT;
1537 return 0;
1538 }
1539
1540
1541 case VIDIOCSWIN:
1542 {
1543 struct video_window v;
1544 if(copy_from_user(&amp;v, arg, sizeof(v)))
1545 return -EFAULT;
1546 if(v.width &gt; 640 || v.height &gt; 480)
1547 return -EINVAL;
1548 if(v.width &lt; 16 || v.height &lt; 16)
1549 return -EINVAL;
1550 hardware_set_key(v.chromakey);
1551 hardware_set_window(v);
1552 memcpy(&amp;capture_win, &amp;v, sizeof(v));
1553 capture_w = v.width;
1554 capture_h = v.height;
1555 return 0;
1556 }
1557
1558
1559 </programlisting>
1560 <para>
1561 Because we are using Chromakey our setup is fairly simple. Mostly we have to
1562 check the values are sane and load them into the capture card.
1563 </para>
1564 <para>
1565 With all the setup done we can now turn on the actual capture/overlay. This
1566 is done with the VIDIOCCAPTURE ioctl. This takes a single integer argument
1567 where 0 is on and 1 is off.
1568 </para>
1569 <programlisting>
1570
1571
1572 case VIDIOCCAPTURE:
1573 {
1574 int v;
1575 if(get_user(v, (int *)arg))
1576 return -EFAULT;
1577 if(v==0)
1578 hardware_capture_off();
1579 else
1580 {
1581 if(capture_fb.width == 0
1582 || capture_w == 0)
1583 return -EINVAL;
1584 hardware_capture_on();
1585 }
1586 return 0;
1587 }
1588
1589
1590 </programlisting>
1591 <para>
1592 We grab the flag from user space and either enable or disable according to
1593 its value. There is one small corner case we have to consider here. Suppose
1594 that the capture was requested before the video window or the frame buffer
1595 had been set up. In those cases there will be unconfigured fields in our
1596 card data, as well as unconfigured hardware settings. We check for this case and
1597 return an error if the frame buffer or the capture window width is zero.
1598 </para>
1599 <programlisting>
1600
1601
1602 default:
1603 return -ENOIOCTLCMD;
1604 }
1605}
1606 </programlisting>
1607 <para>
1608
1609 We don't need to support any other ioctls, so if we get this far, it is time
1610 to tell the video layer that we don't now what the user is talking about.
1611 </para>
1612 </sect1>
1613 <sect1 id="endvid">
1614 <title>Other Functionality</title>
1615 <para>
1616 The Video4Linux layer supports additional features, including a high
1617 performance mmap() based capture mode and capturing part of the image.
1618 These features are out of the scope of the book. You should however have enough
1619 example code to implement most simple video4linux devices for radio and TV
1620 cards.
1621 </para>
1622 </sect1>
1623 </chapter>
1624 <chapter id="bugs">
1625 <title>Known Bugs And Assumptions</title>
1626 <para>
1627 <variablelist>
1628 <varlistentry><term>Multiple Opens</term>
1629 <listitem>
1630 <para>
1631 The driver assumes multiple opens should not be allowed. A driver
1632 can work around this but not cleanly.
1633 </para>
1634 </listitem></varlistentry>
1635
1636 <varlistentry><term>API Deficiencies</term>
1637 <listitem>
1638 <para>
1639 The existing API poorly reflects compression capable devices. There
1640 are plans afoot to merge V4L, V4L2 and some other ideas into a
1641 better interface.
1642 </para>
1643 </listitem></varlistentry>
1644 </variablelist>
1645
1646 </para>
1647 </chapter>
1648
1649 <chapter id="pubfunctions">
1650 <title>Public Functions Provided</title>
1651!Edrivers/media/video/v4l2-dev.c
1652 </chapter>
1653
1654</book>
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index 48a3955f05fc..8495fc970391 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -112,7 +112,7 @@ required reading:
112 112
113 Other excellent descriptions of how to create patches properly are: 113 Other excellent descriptions of how to create patches properly are:
114 "The Perfect Patch" 114 "The Perfect Patch"
115 http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt 115 http://userweb.kernel.org/~akpm/stuff/tpp.txt
116 "Linux kernel patch submission format" 116 "Linux kernel patch submission format"
117 http://linux.yyz.us/patch-format.html 117 http://linux.yyz.us/patch-format.html
118 118
@@ -620,7 +620,7 @@ all time. It should describe the patch completely, containing:
620For more details on what this should all look like, please see the 620For more details on what this should all look like, please see the
621ChangeLog section of the document: 621ChangeLog section of the document:
622 "The Perfect Patch" 622 "The Perfect Patch"
623 http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt 623 http://userweb.kernel.org/~akpm/stuff/tpp.txt
624 624
625 625
626 626
diff --git a/Documentation/SAK.txt b/Documentation/SAK.txt
index b9019ca872ea..74be14679ed8 100644
--- a/Documentation/SAK.txt
+++ b/Documentation/SAK.txt
@@ -1,5 +1,5 @@
1Linux 2.4.2 Secure Attention Key (SAK) handling 1Linux 2.4.2 Secure Attention Key (SAK) handling
218 March 2001, Andrew Morton <akpm@osdl.org> 218 March 2001, Andrew Morton
3 3
4An operating system's Secure Attention Key is a security tool which is 4An operating system's Secure Attention Key is a security tool which is
5provided as protection against trojan password capturing programs. It 5provided as protection against trojan password capturing programs. It
diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
index 21f0795af20f..ac5e0b2f1097 100644
--- a/Documentation/SubmitChecklist
+++ b/Documentation/SubmitChecklist
@@ -85,3 +85,6 @@ kernel patches.
8523: Tested after it has been merged into the -mm patchset to make sure 8523: Tested after it has been merged into the -mm patchset to make sure
86 that it still works with all of the other queued patches and various 86 that it still works with all of the other queued patches and various
87 changes in the VM, VFS, and other subsystems. 87 changes in the VM, VFS, and other subsystems.
88
8924: All memory barriers {e.g., barrier(), rmb(), wmb()} need a comment in the
90 source code that explains the logic of what they are doing and why.
diff --git a/Documentation/SubmittingDrivers b/Documentation/SubmittingDrivers
index 24f2eb40cae5..99e72a81fa2f 100644
--- a/Documentation/SubmittingDrivers
+++ b/Documentation/SubmittingDrivers
@@ -41,7 +41,7 @@ Linux 2.4:
41Linux 2.6: 41Linux 2.6:
42 The same rules apply as 2.4 except that you should follow linux-kernel 42 The same rules apply as 2.4 except that you should follow linux-kernel
43 to track changes in API's. The final contact point for Linux 2.6 43 to track changes in API's. The final contact point for Linux 2.6
44 submissions is Andrew Morton <akpm@osdl.org>. 44 submissions is Andrew Morton.
45 45
46What Criteria Determine Acceptance 46What Criteria Determine Acceptance
47---------------------------------- 47----------------------------------
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index f79ad9ff6031..f309d3c6221c 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -77,7 +77,7 @@ Quilt:
77http://savannah.nongnu.org/projects/quilt 77http://savannah.nongnu.org/projects/quilt
78 78
79Andrew Morton's patch scripts: 79Andrew Morton's patch scripts:
80http://www.zip.com.au/~akpm/linux/patches/ 80http://userweb.kernel.org/~akpm/stuff/patch-scripts.tar.gz
81Instead of these scripts, quilt is the recommended patch management 81Instead of these scripts, quilt is the recommended patch management
82tool (see above). 82tool (see above).
83 83
@@ -405,7 +405,7 @@ person it names. This tag documents that potentially interested parties
405have been included in the discussion 405have been included in the discussion
406 406
407 407
40814) Using Test-by: and Reviewed-by: 40814) Using Tested-by: and Reviewed-by:
409 409
410A Tested-by: tag indicates that the patch has been successfully tested (in 410A Tested-by: tag indicates that the patch has been successfully tested (in
411some environment) by the person named. This tag informs maintainers that 411some environment) by the person named. This tag informs maintainers that
@@ -653,7 +653,7 @@ SECTION 3 - REFERENCES
653---------------------- 653----------------------
654 654
655Andrew Morton, "The perfect patch" (tpp). 655Andrew Morton, "The perfect patch" (tpp).
656 <http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt> 656 <http://userweb.kernel.org/~akpm/stuff/tpp.txt>
657 657
658Jeff Garzik, "Linux kernel patch submission format". 658Jeff Garzik, "Linux kernel patch submission format".
659 <http://linux.yyz.us/patch-format.html> 659 <http://linux.yyz.us/patch-format.html>
@@ -672,4 +672,9 @@ Kernel Documentation/CodingStyle:
672 672
673Linus Torvalds's mail on the canonical patch format: 673Linus Torvalds's mail on the canonical patch format:
674 <http://lkml.org/lkml/2005/4/7/183> 674 <http://lkml.org/lkml/2005/4/7/183>
675
676Andi Kleen, "On submitting kernel patches"
677 Some strategies to get difficult or controversal changes in.
678 http://halobates.de/on-submitting-patches.pdf
679
675-- 680--
diff --git a/Documentation/block/data-integrity.txt b/Documentation/block/data-integrity.txt
index e9dc8d86adc7..e8ca040ba2cf 100644
--- a/Documentation/block/data-integrity.txt
+++ b/Documentation/block/data-integrity.txt
@@ -246,7 +246,7 @@ will require extra work due to the application tag.
246 retrieve the tag buffer using bio_integrity_get_tag(). 246 retrieve the tag buffer using bio_integrity_get_tag().
247 247
248 248
2496.3 PASSING EXISTING INTEGRITY METADATA 2495.3 PASSING EXISTING INTEGRITY METADATA
250 250
251 Filesystems that either generate their own integrity metadata or 251 Filesystems that either generate their own integrity metadata or
252 are capable of transferring IMD from user space can use the 252 are capable of transferring IMD from user space can use the
@@ -283,7 +283,7 @@ will require extra work due to the application tag.
283 integrity upon completion. 283 integrity upon completion.
284 284
285 285
2866.4 REGISTERING A BLOCK DEVICE AS CAPABLE OF EXCHANGING INTEGRITY 2865.4 REGISTERING A BLOCK DEVICE AS CAPABLE OF EXCHANGING INTEGRITY
287 METADATA 287 METADATA
288 288
289 To enable integrity exchange on a block device the gendisk must be 289 To enable integrity exchange on a block device the gendisk must be
diff --git a/Documentation/cris/README b/Documentation/cris/README
index 795a1dabe6c7..d9b086869a60 100644
--- a/Documentation/cris/README
+++ b/Documentation/cris/README
@@ -27,7 +27,7 @@ operating system.
27The ETRAX 100LX chip 27The ETRAX 100LX chip
28-------------------- 28--------------------
29 29
30For reference, plase see the press-release: 30For reference, please see the press-release:
31 31
32http://www.axis.com/news/us/001101_etrax.htm 32http://www.axis.com/news/us/001101_etrax.htm
33 33
diff --git a/Documentation/development-process/1.Intro b/Documentation/development-process/1.Intro
new file mode 100644
index 000000000000..8cc2cba2b10d
--- /dev/null
+++ b/Documentation/development-process/1.Intro
@@ -0,0 +1,274 @@
11: A GUIDE TO THE KERNEL DEVELOPMENT PROCESS
2
3The purpose of this document is to help developers (and their managers)
4work with the development community with a minimum of frustration. It is
5an attempt to document how this community works in a way which is
6accessible to those who are not intimately familiar with Linux kernel
7development (or, indeed, free software development in general). While
8there is some technical material here, this is very much a process-oriented
9discussion which does not require a deep knowledge of kernel programming to
10understand.
11
12
131.1: EXECUTIVE SUMMARY
14
15The rest of this section covers the scope of the kernel development process
16and the kinds of frustrations that developers and their employers can
17encounter there. There are a great many reasons why kernel code should be
18merged into the official ("mainline") kernel, including automatic
19availability to users, community support in many forms, and the ability to
20influence the direction of kernel development. Code contributed to the
21Linux kernel must be made available under a GPL-compatible license.
22
23Section 2 introduces the development process, the kernel release cycle, and
24the mechanics of the merge window. The various phases in the patch
25development, review, and merging cycle are covered. There is some
26discussion of tools and mailing lists. Developers wanting to get started
27with kernel development are encouraged to track down and fix bugs as an
28initial exercise.
29
30Section 3 covers early-stage project planning, with an emphasis on
31involving the development community as soon as possible.
32
33Section 4 is about the coding process; several pitfalls which have been
34encountered by other developers are discussed. Some requirements for
35patches are covered, and there is an introduction to some of the tools
36which can help to ensure that kernel patches are correct.
37
38Section 5 talks about the process of posting patches for review. To be
39taken seriously by the development community, patches must be properly
40formatted and described, and they must be sent to the right place.
41Following the advice in this section should help to ensure the best
42possible reception for your work.
43
44Section 6 covers what happens after posting patches; the job is far from
45done at that point. Working with reviewers is a crucial part of the
46development process; this section offers a number of tips on how to avoid
47problems at this important stage. Developers are cautioned against
48assuming that the job is done when a patch is merged into the mainline.
49
50Section 7 introduces a couple of "advanced" topics: managing patches with
51git and reviewing patches posted by others.
52
53Section 8 concludes the document with pointers to sources for more
54information on kernel development.
55
56
571.2: WHAT THIS DOCUMENT IS ABOUT
58
59The Linux kernel, at over 6 million lines of code and well over 1000 active
60contributors, is one of the largest and most active free software projects
61in existence. Since its humble beginning in 1991, this kernel has evolved
62into a best-of-breed operating system component which runs on pocket-sized
63digital music players, desktop PCs, the largest supercomputers in
64existence, and all types of systems in between. It is a robust, efficient,
65and scalable solution for almost any situation.
66
67With the growth of Linux has come an increase in the number of developers
68(and companies) wishing to participate in its development. Hardware
69vendors want to ensure that Linux supports their products well, making
70those products attractive to Linux users. Embedded systems vendors, who
71use Linux as a component in an integrated product, want Linux to be as
72capable and well-suited to the task at hand as possible. Distributors and
73other software vendors who base their products on Linux have a clear
74interest in the capabilities, performance, and reliability of the Linux
75kernel. And end users, too, will often wish to change Linux to make it
76better suit their needs.
77
78One of the most compelling features of Linux is that it is accessible to
79these developers; anybody with the requisite skills can improve Linux and
80influence the direction of its development. Proprietary products cannot
81offer this kind of openness, which is a characteristic of the free software
82process. But, if anything, the kernel is even more open than most other
83free software projects. A typical three-month kernel development cycle can
84involve over 1000 developers working for more than 100 different companies
85(or for no company at all).
86
87Working with the kernel development community is not especially hard. But,
88that notwithstanding, many potential contributors have experienced
89difficulties when trying to do kernel work. The kernel community has
90evolved its own distinct ways of operating which allow it to function
91smoothly (and produce a high-quality product) in an environment where
92thousands of lines of code are being changed every day. So it is not
93surprising that Linux kernel development process differs greatly from
94proprietary development methods.
95
96The kernel's development process may come across as strange and
97intimidating to new developers, but there are good reasons and solid
98experience behind it. A developer who does not understand the kernel
99community's ways (or, worse, who tries to flout or circumvent them) will
100have a frustrating experience in store. The development community, while
101being helpful to those who are trying to learn, has little time for those
102who will not listen or who do not care about the development process.
103
104It is hoped that those who read this document will be able to avoid that
105frustrating experience. There is a lot of material here, but the effort
106involved in reading it will be repaid in short order. The development
107community is always in need of developers who will help to make the kernel
108better; the following text should help you - or those who work for you -
109join our community.
110
111
1121.3: CREDITS
113
114This document was written by Jonathan Corbet, corbet@lwn.net. It has been
115improved by comments from Johannes Berg, James Berry, Alex Chiang, Roland
116Dreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh,
117Amanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata, and
118Jochen Voß.
119
120This work was supported by the Linux Foundation; thanks especially to
121Amanda McPherson, who saw the value of this effort and made it all happen.
122
123
1241.4: THE IMPORTANCE OF GETTING CODE INTO THE MAINLINE
125
126Some companies and developers occasionally wonder why they should bother
127learning how to work with the kernel community and get their code into the
128mainline kernel (the "mainline" being the kernel maintained by Linus
129Torvalds and used as a base by Linux distributors). In the short term,
130contributing code can look like an avoidable expense; it seems easier to
131just keep the code separate and support users directly. The truth of the
132matter is that keeping code separate ("out of tree") is a false economy.
133
134As a way of illustrating the costs of out-of-tree code, here are a few
135relevant aspects of the kernel development process; most of these will be
136discussed in greater detail later in this document. Consider:
137
138- Code which has been merged into the mainline kernel is available to all
139 Linux users. It will automatically be present on all distributions which
140 enable it. There is no need for driver disks, downloads, or the hassles
141 of supporting multiple versions of multiple distributions; it all just
142 works, for the developer and for the user. Incorporation into the
143 mainline solves a large number of distribution and support problems.
144
145- While kernel developers strive to maintain a stable interface to user
146 space, the internal kernel API is in constant flux. The lack of a stable
147 internal interface is a deliberate design decision; it allows fundamental
148 improvements to be made at any time and results in higher-quality code.
149 But one result of that policy is that any out-of-tree code requires
150 constant upkeep if it is to work with new kernels. Maintaining
151 out-of-tree code requires significant amounts of work just to keep that
152 code working.
153
154 Code which is in the mainline, instead, does not require this work as the
155 result of a simple rule requiring any developer who makes an API change
156 to also fix any code that breaks as the result of that change. So code
157 which has been merged into the mainline has significantly lower
158 maintenance costs.
159
160- Beyond that, code which is in the kernel will often be improved by other
161 developers. Surprising results can come from empowering your user
162 community and customers to improve your product.
163
164- Kernel code is subjected to review, both before and after merging into
165 the mainline. No matter how strong the original developer's skills are,
166 this review process invariably finds ways in which the code can be
167 improved. Often review finds severe bugs and security problems. This is
168 especially true for code which has been developed in a closed
169 environment; such code benefits strongly from review by outside
170 developers. Out-of-tree code is lower-quality code.
171
172- Participation in the development process is your way to influence the
173 direction of kernel development. Users who complain from the sidelines
174 are heard, but active developers have a stronger voice - and the ability
175 to implement changes which make the kernel work better for their needs.
176
177- When code is maintained separately, the possibility that a third party
178 will contribute a different implementation of a similar feature always
179 exists. Should that happen, getting your code merged will become much
180 harder - to the point of impossibility. Then you will be faced with the
181 unpleasant alternatives of either (1) maintaining a nonstandard feature
182 out of tree indefinitely, or (2) abandoning your code and migrating your
183 users over to the in-tree version.
184
185- Contribution of code is the fundamental action which makes the whole
186 process work. By contributing your code you can add new functionality to
187 the kernel and provide capabilities and examples which are of use to
188 other kernel developers. If you have developed code for Linux (or are
189 thinking about doing so), you clearly have an interest in the continued
190 success of this platform; contributing code is one of the best ways to
191 help ensure that success.
192
193All of the reasoning above applies to any out-of-tree kernel code,
194including code which is distributed in proprietary, binary-only form.
195There are, however, additional factors which should be taken into account
196before considering any sort of binary-only kernel code distribution. These
197include:
198
199- The legal issues around the distribution of proprietary kernel modules
200 are cloudy at best; quite a few kernel copyright holders believe that
201 most binary-only modules are derived products of the kernel and that, as
202 a result, their distribution is a violation of the GNU General Public
203 license (about which more will be said below). Your author is not a
204 lawyer, and nothing in this document can possibly be considered to be
205 legal advice. The true legal status of closed-source modules can only be
206 determined by the courts. But the uncertainty which haunts those modules
207 is there regardless.
208
209- Binary modules greatly increase the difficulty of debugging kernel
210 problems, to the point that most kernel developers will not even try. So
211 the distribution of binary-only modules will make it harder for your
212 users to get support from the community.
213
214- Support is also harder for distributors of binary-only modules, who must
215 provide a version of the module for every distribution and every kernel
216 version they wish to support. Dozens of builds of a single module can
217 be required to provide reasonably comprehensive coverage, and your users
218 will have to upgrade your module separately every time they upgrade their
219 kernel.
220
221- Everything that was said above about code review applies doubly to
222 closed-source code. Since this code is not available at all, it cannot
223 have been reviewed by the community and will, beyond doubt, have serious
224 problems.
225
226Makers of embedded systems, in particular, may be tempted to disregard much
227of what has been said in this section in the belief that they are shipping
228a self-contained product which uses a frozen kernel version and requires no
229more development after its release. This argument misses the value of
230widespread code review and the value of allowing your users to add
231capabilities to your product. But these products, too, have a limited
232commercial life, after which a new version must be released. At that
233point, vendors whose code is in the mainline and well maintained will be
234much better positioned to get the new product ready for market quickly.
235
236
2371.5: LICENSING
238
239Code is contributed to the Linux kernel under a number of licenses, but all
240code must be compatible with version 2 of the GNU General Public License
241(GPLv2), which is the license covering the kernel distribution as a whole.
242In practice, that means that all code contributions are covered either by
243GPLv2 (with, optionally, language allowing distribution under later
244versions of the GPL) or the three-clause BSD license. Any contributions
245which are not covered by a compatible license will not be accepted into the
246kernel.
247
248Copyright assignments are not required (or requested) for code contributed
249to the kernel. All code merged into the mainline kernel retains its
250original ownership; as a result, the kernel now has thousands of owners.
251
252One implication of this ownership structure is that any attempt to change
253the licensing of the kernel is doomed to almost certain failure. There are
254few practical scenarios where the agreement of all copyright holders could
255be obtained (or their code removed from the kernel). So, in particular,
256there is no prospect of a migration to version 3 of the GPL in the
257foreseeable future.
258
259It is imperative that all code contributed to the kernel be legitimately
260free software. For that reason, code from anonymous (or pseudonymous)
261contributors will not be accepted. All contributors are required to "sign
262off" on their code, stating that the code can be distributed with the
263kernel under the GPL. Code which has not been licensed as free software by
264its owner, or which risks creating copyright-related problems for the
265kernel (such as code which derives from reverse-engineering efforts lacking
266proper safeguards) cannot be contributed.
267
268Questions about copyright-related issues are common on Linux development
269mailing lists. Such questions will normally receive no shortage of
270answers, but one should bear in mind that the people answering those
271questions are not lawyers and cannot provide legal advice. If you have
272legal questions relating to Linux source code, there is no substitute for
273talking with a lawyer who understands this field. Relying on answers
274obtained on technical mailing lists is a risky affair.
diff --git a/Documentation/development-process/2.Process b/Documentation/development-process/2.Process
new file mode 100644
index 000000000000..d750321acd5a
--- /dev/null
+++ b/Documentation/development-process/2.Process
@@ -0,0 +1,459 @@
12: HOW THE DEVELOPMENT PROCESS WORKS
2
3Linux kernel development in the early 1990's was a pretty loose affair,
4with relatively small numbers of users and developers involved. With a
5user base in the millions and with some 2,000 developers involved over the
6course of one year, the kernel has since had to evolve a number of
7processes to keep development happening smoothly. A solid understanding of
8how the process works is required in order to be an effective part of it.
9
10
112.1: THE BIG PICTURE
12
13The kernel developers use a loosely time-based release process, with a new
14major kernel release happening every two or three months. The recent
15release history looks like this:
16
17 2.6.26 July 13, 2008
18 2.6.25 April 16, 2008
19 2.6.24 January 24, 2008
20 2.6.23 October 9, 2007
21 2.6.22 July 8, 2007
22 2.6.21 April 25, 2007
23 2.6.20 February 4, 2007
24
25Every 2.6.x release is a major kernel release with new features, internal
26API changes, and more. A typical 2.6 release can contain over 10,000
27changesets with changes to several hundred thousand lines of code. 2.6 is
28thus the leading edge of Linux kernel development; the kernel uses a
29rolling development model which is continually integrating major changes.
30
31A relatively straightforward discipline is followed with regard to the
32merging of patches for each release. At the beginning of each development
33cycle, the "merge window" is said to be open. At that time, code which is
34deemed to be sufficiently stable (and which is accepted by the development
35community) is merged into the mainline kernel. The bulk of changes for a
36new development cycle (and all of the major changes) will be merged during
37this time, at a rate approaching 1,000 changes ("patches," or "changesets")
38per day.
39
40(As an aside, it is worth noting that the changes integrated during the
41merge window do not come out of thin air; they have been collected, tested,
42and staged ahead of time. How that process works will be described in
43detail later on).
44
45The merge window lasts for two weeks. At the end of this time, Linus
46Torvalds will declare that the window is closed and release the first of
47the "rc" kernels. For the kernel which is destined to be 2.6.26, for
48example, the release which happens at the end of the merge window will be
49called 2.6.26-rc1. The -rc1 release is the signal that the time to merge
50new features has passed, and that the time to stabilize the next kernel has
51begun.
52
53Over the next six to ten weeks, only patches which fix problems should be
54submitted to the mainline. On occasion a more significant change will be
55allowed, but such occasions are rare; developers who try to merge new
56features outside of the merge window tend to get an unfriendly reception.
57As a general rule, if you miss the merge window for a given feature, the
58best thing to do is to wait for the next development cycle. (An occasional
59exception is made for drivers for previously-unsupported hardware; if they
60touch no in-tree code, they cannot cause regressions and should be safe to
61add at any time).
62
63As fixes make their way into the mainline, the patch rate will slow over
64time. Linus releases new -rc kernels about once a week; a normal series
65will get up to somewhere between -rc6 and -rc9 before the kernel is
66considered to be sufficiently stable and the final 2.6.x release is made.
67At that point the whole process starts over again.
68
69As an example, here is how the 2.6.25 development cycle went (all dates in
702008):
71
72 January 24 2.6.24 stable release
73 February 10 2.6.25-rc1, merge window closes
74 February 15 2.6.25-rc2
75 February 24 2.6.25-rc3
76 March 4 2.6.25-rc4
77 March 9 2.6.25-rc5
78 March 16 2.6.25-rc6
79 March 25 2.6.25-rc7
80 April 1 2.6.25-rc8
81 April 11 2.6.25-rc9
82 April 16 2.6.25 stable release
83
84How do the developers decide when to close the development cycle and create
85the stable release? The most significant metric used is the list of
86regressions from previous releases. No bugs are welcome, but those which
87break systems which worked in the past are considered to be especially
88serious. For this reason, patches which cause regressions are looked upon
89unfavorably and are quite likely to be reverted during the stabilization
90period.
91
92The developers' goal is to fix all known regressions before the stable
93release is made. In the real world, this kind of perfection is hard to
94achieve; there are just too many variables in a project of this size.
95There comes a point where delaying the final release just makes the problem
96worse; the pile of changes waiting for the next merge window will grow
97larger, creating even more regressions the next time around. So most 2.6.x
98kernels go out with a handful of known regressions though, hopefully, none
99of them are serious.
100
101Once a stable release is made, its ongoing maintenance is passed off to the
102"stable team," currently comprised of Greg Kroah-Hartman and Chris Wright.
103The stable team will release occasional updates to the stable release using
104the 2.6.x.y numbering scheme. To be considered for an update release, a
105patch must (1) fix a significant bug, and (2) already be merged into the
106mainline for the next development kernel. Continuing our 2.6.25 example,
107the history (as of this writing) is:
108
109 May 1 2.6.25.1
110 May 6 2.6.25.2
111 May 9 2.6.25.3
112 May 15 2.6.25.4
113 June 7 2.6.25.5
114 June 9 2.6.25.6
115 June 16 2.6.25.7
116 June 21 2.6.25.8
117 June 24 2.6.25.9
118
119Stable updates for a given kernel are made for approximately six months;
120after that, the maintenance of stable releases is solely the responsibility
121of the distributors which have shipped that particular kernel.
122
123
1242.2: THE LIFECYCLE OF A PATCH
125
126Patches do not go directly from the developer's keyboard into the mainline
127kernel. There is, instead, a somewhat involved (if somewhat informal)
128process designed to ensure that each patch is reviewed for quality and that
129each patch implements a change which is desirable to have in the mainline.
130This process can happen quickly for minor fixes, or, in the case of large
131and controversial changes, go on for years. Much developer frustration
132comes from a lack of understanding of this process or from attempts to
133circumvent it.
134
135In the hopes of reducing that frustration, this document will describe how
136a patch gets into the kernel. What follows below is an introduction which
137describes the process in a somewhat idealized way. A much more detailed
138treatment will come in later sections.
139
140The stages that a patch goes through are, generally:
141
142 - Design. This is where the real requirements for the patch - and the way
143 those requirements will be met - are laid out. Design work is often
144 done without involving the community, but it is better to do this work
145 in the open if at all possible; it can save a lot of time redesigning
146 things later.
147
148 - Early review. Patches are posted to the relevant mailing list, and
149 developers on that list reply with any comments they may have. This
150 process should turn up any major problems with a patch if all goes
151 well.
152
153 - Wider review. When the patch is getting close to ready for mainline
154 inclusion, it will be accepted by a relevant subsystem maintainer -
155 though this acceptance is not a guarantee that the patch will make it
156 all the way to the mainline. The patch will show up in the maintainer's
157 subsystem tree and into the staging trees (described below). When the
158 process works, this step leads to more extensive review of the patch and
159 the discovery of any problems resulting from the integration of this
160 patch with work being done by others.
161
162 - Merging into the mainline. Eventually, a successful patch will be
163 merged into the mainline repository managed by Linus Torvalds. More
164 comments and/or problems may surface at this time; it is important that
165 the developer be responsive to these and fix any issues which arise.
166
167 - Stable release. The number of users potentially affected by the patch
168 is now large, so, once again, new problems may arise.
169
170 - Long-term maintenance. While it is certainly possible for a developer
171 to forget about code after merging it, that sort of behavior tends to
172 leave a poor impression in the development community. Merging code
173 eliminates some of the maintenance burden, in that others will fix
174 problems caused by API changes. But the original developer should
175 continue to take responsibility for the code if it is to remain useful
176 in the longer term.
177
178One of the largest mistakes made by kernel developers (or their employers)
179is to try to cut the process down to a single "merging into the mainline"
180step. This approach invariably leads to frustration for everybody
181involved.
182
183
1842.3: HOW PATCHES GET INTO THE KERNEL
185
186There is exactly one person who can merge patches into the mainline kernel
187repository: Linus Torvalds. But, of the over 12,000 patches which went
188into the 2.6.25 kernel, only 250 (around 2%) were directly chosen by Linus
189himself. The kernel project has long since grown to a size where no single
190developer could possibly inspect and select every patch unassisted. The
191way the kernel developers have addressed this growth is through the use of
192a lieutenant system built around a chain of trust.
193
194The kernel code base is logically broken down into a set of subsystems:
195networking, specific architecture support, memory management, video
196devices, etc. Most subsystems have a designated maintainer, a developer
197who has overall responsibility for the code within that subsystem. These
198subsystem maintainers are the gatekeepers (in a loose way) for the portion
199of the kernel they manage; they are the ones who will (usually) accept a
200patch for inclusion into the mainline kernel.
201
202Subsystem maintainers each manage their own version of the kernel source
203tree, usually (but certainly not always) using the git source management
204tool. Tools like git (and related tools like quilt or mercurial) allow
205maintainers to track a list of patches, including authorship information
206and other metadata. At any given time, the maintainer can identify which
207patches in his or her repository are not found in the mainline.
208
209When the merge window opens, top-level maintainers will ask Linus to "pull"
210the patches they have selected for merging from their repositories. If
211Linus agrees, the stream of patches will flow up into his repository,
212becoming part of the mainline kernel. The amount of attention that Linus
213pays to specific patches received in a pull operation varies. It is clear
214that, sometimes, he looks quite closely. But, as a general rule, Linus
215trusts the subsystem maintainers to not send bad patches upstream.
216
217Subsystem maintainers, in turn, can pull patches from other maintainers.
218For example, the networking tree is built from patches which accumulated
219first in trees dedicated to network device drivers, wireless networking,
220etc. This chain of repositories can be arbitrarily long, though it rarely
221exceeds two or three links. Since each maintainer in the chain trusts
222those managing lower-level trees, this process is known as the "chain of
223trust."
224
225Clearly, in a system like this, getting patches into the kernel depends on
226finding the right maintainer. Sending patches directly to Linus is not
227normally the right way to go.
228
229
2302.4: STAGING TREES
231
232The chain of subsystem trees guides the flow of patches into the kernel,
233but it also raises an interesting question: what if somebody wants to look
234at all of the patches which are being prepared for the next merge window?
235Developers will be interested in what other changes are pending to see
236whether there are any conflicts to worry about; a patch which changes a
237core kernel function prototype, for example, will conflict with any other
238patches which use the older form of that function. Reviewers and testers
239want access to the changes in their integrated form before all of those
240changes land in the mainline kernel. One could pull changes from all of
241the interesting subsystem trees, but that would be a big and error-prone
242job.
243
244The answer comes in the form of staging trees, where subsystem trees are
245collected for testing and review. The older of these trees, maintained by
246Andrew Morton, is called "-mm" (for memory management, which is how it got
247started). The -mm tree integrates patches from a long list of subsystem
248trees; it also has some patches aimed at helping with debugging.
249
250Beyond that, -mm contains a significant collection of patches which have
251been selected by Andrew directly. These patches may have been posted on a
252mailing list, or they may apply to a part of the kernel for which there is
253no designated subsystem tree. As a result, -mm operates as a sort of
254subsystem tree of last resort; if there is no other obvious path for a
255patch into the mainline, it is likely to end up in -mm. Miscellaneous
256patches which accumulate in -mm will eventually either be forwarded on to
257an appropriate subsystem tree or be sent directly to Linus. In a typical
258development cycle, approximately 10% of the patches going into the mainline
259get there via -mm.
260
261The current -mm patch can always be found from the front page of
262
263 http://kernel.org/
264
265Those who want to see the current state of -mm can get the "-mm of the
266moment" tree, found at:
267
268 http://userweb.kernel.org/~akpm/mmotm/
269
270Use of the MMOTM tree is likely to be a frustrating experience, though;
271there is a definite chance that it will not even compile.
272
273The other staging tree, started more recently, is linux-next, maintained by
274Stephen Rothwell. The linux-next tree is, by design, a snapshot of what
275the mainline is expected to look like after the next merge window closes.
276Linux-next trees are announced on the linux-kernel and linux-next mailing
277lists when they are assembled; they can be downloaded from:
278
279 http://www.kernel.org/pub/linux/kernel/people/sfr/linux-next/
280
281Some information about linux-next has been gathered at:
282
283 http://linux.f-seidel.de/linux-next/pmwiki/
284
285How the linux-next tree will fit into the development process is still
286changing. As of this writing, the first full development cycle involving
287linux-next (2.6.26) is coming to an end; thus far, it has proved to be a
288valuable resource for finding and fixing integration problems before the
289beginning of the merge window. See http://lwn.net/Articles/287155/ for
290more information on how linux-next has worked to set up the 2.6.27 merge
291window.
292
293Some developers have begun to suggest that linux-next should be used as the
294target for future development as well. The linux-next tree does tend to be
295far ahead of the mainline and is more representative of the tree into which
296any new work will be merged. The downside to this idea is that the
297volatility of linux-next tends to make it a difficult development target.
298See http://lwn.net/Articles/289013/ for more information on this topic, and
299stay tuned; much is still in flux where linux-next is involved.
300
301
3022.5: TOOLS
303
304As can be seen from the above text, the kernel development process depends
305heavily on the ability to herd collections of patches in various
306directions. The whole thing would not work anywhere near as well as it
307does without suitably powerful tools. Tutorials on how to use these tools
308are well beyond the scope of this document, but there is space for a few
309pointers.
310
311By far the dominant source code management system used by the kernel
312community is git. Git is one of a number of distributed version control
313systems being developed in the free software community. It is well tuned
314for kernel development, in that it performs quite well when dealing with
315large repositories and large numbers of patches. It also has a reputation
316for being difficult to learn and use, though it has gotten better over
317time. Some sort of familiarity with git is almost a requirement for kernel
318developers; even if they do not use it for their own work, they'll need git
319to keep up with what other developers (and the mainline) are doing.
320
321Git is now packaged by almost all Linux distributions. There is a home
322page at
323
324 http://git.or.cz/
325
326That page has pointers to documentation and tutorials. One should be
327aware, in particular, of the Kernel Hacker's Guide to git, which has
328information specific to kernel development:
329
330 http://linux.yyz.us/git-howto.html
331
332Among the kernel developers who do not use git, the most popular choice is
333almost certainly Mercurial:
334
335 http://www.selenic.com/mercurial/
336
337Mercurial shares many features with git, but it provides an interface which
338many find easier to use.
339
340The other tool worth knowing about is Quilt:
341
342 http://savannah.nongnu.org/projects/quilt/
343
344Quilt is a patch management system, rather than a source code management
345system. It does not track history over time; it is, instead, oriented
346toward tracking a specific set of changes against an evolving code base.
347Some major subsystem maintainers use quilt to manage patches intended to go
348upstream. For the management of certain kinds of trees (-mm, for example),
349quilt is the best tool for the job.
350
351
3522.6: MAILING LISTS
353
354A great deal of Linux kernel development work is done by way of mailing
355lists. It is hard to be a fully-functioning member of the community
356without joining at least one list somewhere. But Linux mailing lists also
357represent a potential hazard to developers, who risk getting buried under a
358load of electronic mail, running afoul of the conventions used on the Linux
359lists, or both.
360
361Most kernel mailing lists are run on vger.kernel.org; the master list can
362be found at:
363
364 http://vger.kernel.org/vger-lists.html
365
366There are lists hosted elsewhere, though; a number of them are at
367lists.redhat.com.
368
369The core mailing list for kernel development is, of course, linux-kernel.
370This list is an intimidating place to be; volume can reach 500 messages per
371day, the amount of noise is high, the conversation can be severely
372technical, and participants are not always concerned with showing a high
373degree of politeness. But there is no other place where the kernel
374development community comes together as a whole; developers who avoid this
375list will miss important information.
376
377There are a few hints which can help with linux-kernel survival:
378
379- Have the list delivered to a separate folder, rather than your main
380 mailbox. One must be able to ignore the stream for sustained periods of
381 time.
382
383- Do not try to follow every conversation - nobody else does. It is
384 important to filter on both the topic of interest (though note that
385 long-running conversations can drift away from the original subject
386 without changing the email subject line) and the people who are
387 participating.
388
389- Do not feed the trolls. If somebody is trying to stir up an angry
390 response, ignore them.
391
392- When responding to linux-kernel email (or that on other lists) preserve
393 the Cc: header for all involved. In the absence of a strong reason (such
394 as an explicit request), you should never remove recipients. Always make
395 sure that the person you are responding to is in the Cc: list. This
396 convention also makes it unnecessary to explicitly ask to be copied on
397 replies to your postings.
398
399- Search the list archives (and the net as a whole) before asking
400 questions. Some developers can get impatient with people who clearly
401 have not done their homework.
402
403- Avoid top-posting (the practice of putting your answer above the quoted
404 text you are responding to). It makes your response harder to read and
405 makes a poor impression.
406
407- Ask on the correct mailing list. Linux-kernel may be the general meeting
408 point, but it is not the best place to find developers from all
409 subsystems.
410
411The last point - finding the correct mailing list - is a common place for
412beginning developers to go wrong. Somebody who asks a networking-related
413question on linux-kernel will almost certainly receive a polite suggestion
414to ask on the netdev list instead, as that is the list frequented by most
415networking developers. Other lists exist for the SCSI, video4linux, IDE,
416filesystem, etc. subsystems. The best place to look for mailing lists is
417in the MAINTAINERS file packaged with the kernel source.
418
419
4202.7: GETTING STARTED WITH KERNEL DEVELOPMENT
421
422Questions about how to get started with the kernel development process are
423common - from both individuals and companies. Equally common are missteps
424which make the beginning of the relationship harder than it has to be.
425
426Companies often look to hire well-known developers to get a development
427group started. This can, in fact, be an effective technique. But it also
428tends to be expensive and does not do much to grow the pool of experienced
429kernel developers. It is possible to bring in-house developers up to speed
430on Linux kernel development, given the investment of a bit of time. Taking
431this time can endow an employer with a group of developers who understand
432the kernel and the company both, and who can help to train others as well.
433Over the medium term, this is often the more profitable approach.
434
435Individual developers are often, understandably, at a loss for a place to
436start. Beginning with a large project can be intimidating; one often wants
437to test the waters with something smaller first. This is the point where
438some developers jump into the creation of patches fixing spelling errors or
439minor coding style issues. Unfortunately, such patches create a level of
440noise which is distracting for the development community as a whole, so,
441increasingly, they are looked down upon. New developers wishing to
442introduce themselves to the community will not get the sort of reception
443they wish for by these means.
444
445Andrew Morton gives this advice for aspiring kernel developers
446
447 The #1 project for all kernel beginners should surely be "make sure
448 that the kernel runs perfectly at all times on all machines which
449 you can lay your hands on". Usually the way to do this is to work
450 with others on getting things fixed up (this can require
451 persistence!) but that's fine - it's a part of kernel development.
452
453(http://lwn.net/Articles/283982/).
454
455In the absence of obvious problems to fix, developers are advised to look
456at the current lists of regressions and open bugs in general. There is
457never any shortage of issues in need of fixing; by addressing these issues,
458developers will gain experience with the process while, at the same time,
459building respect with the rest of the development community.
diff --git a/Documentation/development-process/3.Early-stage b/Documentation/development-process/3.Early-stage
new file mode 100644
index 000000000000..307a159a70ca
--- /dev/null
+++ b/Documentation/development-process/3.Early-stage
@@ -0,0 +1,195 @@
13: EARLY-STAGE PLANNING
2
3When contemplating a Linux kernel development project, it can be tempting
4to jump right in and start coding. As with any significant project,
5though, much of the groundwork for success is best laid before the first
6line of code is written. Some time spent in early planning and
7communication can save far more time later on.
8
9
103.1: SPECIFYING THE PROBLEM
11
12Like any engineering project, a successful kernel enhancement starts with a
13clear description of the problem to be solved. In some cases, this step is
14easy: when a driver is needed for a specific piece of hardware, for
15example. In others, though, it is tempting to confuse the real problem
16with the proposed solution, and that can lead to difficulties.
17
18Consider an example: some years ago, developers working with Linux audio
19sought a way to run applications without dropouts or other artifacts caused
20by excessive latency in the system. The solution they arrived at was a
21kernel module intended to hook into the Linux Security Module (LSM)
22framework; this module could be configured to give specific applications
23access to the realtime scheduler. This module was implemented and sent to
24the linux-kernel mailing list, where it immediately ran into problems.
25
26To the audio developers, this security module was sufficient to solve their
27immediate problem. To the wider kernel community, though, it was seen as a
28misuse of the LSM framework (which is not intended to confer privileges
29onto processes which they would not otherwise have) and a risk to system
30stability. Their preferred solutions involved realtime scheduling access
31via the rlimit mechanism for the short term, and ongoing latency reduction
32work in the long term.
33
34The audio community, however, could not see past the particular solution
35they had implemented; they were unwilling to accept alternatives. The
36resulting disagreement left those developers feeling disillusioned with the
37entire kernel development process; one of them went back to an audio list
38and posted this:
39
40 There are a number of very good Linux kernel developers, but they
41 tend to get outshouted by a large crowd of arrogant fools. Trying
42 to communicate user requirements to these people is a waste of
43 time. They are much too "intelligent" to listen to lesser mortals.
44
45(http://lwn.net/Articles/131776/).
46
47The reality of the situation was different; the kernel developers were far
48more concerned about system stability, long-term maintenance, and finding
49the right solution to the problem than they were with a specific module.
50The moral of the story is to focus on the problem - not a specific solution
51- and to discuss it with the development community before investing in the
52creation of a body of code.
53
54So, when contemplating a kernel development project, one should obtain
55answers to a short set of questions:
56
57 - What, exactly, is the problem which needs to be solved?
58
59 - Who are the users affected by this problem? Which use cases should the
60 solution address?
61
62 - How does the kernel fall short in addressing that problem now?
63
64Only then does it make sense to start considering possible solutions.
65
66
673.2: EARLY DISCUSSION
68
69When planning a kernel development project, it makes great sense to hold
70discussions with the community before launching into implementation. Early
71communication can save time and trouble in a number of ways:
72
73 - It may well be that the problem is addressed by the kernel in ways which
74 you have not understood. The Linux kernel is large and has a number of
75 features and capabilities which are not immediately obvious. Not all
76 kernel capabilities are documented as well as one might like, and it is
77 easy to miss things. Your author has seen the posting of a complete
78 driver which duplicated an existing driver that the new author had been
79 unaware of. Code which reinvents existing wheels is not only wasteful;
80 it will also not be accepted into the mainline kernel.
81
82 - There may be elements of the proposed solution which will not be
83 acceptable for mainline merging. It is better to find out about
84 problems like this before writing the code.
85
86 - It's entirely possible that other developers have thought about the
87 problem; they may have ideas for a better solution, and may be willing
88 to help in the creation of that solution.
89
90Years of experience with the kernel development community have taught a
91clear lesson: kernel code which is designed and developed behind closed
92doors invariably has problems which are only revealed when the code is
93released into the community. Sometimes these problems are severe,
94requiring months or years of effort before the code can be brought up to
95the kernel community's standards. Some examples include:
96
97 - The Devicescape network stack was designed and implemented for
98 single-processor systems. It could not be merged into the mainline
99 until it was made suitable for multiprocessor systems. Retrofitting
100 locking and such into code is a difficult task; as a result, the merging
101 of this code (now called mac80211) was delayed for over a year.
102
103 - The Reiser4 filesystem included a number of capabilities which, in the
104 core kernel developers' opinion, should have been implemented in the
105 virtual filesystem layer instead. It also included features which could
106 not easily be implemented without exposing the system to user-caused
107 deadlocks. The late revelation of these problems - and refusal to
108 address some of them - has caused Reiser4 to stay out of the mainline
109 kernel.
110
111 - The AppArmor security module made use of internal virtual filesystem
112 data structures in ways which were considered to be unsafe and
113 unreliable. This code has since been significantly reworked, but
114 remains outside of the mainline.
115
116In each of these cases, a great deal of pain and extra work could have been
117avoided with some early discussion with the kernel developers.
118
119
1203.3: WHO DO YOU TALK TO?
121
122When developers decide to take their plans public, the next question will
123be: where do we start? The answer is to find the right mailing list(s) and
124the right maintainer. For mailing lists, the best approach is to look in
125the MAINTAINERS file for a relevant place to post. If there is a suitable
126subsystem list, posting there is often preferable to posting on
127linux-kernel; you are more likely to reach developers with expertise in the
128relevant subsystem and the environment may be more supportive.
129
130Finding maintainers can be a bit harder. Again, the MAINTAINERS file is
131the place to start. That file tends to not always be up to date, though,
132and not all subsystems are represented there. The person listed in the
133MAINTAINERS file may, in fact, not be the person who is actually acting in
134that role currently. So, when there is doubt about who to contact, a
135useful trick is to use git (and "git log" in particular) to see who is
136currently active within the subsystem of interest. Look at who is writing
137patches, and who, if anybody, is attaching Signed-off-by lines to those
138patches. Those are the people who will be best placed to help with a new
139development project.
140
141If all else fails, talking to Andrew Morton can be an effective way to
142track down a maintainer for a specific piece of code.
143
144
1453.4: WHEN TO POST?
146
147If possible, posting your plans during the early stages can only be
148helpful. Describe the problem being solved and any plans that have been
149made on how the implementation will be done. Any information you can
150provide can help the development community provide useful input on the
151project.
152
153One discouraging thing which can happen at this stage is not a hostile
154reaction, but, instead, little or no reaction at all. The sad truth of the
155matter is (1) kernel developers tend to be busy, (2) there is no shortage
156of people with grand plans and little code (or even prospect of code) to
157back them up, and (3) nobody is obligated to review or comment on ideas
158posted by others. If a request-for-comments posting yields little in the
159way of comments, do not assume that it means there is no interest in the
160project. Unfortunately, you also cannot assume that there are no problems
161with your idea. The best thing to do in this situation is to proceed,
162keeping the community informed as you go.
163
164
1653.5: GETTING OFFICIAL BUY-IN
166
167If your work is being done in a corporate environment - as most Linux
168kernel work is - you must, obviously, have permission from suitably
169empowered managers before you can post your company's plans or code to a
170public mailing list. The posting of code which has not been cleared for
171release under a GPL-compatible license can be especially problematic; the
172sooner that a company's management and legal staff can agree on the posting
173of a kernel development project, the better off everybody involved will be.
174
175Some readers may be thinking at this point that their kernel work is
176intended to support a product which does not yet have an officially
177acknowledged existence. Revealing their employer's plans on a public
178mailing list may not be a viable option. In cases like this, it is worth
179considering whether the secrecy is really necessary; there is often no real
180need to keep development plans behind closed doors.
181
182That said, there are also cases where a company legitimately cannot
183disclose its plans early in the development process. Companies with
184experienced kernel developers may choose to proceed in an open-loop manner
185on the assumption that they will be able to avoid serious integration
186problems later. For companies without that sort of in-house expertise, the
187best option is often to hire an outside developer to review the plans under
188a non-disclosure agreement. The Linux Foundation operates an NDA program
189designed to help with this sort of situation; more information can be found
190at:
191
192 http://www.linuxfoundation.org/en/NDA_program
193
194This kind of review is often enough to avoid serious problems later on
195without requiring public disclosure of the project.
diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding
new file mode 100644
index 000000000000..014aca8f14e2
--- /dev/null
+++ b/Documentation/development-process/4.Coding
@@ -0,0 +1,384 @@
14: GETTING THE CODE RIGHT
2
3While there is much to be said for a solid and community-oriented design
4process, the proof of any kernel development project is in the resulting
5code. It is the code which will be examined by other developers and merged
6(or not) into the mainline tree. So it is the quality of this code which
7will determine the ultimate success of the project.
8
9This section will examine the coding process. We'll start with a look at a
10number of ways in which kernel developers can go wrong. Then the focus
11will shift toward doing things right and the tools which can help in that
12quest.
13
14
154.1: PITFALLS
16
17* Coding style
18
19The kernel has long had a standard coding style, described in
20Documentation/CodingStyle. For much of that time, the policies described
21in that file were taken as being, at most, advisory. As a result, there is
22a substantial amount of code in the kernel which does not meet the coding
23style guidelines. The presence of that code leads to two independent
24hazards for kernel developers.
25
26The first of these is to believe that the kernel coding standards do not
27matter and are not enforced. The truth of the matter is that adding new
28code to the kernel is very difficult if that code is not coded according to
29the standard; many developers will request that the code be reformatted
30before they will even review it. A code base as large as the kernel
31requires some uniformity of code to make it possible for developers to
32quickly understand any part of it. So there is no longer room for
33strangely-formatted code.
34
35Occasionally, the kernel's coding style will run into conflict with an
36employer's mandated style. In such cases, the kernel's style will have to
37win before the code can be merged. Putting code into the kernel means
38giving up a degree of control in a number of ways - including control over
39how the code is formatted.
40
41The other trap is to assume that code which is already in the kernel is
42urgently in need of coding style fixes. Developers may start to generate
43reformatting patches as a way of gaining familiarity with the process, or
44as a way of getting their name into the kernel changelogs - or both. But
45pure coding style fixes are seen as noise by the development community;
46they tend to get a chilly reception. So this type of patch is best
47avoided. It is natural to fix the style of a piece of code while working
48on it for other reasons, but coding style changes should not be made for
49their own sake.
50
51The coding style document also should not be read as an absolute law which
52can never be transgressed. If there is a good reason to go against the
53style (a line which becomes far less readable if split to fit within the
5480-column limit, for example), just do it.
55
56
57* Abstraction layers
58
59Computer Science professors teach students to make extensive use of
60abstraction layers in the name of flexibility and information hiding.
61Certainly the kernel makes extensive use of abstraction; no project
62involving several million lines of code could do otherwise and survive.
63But experience has shown that excessive or premature abstraction can be
64just as harmful as premature optimization. Abstraction should be used to
65the level required and no further.
66
67At a simple level, consider a function which has an argument which is
68always passed as zero by all callers. One could retain that argument just
69in case somebody eventually needs to use the extra flexibility that it
70provides. By that time, though, chances are good that the code which
71implements this extra argument has been broken in some subtle way which was
72never noticed - because it has never been used. Or, when the need for
73extra flexibility arises, it does not do so in a way which matches the
74programmer's early expectation. Kernel developers will routinely submit
75patches to remove unused arguments; they should, in general, not be added
76in the first place.
77
78Abstraction layers which hide access to hardware - often to allow the bulk
79of a driver to be used with multiple operating systems - are especially
80frowned upon. Such layers obscure the code and may impose a performance
81penalty; they do not belong in the Linux kernel.
82
83On the other hand, if you find yourself copying significant amounts of code
84from another kernel subsystem, it is time to ask whether it would, in fact,
85make sense to pull out some of that code into a separate library or to
86implement that functionality at a higher level. There is no value in
87replicating the same code throughout the kernel.
88
89
90* #ifdef and preprocessor use in general
91
92The C preprocessor seems to present a powerful temptation to some C
93programmers, who see it as a way to efficiently encode a great deal of
94flexibility into a source file. But the preprocessor is not C, and heavy
95use of it results in code which is much harder for others to read and
96harder for the compiler to check for correctness. Heavy preprocessor use
97is almost always a sign of code which needs some cleanup work.
98
99Conditional compilation with #ifdef is, indeed, a powerful feature, and it
100is used within the kernel. But there is little desire to see code which is
101sprinkled liberally with #ifdef blocks. As a general rule, #ifdef use
102should be confined to header files whenever possible.
103Conditionally-compiled code can be confined to functions which, if the code
104is not to be present, simply become empty. The compiler will then quietly
105optimize out the call to the empty function. The result is far cleaner
106code which is easier to follow.
107
108C preprocessor macros present a number of hazards, including possible
109multiple evaluation of expressions with side effects and no type safety.
110If you are tempted to define a macro, consider creating an inline function
111instead. The code which results will be the same, but inline functions are
112easier to read, do not evaluate their arguments multiple times, and allow
113the compiler to perform type checking on the arguments and return value.
114
115
116* Inline functions
117
118Inline functions present a hazard of their own, though. Programmers can
119become enamored of the perceived efficiency inherent in avoiding a function
120call and fill a source file with inline functions. Those functions,
121however, can actually reduce performance. Since their code is replicated
122at each call site, they end up bloating the size of the compiled kernel.
123That, in turn, creates pressure on the processor's memory caches, which can
124slow execution dramatically. Inline functions, as a rule, should be quite
125small and relatively rare. The cost of a function call, after all, is not
126that high; the creation of large numbers of inline functions is a classic
127example of premature optimization.
128
129In general, kernel programmers ignore cache effects at their peril. The
130classic time/space tradeoff taught in beginning data structures classes
131often does not apply to contemporary hardware. Space *is* time, in that a
132larger program will run slower than one which is more compact.
133
134
135* Locking
136
137In May, 2006, the "Devicescape" networking stack was, with great
138fanfare, released under the GPL and made available for inclusion in the
139mainline kernel. This donation was welcome news; support for wireless
140networking in Linux was considered substandard at best, and the Devicescape
141stack offered the promise of fixing that situation. Yet, this code did not
142actually make it into the mainline until June, 2007 (2.6.22). What
143happened?
144
145This code showed a number of signs of having been developed behind
146corporate doors. But one large problem in particular was that it was not
147designed to work on multiprocessor systems. Before this networking stack
148(now called mac80211) could be merged, a locking scheme needed to be
149retrofitted onto it.
150
151Once upon a time, Linux kernel code could be developed without thinking
152about the concurrency issues presented by multiprocessor systems. Now,
153however, this document is being written on a dual-core laptop. Even on
154single-processor systems, work being done to improve responsiveness will
155raise the level of concurrency within the kernel. The days when kernel
156code could be written without thinking about locking are long past.
157
158Any resource (data structures, hardware registers, etc.) which could be
159accessed concurrently by more than one thread must be protected by a lock.
160New code should be written with this requirement in mind; retrofitting
161locking after the fact is a rather more difficult task. Kernel developers
162should take the time to understand the available locking primitives well
163enough to pick the right tool for the job. Code which shows a lack of
164attention to concurrency will have a difficult path into the mainline.
165
166
167* Regressions
168
169One final hazard worth mentioning is this: it can be tempting to make a
170change (which may bring big improvements) which causes something to break
171for existing users. This kind of change is called a "regression," and
172regressions have become most unwelcome in the mainline kernel. With few
173exceptions, changes which cause regressions will be backed out if the
174regression cannot be fixed in a timely manner. Far better to avoid the
175regression in the first place.
176
177It is often argued that a regression can be justified if it causes things
178to work for more people than it creates problems for. Why not make a
179change if it brings new functionality to ten systems for each one it
180breaks? The best answer to this question was expressed by Linus in July,
1812007:
182
183 So we don't fix bugs by introducing new problems. That way lies
184 madness, and nobody ever knows if you actually make any real
185 progress at all. Is it two steps forwards, one step back, or one
186 step forward and two steps back?
187
188(http://lwn.net/Articles/243460/).
189
190An especially unwelcome type of regression is any sort of change to the
191user-space ABI. Once an interface has been exported to user space, it must
192be supported indefinitely. This fact makes the creation of user-space
193interfaces particularly challenging: since they cannot be changed in
194incompatible ways, they must be done right the first time. For this
195reason, a great deal of thought, clear documentation, and wide review for
196user-space interfaces is always required.
197
198
199
2004.2: CODE CHECKING TOOLS
201
202For now, at least, the writing of error-free code remains an ideal that few
203of us can reach. What we can hope to do, though, is to catch and fix as
204many of those errors as possible before our code goes into the mainline
205kernel. To that end, the kernel developers have put together an impressive
206array of tools which can catch a wide variety of obscure problems in an
207automated way. Any problem caught by the computer is a problem which will
208not afflict a user later on, so it stands to reason that the automated
209tools should be used whenever possible.
210
211The first step is simply to heed the warnings produced by the compiler.
212Contemporary versions of gcc can detect (and warn about) a large number of
213potential errors. Quite often, these warnings point to real problems.
214Code submitted for review should, as a rule, not produce any compiler
215warnings. When silencing warnings, take care to understand the real cause
216and try to avoid "fixes" which make the warning go away without addressing
217its cause.
218
219Note that not all compiler warnings are enabled by default. Build the
220kernel with "make EXTRA_CFLAGS=-W" to get the full set.
221
222The kernel provides several configuration options which turn on debugging
223features; most of these are found in the "kernel hacking" submenu. Several
224of these options should be turned on for any kernel used for development or
225testing purposes. In particular, you should turn on:
226
227 - ENABLE_WARN_DEPRECATED, ENABLE_MUST_CHECK, and FRAME_WARN to get an
228 extra set of warnings for problems like the use of deprecated interfaces
229 or ignoring an important return value from a function. The output
230 generated by these warnings can be verbose, but one need not worry about
231 warnings from other parts of the kernel.
232
233 - DEBUG_OBJECTS will add code to track the lifetime of various objects
234 created by the kernel and warn when things are done out of order. If
235 you are adding a subsystem which creates (and exports) complex objects
236 of its own, consider adding support for the object debugging
237 infrastructure.
238
239 - DEBUG_SLAB can find a variety of memory allocation and use errors; it
240 should be used on most development kernels.
241
242 - DEBUG_SPINLOCK, DEBUG_SPINLOCK_SLEEP, and DEBUG_MUTEXES will find a
243 number of common locking errors.
244
245There are quite a few other debugging options, some of which will be
246discussed below. Some of them have a significant performance impact and
247should not be used all of the time. But some time spent learning the
248available options will likely be paid back many times over in short order.
249
250One of the heavier debugging tools is the locking checker, or "lockdep."
251This tool will track the acquisition and release of every lock (spinlock or
252mutex) in the system, the order in which locks are acquired relative to
253each other, the current interrupt environment, and more. It can then
254ensure that locks are always acquired in the same order, that the same
255interrupt assumptions apply in all situations, and so on. In other words,
256lockdep can find a number of scenarios in which the system could, on rare
257occasion, deadlock. This kind of problem can be painful (for both
258developers and users) in a deployed system; lockdep allows them to be found
259in an automated manner ahead of time. Code with any sort of non-trivial
260locking should be run with lockdep enabled before being submitted for
261inclusion.
262
263As a diligent kernel programmer, you will, beyond doubt, check the return
264status of any operation (such as a memory allocation) which can fail. The
265fact of the matter, though, is that the resulting failure recovery paths
266are, probably, completely untested. Untested code tends to be broken code;
267you could be much more confident of your code if all those error-handling
268paths had been exercised a few times.
269
270The kernel provides a fault injection framework which can do exactly that,
271especially where memory allocations are involved. With fault injection
272enabled, a configurable percentage of memory allocations will be made to
273fail; these failures can be restricted to a specific range of code.
274Running with fault injection enabled allows the programmer to see how the
275code responds when things go badly. See
276Documentation/fault-injection/fault-injection.text for more information on
277how to use this facility.
278
279Other kinds of errors can be found with the "sparse" static analysis tool.
280With sparse, the programmer can be warned about confusion between
281user-space and kernel-space addresses, mixture of big-endian and
282small-endian quantities, the passing of integer values where a set of bit
283flags is expected, and so on. Sparse must be installed separately (it can
284be found at http://www.kernel.org/pub/software/devel/sparse/ if your
285distributor does not package it); it can then be run on the code by adding
286"C=1" to your make command.
287
288Other kinds of portability errors are best found by compiling your code for
289other architectures. If you do not happen to have an S/390 system or a
290Blackfin development board handy, you can still perform the compilation
291step. A large set of cross compilers for x86 systems can be found at
292
293 http://www.kernel.org/pub/tools/crosstool/
294
295Some time spent installing and using these compilers will help avoid
296embarrassment later.
297
298
2994.3: DOCUMENTATION
300
301Documentation has often been more the exception than the rule with kernel
302development. Even so, adequate documentation will help to ease the merging
303of new code into the kernel, make life easier for other developers, and
304will be helpful for your users. In many cases, the addition of
305documentation has become essentially mandatory.
306
307The first piece of documentation for any patch is its associated
308changelog. Log entries should describe the problem being solved, the form
309of the solution, the people who worked on the patch, any relevant
310effects on performance, and anything else that might be needed to
311understand the patch.
312
313Any code which adds a new user-space interface - including new sysfs or
314/proc files - should include documentation of that interface which enables
315user-space developers to know what they are working with. See
316Documentation/ABI/README for a description of how this documentation should
317be formatted and what information needs to be provided.
318
319The file Documentation/kernel-parameters.txt describes all of the kernel's
320boot-time parameters. Any patch which adds new parameters should add the
321appropriate entries to this file.
322
323Any new configuration options must be accompanied by help text which
324clearly explains the options and when the user might want to select them.
325
326Internal API information for many subsystems is documented by way of
327specially-formatted comments; these comments can be extracted and formatted
328in a number of ways by the "kernel-doc" script. If you are working within
329a subsystem which has kerneldoc comments, you should maintain them and add
330them, as appropriate, for externally-available functions. Even in areas
331which have not been so documented, there is no harm in adding kerneldoc
332comments for the future; indeed, this can be a useful activity for
333beginning kernel developers. The format of these comments, along with some
334information on how to create kerneldoc templates can be found in the file
335Documentation/kernel-doc-nano-HOWTO.txt.
336
337Anybody who reads through a significant amount of existing kernel code will
338note that, often, comments are most notable by their absence. Once again,
339the expectations for new code are higher than they were in the past;
340merging uncommented code will be harder. That said, there is little desire
341for verbosely-commented code. The code should, itself, be readable, with
342comments explaining the more subtle aspects.
343
344Certain things should always be commented. Uses of memory barriers should
345be accompanied by a line explaining why the barrier is necessary. The
346locking rules for data structures generally need to be explained somewhere.
347Major data structures need comprehensive documentation in general.
348Non-obvious dependencies between separate bits of code should be pointed
349out. Anything which might tempt a code janitor to make an incorrect
350"cleanup" needs a comment saying why it is done the way it is. And so on.
351
352
3534.4: INTERNAL API CHANGES
354
355The binary interface provided by the kernel to user space cannot be broken
356except under the most severe circumstances. The kernel's internal
357programming interfaces, instead, are highly fluid and can be changed when
358the need arises. If you find yourself having to work around a kernel API,
359or simply not using a specific functionality because it does not meet your
360needs, that may be a sign that the API needs to change. As a kernel
361developer, you are empowered to make such changes.
362
363There are, of course, some catches. API changes can be made, but they need
364to be well justified. So any patch making an internal API change should be
365accompanied by a description of what the change is and why it is
366necessary. This kind of change should also be broken out into a separate
367patch, rather than buried within a larger patch.
368
369The other catch is that a developer who changes an internal API is
370generally charged with the task of fixing any code within the kernel tree
371which is broken by the change. For a widely-used function, this duty can
372lead to literally hundreds or thousands of changes - many of which are
373likely to conflict with work being done by other developers. Needless to
374say, this can be a large job, so it is best to be sure that the
375justification is solid.
376
377When making an incompatible API change, one should, whenever possible,
378ensure that code which has not been updated is caught by the compiler.
379This will help you to be sure that you have found all in-tree uses of that
380interface. It will also alert developers of out-of-tree code that there is
381a change that they need to respond to. Supporting out-of-tree code is not
382something that kernel developers need to be worried about, but we also do
383not have to make life harder for out-of-tree developers than it it needs to
384be.
diff --git a/Documentation/development-process/5.Posting b/Documentation/development-process/5.Posting
new file mode 100644
index 000000000000..dd48132a74dd
--- /dev/null
+++ b/Documentation/development-process/5.Posting
@@ -0,0 +1,278 @@
15: POSTING PATCHES
2
3Sooner or later, the time comes when your work is ready to be presented to
4the community for review and, eventually, inclusion into the mainline
5kernel. Unsurprisingly, the kernel development community has evolved a set
6of conventions and procedures which are used in the posting of patches;
7following them will make life much easier for everybody involved. This
8document will attempt to cover these expectations in reasonable detail;
9more information can also be found in the files SubmittingPatches,
10SubmittingDrivers, and SubmitChecklist in the kernel documentation
11directory.
12
13
145.1: WHEN TO POST
15
16There is a constant temptation to avoid posting patches before they are
17completely "ready." For simple patches, that is not a problem. If the
18work being done is complex, though, there is a lot to be gained by getting
19feedback from the community before the work is complete. So you should
20consider posting in-progress work, or even making a git tree available so
21that interested developers can catch up with your work at any time.
22
23When posting code which is not yet considered ready for inclusion, it is a
24good idea to say so in the posting itself. Also mention any major work
25which remains to be done and any known problems. Fewer people will look at
26patches which are known to be half-baked, but those who do will come in
27with the idea that they can help you drive the work in the right direction.
28
29
305.2: BEFORE CREATING PATCHES
31
32There are a number of things which should be done before you consider
33sending patches to the development community. These include:
34
35 - Test the code to the extent that you can. Make use of the kernel's
36 debugging tools, ensure that the kernel will build with all reasonable
37 combinations of configuration options, use cross-compilers to build for
38 different architectures, etc.
39
40 - Make sure your code is compliant with the kernel coding style
41 guidelines.
42
43 - Does your change have performance implications? If so, you should run
44 benchmarks showing what the impact (or benefit) of your change is; a
45 summary of the results should be included with the patch.
46
47 - Be sure that you have the right to post the code. If this work was done
48 for an employer, the employer likely has a right to the work and must be
49 agreeable with its release under the GPL.
50
51As a general rule, putting in some extra thought before posting code almost
52always pays back the effort in short order.
53
54
555.3: PATCH PREPARATION
56
57The preparation of patches for posting can be a surprising amount of work,
58but, once again, attempting to save time here is not generally advisable
59even in the short term.
60
61Patches must be prepared against a specific version of the kernel. As a
62general rule, a patch should be based on the current mainline as found in
63Linus's git tree. It may become necessary to make versions against -mm,
64linux-next, or a subsystem tree, though, to facilitate wider testing and
65review. Depending on the area of your patch and what is going on
66elsewhere, basing a patch against these other trees can require a
67significant amount of work resolving conflicts and dealing with API
68changes.
69
70Only the most simple changes should be formatted as a single patch;
71everything else should be made as a logical series of changes. Splitting
72up patches is a bit of an art; some developers spend a long time figuring
73out how to do it in the way that the community expects. There are a few
74rules of thumb, however, which can help considerably:
75
76 - The patch series you post will almost certainly not be the series of
77 changes found in your working revision control system. Instead, the
78 changes you have made need to be considered in their final form, then
79 split apart in ways which make sense. The developers are interested in
80 discrete, self-contained changes, not the path you took to get to those
81 changes.
82
83 - Each logically independent change should be formatted as a separate
84 patch. These changes can be small ("add a field to this structure") or
85 large (adding a significant new driver, for example), but they should be
86 conceptually small and amenable to a one-line description. Each patch
87 should make a specific change which can be reviewed on its own and
88 verified to do what it says it does.
89
90 - As a way of restating the guideline above: do not mix different types of
91 changes in the same patch. If a single patch fixes a critical security
92 bug, rearranges a few structures, and reformats the code, there is a
93 good chance that it will be passed over and the important fix will be
94 lost.
95
96 - Each patch should yield a kernel which builds and runs properly; if your
97 patch series is interrupted in the middle, the result should still be a
98 working kernel. Partial application of a patch series is a common
99 scenario when the "git bisect" tool is used to find regressions; if the
100 result is a broken kernel, you will make life harder for developers and
101 users who are engaging in the noble work of tracking down problems.
102
103 - Do not overdo it, though. One developer recently posted a set of edits
104 to a single file as 500 separate patches - an act which did not make him
105 the most popular person on the kernel mailing list. A single patch can
106 be reasonably large as long as it still contains a single *logical*
107 change.
108
109 - It can be tempting to add a whole new infrastructure with a series of
110 patches, but to leave that infrastructure unused until the final patch
111 in the series enables the whole thing. This temptation should be
112 avoided if possible; if that series adds regressions, bisection will
113 finger the last patch as the one which caused the problem, even though
114 the real bug is elsewhere. Whenever possible, a patch which adds new
115 code should make that code active immediately.
116
117Working to create the perfect patch series can be a frustrating process
118which takes quite a bit of time and thought after the "real work" has been
119done. When done properly, though, it is time well spent.
120
121
1225.4: PATCH FORMATTING
123
124So now you have a perfect series of patches for posting, but the work is
125not done quite yet. Each patch needs to be formatted into a message which
126quickly and clearly communicates its purpose to the rest of the world. To
127that end, each patch will be composed of the following:
128
129 - An optional "From" line naming the author of the patch. This line is
130 only necessary if you are passing on somebody else's patch via email,
131 but it never hurts to add it when in doubt.
132
133 - A one-line description of what the patch does. This message should be
134 enough for a reader who sees it with no other context to figure out the
135 scope of the patch; it is the line that will show up in the "short form"
136 changelogs. This message is usually formatted with the relevant
137 subsystem name first, followed by the purpose of the patch. For
138 example:
139
140 gpio: fix build on CONFIG_GPIO_SYSFS=n
141
142 - A blank line followed by a detailed description of the contents of the
143 patch. This description can be as long as is required; it should say
144 what the patch does and why it should be applied to the kernel.
145
146 - One or more tag lines, with, at a minimum, one Signed-off-by: line from
147 the author of the patch. Tags will be described in more detail below.
148
149The above three items should, normally, be the text used when committing
150the change to a revision control system. They are followed by:
151
152 - The patch itself, in the unified ("-u") patch format. Using the "-p"
153 option to diff will associate function names with changes, making the
154 resulting patch easier for others to read.
155
156You should avoid including changes to irrelevant files (those generated by
157the build process, for example, or editor backup files) in the patch. The
158file "dontdiff" in the Documentation directory can help in this regard;
159pass it to diff with the "-X" option.
160
161The tags mentioned above are used to describe how various developers have
162been associated with the development of this patch. They are described in
163detail in the SubmittingPatches document; what follows here is a brief
164summary. Each of these lines has the format:
165
166 tag: Full Name <email address> optional-other-stuff
167
168The tags in common use are:
169
170 - Signed-off-by: this is a developer's certification that he or she has
171 the right to submit the patch for inclusion into the kernel. It is an
172 agreement to the Developer's Certificate of Origin, the full text of
173 which can be found in Documentation/SubmittingPatches. Code without a
174 proper signoff cannot be merged into the mainline.
175
176 - Acked-by: indicates an agreement by another developer (often a
177 maintainer of the relevant code) that the patch is appropriate for
178 inclusion into the kernel.
179
180 - Tested-by: states that the named person has tested the patch and found
181 it to work.
182
183 - Reviewed-by: the named developer has reviewed the patch for correctness;
184 see the reviewer's statement in Documentation/SubmittingPatches for more
185 detail.
186
187 - Reported-by: names a user who reported a problem which is fixed by this
188 patch; this tag is used to give credit to the (often underappreciated)
189 people who test our code and let us know when things do not work
190 correctly.
191
192 - Cc: the named person received a copy of the patch and had the
193 opportunity to comment on it.
194
195Be careful in the addition of tags to your patches: only Cc: is appropriate
196for addition without the explicit permission of the person named.
197
198
1995.5: SENDING THE PATCH
200
201Before you mail your patches, there are a couple of other things you should
202take care of:
203
204 - Are you sure that your mailer will not corrupt the patches? Patches
205 which have had gratuitous white-space changes or line wrapping performed
206 by the mail client will not apply at the other end, and often will not
207 be examined in any detail. If there is any doubt at all, mail the patch
208 to yourself and convince yourself that it shows up intact.
209
210 Documentation/email-clients.txt has some helpful hints on making
211 specific mail clients work for sending patches.
212
213 - Are you sure your patch is free of silly mistakes? You should always
214 run patches through scripts/checkpatch.pl and address the complaints it
215 comes up with. Please bear in mind that checkpatch.pl, while being the
216 embodiment of a fair amount of thought about what kernel patches should
217 look like, is not smarter than you. If fixing a checkpatch.pl complaint
218 would make the code worse, don't do it.
219
220Patches should always be sent as plain text. Please do not send them as
221attachments; that makes it much harder for reviewers to quote sections of
222the patch in their replies. Instead, just put the patch directly into your
223message.
224
225When mailing patches, it is important to send copies to anybody who might
226be interested in it. Unlike some other projects, the kernel encourages
227people to err on the side of sending too many copies; don't assume that the
228relevant people will see your posting on the mailing lists. In particular,
229copies should go to:
230
231 - The maintainer(s) of the affected subsystem(s). As described earlier,
232 the MAINTAINERS file is the first place to look for these people.
233
234 - Other developers who have been working in the same area - especially
235 those who might be working there now. Using git to see who else has
236 modified the files you are working on can be helpful.
237
238 - If you are responding to a bug report or a feature request, copy the
239 original poster as well.
240
241 - Send a copy to the relevant mailing list, or, if nothing else applies,
242 the linux-kernel list.
243
244 - If you are fixing a bug, think about whether the fix should go into the
245 next stable update. If so, stable@kernel.org should get a copy of the
246 patch. Also add a "Cc: stable@kernel.org" to the tags within the patch
247 itself; that will cause the stable team to get a notification when your
248 fix goes into the mainline.
249
250When selecting recipients for a patch, it is good to have an idea of who
251you think will eventually accept the patch and get it merged. While it
252is possible to send patches directly to Linus Torvalds and have him merge
253them, things are not normally done that way. Linus is busy, and there are
254subsystem maintainers who watch over specific parts of the kernel. Usually
255you will be wanting that maintainer to merge your patches. If there is no
256obvious maintainer, Andrew Morton is often the patch target of last resort.
257
258Patches need good subject lines. The canonical format for a patch line is
259something like:
260
261 [PATCH nn/mm] subsys: one-line description of the patch
262
263where "nn" is the ordinal number of the patch, "mm" is the total number of
264patches in the series, and "subsys" is the name of the affected subsystem.
265Clearly, nn/mm can be omitted for a single, standalone patch.
266
267If you have a significant series of patches, it is customary to send an
268introductory description as part zero. This convention is not universally
269followed though; if you use it, remember that information in the
270introduction does not make it into the kernel changelogs. So please ensure
271that the patches, themselves, have complete changelog information.
272
273In general, the second and following parts of a multi-part patch should be
274sent as a reply to the first part so that they all thread together at the
275receiving end. Tools like git and quilt have commands to mail out a set of
276patches with the proper threading. If you have a long series, though, and
277are using git, please provide the --no-chain-reply-to option to avoid
278creating exceptionally deep nesting.
diff --git a/Documentation/development-process/6.Followthrough b/Documentation/development-process/6.Followthrough
new file mode 100644
index 000000000000..a8fba3d83a85
--- /dev/null
+++ b/Documentation/development-process/6.Followthrough
@@ -0,0 +1,202 @@
16: FOLLOWTHROUGH
2
3At this point, you have followed the guidelines given so far and, with the
4addition of your own engineering skills, have posted a perfect series of
5patches. One of the biggest mistakes that even experienced kernel
6developers can make is to conclude that their work is now done. In truth,
7posting patches indicates a transition into the next stage of the process,
8with, possibly, quite a bit of work yet to be done.
9
10It is a rare patch which is so good at its first posting that there is no
11room for improvement. The kernel development process recognizes this fact,
12and, as a result, is heavily oriented toward the improvement of posted
13code. You, as the author of that code, will be expected to work with the
14kernel community to ensure that your code is up to the kernel's quality
15standards. A failure to participate in this process is quite likely to
16prevent the inclusion of your patches into the mainline.
17
18
196.1: WORKING WITH REVIEWERS
20
21A patch of any significance will result in a number of comments from other
22developers as they review the code. Working with reviewers can be, for
23many developers, the most intimidating part of the kernel development
24process. Life can be made much easier, though, if you keep a few things in
25mind:
26
27 - If you have explained your patch well, reviewers will understand its
28 value and why you went to the trouble of writing it. But that value
29 will not keep them from asking a fundamental question: what will it be
30 like to maintain a kernel with this code in it five or ten years later?
31 Many of the changes you may be asked to make - from coding style tweaks
32 to substantial rewrites - come from the understanding that Linux will
33 still be around and under development a decade from now.
34
35 - Code review is hard work, and it is a relatively thankless occupation;
36 people remember who wrote kernel code, but there is little lasting fame
37 for those who reviewed it. So reviewers can get grumpy, especially when
38 they see the same mistakes being made over and over again. If you get a
39 review which seems angry, insulting, or outright offensive, resist the
40 impulse to respond in kind. Code review is about the code, not about
41 the people, and code reviewers are not attacking you personally.
42
43 - Similarly, code reviewers are not trying to promote their employers'
44 agendas at the expense of your own. Kernel developers often expect to
45 be working on the kernel years from now, but they understand that their
46 employer could change. They truly are, almost without exception,
47 working toward the creation of the best kernel they can; they are not
48 trying to create discomfort for their employers' competitors.
49
50What all of this comes down to is that, when reviewers send you comments,
51you need to pay attention to the technical observations that they are
52making. Do not let their form of expression or your own pride keep that
53from happening. When you get review comments on a patch, take the time to
54understand what the reviewer is trying to say. If possible, fix the things
55that the reviewer is asking you to fix. And respond back to the reviewer:
56thank them, and describe how you will answer their questions.
57
58Note that you do not have to agree with every change suggested by
59reviewers. If you believe that the reviewer has misunderstood your code,
60explain what is really going on. If you have a technical objection to a
61suggested change, describe it and justify your solution to the problem. If
62your explanations make sense, the reviewer will accept them. Should your
63explanation not prove persuasive, though, especially if others start to
64agree with the reviewer, take some time to think things over again. It can
65be easy to become blinded by your own solution to a problem to the point
66that you don't realize that something is fundamentally wrong or, perhaps,
67you're not even solving the right problem.
68
69One fatal mistake is to ignore review comments in the hope that they will
70go away. They will not go away. If you repost code without having
71responded to the comments you got the time before, you're likely to find
72that your patches go nowhere.
73
74Speaking of reposting code: please bear in mind that reviewers are not
75going to remember all the details of the code you posted the last time
76around. So it is always a good idea to remind reviewers of previously
77raised issues and how you dealt with them; the patch changelog is a good
78place for this kind of information. Reviewers should not have to search
79through list archives to familiarize themselves with what was said last
80time; if you help them get a running start, they will be in a better mood
81when they revisit your code.
82
83What if you've tried to do everything right and things still aren't going
84anywhere? Most technical disagreements can be resolved through discussion,
85but there are times when somebody simply has to make a decision. If you
86honestly believe that this decision is going against you wrongly, you can
87always try appealing to a higher power. As of this writing, that higher
88power tends to be Andrew Morton. Andrew has a great deal of respect in the
89kernel development community; he can often unjam a situation which seems to
90be hopelessly blocked. Appealing to Andrew should not be done lightly,
91though, and not before all other alternatives have been explored. And bear
92in mind, of course, that he may not agree with you either.
93
94
956.2: WHAT HAPPENS NEXT
96
97If a patch is considered to be a good thing to add to the kernel, and once
98most of the review issues have been resolved, the next step is usually
99entry into a subsystem maintainer's tree. How that works varies from one
100subsystem to the next; each maintainer has his or her own way of doing
101things. In particular, there may be more than one tree - one, perhaps,
102dedicated to patches planned for the next merge window, and another for
103longer-term work.
104
105For patches applying to areas for which there is no obvious subsystem tree
106(memory management patches, for example), the default tree often ends up
107being -mm. Patches which affect multiple subsystems can also end up going
108through the -mm tree.
109
110Inclusion into a subsystem tree can bring a higher level of visibility to a
111patch. Now other developers working with that tree will get the patch by
112default. Subsystem trees typically feed into -mm and linux-next as well,
113making their contents visible to the development community as a whole. At
114this point, there's a good chance that you will get more comments from a
115new set of reviewers; these comments need to be answered as in the previous
116round.
117
118What may also happen at this point, depending on the nature of your patch,
119is that conflicts with work being done by others turn up. In the worst
120case, heavy patch conflicts can result in some work being put on the back
121burner so that the remaining patches can be worked into shape and merged.
122Other times, conflict resolution will involve working with the other
123developers and, possibly, moving some patches between trees to ensure that
124everything applies cleanly. This work can be a pain, but count your
125blessings: before the advent of the linux-next tree, these conflicts often
126only turned up during the merge window and had to be addressed in a hurry.
127Now they can be resolved at leisure, before the merge window opens.
128
129Some day, if all goes well, you'll log on and see that your patch has been
130merged into the mainline kernel. Congratulations! Once the celebration is
131complete (and you have added yourself to the MAINTAINERS file), though, it
132is worth remembering an important little fact: the job still is not done.
133Merging into the mainline brings its own challenges.
134
135To begin with, the visibility of your patch has increased yet again. There
136may be a new round of comments from developers who had not been aware of
137the patch before. It may be tempting to ignore them, since there is no
138longer any question of your code being merged. Resist that temptation,
139though; you still need to be responsive to developers who have questions or
140suggestions.
141
142More importantly, though: inclusion into the mainline puts your code into
143the hands of a much larger group of testers. Even if you have contributed
144a driver for hardware which is not yet available, you will be surprised by
145how many people will build your code into their kernels. And, of course,
146where there are testers, there will be bug reports.
147
148The worst sort of bug reports are regressions. If your patch causes a
149regression, you'll find an uncomfortable number of eyes upon you;
150regressions need to be fixed as soon as possible. If you are unwilling or
151unable to fix the regression (and nobody else does it for you), your patch
152will almost certainly be removed during the stabilization period. Beyond
153negating all of the work you have done to get your patch into the mainline,
154having a patch pulled as the result of a failure to fix a regression could
155well make it harder for you to get work merged in the future.
156
157After any regressions have been dealt with, there may be other, ordinary
158bugs to deal with. The stabilization period is your best opportunity to
159fix these bugs and ensure that your code's debut in a mainline kernel
160release is as solid as possible. So, please, answer bug reports, and fix
161the problems if at all possible. That's what the stabilization period is
162for; you can start creating cool new patches once any problems with the old
163ones have been taken care of.
164
165And don't forget that there are other milestones which may also create bug
166reports: the next mainline stable release, when prominent distributors pick
167up a version of the kernel containing your patch, etc. Continuing to
168respond to these reports is a matter of basic pride in your work. If that
169is insufficient motivation, though, it's also worth considering that the
170development community remembers developers who lose interest in their code
171after it's merged. The next time you post a patch, they will be evaluating
172it with the assumption that you will not be around to maintain it
173afterward.
174
175
1766.3: OTHER THINGS THAT CAN HAPPEN
177
178One day, you may open your mail client and see that somebody has mailed you
179a patch to your code. That is one of the advantages of having your code
180out there in the open, after all. If you agree with the patch, you can
181either forward it on to the subsystem maintainer (be sure to include a
182proper From: line so that the attribution is correct, and add a signoff of
183your own), or send an Acked-by: response back and let the original poster
184send it upward.
185
186If you disagree with the patch, send a polite response explaining why. If
187possible, tell the author what changes need to be made to make the patch
188acceptable to you. There is a certain resistance to merging patches which
189are opposed by the author and maintainer of the code, but it only goes so
190far. If you are seen as needlessly blocking good work, those patches will
191eventually flow around you and get into the mainline anyway. In the Linux
192kernel, nobody has absolute veto power over any code. Except maybe Linus.
193
194On very rare occasion, you may see something completely different: another
195developer posts a different solution to your problem. At that point,
196chances are that one of the two patches will not be merged, and "mine was
197here first" is not considered to be a compelling technical argument. If
198somebody else's patch displaces yours and gets into the mainline, there is
199really only one way to respond: be pleased that your problem got solved and
200get on with your work. Having one's work shoved aside in this manner can
201be hurtful and discouraging, but the community will remember your reaction
202long after they have forgotten whose patch actually got merged.
diff --git a/Documentation/development-process/7.AdvancedTopics b/Documentation/development-process/7.AdvancedTopics
new file mode 100644
index 000000000000..a2cf74093aa1
--- /dev/null
+++ b/Documentation/development-process/7.AdvancedTopics
@@ -0,0 +1,173 @@
17: ADVANCED TOPICS
2
3At this point, hopefully, you have a handle on how the development process
4works. There is still more to learn, however! This section will cover a
5number of topics which can be helpful for developers wanting to become a
6regular part of the Linux kernel development process.
7
87.1: MANAGING PATCHES WITH GIT
9
10The use of distributed version control for the kernel began in early 2002,
11when Linus first started playing with the proprietary BitKeeper
12application. While BitKeeper was controversial, the approach to software
13version management it embodied most certainly was not. Distributed version
14control enabled an immediate acceleration of the kernel development
15project. In current times, there are several free alternatives to
16BitKeeper. For better or for worse, the kernel project has settled on git
17as its tool of choice.
18
19Managing patches with git can make life much easier for the developer,
20especially as the volume of those patches grows. Git also has its rough
21edges and poses certain hazards; it is a young and powerful tool which is
22still being civilized by its developers. This document will not attempt to
23teach the reader how to use git; that would be sufficient material for a
24long document in its own right. Instead, the focus here will be on how git
25fits into the kernel development process in particular. Developers who
26wish to come up to speed with git will find more information at:
27
28 http://git.or.cz/
29
30 http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
31
32and on various tutorials found on the web.
33
34The first order of business is to read the above sites and get a solid
35understanding of how git works before trying to use it to make patches
36available to others. A git-using developer should be able to obtain a copy
37of the mainline repository, explore the revision history, commit changes to
38the tree, use branches, etc. An understanding of git's tools for the
39rewriting of history (such as rebase) is also useful. Git comes with its
40own terminology and concepts; a new user of git should know about refs,
41remote branches, the index, fast-forward merges, pushes and pulls, detached
42heads, etc. It can all be a little intimidating at the outset, but the
43concepts are not that hard to grasp with a bit of study.
44
45Using git to generate patches for submission by email can be a good
46exercise while coming up to speed.
47
48When you are ready to start putting up git trees for others to look at, you
49will, of course, need a server that can be pulled from. Setting up such a
50server with git-daemon is relatively straightforward if you have a system
51which is accessible to the Internet. Otherwise, free, public hosting sites
52(Github, for example) are starting to appear on the net. Established
53developers can get an account on kernel.org, but those are not easy to come
54by; see http://kernel.org/faq/ for more information.
55
56The normal git workflow involves the use of a lot of branches. Each line
57of development can be separated into a separate "topic branch" and
58maintained independently. Branches in git are cheap, there is no reason to
59not make free use of them. And, in any case, you should not do your
60development in any branch which you intend to ask others to pull from.
61Publicly-available branches should be created with care; merge in patches
62from development branches when they are in complete form and ready to go -
63not before.
64
65Git provides some powerful tools which can allow you to rewrite your
66development history. An inconvenient patch (one which breaks bisection,
67say, or which has some other sort of obvious bug) can be fixed in place or
68made to disappear from the history entirely. A patch series can be
69rewritten as if it had been written on top of today's mainline, even though
70you have been working on it for months. Changes can be transparently
71shifted from one branch to another. And so on. Judicious use of git's
72ability to revise history can help in the creation of clean patch sets with
73fewer problems.
74
75Excessive use of this capability can lead to other problems, though, beyond
76a simple obsession for the creation of the perfect project history.
77Rewriting history will rewrite the changes contained in that history,
78turning a tested (hopefully) kernel tree into an untested one. But, beyond
79that, developers cannot easily collaborate if they do not have a shared
80view of the project history; if you rewrite history which other developers
81have pulled into their repositories, you will make life much more difficult
82for those developers. So a simple rule of thumb applies here: history
83which has been exported to others should generally be seen as immutable
84thereafter.
85
86So, once you push a set of changes to your publicly-available server, those
87changes should not be rewritten. Git will attempt to enforce this rule if
88you try to push changes which do not result in a fast-forward merge
89(i.e. changes which do not share the same history). It is possible to
90override this check, and there may be times when it is necessary to rewrite
91an exported tree. Moving changesets between trees to avoid conflicts in
92linux-next is one example. But such actions should be rare. This is one
93of the reasons why development should be done in private branches (which
94can be rewritten if necessary) and only moved into public branches when
95it's in a reasonably advanced state.
96
97As the mainline (or other tree upon which a set of changes is based)
98advances, it is tempting to merge with that tree to stay on the leading
99edge. For a private branch, rebasing can be an easy way to keep up with
100another tree, but rebasing is not an option once a tree is exported to the
101world. Once that happens, a full merge must be done. Merging occasionally
102makes good sense, but overly frequent merges can clutter the history
103needlessly. Suggested technique in this case is to merge infrequently, and
104generally only at specific release points (such as a mainline -rc
105release). If you are nervous about specific changes, you can always
106perform test merges in a private branch. The git "rerere" tool can be
107useful in such situations; it remembers how merge conflicts were resolved
108so that you don't have to do the same work twice.
109
110One of the biggest recurring complaints about tools like git is this: the
111mass movement of patches from one repository to another makes it easy to
112slip in ill-advised changes which go into the mainline below the review
113radar. Kernel developers tend to get unhappy when they see that kind of
114thing happening; putting up a git tree with unreviewed or off-topic patches
115can affect your ability to get trees pulled in the future. Quoting Linus:
116
117 You can send me patches, but for me to pull a git patch from you, I
118 need to know that you know what you're doing, and I need to be able
119 to trust things *without* then having to go and check every
120 individual change by hand.
121
122(http://lwn.net/Articles/224135/).
123
124To avoid this kind of situation, ensure that all patches within a given
125branch stick closely to the associated topic; a "driver fixes" branch
126should not be making changes to the core memory management code. And, most
127importantly, do not use a git tree to bypass the review process. Post an
128occasional summary of the tree to the relevant list, and, when the time is
129right, request that the tree be included in linux-next.
130
131If and when others start to send patches for inclusion into your tree,
132don't forget to review them. Also ensure that you maintain the correct
133authorship information; the git "am" tool does its best in this regard, but
134you may have to add a "From:" line to the patch if it has been relayed to
135you via a third party.
136
137When requesting a pull, be sure to give all the relevant information: where
138your tree is, what branch to pull, and what changes will result from the
139pull. The git request-pull command can be helpful in this regard; it will
140format the request as other developers expect, and will also check to be
141sure that you have remembered to push those changes to the public server.
142
143
1447.2: REVIEWING PATCHES
145
146Some readers will certainly object to putting this section with "advanced
147topics" on the grounds that even beginning kernel developers should be
148reviewing patches. It is certainly true that there is no better way to
149learn how to program in the kernel environment than by looking at code
150posted by others. In addition, reviewers are forever in short supply; by
151looking at code you can make a significant contribution to the process as a
152whole.
153
154Reviewing code can be an intimidating prospect, especially for a new kernel
155developer who may well feel nervous about questioning code - in public -
156which has been posted by those with more experience. Even code written by
157the most experienced developers can be improved, though. Perhaps the best
158piece of advice for reviewers (all reviewers) is this: phrase review
159comments as questions rather than criticisms. Asking "how does the lock
160get released in this path?" will always work better than stating "the
161locking here is wrong."
162
163Different developers will review code from different points of view. Some
164are mostly concerned with coding style and whether code lines have trailing
165white space. Others will focus primarily on whether the change implemented
166by the patch as a whole is a good thing for the kernel or not. Yet others
167will check for problematic locking, excessive stack usage, possible
168security issues, duplication of code found elsewhere, adequate
169documentation, adverse effects on performance, user-space ABI changes, etc.
170All types of review, if they lead to better code going into the kernel, are
171welcome and worthwhile.
172
173
diff --git a/Documentation/development-process/8.Conclusion b/Documentation/development-process/8.Conclusion
new file mode 100644
index 000000000000..1990ab4b4949
--- /dev/null
+++ b/Documentation/development-process/8.Conclusion
@@ -0,0 +1,74 @@
18: FOR MORE INFORMATION
2
3There are numerous sources of information on Linux kernel development and
4related topics. First among those will always be the Documentation
5directory found in the kernel source distribution. The top-level HOWTO
6file is an important starting point; SubmittingPatches and
7SubmittingDrivers are also something which all kernel developers should
8read. Many internal kernel APIs are documented using the kerneldoc
9mechanism; "make htmldocs" or "make pdfdocs" can be used to generate those
10documents in HTML or PDF format (though the version of TeX shipped by some
11distributions runs into internal limits and fails to process the documents
12properly).
13
14Various web sites discuss kernel development at all levels of detail. Your
15author would like to humbly suggest http://lwn.net/ as a source;
16information on many specific kernel topics can be found via the LWN kernel
17index at:
18
19 http://lwn.net/Kernel/Index/
20
21Beyond that, a valuable resource for kernel developers is:
22
23 http://kernelnewbies.org/
24
25Information about the linux-next tree gathers at:
26
27 http://linux.f-seidel.de/linux-next/pmwiki/
28
29And, of course, one should not forget http://kernel.org/, the definitive
30location for kernel release information.
31
32There are a number of books on kernel development:
33
34 Linux Device Drivers, 3rd Edition (Jonathan Corbet, Alessandro
35 Rubini, and Greg Kroah-Hartman). Online at
36 http://lwn.net/Kernel/LDD3/.
37
38 Linux Kernel Development (Robert Love).
39
40 Understanding the Linux Kernel (Daniel Bovet and Marco Cesati).
41
42All of these books suffer from a common fault, though: they tend to be
43somewhat obsolete by the time they hit the shelves, and they have been on
44the shelves for a while now. Still, there is quite a bit of good
45information to be found there.
46
47Documentation for git can be found at:
48
49 http://www.kernel.org/pub/software/scm/git/docs/
50
51 http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
52
53
549: CONCLUSION
55
56Congratulations to anybody who has made it through this long-winded
57document. Hopefully it has provided a helpful understanding of how the
58Linux kernel is developed and how you can participate in that process.
59
60In the end, it's the participation that matters. Any open source software
61project is no more than the sum of what its contributors put into it. The
62Linux kernel has progressed as quickly and as well as it has because it has
63been helped by an impressively large group of developers, all of whom are
64working to make it better. The kernel is a premier example of what can be
65done when thousands of people work together toward a common goal.
66
67The kernel can always benefit from a larger developer base, though. There
68is always more work to do. But, just as importantly, most other
69participants in the Linux ecosystem can benefit through contributing to the
70kernel. Getting code into the mainline is the key to higher code quality,
71lower maintenance and distribution costs, a higher level of influence over
72the direction of kernel development, and more. It is a situation where
73everybody involved wins. Fire up your editor and come join us; you will be
74more than welcome.
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 27809357da58..1e89a51ea49b 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -2,11 +2,13 @@
2*.aux 2*.aux
3*.bin 3*.bin
4*.cpio 4*.cpio
5*.css 5*.csp
6*.dsp
6*.dvi 7*.dvi
8*.elf
7*.eps 9*.eps
8*.fw.gen.S
9*.fw 10*.fw
11*.gen.S
10*.gif 12*.gif
11*.grep 13*.grep
12*.grp 14*.grp
@@ -30,6 +32,7 @@
30*.s 32*.s
31*.sgml 33*.sgml
32*.so 34*.so
35*.so.dbg
33*.symtypes 36*.symtypes
34*.tab.c 37*.tab.c
35*.tab.h 38*.tab.h
@@ -38,24 +41,17 @@
38*.xml 41*.xml
39*_MODULES 42*_MODULES
40*_vga16.c 43*_vga16.c
41*cscope*
42*~ 44*~
43*.9 45*.9
44*.9.gz 46*.9.gz
45.* 47.*
46.cscope
47.gitignore
48.mailmap
49.mm 48.mm
5053c700_d.h 4953c700_d.h
5153c8xx_d.h*
52COPYING
53CREDITS
54CVS 50CVS
55ChangeSet 51ChangeSet
56Image 52Image
57Kerntypes 53Kerntypes
58MODS.txt 54Module.markers
59Module.symvers 55Module.symvers
60PENDING 56PENDING
61SCCS 57SCCS
@@ -73,7 +69,9 @@ autoconf.h*
73bbootsect 69bbootsect
74bin2c 70bin2c
75binkernel.spec 71binkernel.spec
72binoffset
76bootsect 73bootsect
74bounds.h
77bsetup 75bsetup
78btfixupprep 76btfixupprep
79build 77build
@@ -89,39 +87,36 @@ config_data.h*
89config_data.gz* 87config_data.gz*
90conmakehash 88conmakehash
91consolemap_deftbl.c* 89consolemap_deftbl.c*
90cpustr.h
92crc32table.h* 91crc32table.h*
93cscope.* 92cscope.*
94defkeymap.c* 93defkeymap.c
95devlist.h* 94devlist.h*
96docproc 95docproc
97dummy_sym.c*
98elf2ecoff 96elf2ecoff
99elfconfig.h* 97elfconfig.h*
100filelist
101fixdep 98fixdep
102fore200e_mkfirm 99fore200e_mkfirm
103fore200e_pca_fw.c* 100fore200e_pca_fw.c*
104gconf 101gconf
105gen-devlist 102gen-devlist
106gen-kdb_cmds.c*
107gen_crc32table 103gen_crc32table
108gen_init_cpio 104gen_init_cpio
109genksyms 105genksyms
110gentbl
111*_gray256.c 106*_gray256.c
107ihex2fw
112ikconfig.h* 108ikconfig.h*
113initramfs_data.cpio 109initramfs_data.cpio
114initramfs_data.cpio.gz 110initramfs_data.cpio.gz
115initramfs_list 111initramfs_list
116kallsyms 112kallsyms
117kconfig 113kconfig
118kconfig.tk 114keywords.c
119keywords.c*
120ksym.c* 115ksym.c*
121ksym.h* 116ksym.h*
122kxgettext 117kxgettext
123lkc_defs.h 118lkc_defs.h
124lex.c* 119lex.c
125lex.*.c 120lex.*.c
126logo_*.c 121logo_*.c
127logo_*_clut224.c 122logo_*_clut224.c
@@ -130,7 +125,6 @@ lxdialog
130mach-types 125mach-types
131mach-types.h 126mach-types.h
132machtypes.h 127machtypes.h
133make_times_h
134map 128map
135maui_boot.h 129maui_boot.h
136mconf 130mconf
@@ -138,6 +132,7 @@ miboot*
138mk_elfconfig 132mk_elfconfig
139mkboot 133mkboot
140mkbugboot 134mkbugboot
135mkcpustr
141mkdep 136mkdep
142mkprep 137mkprep
143mktables 138mktables
@@ -145,11 +140,12 @@ mktree
145modpost 140modpost
146modules.order 141modules.order
147modversions.h* 142modversions.h*
143ncscope.*
148offset.h 144offset.h
149offsets.h 145offsets.h
150oui.c* 146oui.c*
151parse.c* 147parse.c
152parse.h* 148parse.h
153patches* 149patches*
154pca200e.bin 150pca200e.bin
155pca200e_ecd.bin2 151pca200e_ecd.bin2
@@ -157,7 +153,7 @@ piggy.gz
157piggyback 153piggyback
158pnmtologo 154pnmtologo
159ppc_defs.h* 155ppc_defs.h*
160promcon_tbl.c* 156promcon_tbl.c
161pss_boot.h 157pss_boot.h
162qconf 158qconf
163raid6altivec*.c 159raid6altivec*.c
@@ -168,27 +164,38 @@ series
168setup 164setup
169setup.bin 165setup.bin
170setup.elf 166setup.elf
171sim710_d.h*
172sImage 167sImage
173sm_tbl* 168sm_tbl*
174split-include 169split-include
170syscalltab.h
175tags 171tags
176tftpboot.img 172tftpboot.img
177timeconst.h 173timeconst.h
178times.h* 174times.h*
179tkparse
180trix_boot.h 175trix_boot.h
181utsrelease.h* 176utsrelease.h*
177vdso-syms.lds
182vdso.lds 178vdso.lds
179vdso32-int80-syms.lds
180vdso32-syms.lds
181vdso32-syscall-syms.lds
182vdso32-sysenter-syms.lds
183vdso32.lds
184vdso32.so.dbg
185vdso64.lds
186vdso64.so.dbg
183version.h* 187version.h*
184vmlinux 188vmlinux
185vmlinux-* 189vmlinux-*
186vmlinux.aout 190vmlinux.aout
187vmlinux*.lds* 191vmlinux.lds
188vmlinux*.scr
189vsyscall.lds 192vsyscall.lds
193vsyscall_32.lds
190wanxlfw.inc 194wanxlfw.inc
191uImage 195uImage
192unifdef 196unifdef
197wakeup.bin
198wakeup.elf
199wakeup.lds
193zImage* 200zImage*
194zconf.hash.c 201zconf.hash.c
diff --git a/Documentation/fb/intelfb.txt b/Documentation/fb/intelfb.txt
index 27a3160650a4..dd9e944ea628 100644
--- a/Documentation/fb/intelfb.txt
+++ b/Documentation/fb/intelfb.txt
@@ -14,6 +14,7 @@ graphics devices. These would include:
14 Intel 915GM 14 Intel 915GM
15 Intel 945G 15 Intel 945G
16 Intel 945GM 16 Intel 945GM
17 Intel 945GME
17 Intel 965G 18 Intel 965G
18 Intel 965GM 19 Intel 965GM
19 20
diff --git a/Documentation/fb/uvesafb.txt b/Documentation/fb/uvesafb.txt
index bcfc233a0080..7ac3c4078ff9 100644
--- a/Documentation/fb/uvesafb.txt
+++ b/Documentation/fb/uvesafb.txt
@@ -52,7 +52,7 @@ are either given on the kernel command line or as module parameters, e.g.:
52 52
53 video=uvesafb:1024x768-32,mtrr:3,ywrap (compiled into the kernel) 53 video=uvesafb:1024x768-32,mtrr:3,ywrap (compiled into the kernel)
54 54
55 # modprobe uvesafb mode=1024x768-32 mtrr=3 scroll=ywrap (module) 55 # modprobe uvesafb mode_option=1024x768-32 mtrr=3 scroll=ywrap (module)
56 56
57Accepted options: 57Accepted options:
58 58
@@ -105,7 +105,7 @@ vtotal:n
105<mode> The mode you want to set, in the standard modedb format. Refer to 105<mode> The mode you want to set, in the standard modedb format. Refer to
106 modedb.txt for a detailed description. When uvesafb is compiled as 106 modedb.txt for a detailed description. When uvesafb is compiled as
107 a module, the mode string should be provided as a value of the 107 a module, the mode string should be provided as a value of the
108 'mode' option. 108 'mode_option' option.
109 109
110vbemode:x 110vbemode:x
111 Force the use of VBE mode x. The mode will only be set if it's 111 Force the use of VBE mode x. The mode will only be set if it's
diff --git a/Documentation/fb/viafb.modes b/Documentation/fb/viafb.modes
new file mode 100644
index 000000000000..02e5b487f00e
--- /dev/null
+++ b/Documentation/fb/viafb.modes
@@ -0,0 +1,870 @@
1#
2#
3# These data are based on the CRTC parameters in
4#
5# VIA Integration Graphics Chip
6# (C) 2004 VIA Technologies Inc.
7#
8
9#
10# 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock)
11#
12# Horizontal Vertical
13# Resolution 640 480
14# Scan Frequency 31.469 kHz 59.94 Hz
15# Sync Width 3.813 us 0.064 ms
16# 12 chars 2 lines
17# Front Porch 0.636 us 0.318 ms
18# 2 chars 10 lines
19# Back Porch 1.907 us 1.048 ms
20# 6 chars 33 lines
21# Active Time 25.422 us 15.253 ms
22# 80 chars 480 lines
23# Blank Time 6.356 us 1.430 ms
24# 20 chars 45 lines
25# Polarity negative negative
26#
27
28mode "640x480-60"
29# D: 25.175 MHz, H: 31.469 kHz, V: 59.94 Hz
30 geometry 640 480 640 480 32
31 timings 39722 48 16 33 10 96 2 endmode mode "480x640-60"
32# D: 24.823 MHz, H: 39.780 kHz, V: 60.00 Hz
33 geometry 480 640 480 640 32 timings 39722 72 24 19 1 48 3 endmode
34#
35# 640x480, 75 Hz, Non-Interlaced (31.50 MHz dotclock)
36#
37# Horizontal Vertical
38# Resolution 640 480
39# Scan Frequency 37.500 kHz 75.00 Hz
40# Sync Width 2.032 us 0.080 ms
41# 8 chars 3 lines
42# Front Porch 0.508 us 0.027 ms
43# 2 chars 1 lines
44# Back Porch 3.810 us 0.427 ms
45# 15 chars 16 lines
46# Active Time 20.317 us 12.800 ms
47# 80 chars 480 lines
48# Blank Time 6.349 us 0.533 ms
49# 25 chars 20 lines
50# Polarity negative negative
51#
52 mode "640x480-75"
53# D: 31.50 MHz, H: 37.500 kHz, V: 75.00 Hz
54 geometry 640 480 640 480 32 timings 31747 120 16 16 1 64 3 endmode
55#
56# 640x480, 85 Hz, Non-Interlaced (36.000 MHz dotclock)
57#
58# Horizontal Vertical
59# Resolution 640 480
60# Scan Frequency 43.269 kHz 85.00 Hz
61# Sync Width 1.556 us 0.069 ms
62# 7 chars 3 lines
63# Front Porch 1.556 us 0.023 ms
64# 7 chars 1 lines
65# Back Porch 2.222 us 0.578 ms
66# 10 chars 25 lines
67# Active Time 17.778 us 11.093 ms
68# 80 chars 480 lines
69# Blank Time 5.333 us 0.670 ms
70# 24 chars 29 lines
71# Polarity negative negative
72#
73 mode "640x480-85"
74# D: 36.000 MHz, H: 43.269 kHz, V: 85.00 Hz
75 geometry 640 480 640 480 32 timings 27777 80 56 25 1 56 3 endmode
76#
77# 640x480, 100 Hz, Non-Interlaced (43.163 MHz dotclock)
78#
79# Horizontal Vertical
80# Resolution 640 480
81# Scan Frequency 50.900 kHz 100.00 Hz
82# Sync Width 1.483 us 0.058 ms
83# 8 chars 3 lines
84# Front Porch 0.927 us 0.019 ms
85# 5 chars 1 lines
86# Back Porch 2.409 us 0.475 ms
87# 13 chars 25 lines
88# Active Time 14.827 us 9.430 ms
89# 80 chars 480 lines
90# Blank Time 4.819 us 0.570 ms
91# 26 chars 29 lines
92# Polarity positive positive
93#
94 mode "640x480-100"
95# D: 43.163 MHz, H: 50.900 kHz, V: 100.00 Hz
96 geometry 640 480 640 480 32 timings 23168 104 40 25 1 64 3 endmode
97#
98# 640x480, 120 Hz, Non-Interlaced (52.406 MHz dotclock)
99#
100# Horizontal Vertical
101# Resolution 640 480
102# Scan Frequency 61.800 kHz 120.00 Hz
103# Sync Width 1.221 us 0.048 ms
104# 8 chars 3 lines
105# Front Porch 0.763 us 0.016 ms
106# 5 chars 1 lines
107# Back Porch 1.984 us 0.496 ms
108# 13 chars 31 lines
109# Active Time 12.212 us 7.767 ms
110# 80 chars 480 lines
111# Blank Time 3.969 us 0.566 ms
112# 26 chars 35 lines
113# Polarity positive positive
114#
115 mode "640x480-120"
116# D: 52.406 MHz, H: 61.800 kHz, V: 120.00 Hz
117 geometry 640 480 640 480 32 timings 19081 104 40 31 1 64 3 endmode
118#
119# 720x480, 60 Hz, Non-Interlaced (26.880 MHz dotclock)
120#
121# Horizontal Vertical
122# Resolution 720 480
123# Scan Frequency 30.000 kHz 60.241 Hz
124# Sync Width 2.679 us 0.099 ms
125# 9 chars 3 lines
126# Front Porch 0.595 us 0.033 ms
127# 2 chars 1 lines
128# Back Porch 3.274 us 0.462 ms
129# 11 chars 14 lines
130# Active Time 26.786 us 16.000 ms
131# 90 chars 480 lines
132# Blank Time 6.548 us 0.600 ms
133# 22 chars 18 lines
134# Polarity positive positive
135#
136 mode "720x480-60"
137# D: 26.880 MHz, H: 30.000 kHz, V: 60.24 Hz
138 geometry 720 480 720 480 32 timings 37202 88 16 14 1 72 3 endmode
139#
140# 800x480, 60 Hz, Non-Interlaced (29.581 MHz dotclock)
141#
142# Horizontal Vertical
143# Resolution 800 480
144# Scan Frequency 29.892 kHz 60.00 Hz
145# Sync Width 2.704 us 100.604 us
146# 10 chars 3 lines
147# Front Porch 0.541 us 33.535 us
148# 2 chars 1 lines
149# Back Porch 3.245 us 435.949 us
150# 12 chars 13 lines
151# Active Time 27.044 us 16.097 ms
152# 100 chars 480 lines
153# Blank Time 6.491 us 0.570 ms
154# 24 chars 17 lines
155# Polarity positive positive
156#
157 mode "800x480-60"
158# D: 29.500 MHz, H: 29.738 kHz, V: 60.00 Hz
159 geometry 800 480 800 480 32 timings 33805 96 24 10 3 72 7 endmode
160#
161# 720x576, 60 Hz, Non-Interlaced (32.668 MHz dotclock)
162#
163# Horizontal Vertical
164# Resolution 720 576
165# Scan Frequency 35.820 kHz 60.00 Hz
166# Sync Width 2.204 us 0.083 ms
167# 9 chars 3 lines
168# Front Porch 0.735 us 0.027 ms
169# 3 chars 1 lines
170# Back Porch 2.939 us 0.459 ms
171# 12 chars 17 lines
172# Active Time 22.040 us 16.080 ms
173# 90 chars 476 lines
174# Blank Time 5.877 us 0.586 ms
175# 24 chars 21 lines
176# Polarity positive positive
177#
178 mode "720x576-60"
179# D: 32.668 MHz, H: 35.820 kHz, V: 60.00 Hz
180 geometry 720 576 720 576 32 timings 30611 96 24 17 1 72 3 endmode
181#
182# 800x600, 60 Hz, Non-Interlaced (40.00 MHz dotclock)
183#
184# Horizontal Vertical
185# Resolution 800 600
186# Scan Frequency 37.879 kHz 60.32 Hz
187# Sync Width 3.200 us 0.106 ms
188# 16 chars 4 lines
189# Front Porch 1.000 us 0.026 ms
190# 5 chars 1 lines
191# Back Porch 2.200 us 0.607 ms
192# 11 chars 23 lines
193# Active Time 20.000 us 15.840 ms
194# 100 chars 600 lines
195# Blank Time 6.400 us 0.739 ms
196# 32 chars 28 lines
197# Polarity positive positive
198#
199 mode "800x600-60"
200# D: 40.00 MHz, H: 37.879 kHz, V: 60.32 Hz
201 geometry 800 600 800 600 32
202 timings 25000 88 40 23 1 128 4 hsync high vsync high endmode
203#
204# 800x600, 75 Hz, Non-Interlaced (49.50 MHz dotclock)
205#
206# Horizontal Vertical
207# Resolution 800 600
208# Scan Frequency 46.875 kHz 75.00 Hz
209# Sync Width 1.616 us 0.064 ms
210# 10 chars 3 lines
211# Front Porch 0.323 us 0.021 ms
212# 2 chars 1 lines
213# Back Porch 3.232 us 0.448 ms
214# 20 chars 21 lines
215# Active Time 16.162 us 12.800 ms
216# 100 chars 600 lines
217# Blank Time 5.172 us 0.533 ms
218# 32 chars 25 lines
219# Polarity positive positive
220#
221 mode "800x600-75"
222# D: 49.50 MHz, H: 46.875 kHz, V: 75.00 Hz
223 geometry 800 600 800 600 32
224 timings 20203 160 16 21 1 80 3 hsync high vsync high endmode
225#
226# 800x600, 85 Hz, Non-Interlaced (56.25 MHz dotclock)
227#
228# Horizontal Vertical
229# Resolution 800 600
230# Scan Frequency 53.674 kHz 85.061 Hz
231# Sync Width 1.138 us 0.056 ms
232# 8 chars 3 lines
233# Front Porch 0.569 us 0.019 ms
234# 4 chars 1 lines
235# Back Porch 2.702 us 0.503 ms
236# 19 chars 27 lines
237# Active Time 14.222 us 11.179 ms
238# 100 chars 600 lines
239# Blank Time 4.409 us 0.578 ms
240# 31 chars 31 lines
241# Polarity positive positive
242#
243 mode "800x600-85"
244# D: 56.25 MHz, H: 53.674 kHz, V: 85.061 Hz
245 geometry 800 600 800 600 32
246 timings 17777 152 32 27 1 64 3 hsync high vsync high endmode
247#
248# 800x600, 100 Hz, Non-Interlaced (67.50 MHz dotclock)
249#
250# Horizontal Vertical
251# Resolution 800 600
252# Scan Frequency 62.500 kHz 100.00 Hz
253# Sync Width 0.948 us 0.064 ms
254# 8 chars 4 lines
255# Front Porch 0.000 us 0.112 ms
256# 0 chars 7 lines
257# Back Porch 3.200 us 0.224 ms
258# 27 chars 14 lines
259# Active Time 11.852 us 9.600 ms
260# 100 chars 600 lines
261# Blank Time 4.148 us 0.400 ms
262# 35 chars 25 lines
263# Polarity positive positive
264#
265 mode "800x600-100"
266# D: 67.50 MHz, H: 62.500 kHz, V: 100.00 Hz
267 geometry 800 600 800 600 32
268 timings 14667 216 0 14 7 64 4 hsync high vsync high endmode
269#
270# 800x600, 120 Hz, Non-Interlaced (83.950 MHz dotclock)
271#
272# Horizontal Vertical
273# Resolution 800 600
274# Scan Frequency 77.160 kHz 120.00 Hz
275# Sync Width 1.048 us 0.039 ms
276# 11 chars 3 lines
277# Front Porch 0.667 us 0.013 ms
278# 7 chars 1 lines
279# Back Porch 1.715 us 0.507 ms
280# 18 chars 39 lines
281# Active Time 9.529 us 7.776 ms
282# 100 chars 600 lines
283# Blank Time 3.431 us 0.557 ms
284# 36 chars 43 lines
285# Polarity positive positive
286#
287 mode "800x600-120"
288# D: 83.950 MHz, H: 77.160 kHz, V: 120.00 Hz
289 geometry 800 600 800 600 32
290 timings 11912 144 56 39 1 88 3 hsync high vsync high endmode
291#
292# 848x480, 60 Hz, Non-Interlaced (31.490 MHz dotclock)
293#
294# Horizontal Vertical
295# Resolution 848 480
296# Scan Frequency 29.820 kHz 60.00 Hz
297# Sync Width 2.795 us 0.099 ms
298# 11 chars 3 lines
299# Front Porch 0.508 us 0.033 ms
300# 2 chars 1 lines
301# Back Porch 3.303 us 0.429 ms
302# 13 chars 13 lines
303# Active Time 26.929 us 16.097 ms
304# 106 chars 480 lines
305# Blank Time 6.605 us 0.570 ms
306# 26 chars 17 lines
307# Polarity positive positive
308#
309 mode "848x480-60"
310# D: 31.500 MHz, H: 29.830 kHz, V: 60.00 Hz
311 geometry 848 480 848 480 32
312 timings 31746 104 24 12 3 80 5 hsync high vsync high endmode
313#
314# 856x480, 60 Hz, Non-Interlaced (31.728 MHz dotclock)
315#
316# Horizontal Vertical
317# Resolution 856 480
318# Scan Frequency 29.820 kHz 60.00 Hz
319# Sync Width 2.774 us 0.099 ms
320# 11 chars 3 lines
321# Front Porch 0.504 us 0.033 ms
322# 2 chars 1 lines
323# Back Porch 3.728 us 0.429 ms
324# 13 chars 13 lines
325# Active Time 26.979 us 16.097 ms
326# 107 chars 480 lines
327# Blank Time 6.556 us 0.570 ms
328# 26 chars 17 lines
329# Polarity positive positive
330#
331 mode "856x480-60"
332# D: 31.728 MHz, H: 29.820 kHz, V: 60.00 Hz
333 geometry 856 480 856 480 32
334 timings 31518 104 16 13 1 88 3
335 hsync high vsync high endmode mode "960x600-60"
336# D: 45.250 MHz, H: 37.212 kHz, V: 60.00 Hz
337 geometry 960 600 960 600 32 timings 22099 128 32 15 3 96 6 endmode
338#
339# 1000x600, 60 Hz, Non-Interlaced (48.068 MHz dotclock)
340#
341# Horizontal Vertical
342# Resolution 1000 600
343# Scan Frequency 37.320 kHz 60.00 Hz
344# Sync Width 2.164 us 0.080 ms
345# 13 chars 3 lines
346# Front Porch 0.832 us 0.027 ms
347# 5 chars 1 lines
348# Back Porch 2.996 us 0.483 ms
349# 18 chars 18 lines
350# Active Time 20.804 us 16.077 ms
351# 125 chars 600 lines
352# Blank Time 5.991 us 0.589 ms
353# 36 chars 22 lines
354# Polarity negative positive
355#
356 mode "1000x600-60"
357# D: 48.068 MHz, H: 37.320 kHz, V: 60.00 Hz
358 geometry 1000 600 1000 600 32
359 timings 20834 144 40 18 1 104 3 endmode mode "1024x576-60"
360# D: 46.996 MHz, H: 35.820 kHz, V: 60.00 Hz
361 geometry 1024 576 1024 576 32
362 timings 21278 144 40 17 1 104 3 endmode mode "1024x600-60"
363# D: 48.964 MHz, H: 37.320 kHz, V: 60.00 Hz
364 geometry 1024 600 1024 600 32
365 timings 20461 144 40 18 1 104 3 endmode mode "1088x612-60"
366# D: 52.952 MHz, H: 38.040 kHz, V: 60.00 Hz
367 geometry 1088 612 1088 612 32 timings 18877 152 48 16 3 104 5 endmode
368#
369# 1024x512, 60 Hz, Non-Interlaced (41.291 MHz dotclock)
370#
371# Horizontal Vertical
372# Resolution 1024 512
373# Scan Frequency 31.860 kHz 60.00 Hz
374# Sync Width 2.519 us 0.094 ms
375# 13 chars 3 lines
376# Front Porch 0.775 us 0.031 ms
377# 4 chars 1 lines
378# Back Porch 3.294 us 0.465 ms
379# 17 chars 15 lines
380# Active Time 24.800 us 16.070 ms
381# 128 chars 512 lines
382# Blank Time 6.587 us 0.596 ms
383# 34 chars 19 lines
384# Polarity positive positive
385#
386 mode "1024x512-60"
387# D: 41.291 MHz, H: 31.860 kHz, V: 60.00 Hz
388 geometry 1024 512 1024 512 32
389 timings 24218 126 32 15 1 104 3 hsync high vsync high endmode
390#
391# 1024x600, 60 Hz, Non-Interlaced (48.875 MHz dotclock)
392#
393# Horizontal Vertical
394# Resolution 1024 768
395# Scan Frequency 37.252 kHz 60.00 Hz
396# Sync Width 2.128 us 80.532us
397# 13 chars 3 lines
398# Front Porch 0.818 us 26.844 us
399# 5 chars 1 lines
400# Back Porch 2.946 us 483.192 us
401# 18 chars 18 lines
402# Active Time 20.951 us 16.697 ms
403# 128 chars 622 lines
404# Blank Time 5.893 us 0.591 ms
405# 36 chars 22 lines
406# Polarity negative positive
407#
408#mode "1024x600-60"
409# # D: 48.875 MHz, H: 37.252 kHz, V: 60.00 Hz
410# geometry 1024 600 1024 600 32
411# timings 20460 144 40 18 1 104 3
412# endmode
413#
414# 1024x768, 60 Hz, Non-Interlaced (65.00 MHz dotclock)
415#
416# Horizontal Vertical
417# Resolution 1024 768
418# Scan Frequency 48.363 kHz 60.00 Hz
419# Sync Width 2.092 us 0.124 ms
420# 17 chars 6 lines
421# Front Porch 0.369 us 0.062 ms
422# 3 chars 3 lines
423# Back Porch 2.462 us 0.601 ms
424# 20 chars 29 lines
425# Active Time 15.754 us 15.880 ms
426# 128 chars 768 lines
427# Blank Time 4.923 us 0.786 ms
428# 40 chars 38 lines
429# Polarity negative negative
430#
431 mode "1024x768-60"
432# D: 65.00 MHz, H: 48.363 kHz, V: 60.00 Hz
433 geometry 1024 768 1024 768 32 timings 15385 160 24 29 3 136 6 endmode
434#
435# 1024x768, 75 Hz, Non-Interlaced (78.75 MHz dotclock)
436#
437# Horizontal Vertical
438# Resolution 1024 768
439# Scan Frequency 60.023 kHz 75.03 Hz
440# Sync Width 1.219 us 0.050 ms
441# 12 chars 3 lines
442# Front Porch 0.203 us 0.017 ms
443# 2 chars 1 lines
444# Back Porch 2.235 us 0.466 ms
445# 22 chars 28 lines
446# Active Time 13.003 us 12.795 ms
447# 128 chars 768 lines
448# Blank Time 3.657 us 0.533 ms
449# 36 chars 32 lines
450# Polarity positive positive
451#
452 mode "1024x768-75"
453# D: 78.75 MHz, H: 60.023 kHz, V: 75.03 Hz
454 geometry 1024 768 1024 768 32
455 timings 12699 176 16 28 1 96 3 hsync high vsync high endmode
456#
457# 1024x768, 85 Hz, Non-Interlaced (94.50 MHz dotclock)
458#
459# Horizontal Vertical
460# Resolution 1024 768
461# Scan Frequency 68.677 kHz 85.00 Hz
462# Sync Width 1.016 us 0.044 ms
463# 12 chars 3 lines
464# Front Porch 0.508 us 0.015 ms
465# 6 chars 1 lines
466# Back Porch 2.201 us 0.524 ms
467# 26 chars 36 lines
468# Active Time 10.836 us 11.183 ms
469# 128 chars 768 lines
470# Blank Time 3.725 us 0.582 ms
471# 44 chars 40 lines
472# Polarity positive positive
473#
474 mode "1024x768-85"
475# D: 94.50 MHz, H: 68.677 kHz, V: 85.00 Hz
476 geometry 1024 768 1024 768 32
477 timings 10582 208 48 36 1 96 3 hsync high vsync high endmode
478#
479# 1024x768, 100 Hz, Non-Interlaced (110.0 MHz dotclock)
480#
481# Horizontal Vertical
482# Resolution 1024 768
483# Scan Frequency 79.023 kHz 99.78 Hz
484# Sync Width 0.800 us 0.101 ms
485# 11 chars 8 lines
486# Front Porch 0.000 us 0.000 ms
487# 0 chars 0 lines
488# Back Porch 2.545 us 0.202 ms
489# 35 chars 16 lines
490# Active Time 9.309 us 9.719 ms
491# 128 chars 768 lines
492# Blank Time 3.345 us 0.304 ms
493# 46 chars 24 lines
494# Polarity negative negative
495#
496 mode "1024x768-100"
497# D: 113.3 MHz, H: 79.023 kHz, V: 99.78 Hz
498 geometry 1024 768 1024 768 32
499 timings 8825 280 0 16 0 88 8 endmode mode "1152x720-60"
500# D: 66.750 MHz, H: 44.859 kHz, V: 60.00 Hz
501 geometry 1152 720 1152 720 32 timings 14981 168 56 19 3 112 6 endmode
502#
503# 1152x864, 75 Hz, Non-Interlaced (110.0 MHz dotclock)
504#
505# Horizontal Vertical
506# Resolution 1152 864
507# Scan Frequency 75.137 kHz 74.99 Hz
508# Sync Width 1.309 us 0.106 ms
509# 18 chars 8 lines
510# Front Porch 0.245 us 0.599 ms
511# 3 chars 45 lines
512# Back Porch 1.282 us 1.132 ms
513# 18 chars 85 lines
514# Active Time 10.473 us 11.499 ms
515# 144 chars 864 lines
516# Blank Time 2.836 us 1.837 ms
517# 39 chars 138 lines
518# Polarity positive positive
519#
520 mode "1152x864-75"
521# D: 110.0 MHz, H: 75.137 kHz, V: 74.99 Hz
522 geometry 1152 864 1152 864 32
523 timings 9259 144 24 85 45 144 8
524 hsync high vsync high endmode mode "1200x720-60"
525# D: 70.184 MHz, H: 44.760 kHz, V: 60.00 Hz
526 geometry 1200 720 1200 720 32
527 timings 14253 184 28 22 1 128 3 endmode mode "1280x600-60"
528# D: 61.503 MHz, H: 37.320 kHz, V: 60.00 Hz
529 geometry 1280 600 1280 600 32
530 timings 16260 184 28 18 1 128 3 endmode mode "1280x720-50"
531# D: 60.466 MHz, H: 37.050 kHz, V: 50.00 Hz
532 geometry 1280 720 1280 720 32
533 timings 16538 176 48 17 1 128 3 endmode mode "1280x768-50"
534# D: 65.178 MHz, H: 39.550 kHz, V: 50.00 Hz
535 geometry 1280 768 1280 768 32 timings 15342 184 28 19 1 128 3 endmode
536#
537# 1280x768, 60 Hz, Non-Interlaced (80.136 MHz dotclock)
538#
539# Horizontal Vertical
540# Resolution 1280 768
541# Scan Frequency 47.700 kHz 60.00 Hz
542# Sync Width 1.697 us 0.063 ms
543# 17 chars 3 lines
544# Front Porch 0.799 us 0.021 ms
545# 8 chars 1 lines
546# Back Porch 2.496 us 0.483 ms
547# 25 chars 23 lines
548# Active Time 15.973 us 16.101 ms
549# 160 chars 768 lines
550# Blank Time 4.992 us 0.566 ms
551# 50 chars 27 lines
552# Polarity positive positive
553#
554 mode "1280x768-60"
555# D: 80.13 MHz, H: 47.700 kHz, V: 60.00 Hz
556 geometry 1280 768 1280 768 32
557 timings 12480 200 48 23 1 126 3 hsync high vsync high endmode
558#
559# 1280x800, 60 Hz, Non-Interlaced (83.375 MHz dotclock)
560#
561# Horizontal Vertical
562# Resolution 1280 800
563# Scan Frequency 49.628 kHz 60.00 Hz
564# Sync Width 1.631 us 60.450 us
565# 17 chars 3 lines
566# Front Porch 0.768 us 20.15 us
567# 8 chars 1 lines
568# Back Porch 2.399 us 0.483 ms
569# 25 chars 24 lines
570# Active Time 15.352 us 16.120 ms
571# 160 chars 800 lines
572# Blank Time 4.798 us 0.564 ms
573# 50 chars 28 lines
574# Polarity negtive positive
575#
576 mode "1280x800-60"
577# D: 83.500 MHz, H: 49.702 kHz, V: 60.00 Hz
578 geometry 1280 800 1280 800 32 timings 11994 200 72 22 3 128 6 endmode
579#
580# 1280x960, 60 Hz, Non-Interlaced (108.00 MHz dotclock)
581#
582# Horizontal Vertical
583# Resolution 1280 960
584# Scan Frequency 60.000 kHz 60.00 Hz
585# Sync Width 1.037 us 0.050 ms
586# 14 chars 3 lines
587# Front Porch 0.889 us 0.017 ms
588# 12 chars 1 lines
589# Back Porch 2.889 us 0.600 ms
590# 39 chars 36 lines
591# Active Time 11.852 us 16.000 ms
592# 160 chars 960 lines
593# Blank Time 4.815 us 0.667 ms
594# 65 chars 40 lines
595# Polarity positive positive
596#
597 mode "1280x960-60"
598# D: 108.00 MHz, H: 60.000 kHz, V: 60.00 Hz
599 geometry 1280 960 1280 960 32
600 timings 9259 312 96 36 1 112 3 hsync high vsync high endmode
601#
602# 1280x1024, 60 Hz, Non-Interlaced (108.00 MHz dotclock)
603#
604# Horizontal Vertical
605# Resolution 1280 1024
606# Scan Frequency 63.981 kHz 60.02 Hz
607# Sync Width 1.037 us 0.047 ms
608# 14 chars 3 lines
609# Front Porch 0.444 us 0.015 ms
610# 6 chars 1 lines
611# Back Porch 2.297 us 0.594 ms
612# 31 chars 38 lines
613# Active Time 11.852 us 16.005 ms
614# 160 chars 1024 lines
615# Blank Time 3.778 us 0.656 ms
616# 51 chars 42 lines
617# Polarity positive positive
618#
619 mode "1280x1024-60"
620# D: 108.00 MHz, H: 63.981 kHz, V: 60.02 Hz
621 geometry 1280 1024 1280 1024 32
622 timings 9260 248 48 38 1 112 3 hsync high vsync high endmode
623#
624# 1280x1024, 75 Hz, Non-Interlaced (135.00 MHz dotclock)
625#
626# Horizontal Vertical
627# Resolution 1280 1024
628# Scan Frequency 79.976 kHz 75.02 Hz
629# Sync Width 1.067 us 0.038 ms
630# 18 chars 3 lines
631# Front Porch 0.119 us 0.012 ms
632# 2 chars 1 lines
633# Back Porch 1.837 us 0.475 ms
634# 31 chars 38 lines
635# Active Time 9.481 us 12.804 ms
636# 160 chars 1024 lines
637# Blank Time 3.022 us 0.525 ms
638# 51 chars 42 lines
639# Polarity positive positive
640#
641 mode "1280x1024-75"
642# D: 135.00 MHz, H: 79.976 kHz, V: 75.02 Hz
643 geometry 1280 1024 1280 1024 32
644 timings 7408 248 16 38 1 144 3 hsync high vsync high endmode
645#
646# 1280x1024, 85 Hz, Non-Interlaced (157.50 MHz dotclock)
647#
648# Horizontal Vertical
649# Resolution 1280 1024
650# Scan Frequency 91.146 kHz 85.02 Hz
651# Sync Width 1.016 us 0.033 ms
652# 20 chars 3 lines
653# Front Porch 0.406 us 0.011 ms
654# 8 chars 1 lines
655# Back Porch 1.422 us 0.483 ms
656# 28 chars 44 lines
657# Active Time 8.127 us 11.235 ms
658# 160 chars 1024 lines
659# Blank Time 2.844 us 0.527 ms
660# 56 chars 48 lines
661# Polarity positive positive
662#
663 mode "1280x1024-85"
664# D: 157.50 MHz, H: 91.146 kHz, V: 85.02 Hz
665 geometry 1280 1024 1280 1024 32
666 timings 6349 224 64 44 1 160 3
667 hsync high vsync high endmode mode "1440x900-60"
668# D: 106.500 MHz, H: 55.935 kHz, V: 60.00 Hz
669 geometry 1440 900 1440 900 32
670 timings 9390 232 80 25 3 152 6
671 hsync high vsync high endmode mode "1440x900-75"
672# D: 136.750 MHz, H: 70.635 kHz, V: 75.00 Hz
673 geometry 1440 900 1440 900 32
674 timings 7315 248 96 33 3 152 6 hsync high vsync high endmode
675#
676# 1440x1050, 60 Hz, Non-Interlaced (125.10 MHz dotclock)
677#
678# Horizontal Vertical
679# Resolution 1440 1050
680# Scan Frequency 65.220 kHz 60.00 Hz
681# Sync Width 1.204 us 0.046 ms
682# 19 chars 3 lines
683# Front Porch 0.760 us 0.015 ms
684# 12 chars 1 lines
685# Back Porch 1.964 us 0.495 ms
686# 31 chars 33 lines
687# Active Time 11.405 us 16.099 ms
688# 180 chars 1050 lines
689# Blank Time 3.928 us 0.567 ms
690# 62 chars 37 lines
691# Polarity positive positive
692#
693 mode "1440x1050-60"
694# D: 125.10 MHz, H: 65.220 kHz, V: 60.00 Hz
695 geometry 1440 1050 1440 1050 32
696 timings 7993 248 96 33 1 152 3
697 hsync high vsync high endmode mode "1600x900-60"
698# D: 118.250 MHz, H: 55.990 kHz, V: 60.00 Hz
699 geometry 1600 900 1600 900 32
700 timings 8415 256 88 26 3 168 5 endmode mode "1600x1024-60"
701# D: 136.358 MHz, H: 63.600 kHz, V: 60.00 Hz
702 geometry 1600 1024 1600 1024 32 timings 7315 272 104 32 1 168 3 endmode
703#
704# 1600x1200, 60 Hz, Non-Interlaced (156.00 MHz dotclock)
705#
706# Horizontal Vertical
707# Resolution 1600 1200
708# Scan Frequency 76.200 kHz 60.00 Hz
709# Sync Width 1.026 us 0.105 ms
710# 20 chars 8 lines
711# Front Porch 0.205 us 0.131 ms
712# 4 chars 10 lines
713# Back Porch 1.636 us 0.682 ms
714# 32 chars 52 lines
715# Active Time 10.256 us 15.748 ms
716# 200 chars 1200 lines
717# Blank Time 2.872 us 0.866 ms
718# 56 chars 66 lines
719# Polarity negative negative
720#
721 mode "1600x1200-60"
722# D: 156.00 MHz, H: 76.200 kHz, V: 60.00 Hz
723 geometry 1600 1200 1600 1200 32 timings 6172 256 32 52 10 160 8 endmode
724#
725# 1600x1200, 75 Hz, Non-Interlaced (202.50 MHz dotclock)
726#
727# Horizontal Vertical
728# Resolution 1600 1200
729# Scan Frequency 93.750 kHz 75.00 Hz
730# Sync Width 0.948 us 0.032 ms
731# 24 chars 3 lines
732# Front Porch 0.316 us 0.011 ms
733# 8 chars 1 lines
734# Back Porch 1.501 us 0.491 ms
735# 38 chars 46 lines
736# Active Time 7.901 us 12.800 ms
737# 200 chars 1200 lines
738# Blank Time 2.765 us 0.533 ms
739# 70 chars 50 lines
740# Polarity positive positive
741#
742 mode "1600x1200-75"
743# D: 202.50 MHz, H: 93.750 kHz, V: 75.00 Hz
744 geometry 1600 1200 1600 1200 32
745 timings 4938 304 64 46 1 192 3
746 hsync high vsync high endmode mode "1680x1050-60"
747# D: 146.250 MHz, H: 65.290 kHz, V: 59.954 Hz
748 geometry 1680 1050 1680 1050 32
749 timings 6814 280 104 30 3 176 6
750 hsync high vsync high endmode mode "1680x1050-75"
751# D: 187.000 MHz, H: 82.306 kHz, V: 74.892 Hz
752 geometry 1680 1050 1680 1050 32
753 timings 5348 296 120 40 3 176 6
754 hsync high vsync high endmode mode "1792x1344-60"
755# D: 202.975 MHz, H: 83.460 kHz, V: 60.00 Hz
756 geometry 1792 1344 1792 1344 32
757 timings 4902 320 128 43 1 192 3
758 hsync high vsync high endmode mode "1856x1392-60"
759# D: 218.571 MHz, H: 86.460 kHz, V: 60.00 Hz
760 geometry 1856 1392 1856 1392 32
761 timings 4577 336 136 45 1 200 3
762 hsync high vsync high endmode mode "1920x1200-60"
763# D: 193.250 MHz, H: 74.556 kHz, V: 60.00 Hz
764 geometry 1920 1200 1920 1200 32
765 timings 5173 336 136 36 3 200 6
766 hsync high vsync high endmode mode "1920x1440-60"
767# D: 234.000 MHz, H:90.000 kHz, V: 60.00 Hz
768 geometry 1920 1440 1920 1440 32
769 timings 4274 344 128 56 1 208 3
770 hsync high vsync high endmode mode "1920x1440-75"
771# D: 297.000 MHz, H:112.500 kHz, V: 75.00 Hz
772 geometry 1920 1440 1920 1440 32
773 timings 3367 352 144 56 1 224 3
774 hsync high vsync high endmode mode "2048x1536-60"
775# D: 267.250 MHz, H: 95.446 kHz, V: 60.00 Hz
776 geometry 2048 1536 2048 1536 32
777 timings 3742 376 152 49 3 224 4 hsync high vsync high endmode
778#
779# 1280x720, 60 Hz, Non-Interlaced (74.481 MHz dotclock)
780#
781# Horizontal Vertical
782# Resolution 1280 720
783# Scan Frequency 44.760 kHz 60.00 Hz
784# Sync Width 1.826 us 67.024 ms
785# 17 chars 3 lines
786# Front Porch 0.752 us 22.341 ms
787# 7 chars 1 lines
788# Back Porch 2.578 us 491.510 ms
789# 24 chars 22 lines
790# Active Time 17.186 us 16.086 ms
791# 160 chars 720 lines
792# Blank Time 5.156 us 0.581 ms
793# 48 chars 26 lines
794# Polarity negative negative
795#
796 mode "1280x720-60"
797# D: 74.481 MHz, H: 44.760 kHz, V: 60.00 Hz
798 geometry 1280 720 1280 720 32 timings 13426 192 64 22 1 136 3 endmode
799#
800# 1920x1080, 60 Hz, Non-Interlaced (172.798 MHz dotclock)
801#
802# Horizontal Vertical
803# Resolution 1920 1080
804# Scan Frequency 67.080 kHz 60.00 Hz
805# Sync Width 1.204 us 44.723 ms
806# 26 chars 3 lines
807# Front Porch 0.694 us 14.908 ms
808# 15 chars 1 lines
809# Back Porch 1.898 us 506.857 ms
810# 41 chars 34 lines
811# Active Time 11.111 us 16.100 ms
812# 240 chars 1080 lines
813# Blank Time 3.796 us 0.566 ms
814# 82 chars 38 lines
815# Polarity negative negative
816#
817 mode "1920x1080-60"
818# D: 74.481 MHz, H: 67.080 kHz, V: 60.00 Hz
819 geometry 1920 1080 1920 1080 32 timings 5787 328 120 34 1 208 3 endmode
820#
821# 1400x1050, 60 Hz, Non-Interlaced (122.61 MHz dotclock)
822#
823# Horizontal Vertical
824# Resolution 1400 1050
825# Scan Frequency 65.218 kHz 59.99 Hz
826# Sync Width 1.037 us 0.047 ms
827# 19 chars 3 lines
828# Front Porch 0.444 us 0.015 ms
829# 11 chars 1 lines
830# Back Porch 1.185 us 0.188 ms
831# 30 chars 33 lines
832# Active Time 12.963 us 16.411 ms
833# 175 chars 1050 lines
834# Blank Time 2.667 us 0.250 ms
835# 60 chars 37 lines
836# Polarity negative positive
837#
838 mode "1400x1050-60"
839# D: 122.750 MHz, H: 65.317 kHz, V: 59.99 Hz
840 geometry 1400 1050 1408 1050 32
841 timings 8214 232 88 32 3 144 4 endmode mode "1400x1050-75"
842# D: 156.000 MHz, H: 82.278 kHz, V: 74.867 Hz
843 geometry 1400 1050 1408 1050 32 timings 6410 248 104 42 3 144 4 endmode
844#
845# 1366x768, 60 Hz, Non-Interlaced (85.86 MHz dotclock)
846#
847# Horizontal Vertical
848# Resolution 1366 768
849# Scan Frequency 47.700 kHz 60.00 Hz
850# Sync Width 1.677 us 0.063 ms
851# 18 chars 3 lines
852# Front Porch 0.839 us 0.021 ms
853# 9 chars 1 lines
854# Back Porch 2.516 us 0.482 ms
855# 27 chars 23 lines
856# Active Time 15.933 us 16.101 ms
857# 171 chars 768 lines
858# Blank Time 5.031 us 0.566 ms
859# 54 chars 27 lines
860# Polarity negative positive
861#
862 mode "1360x768-60"
863# D: 84.750 MHz, H: 47.720 kHz, V: 60.00 Hz
864 geometry 1360 768 1360 768 32
865 timings 11799 208 72 22 3 136 5 endmode mode "1366x768-60"
866# D: 85.86 MHz, H: 47.700 kHz, V: 60.00 Hz
867 geometry 1366 768 1366 768 32
868 timings 11647 216 72 23 1 144 3 endmode mode "1366x768-50"
869# D: 69,924 MHz, H: 39.550 kHz, V: 50.00 Hz
870 geometry 1366 768 1366 768 32 timings 14301 200 56 19 1 144 3 endmode
diff --git a/Documentation/fb/viafb.txt b/Documentation/fb/viafb.txt
new file mode 100644
index 000000000000..67dbf442b0b6
--- /dev/null
+++ b/Documentation/fb/viafb.txt
@@ -0,0 +1,214 @@
1
2 VIA Integration Graphic Chip Console Framebuffer Driver
3
4[Platform]
5-----------------------
6 The console framebuffer driver is for graphics chips of
7 VIA UniChrome Family(CLE266, PM800 / CN400 / CN300,
8 P4M800CE / P4M800Pro / CN700 / VN800,
9 CX700 / VX700, K8M890, P4M890,
10 CN896 / P4M900, VX800)
11
12[Driver features]
13------------------------
14 Device: CRT, LCD, DVI
15
16 Support viafb_mode:
17 CRT:
18 640x480(60, 75, 85, 100, 120 Hz), 720x480(60 Hz),
19 720x576(60 Hz), 800x600(60, 75, 85, 100, 120 Hz),
20 848x480(60 Hz), 856x480(60 Hz), 1024x512(60 Hz),
21 1024x768(60, 75, 85, 100 Hz), 1152x864(75 Hz),
22 1280x768(60 Hz), 1280x960(60 Hz), 1280x1024(60, 75, 85 Hz),
23 1440x1050(60 Hz), 1600x1200(60, 75 Hz), 1280x720(60 Hz),
24 1920x1080(60 Hz), 1400x1050(60 Hz), 800x480(60 Hz)
25
26 color depth: 8 bpp, 16 bpp, 32 bpp supports.
27
28 Support 2D hardware accelerator.
29
30[Using the viafb module]
31-- -- --------------------
32 Start viafb with default settings:
33 #modprobe viafb
34
35 Start viafb with with user options:
36 #modprobe viafb viafb_mode=800x600 viafb_bpp=16 viafb_refresh=60
37 viafb_active_dev=CRT+DVI viafb_dvi_port=DVP1
38 viafb_mode1=1024x768 viafb_bpp=16 viafb_refresh1=60
39 viafb_SAMM_ON=1
40
41 viafb_mode:
42 640x480 (default)
43 720x480
44 800x600
45 1024x768
46 ......
47
48 viafb_bpp:
49 8, 16, 32 (default:32)
50
51 viafb_refresh:
52 60, 75, 85, 100, 120 (default:60)
53
54 viafb_lcd_dsp_method:
55 0 : expansion (default)
56 1 : centering
57
58 viafb_lcd_mode:
59 0 : LCD panel with LSB data format input (default)
60 1 : LCD panel with MSB data format input
61
62 viafb_lcd_panel_id:
63 0 : Resolution: 640x480, Channel: single, Dithering: Enable
64 1 : Resolution: 800x600, Channel: single, Dithering: Enable
65 2 : Resolution: 1024x768, Channel: single, Dithering: Enable (default)
66 3 : Resolution: 1280x768, Channel: single, Dithering: Enable
67 4 : Resolution: 1280x1024, Channel: dual, Dithering: Enable
68 5 : Resolution: 1400x1050, Channel: dual, Dithering: Enable
69 6 : Resolution: 1600x1200, Channel: dual, Dithering: Enable
70
71 8 : Resolution: 800x480, Channel: single, Dithering: Enable
72 9 : Resolution: 1024x768, Channel: dual, Dithering: Enable
73 10: Resolution: 1024x768, Channel: single, Dithering: Disable
74 11: Resolution: 1024x768, Channel: dual, Dithering: Disable
75 12: Resolution: 1280x768, Channel: single, Dithering: Disable
76 13: Resolution: 1280x1024, Channel: dual, Dithering: Disable
77 14: Resolution: 1400x1050, Channel: dual, Dithering: Disable
78 15: Resolution: 1600x1200, Channel: dual, Dithering: Disable
79 16: Resolution: 1366x768, Channel: single, Dithering: Disable
80 17: Resolution: 1024x600, Channel: single, Dithering: Enable
81 18: Resolution: 1280x768, Channel: dual, Dithering: Enable
82 19: Resolution: 1280x800, Channel: single, Dithering: Enable
83
84 viafb_accel:
85 0 : No 2D Hardware Acceleration
86 1 : 2D Hardware Acceleration (default)
87
88 viafb_SAMM_ON:
89 0 : viafb_SAMM_ON disable (default)
90 1 : viafb_SAMM_ON enable
91
92 viafb_mode1: (secondary display device)
93 640x480 (default)
94 720x480
95 800x600
96 1024x768
97 ... ...
98
99 viafb_bpp1: (secondary display device)
100 8, 16, 32 (default:32)
101
102 viafb_refresh1: (secondary display device)
103 60, 75, 85, 100, 120 (default:60)
104
105 viafb_active_dev:
106 This option is used to specify active devices.(CRT, DVI, CRT+LCD...)
107 DVI stands for DVI or HDMI, E.g., If you want to enable HDMI,
108 set viafb_active_dev=DVI. In SAMM case, the previous of
109 viafb_active_dev is primary device, and the following is
110 secondary device.
111
112 For example:
113 To enable one device, such as DVI only, we can use:
114 modprobe viafb viafb_active_dev=DVI
115 To enable two devices, such as CRT+DVI:
116 modprobe viafb viafb_active_dev=CRT+DVI;
117
118 For DuoView case, we can use:
119 modprobe viafb viafb_active_dev=CRT+DVI
120 OR
121 modprobe viafb viafb_active_dev=DVI+CRT...
122
123 For SAMM case:
124 If CRT is primary and DVI is secondary, we should use:
125 modprobe viafb viafb_active_dev=CRT+DVI viafb_SAMM_ON=1...
126 If DVI is primary and CRT is secondary, we should use:
127 modprobe viafb viafb_active_dev=DVI+CRT viafb_SAMM_ON=1...
128
129 viafb_display_hardware_layout:
130 This option is used to specify display hardware layout for CX700 chip.
131 1 : LCD only
132 2 : DVI only
133 3 : LCD+DVI (default)
134 4 : LCD1+LCD2 (internal + internal)
135 16: LCD1+ExternalLCD2 (internal + external)
136
137 viafb_second_size:
138 This option is used to set second device memory size(MB) in SAMM case.
139 The minimal size is 16.
140
141 viafb_platform_epia_dvi:
142 This option is used to enable DVI on EPIA - M
143 0 : No DVI on EPIA - M (default)
144 1 : DVI on EPIA - M
145
146 viafb_bus_width:
147 When using 24 - Bit Bus Width Digital Interface,
148 this option should be set.
149 12: 12-Bit LVDS or 12-Bit TMDS (default)
150 24: 24-Bit LVDS or 24-Bit TMDS
151
152 viafb_device_lcd_dualedge:
153 When using Dual Edge Panel, this option should be set.
154 0 : No Dual Edge Panel (default)
155 1 : Dual Edge Panel
156
157 viafb_video_dev:
158 This option is used to specify video output devices(CRT, DVI, LCD) for
159 duoview case.
160 For example:
161 To output video on DVI, we should use:
162 modprobe viafb viafb_video_dev=DVI...
163
164 viafb_lcd_port:
165 This option is used to specify LCD output port,
166 available values are "DVP0" "DVP1" "DFP_HIGHLOW" "DFP_HIGH" "DFP_LOW".
167 for external LCD + external DVI on CX700(External LCD is on DVP0),
168 we should use:
169 modprobe viafb viafb_lcd_port=DVP0...
170
171Notes:
172 1. CRT may not display properly for DuoView CRT & DVI display at
173 the "640x480" PAL mode with DVI overscan enabled.
174 2. SAMM stands for single adapter multi monitors. It is different from
175 multi-head since SAMM support multi monitor at driver layers, thus fbcon
176 layer doesn't even know about it; SAMM's second screen doesn't have a
177 device node file, thus a user mode application can't access it directly.
178 When SAMM is enabled, viafb_mode and viafb_mode1, viafb_bpp and
179 viafb_bpp1, viafb_refresh and viafb_refresh1 can be different.
180 3. When console is depending on viafbinfo1, dynamically change resolution
181 and bpp, need to call VIAFB specified ioctl interface VIAFB_SET_DEVICE
182 instead of calling common ioctl function FBIOPUT_VSCREENINFO since
183 viafb doesn't support multi-head well, or it will cause screen crush.
184 4. VX800 2D accelerator hasn't been supported in this driver yet. When
185 using driver on VX800, the driver will disable the acceleration
186 function as default.
187
188
189[Configure viafb with "fbset" tool]
190-----------------------------------
191 "fbset" is an inbox utility of Linux.
192 1. Inquire current viafb information, type,
193 # fbset -i
194
195 2. Set various resolutions and viafb_refresh rates,
196 # fbset <resolution-vertical_sync>
197
198 example,
199 # fbset "1024x768-75"
200 or
201 # fbset -g 1024 768 1024 768 32
202 Check the file "/etc/fb.modes" to find display modes available.
203
204 3. Set the color depth,
205 # fbset -depth <value>
206
207 example,
208 # fbset -depth 16
209
210[Bootup with viafb]:
211--------------------
212 Add the following line to your grub.conf:
213 append = "video=viafb:viafb_mode=1024x768,viafb_bpp=32,viafb_refresh=85"
214
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 4d2566a7d168..f5f812daf9f4 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -294,6 +294,15 @@ Who: Jiri Slaby <jirislaby@gmail.com>
294 294
295--------------------------- 295---------------------------
296 296
297What: print_fn_descriptor_symbol()
298When: October 2009
299Why: The %pF vsprintf format provides the same functionality in a
300 simpler way. print_fn_descriptor_symbol() is deprecated but
301 still present to give out-of-tree modules time to change.
302Who: Bjorn Helgaas <bjorn.helgaas@hp.com>
303
304---------------------------
305
297What: /sys/o2cb symlink 306What: /sys/o2cb symlink
298When: January 2010 307When: January 2010
299Why: /sys/fs/o2cb is the proper location for this information - /sys/o2cb 308Why: /sys/fs/o2cb is the proper location for this information - /sys/o2cb
diff --git a/Documentation/filesystems/autofs4-mount-control.txt b/Documentation/filesystems/autofs4-mount-control.txt
new file mode 100644
index 000000000000..c6341745df37
--- /dev/null
+++ b/Documentation/filesystems/autofs4-mount-control.txt
@@ -0,0 +1,393 @@
1
2Miscellaneous Device control operations for the autofs4 kernel module
3====================================================================
4
5The problem
6===========
7
8There is a problem with active restarts in autofs (that is to say
9restarting autofs when there are busy mounts).
10
11During normal operation autofs uses a file descriptor opened on the
12directory that is being managed in order to be able to issue control
13operations. Using a file descriptor gives ioctl operations access to
14autofs specific information stored in the super block. The operations
15are things such as setting an autofs mount catatonic, setting the
16expire timeout and requesting expire checks. As is explained below,
17certain types of autofs triggered mounts can end up covering an autofs
18mount itself which prevents us being able to use open(2) to obtain a
19file descriptor for these operations if we don't already have one open.
20
21Currently autofs uses "umount -l" (lazy umount) to clear active mounts
22at restart. While using lazy umount works for most cases, anything that
23needs to walk back up the mount tree to construct a path, such as
24getcwd(2) and the proc file system /proc/<pid>/cwd, no longer works
25because the point from which the path is constructed has been detached
26from the mount tree.
27
28The actual problem with autofs is that it can't reconnect to existing
29mounts. Immediately one thinks of just adding the ability to remount
30autofs file systems would solve it, but alas, that can't work. This is
31because autofs direct mounts and the implementation of "on demand mount
32and expire" of nested mount trees have the file system mounted directly
33on top of the mount trigger directory dentry.
34
35For example, there are two types of automount maps, direct (in the kernel
36module source you will see a third type called an offset, which is just
37a direct mount in disguise) and indirect.
38
39Here is a master map with direct and indirect map entries:
40
41/- /etc/auto.direct
42/test /etc/auto.indirect
43
44and the corresponding map files:
45
46/etc/auto.direct:
47
48/automount/dparse/g6 budgie:/autofs/export1
49/automount/dparse/g1 shark:/autofs/export1
50and so on.
51
52/etc/auto.indirect:
53
54g1 shark:/autofs/export1
55g6 budgie:/autofs/export1
56and so on.
57
58For the above indirect map an autofs file system is mounted on /test and
59mounts are triggered for each sub-directory key by the inode lookup
60operation. So we see a mount of shark:/autofs/export1 on /test/g1, for
61example.
62
63The way that direct mounts are handled is by making an autofs mount on
64each full path, such as /automount/dparse/g1, and using it as a mount
65trigger. So when we walk on the path we mount shark:/autofs/export1 "on
66top of this mount point". Since these are always directories we can
67use the follow_link inode operation to trigger the mount.
68
69But, each entry in direct and indirect maps can have offsets (making
70them multi-mount map entries).
71
72For example, an indirect mount map entry could also be:
73
74g1 \
75 / shark:/autofs/export5/testing/test \
76 /s1 shark:/autofs/export/testing/test/s1 \
77 /s2 shark:/autofs/export5/testing/test/s2 \
78 /s1/ss1 shark:/autofs/export1 \
79 /s2/ss2 shark:/autofs/export2
80
81and a similarly a direct mount map entry could also be:
82
83/automount/dparse/g1 \
84 / shark:/autofs/export5/testing/test \
85 /s1 shark:/autofs/export/testing/test/s1 \
86 /s2 shark:/autofs/export5/testing/test/s2 \
87 /s1/ss1 shark:/autofs/export2 \
88 /s2/ss2 shark:/autofs/export2
89
90One of the issues with version 4 of autofs was that, when mounting an
91entry with a large number of offsets, possibly with nesting, we needed
92to mount and umount all of the offsets as a single unit. Not really a
93problem, except for people with a large number of offsets in map entries.
94This mechanism is used for the well known "hosts" map and we have seen
95cases (in 2.4) where the available number of mounts are exhausted or
96where the number of privileged ports available is exhausted.
97
98In version 5 we mount only as we go down the tree of offsets and
99similarly for expiring them which resolves the above problem. There is
100somewhat more detail to the implementation but it isn't needed for the
101sake of the problem explanation. The one important detail is that these
102offsets are implemented using the same mechanism as the direct mounts
103above and so the mount points can be covered by a mount.
104
105The current autofs implementation uses an ioctl file descriptor opened
106on the mount point for control operations. The references held by the
107descriptor are accounted for in checks made to determine if a mount is
108in use and is also used to access autofs file system information held
109in the mount super block. So the use of a file handle needs to be
110retained.
111
112
113The Solution
114============
115
116To be able to restart autofs leaving existing direct, indirect and
117offset mounts in place we need to be able to obtain a file handle
118for these potentially covered autofs mount points. Rather than just
119implement an isolated operation it was decided to re-implement the
120existing ioctl interface and add new operations to provide this
121functionality.
122
123In addition, to be able to reconstruct a mount tree that has busy mounts,
124the uid and gid of the last user that triggered the mount needs to be
125available because these can be used as macro substitution variables in
126autofs maps. They are recorded at mount request time and an operation
127has been added to retrieve them.
128
129Since we're re-implementing the control interface, a couple of other
130problems with the existing interface have been addressed. First, when
131a mount or expire operation completes a status is returned to the
132kernel by either a "send ready" or a "send fail" operation. The
133"send fail" operation of the ioctl interface could only ever send
134ENOENT so the re-implementation allows user space to send an actual
135status. Another expensive operation in user space, for those using
136very large maps, is discovering if a mount is present. Usually this
137involves scanning /proc/mounts and since it needs to be done quite
138often it can introduce significant overhead when there are many entries
139in the mount table. An operation to lookup the mount status of a mount
140point dentry (covered or not) has also been added.
141
142Current kernel development policy recommends avoiding the use of the
143ioctl mechanism in favor of systems such as Netlink. An implementation
144using this system was attempted to evaluate its suitability and it was
145found to be inadequate, in this case. The Generic Netlink system was
146used for this as raw Netlink would lead to a significant increase in
147complexity. There's no question that the Generic Netlink system is an
148elegant solution for common case ioctl functions but it's not a complete
149replacement probably because it's primary purpose in life is to be a
150message bus implementation rather than specifically an ioctl replacement.
151While it would be possible to work around this there is one concern
152that lead to the decision to not use it. This is that the autofs
153expire in the daemon has become far to complex because umount
154candidates are enumerated, almost for no other reason than to "count"
155the number of times to call the expire ioctl. This involves scanning
156the mount table which has proved to be a big overhead for users with
157large maps. The best way to improve this is try and get back to the
158way the expire was done long ago. That is, when an expire request is
159issued for a mount (file handle) we should continually call back to
160the daemon until we can't umount any more mounts, then return the
161appropriate status to the daemon. At the moment we just expire one
162mount at a time. A Generic Netlink implementation would exclude this
163possibility for future development due to the requirements of the
164message bus architecture.
165
166
167autofs4 Miscellaneous Device mount control interface
168====================================================
169
170The control interface is opening a device node, typically /dev/autofs.
171
172All the ioctls use a common structure to pass the needed parameter
173information and return operation results:
174
175struct autofs_dev_ioctl {
176 __u32 ver_major;
177 __u32 ver_minor;
178 __u32 size; /* total size of data passed in
179 * including this struct */
180 __s32 ioctlfd; /* automount command fd */
181
182 __u32 arg1; /* Command parameters */
183 __u32 arg2;
184
185 char path[0];
186};
187
188The ioctlfd field is a mount point file descriptor of an autofs mount
189point. It is returned by the open call and is used by all calls except
190the check for whether a given path is a mount point, where it may
191optionally be used to check a specific mount corresponding to a given
192mount point file descriptor, and when requesting the uid and gid of the
193last successful mount on a directory within the autofs file system.
194
195The fields arg1 and arg2 are used to communicate parameters and results of
196calls made as described below.
197
198The path field is used to pass a path where it is needed and the size field
199is used account for the increased structure length when translating the
200structure sent from user space.
201
202This structure can be initialized before setting specific fields by using
203the void function call init_autofs_dev_ioctl(struct autofs_dev_ioctl *).
204
205All of the ioctls perform a copy of this structure from user space to
206kernel space and return -EINVAL if the size parameter is smaller than
207the structure size itself, -ENOMEM if the kernel memory allocation fails
208or -EFAULT if the copy itself fails. Other checks include a version check
209of the compiled in user space version against the module version and a
210mismatch results in a -EINVAL return. If the size field is greater than
211the structure size then a path is assumed to be present and is checked to
212ensure it begins with a "/" and is NULL terminated, otherwise -EINVAL is
213returned. Following these checks, for all ioctl commands except
214AUTOFS_DEV_IOCTL_VERSION_CMD, AUTOFS_DEV_IOCTL_OPENMOUNT_CMD and
215AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD the ioctlfd is validated and if it is
216not a valid descriptor or doesn't correspond to an autofs mount point
217an error of -EBADF, -ENOTTY or -EINVAL (not an autofs descriptor) is
218returned.
219
220
221The ioctls
222==========
223
224An example of an implementation which uses this interface can be seen
225in autofs version 5.0.4 and later in file lib/dev-ioctl-lib.c of the
226distribution tar available for download from kernel.org in directory
227/pub/linux/daemons/autofs/v5.
228
229The device node ioctl operations implemented by this interface are:
230
231
232AUTOFS_DEV_IOCTL_VERSION
233------------------------
234
235Get the major and minor version of the autofs4 device ioctl kernel module
236implementation. It requires an initialized struct autofs_dev_ioctl as an
237input parameter and sets the version information in the passed in structure.
238It returns 0 on success or the error -EINVAL if a version mismatch is
239detected.
240
241
242AUTOFS_DEV_IOCTL_PROTOVER_CMD and AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD
243------------------------------------------------------------------
244
245Get the major and minor version of the autofs4 protocol version understood
246by loaded module. This call requires an initialized struct autofs_dev_ioctl
247with the ioctlfd field set to a valid autofs mount point descriptor
248and sets the requested version number in structure field arg1. These
249commands return 0 on success or one of the negative error codes if
250validation fails.
251
252
253AUTOFS_DEV_IOCTL_OPENMOUNT and AUTOFS_DEV_IOCTL_CLOSEMOUNT
254----------------------------------------------------------
255
256Obtain and release a file descriptor for an autofs managed mount point
257path. The open call requires an initialized struct autofs_dev_ioctl with
258the the path field set and the size field adjusted appropriately as well
259as the arg1 field set to the device number of the autofs mount. The
260device number can be obtained from the mount options shown in
261/proc/mounts. The close call requires an initialized struct
262autofs_dev_ioct with the ioctlfd field set to the descriptor obtained
263from the open call. The release of the file descriptor can also be done
264with close(2) so any open descriptors will also be closed at process exit.
265The close call is included in the implemented operations largely for
266completeness and to provide for a consistent user space implementation.
267
268
269AUTOFS_DEV_IOCTL_READY_CMD and AUTOFS_DEV_IOCTL_FAIL_CMD
270--------------------------------------------------------
271
272Return mount and expire result status from user space to the kernel.
273Both of these calls require an initialized struct autofs_dev_ioctl
274with the ioctlfd field set to the descriptor obtained from the open
275call and the arg1 field set to the wait queue token number, received
276by user space in the foregoing mount or expire request. The arg2 field
277is set to the status to be returned. For the ready call this is always
2780 and for the fail call it is set to the errno of the operation.
279
280
281AUTOFS_DEV_IOCTL_SETPIPEFD_CMD
282------------------------------
283
284Set the pipe file descriptor used for kernel communication to the daemon.
285Normally this is set at mount time using an option but when reconnecting
286to a existing mount we need to use this to tell the autofs mount about
287the new kernel pipe descriptor. In order to protect mounts against
288incorrectly setting the pipe descriptor we also require that the autofs
289mount be catatonic (see next call).
290
291The call requires an initialized struct autofs_dev_ioctl with the
292ioctlfd field set to the descriptor obtained from the open call and
293the arg1 field set to descriptor of the pipe. On success the call
294also sets the process group id used to identify the controlling process
295(eg. the owning automount(8) daemon) to the process group of the caller.
296
297
298AUTOFS_DEV_IOCTL_CATATONIC_CMD
299------------------------------
300
301Make the autofs mount point catatonic. The autofs mount will no longer
302issue mount requests, the kernel communication pipe descriptor is released
303and any remaining waits in the queue released.
304
305The call requires an initialized struct autofs_dev_ioctl with the
306ioctlfd field set to the descriptor obtained from the open call.
307
308
309AUTOFS_DEV_IOCTL_TIMEOUT_CMD
310----------------------------
311
312Set the expire timeout for mounts withing an autofs mount point.
313
314The call requires an initialized struct autofs_dev_ioctl with the
315ioctlfd field set to the descriptor obtained from the open call.
316
317
318AUTOFS_DEV_IOCTL_REQUESTER_CMD
319------------------------------
320
321Return the uid and gid of the last process to successfully trigger a the
322mount on the given path dentry.
323
324The call requires an initialized struct autofs_dev_ioctl with the path
325field set to the mount point in question and the size field adjusted
326appropriately as well as the arg1 field set to the device number of the
327containing autofs mount. Upon return the struct field arg1 contains the
328uid and arg2 the gid.
329
330When reconstructing an autofs mount tree with active mounts we need to
331re-connect to mounts that may have used the original process uid and
332gid (or string variations of them) for mount lookups within the map entry.
333This call provides the ability to obtain this uid and gid so they may be
334used by user space for the mount map lookups.
335
336
337AUTOFS_DEV_IOCTL_EXPIRE_CMD
338---------------------------
339
340Issue an expire request to the kernel for an autofs mount. Typically
341this ioctl is called until no further expire candidates are found.
342
343The call requires an initialized struct autofs_dev_ioctl with the
344ioctlfd field set to the descriptor obtained from the open call. In
345addition an immediate expire, independent of the mount timeout, can be
346requested by setting the arg1 field to 1. If no expire candidates can
347be found the ioctl returns -1 with errno set to EAGAIN.
348
349This call causes the kernel module to check the mount corresponding
350to the given ioctlfd for mounts that can be expired, issues an expire
351request back to the daemon and waits for completion.
352
353AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD
354------------------------------
355
356Checks if an autofs mount point is in use.
357
358The call requires an initialized struct autofs_dev_ioctl with the
359ioctlfd field set to the descriptor obtained from the open call and
360it returns the result in the arg1 field, 1 for busy and 0 otherwise.
361
362
363AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD
364---------------------------------
365
366Check if the given path is a mountpoint.
367
368The call requires an initialized struct autofs_dev_ioctl. There are two
369possible variations. Both use the path field set to the path of the mount
370point to check and the size field adjusted appropriately. One uses the
371ioctlfd field to identify a specific mount point to check while the other
372variation uses the path and optionaly arg1 set to an autofs mount type.
373The call returns 1 if this is a mount point and sets arg1 to the device
374number of the mount and field arg2 to the relevant super block magic
375number (described below) or 0 if it isn't a mountpoint. In both cases
376the the device number (as returned by new_encode_dev()) is returned
377in field arg1.
378
379If supplied with a file descriptor we're looking for a specific mount,
380not necessarily at the top of the mounted stack. In this case the path
381the descriptor corresponds to is considered a mountpoint if it is itself
382a mountpoint or contains a mount, such as a multi-mount without a root
383mount. In this case we return 1 if the descriptor corresponds to a mount
384point and and also returns the super magic of the covering mount if there
385is one or 0 if it isn't a mountpoint.
386
387If a path is supplied (and the ioctlfd field is set to -1) then the path
388is looked up and is checked to see if it is the root of a mount. If a
389type is also given we are looking for a particular autofs mount and if
390a match isn't found a fail is returned. If the the located path is the
391root of a mount 1 is returned along with the super magic of the mount
392or 0 otherwise.
393
diff --git a/Documentation/filesystems/ext3.txt b/Documentation/filesystems/ext3.txt
index b45f3c1b8b43..295f26cd895a 100644
--- a/Documentation/filesystems/ext3.txt
+++ b/Documentation/filesystems/ext3.txt
@@ -193,6 +193,5 @@ kernel source: <file:fs/ext3/>
193programs: http://e2fsprogs.sourceforge.net/ 193programs: http://e2fsprogs.sourceforge.net/
194 http://ext2resize.sourceforge.net 194 http://ext2resize.sourceforge.net
195 195
196useful links: http://www.zip.com.au/~akpm/linux/ext3/ext3-usage.html 196useful links: http://www-106.ibm.com/developerworks/linux/library/l-fs7/
197 http://www-106.ibm.com/developerworks/linux/library/l-fs7/
198 http://www-106.ibm.com/developerworks/linux/library/l-fs8/ 197 http://www-106.ibm.com/developerworks/linux/library/l-fs8/
diff --git a/Documentation/filesystems/nfsroot.txt b/Documentation/filesystems/nfsroot.txt
index 31b329172343..68baddf3c3e0 100644
--- a/Documentation/filesystems/nfsroot.txt
+++ b/Documentation/filesystems/nfsroot.txt
@@ -169,7 +169,7 @@ They depend on various facilities being available:
1693.1) Booting from a floppy using syslinux 1693.1) Booting from a floppy using syslinux
170 170
171 When building kernels, an easy way to create a boot floppy that uses 171 When building kernels, an easy way to create a boot floppy that uses
172 syslinux is to use the zdisk or bzdisk make targets which use 172 syslinux is to use the zdisk or bzdisk make targets which use zimage
173 and bzimage images respectively. Both targets accept the 173 and bzimage images respectively. Both targets accept the
174 FDARGS parameter which can be used to set the kernel command line. 174 FDARGS parameter which can be used to set the kernel command line.
175 175
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index b488edad743c..c032bf39e8b9 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -1321,6 +1321,18 @@ debugging information is displayed on console.
1321NMI switch that most IA32 servers have fires unknown NMI up, for example. 1321NMI switch that most IA32 servers have fires unknown NMI up, for example.
1322If a system hangs up, try pressing the NMI switch. 1322If a system hangs up, try pressing the NMI switch.
1323 1323
1324panic_on_unrecovered_nmi
1325------------------------
1326
1327The default Linux behaviour on an NMI of either memory or unknown is to continue
1328operation. For many environments such as scientific computing it is preferable
1329that the box is taken out and the error dealt with than an uncorrected
1330parity/ECC error get propogated.
1331
1332A small number of systems do generate NMI's for bizarre random reasons such as
1333power management so the default is off. That sysctl works like the existing
1334panic controls already in that directory.
1335
1324nmi_watchdog 1336nmi_watchdog
1325------------ 1337------------
1326 1338
diff --git a/Documentation/filesystems/ramfs-rootfs-initramfs.txt b/Documentation/filesystems/ramfs-rootfs-initramfs.txt
index 7be232b44ee4..62fe9b1e0890 100644
--- a/Documentation/filesystems/ramfs-rootfs-initramfs.txt
+++ b/Documentation/filesystems/ramfs-rootfs-initramfs.txt
@@ -263,7 +263,7 @@ User Mode Linux, like so:
263 sleep(999999999); 263 sleep(999999999);
264 } 264 }
265 EOF 265 EOF
266 gcc -static hello2.c -o init 266 gcc -static hello.c -o init
267 echo init | cpio -o -H newc | gzip > test.cpio.gz 267 echo init | cpio -o -H newc | gzip > test.cpio.gz
268 # Testing external initramfs using the initrd loading mechanism. 268 # Testing external initramfs using the initrd loading mechanism.
269 qemu -kernel /boot/vmlinuz -initrd test.cpio.gz /dev/zero 269 qemu -kernel /boot/vmlinuz -initrd test.cpio.gz /dev/zero
diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index 18022e249c53..b1b988701247 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -240,6 +240,10 @@ signal, or (b) something wrongly believes it's safe to remove drivers
240needed to manage a signal that's in active use. That is, requesting a 240needed to manage a signal that's in active use. That is, requesting a
241GPIO can serve as a kind of lock. 241GPIO can serve as a kind of lock.
242 242
243Some platforms may also use knowledge about what GPIOs are active for
244power management, such as by powering down unused chip sectors and, more
245easily, gating off unused clocks.
246
243These two calls are optional because not not all current Linux platforms 247These two calls are optional because not not all current Linux platforms
244offer such functionality in their GPIO support; a valid implementation 248offer such functionality in their GPIO support; a valid implementation
245could return success for all gpio_request() calls. Unlike the other calls, 249could return success for all gpio_request() calls. Unlike the other calls,
@@ -264,7 +268,7 @@ map between them using calls like:
264 /* map GPIO numbers to IRQ numbers */ 268 /* map GPIO numbers to IRQ numbers */
265 int gpio_to_irq(unsigned gpio); 269 int gpio_to_irq(unsigned gpio);
266 270
267 /* map IRQ numbers to GPIO numbers */ 271 /* map IRQ numbers to GPIO numbers (avoid using this) */
268 int irq_to_gpio(unsigned irq); 272 int irq_to_gpio(unsigned irq);
269 273
270Those return either the corresponding number in the other namespace, or 274Those return either the corresponding number in the other namespace, or
@@ -284,7 +288,8 @@ system wakeup capabilities.
284 288
285Non-error values returned from irq_to_gpio() would most commonly be used 289Non-error values returned from irq_to_gpio() would most commonly be used
286with gpio_get_value(), for example to initialize or update driver state 290with gpio_get_value(), for example to initialize or update driver state
287when the IRQ is edge-triggered. 291when the IRQ is edge-triggered. Note that some platforms don't support
292this reverse mapping, so you should avoid using it.
288 293
289 294
290Emulating Open Drain Signals 295Emulating Open Drain Signals
diff --git a/Documentation/ia64/kvm.txt b/Documentation/ia64/kvm.txt
index 914d07f49268..84f7cb3d5bec 100644
--- a/Documentation/ia64/kvm.txt
+++ b/Documentation/ia64/kvm.txt
@@ -1,7 +1,8 @@
1Currently, kvm module in EXPERIMENTAL stage on IA64. This means that 1Currently, kvm module is in EXPERIMENTAL stage on IA64. This means that
2interfaces are not stable enough to use. So, plase had better don't run 2interfaces are not stable enough to use. So, please don't run critical
3critical applications in virtual machine. We will try our best to make it 3applications in virtual machine.
4strong in future versions! 4We will try our best to improve it in future versions!
5
5 Guide: How to boot up guests on kvm/ia64 6 Guide: How to boot up guests on kvm/ia64
6 7
7This guide is to describe how to enable kvm support for IA-64 systems. 8This guide is to describe how to enable kvm support for IA-64 systems.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 2443f5bb4364..dd28a0d56981 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -796,6 +796,7 @@ and is between 256 and 4096 characters. It is defined in the file
796 Defaults to the default architecture's huge page size 796 Defaults to the default architecture's huge page size
797 if not specified. 797 if not specified.
798 798
799 i8042.debug [HW] Toggle i8042 debug mode
799 i8042.direct [HW] Put keyboard port into non-translated mode 800 i8042.direct [HW] Put keyboard port into non-translated mode
800 i8042.dumbkbd [HW] Pretend that controller can only read data from 801 i8042.dumbkbd [HW] Pretend that controller can only read data from
801 keyboard and cannot control its state 802 keyboard and cannot control its state
@@ -1713,6 +1714,11 @@ and is between 256 and 4096 characters. It is defined in the file
1713 autoconfiguration. 1714 autoconfiguration.
1714 Ranges are in pairs (memory base and size). 1715 Ranges are in pairs (memory base and size).
1715 1716
1717 dynamic_printk
1718 Enables pr_debug()/dev_dbg() calls if
1719 CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. These can also
1720 be switched on/off via <debugfs>/dynamic_printk/modules
1721
1716 print-fatal-signals= 1722 print-fatal-signals=
1717 [KNL] debug: print fatal signals 1723 [KNL] debug: print fatal signals
1718 print-fatal-signals=1: print segfault info to 1724 print-fatal-signals=1: print segfault info to
diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
index 51a8021ee532..f5d2aad65a67 100644
--- a/Documentation/kobject.txt
+++ b/Documentation/kobject.txt
@@ -118,6 +118,10 @@ the name of the kobject, call kobject_rename():
118 118
119 int kobject_rename(struct kobject *kobj, const char *new_name); 119 int kobject_rename(struct kobject *kobj, const char *new_name);
120 120
121Note kobject_rename does perform any locking or have a solid notion of
122what names are valid so the provide must provide their own sanity checking
123and serialization.
124
121There is a function called kobject_set_name() but that is legacy cruft and 125There is a function called kobject_set_name() but that is legacy cruft and
122is being removed. If your code needs to call this function, it is 126is being removed. If your code needs to call this function, it is
123incorrect and needs to be fixed. 127incorrect and needs to be fixed.
diff --git a/Documentation/networking/cs89x0.txt b/Documentation/networking/cs89x0.txt
index 6387d3decf85..c725d33b316f 100644
--- a/Documentation/networking/cs89x0.txt
+++ b/Documentation/networking/cs89x0.txt
@@ -3,7 +3,7 @@ NOTE
3---- 3----
4 4
5This document was contributed by Cirrus Logic for kernel 2.2.5. This version 5This document was contributed by Cirrus Logic for kernel 2.2.5. This version
6has been updated for 2.3.48 by Andrew Morton <andrewm@uow.edu.au> 6has been updated for 2.3.48 by Andrew Morton.
7 7
8Cirrus make a copy of this driver available at their website, as 8Cirrus make a copy of this driver available at their website, as
9described below. In general, you should use the driver version which 9described below. In general, you should use the driver version which
@@ -690,7 +690,7 @@ latest drivers and technical publications.
6906.4 Current maintainer 6906.4 Current maintainer
691 691
692In February 2000 the maintenance of this driver was assumed by Andrew 692In February 2000 the maintenance of this driver was assumed by Andrew
693Morton <akpm@zip.com.au> 693Morton.
694 694
6956.5 Kernel module parameters 6956.5 Kernel module parameters
696 696
diff --git a/Documentation/networking/phonet.txt b/Documentation/networking/phonet.txt
index 0e6e592f4f55..6a07e45d4a93 100644
--- a/Documentation/networking/phonet.txt
+++ b/Documentation/networking/phonet.txt
@@ -146,8 +146,8 @@ WARNING:
146When polling a connected pipe socket for writability, there is an 146When polling a connected pipe socket for writability, there is an
147intrinsic race condition whereby writability might be lost between the 147intrinsic race condition whereby writability might be lost between the
148polling and the writing system calls. In this case, the socket will 148polling and the writing system calls. In this case, the socket will
149block until write because possible again, unless non-blocking mode 149block until write becomes possible again, unless non-blocking mode
150becomes enabled. 150is enabled.
151 151
152 152
153The pipe protocol provides two socket options at the SOL_PNPIPE level: 153The pipe protocol provides two socket options at the SOL_PNPIPE level:
diff --git a/Documentation/networking/vortex.txt b/Documentation/networking/vortex.txt
index 6356d3faed36..bd70976b8160 100644
--- a/Documentation/networking/vortex.txt
+++ b/Documentation/networking/vortex.txt
@@ -1,5 +1,5 @@
1Documentation/networking/vortex.txt 1Documentation/networking/vortex.txt
2Andrew Morton <andrewm@uow.edu.au> 2Andrew Morton
330 April 2000 330 April 2000
4 4
5 5
@@ -11,7 +11,7 @@ The driver was written by Donald Becker <becker@scyld.com>
11Don is no longer the prime maintainer of this version of the driver. 11Don is no longer the prime maintainer of this version of the driver.
12Please report problems to one or more of: 12Please report problems to one or more of:
13 13
14 Andrew Morton <akpm@osdl.org> 14 Andrew Morton
15 Netdev mailing list <netdev@vger.kernel.org> 15 Netdev mailing list <netdev@vger.kernel.org>
16 Linux kernel mailing list <linux-kernel@vger.kernel.org> 16 Linux kernel mailing list <linux-kernel@vger.kernel.org>
17 17
@@ -305,11 +305,6 @@ Donald's wake-on-LAN page:
305 305
306 ftp://ftp.3com.com/pub/nic/3c90x/3c90xx2.exe 306 ftp://ftp.3com.com/pub/nic/3c90x/3c90xx2.exe
307 307
308Driver updates and a detailed changelog for the modifications which
309were made for the 2.3/2,4 series kernel is available at
310
311 http://www.zip.com.au/~akpm/linux/#3c59x-bc
312
313 308
314Autonegotiation notes 309Autonegotiation notes
315--------------------- 310---------------------
diff --git a/Documentation/power/s2ram.txt b/Documentation/power/s2ram.txt
index b05f512130ea..2ebdc6091ce1 100644
--- a/Documentation/power/s2ram.txt
+++ b/Documentation/power/s2ram.txt
@@ -54,3 +54,21 @@ used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
54that "radeonfb" simply cannot resume that device - it tries to set the 54that "radeonfb" simply cannot resume that device - it tries to set the
55PLL's, and it just _hangs_. Using the regular VGA console and letting X 55PLL's, and it just _hangs_. Using the regular VGA console and letting X
56resume it instead works fine. 56resume it instead works fine.
57
58NOTE
59====
60pm_trace uses the system's Real Time Clock (RTC) to save the magic number.
61Reason for this is that the RTC is the only reliably available piece of
62hardware during resume operations where a value can be set that will
63survive a reboot.
64
65Consequence is that after a resume (even if it is successful) your system
66clock will have a value corresponding to the magic mumber instead of the
67correct date/time! It is therefore advisable to use a program like ntp-date
68or rdate to reset the correct date/time from an external time source when
69using this trace option.
70
71As the clock keeps ticking it is also essential that the reboot is done
72quickly after the resume failure. The trace option does not use the seconds
73or the low order bits of the minutes of the RTC, but a too long delay will
74corrupt the magic value.
diff --git a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid
index 37796fe45bd0..eaa4801f2ce6 100644
--- a/Documentation/scsi/ChangeLog.megaraid
+++ b/Documentation/scsi/ChangeLog.megaraid
@@ -409,7 +409,7 @@ i. Function reordering so that inline functions are defined before they
409 megaraid_mbox_prepare_pthru, megaraid_mbox_prepare_epthru, 409 megaraid_mbox_prepare_pthru, megaraid_mbox_prepare_epthru,
410 megaraid_busywait_mbox 410 megaraid_busywait_mbox
411 411
412 - Andrew Morton <akpm@osdl.org>, 08.19.2004 412 - Andrew Morton, 08.19.2004
413 linux-scsi mailing list 413 linux-scsi mailing list
414 414
415 "Something else to clean up after inclusion: every instance of an 415 "Something else to clean up after inclusion: every instance of an
@@ -471,13 +471,13 @@ vi. Add support for 64-bit applications. Current drivers assume only
471vii. Move the function declarations for the management module from 471vii. Move the function declarations for the management module from
472 megaraid_mm.h to megaraid_mm.c 472 megaraid_mm.h to megaraid_mm.c
473 473
474 - Andrew Morton <akpm@osdl.org>, 08.19.2004 474 - Andrew Morton, 08.19.2004
475 linux-scsi mailing list 475 linux-scsi mailing list
476 476
477viii. Change default values for MEGARAID_NEWGEN, MEGARAID_MM, and 477viii. Change default values for MEGARAID_NEWGEN, MEGARAID_MM, and
478 MEGARAID_MAILBOX to 'n' in Kconfig.megaraid 478 MEGARAID_MAILBOX to 'n' in Kconfig.megaraid
479 479
480 - Andrew Morton <akpm@osdl.org>, 08.19.2004 480 - Andrew Morton, 08.19.2004
481 linux-scsi mailing list 481 linux-scsi mailing list
482 482
483ix. replace udelay with msleep 483ix. replace udelay with msleep
diff --git a/Documentation/spi/pxa2xx b/Documentation/spi/pxa2xx
index bbe8dee681a5..6bb916d57c95 100644
--- a/Documentation/spi/pxa2xx
+++ b/Documentation/spi/pxa2xx
@@ -96,7 +96,7 @@ Each slave device attached to the PXA must provide slave specific configuration
96information via the structure "pxa2xx_spi_chip" found in 96information via the structure "pxa2xx_spi_chip" found in
97"arch/arm/mach-pxa/include/mach/pxa2xx_spi.h". The pxa2xx_spi master controller driver 97"arch/arm/mach-pxa/include/mach/pxa2xx_spi.h". The pxa2xx_spi master controller driver
98will uses the configuration whenever the driver communicates with the slave 98will uses the configuration whenever the driver communicates with the slave
99device. 99device. All fields are optional.
100 100
101struct pxa2xx_spi_chip { 101struct pxa2xx_spi_chip {
102 u8 tx_threshold; 102 u8 tx_threshold;
@@ -112,14 +112,17 @@ used to configure the SSP hardware fifo. These fields are critical to the
112performance of pxa2xx_spi driver and misconfiguration will result in rx 112performance of pxa2xx_spi driver and misconfiguration will result in rx
113fifo overruns (especially in PIO mode transfers). Good default values are 113fifo overruns (especially in PIO mode transfers). Good default values are
114 114
115 .tx_threshold = 12, 115 .tx_threshold = 8,
116 .rx_threshold = 4, 116 .rx_threshold = 8,
117
118The range is 1 to 16 where zero indicates "use default".
117 119
118The "pxa2xx_spi_chip.dma_burst_size" field is used to configure PXA2xx DMA 120The "pxa2xx_spi_chip.dma_burst_size" field is used to configure PXA2xx DMA
119engine and is related the "spi_device.bits_per_word" field. Read and understand 121engine and is related the "spi_device.bits_per_word" field. Read and understand
120the PXA2xx "Developer Manual" sections on the DMA controller and SSP Controllers 122the PXA2xx "Developer Manual" sections on the DMA controller and SSP Controllers
121to determine the correct value. An SSP configured for byte-wide transfers would 123to determine the correct value. An SSP configured for byte-wide transfers would
122use a value of 8. 124use a value of 8. The driver will determine a reasonable default if
125dma_burst_size == 0.
123 126
124The "pxa2xx_spi_chip.timeout" fields is used to efficiently handle 127The "pxa2xx_spi_chip.timeout" fields is used to efficiently handle
125trailing bytes in the SSP receiver fifo. The correct value for this field is 128trailing bytes in the SSP receiver fifo. The correct value for this field is
@@ -137,7 +140,13 @@ function for asserting/deasserting a slave device chip select. If the field is
137NULL, the pxa2xx_spi master controller driver assumes that the SSP port is 140NULL, the pxa2xx_spi master controller driver assumes that the SSP port is
138configured to use SSPFRM instead. 141configured to use SSPFRM instead.
139 142
140NSSP SALVE SAMPLE 143NOTE: the SPI driver cannot control the chip select if SSPFRM is used, so the
144chipselect is dropped after each spi_transfer. Most devices need chip select
145asserted around the complete message. Use SSPFRM as a GPIO (through cs_control)
146to accomodate these chips.
147
148
149NSSP SLAVE SAMPLE
141----------------- 150-----------------
142The pxa2xx_spi_chip structure is passed to the pxa2xx_spi driver in the 151The pxa2xx_spi_chip structure is passed to the pxa2xx_spi driver in the
143"spi_board_info.controller_data" field. Below is a sample configuration using 152"spi_board_info.controller_data" field. Below is a sample configuration using
@@ -206,18 +215,21 @@ static void __init streetracer_init(void)
206 215
207DMA and PIO I/O Support 216DMA and PIO I/O Support
208----------------------- 217-----------------------
209The pxa2xx_spi driver support both DMA and interrupt driven PIO message 218The pxa2xx_spi driver supports both DMA and interrupt driven PIO message
210transfers. The driver defaults to PIO mode and DMA transfers must enabled by 219transfers. The driver defaults to PIO mode and DMA transfers must be enabled
211setting the "enable_dma" flag in the "pxa2xx_spi_master" structure and 220by setting the "enable_dma" flag in the "pxa2xx_spi_master" structure. The DMA
212ensuring that the "pxa2xx_spi_chip.dma_burst_size" field is non-zero. The DMA 221mode supports both coherent and stream based DMA mappings.
213mode support both coherent and stream based DMA mappings.
214 222
215The following logic is used to determine the type of I/O to be used on 223The following logic is used to determine the type of I/O to be used on
216a per "spi_transfer" basis: 224a per "spi_transfer" basis:
217 225
218if !enable_dma or dma_burst_size == 0 then 226if !enable_dma then
219 always use PIO transfers 227 always use PIO transfers
220 228
229if spi_message.len > 8191 then
230 print "rate limited" warning
231 use PIO transfers
232
221if spi_message.is_dma_mapped and rx_dma_buf != 0 and tx_dma_buf != 0 then 233if spi_message.is_dma_mapped and rx_dma_buf != 0 and tx_dma_buf != 0 then
222 use coherent DMA mode 234 use coherent DMA mode
223 235
diff --git a/Documentation/w1/00-INDEX b/Documentation/w1/00-INDEX
index 5270cf4cb109..cb49802745dc 100644
--- a/Documentation/w1/00-INDEX
+++ b/Documentation/w1/00-INDEX
@@ -1,5 +1,7 @@
100-INDEX 100-INDEX
2 - This file 2 - This file
3slaves/
4 - Drivers that provide support for specific family codes.
3masters/ 5masters/
4 - Individual chips providing 1-wire busses. 6 - Individual chips providing 1-wire busses.
5w1.generic 7w1.generic
diff --git a/Documentation/w1/masters/ds2490 b/Documentation/w1/masters/ds2490
index 239f9ae01843..28176def3d6f 100644
--- a/Documentation/w1/masters/ds2490
+++ b/Documentation/w1/masters/ds2490
@@ -16,3 +16,55 @@ which allows to build USB <-> W1 bridges.
16DS9490(R) is a USB <-> W1 bus master device 16DS9490(R) is a USB <-> W1 bus master device
17which has 0x81 family ID integrated chip and DS2490 17which has 0x81 family ID integrated chip and DS2490
18low-level operational chip. 18low-level operational chip.
19
20Notes and limitations.
21- The weak pullup current is a minimum of 0.9mA and maximum of 6.0mA.
22- The 5V strong pullup is supported with a minimum of 5.9mA and a
23 maximum of 30.4 mA. (From DS2490.pdf)
24- While the ds2490 supports a hardware search the code doesn't take
25 advantage of it (in tested case it only returned first device).
26- The hardware will detect when devices are attached to the bus on the
27 next bus (reset?) operation, however only a message is printed as
28 the core w1 code doesn't make use of the information. Connecting
29 one device tends to give multiple new device notifications.
30- The number of USB bus transactions could be reduced if w1_reset_send
31 was added to the API. The name is just a suggestion. It would take
32 a write buffer and a read buffer (along with sizes) as arguments.
33 The ds2490 block I/O command supports reset, write buffer, read
34 buffer, and strong pullup all in one command, instead of the current
35 1 reset bus, 2 write the match rom command and slave rom id, 3 block
36 write and read data. The write buffer needs to have the match rom
37 command and slave rom id prepended to the front of the requested
38 write buffer, both of which are known to the driver.
39- The hardware supports normal, flexible, and overdrive bus
40 communication speeds, but only the normal is supported.
41- The registered w1_bus_master functions don't define error
42 conditions. If a bus search is in progress and the ds2490 is
43 removed it can produce a good amount of error output before the bus
44 search finishes.
45- The hardware supports detecting some error conditions, such as
46 short, alarming presence on reset, and no presence on reset, but the
47 driver doesn't query those values.
48- The ds2490 specification doesn't cover short bulk in reads in
49 detail, but my observation is if fewer bytes are requested than are
50 available, the bulk read will return an error and the hardware will
51 clear the entire bulk in buffer. It would be possible to read the
52 maximum buffer size to not run into this error condition, only extra
53 bytes in the buffer is a logic error in the driver. The code should
54 should match reads and writes as well as data sizes. Reads and
55 writes are serialized and the status verifies that the chip is idle
56 (and data is available) before the read is executed, so it should
57 not happen.
58- Running x86_64 2.6.24 UHCI under qemu 0.9.0 under x86_64 2.6.22-rc6
59 with a OHCI controller, ds2490 running in the guest would operate
60 normally the first time the module was loaded after qemu attached
61 the ds2490 hardware, but if the module was unloaded, then reloaded
62 most of the time one of the bulk out or in, and usually the bulk in
63 would fail. qemu sets a 50ms timeout and the bulk in would timeout
64 even when the status shows data available. A bulk out write would
65 show a successful completion, but the ds2490 status register would
66 show 0 bytes written. Detaching qemu from the ds2490 hardware and
67 reattaching would clear the problem. usbmon output in the guest and
68 host did not explain the problem. My guess is a bug in either qemu
69 or the host OS and more likely the host OS.
70-- 03-06-2008 David Fries <David@Fries.net>
diff --git a/Documentation/w1/slaves/00-INDEX b/Documentation/w1/slaves/00-INDEX
new file mode 100644
index 000000000000..f8101d6b07b7
--- /dev/null
+++ b/Documentation/w1/slaves/00-INDEX
@@ -0,0 +1,4 @@
100-INDEX
2 - This file
3w1_therm
4 - The Maxim/Dallas Semiconductor ds18*20 temperature sensor.
diff --git a/Documentation/w1/slaves/w1_therm b/Documentation/w1/slaves/w1_therm
new file mode 100644
index 000000000000..0403aaaba878
--- /dev/null
+++ b/Documentation/w1/slaves/w1_therm
@@ -0,0 +1,41 @@
1Kernel driver w1_therm
2====================
3
4Supported chips:
5 * Maxim ds18*20 based temperature sensors.
6
7Author: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
8
9
10Description
11-----------
12
13w1_therm provides basic temperature conversion for ds18*20 devices.
14supported family codes:
15W1_THERM_DS18S20 0x10
16W1_THERM_DS1822 0x22
17W1_THERM_DS18B20 0x28
18
19Support is provided through the sysfs w1_slave file. Each open and
20read sequence will initiate a temperature conversion then provide two
21lines of ASCII output. The first line contains the nine hex bytes
22read along with a calculated crc value and YES or NO if it matched.
23If the crc matched the returned values are retained. The second line
24displays the retained values along with a temperature in millidegrees
25Centigrade after t=.
26
27Parasite powered devices are limited to one slave performing a
28temperature conversion at a time. If none of the devices are parasite
29powered it would be possible to convert all the devices at the same
30time and then go back to read individual sensors. That isn't
31currently supported. The driver also doesn't support reduced
32precision (which would also reduce the conversion time).
33
34The module parameter strong_pullup can be set to 0 to disable the
35strong pullup or 1 to enable. If enabled the 5V strong pullup will be
36enabled when the conversion is taking place provided the master driver
37must support the strong pullup (or it falls back to a pullup
38resistor). The DS18b20 temperature sensor specification lists a
39maximum current draw of 1.5mA and that a 5k pullup resistor is not
40sufficient. The strong pullup is designed to provide the additional
41current required.
diff --git a/Documentation/w1/w1.generic b/Documentation/w1/w1.generic
index 4c6509dd4789..e3333eec4320 100644
--- a/Documentation/w1/w1.generic
+++ b/Documentation/w1/w1.generic
@@ -79,10 +79,13 @@ w1 master sysfs interface
79<xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial 79<xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial
80bus - (standard) symlink to the w1 bus 80bus - (standard) symlink to the w1 bus
81driver - (standard) symlink to the w1 driver 81driver - (standard) symlink to the w1 driver
82w1_master_add - Manually register a slave device
82w1_master_attempts - the number of times a search was attempted 83w1_master_attempts - the number of times a search was attempted
83w1_master_max_slave_count 84w1_master_max_slave_count
84 - the maximum slaves that may be attached to a master 85 - the maximum slaves that may be attached to a master
85w1_master_name - the name of the device (w1_bus_masterX) 86w1_master_name - the name of the device (w1_bus_masterX)
87w1_master_pullup - 5V strong pullup 0 enabled, 1 disabled
88w1_master_remove - Manually remove a slave device
86w1_master_search - the number of searches left to do, -1=continual (default) 89w1_master_search - the number of searches left to do, -1=continual (default)
87w1_master_slave_count 90w1_master_slave_count
88 - the number of slaves found 91 - the number of slaves found
@@ -90,7 +93,13 @@ w1_master_slaves - the names of the slaves, one per line
90w1_master_timeout - the delay in seconds between searches 93w1_master_timeout - the delay in seconds between searches
91 94
92If you have a w1 bus that never changes (you don't add or remove devices), 95If you have a w1 bus that never changes (you don't add or remove devices),
93you can set w1_master_search to a positive value to disable searches. 96you can set the module parameter search_count to a small positive number
97for an initially small number of bus searches. Alternatively it could be
98set to zero, then manually add the slave device serial numbers by
99w1_master_add device file. The w1_master_add and w1_master_remove files
100generally only make sense when searching is disabled, as a search will
101redetect manually removed devices that are present and timeout manually
102added devices that aren't on the bus.
94 103
95 104
96w1 slave sysfs interface 105w1 slave sysfs interface
diff --git a/MAINTAINERS b/MAINTAINERS
index 5d0b8a23d639..52702b057c02 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1629,6 +1629,11 @@ P: Christopher Hoover
1629M: ch@murgatroid.com, ch@hpl.hp.com 1629M: ch@murgatroid.com, ch@hpl.hp.com
1630S: Maintained 1630S: Maintained
1631 1631
1632EPSON S1D13XXX FRAMEBUFFER DRIVER
1633P: Kristoffer Ericson
1634M: kristoffer.ericson@gmail.com
1635S: Maintained
1636
1632ETHEREXPRESS-16 NETWORK DRIVER 1637ETHEREXPRESS-16 NETWORK DRIVER
1633P: Philip Blundell 1638P: Philip Blundell
1634M: philb@gnu.org 1639M: philb@gnu.org
@@ -2443,7 +2448,14 @@ S: Supported
2443 2448
2444KERNEL VIRTUAL MACHINE (KVM) 2449KERNEL VIRTUAL MACHINE (KVM)
2445P: Avi Kivity 2450P: Avi Kivity
2446M: avi@qumranet.com 2451M: avi@redhat.com
2452L: kvm@vger.kernel.org
2453W: http://kvm.qumranet.com
2454S: Supported
2455
2456KERNEL VIRTUAL MACHINE (KVM) FOR AMD-V
2457P: Joerg Roedel
2458M: joerg.roedel@amd.com
2447L: kvm@vger.kernel.org 2459L: kvm@vger.kernel.org
2448W: http://kvm.qumranet.com 2460W: http://kvm.qumranet.com
2449S: Supported 2461S: Supported
@@ -4089,7 +4101,7 @@ W: http://tpmdd.sourceforge.net
4089P: Marcel Selhorst 4101P: Marcel Selhorst
4090M: tpm@selhorst.net 4102M: tpm@selhorst.net
4091W: http://www.prosec.rub.de/tpm/ 4103W: http://www.prosec.rub.de/tpm/
4092L: tpmdd-devel@lists.sourceforge.net 4104L: tpmdd-devel@lists.sourceforge.net (moderated for non-subscribers)
4093S: Maintained 4105S: Maintained
4094 4106
4095TRIVIAL PATCHES 4107TRIVIAL PATCHES
@@ -4480,6 +4492,13 @@ W: http://kernel.org/~kzak/util-linux-ng/
4480T: git://git.kernel.org/pub/scm/utils/util-linux-ng/util-linux-ng.git 4492T: git://git.kernel.org/pub/scm/utils/util-linux-ng/util-linux-ng.git
4481S: Maintained 4493S: Maintained
4482 4494
4495UVESAFB DRIVER
4496P: Michal Januszewski
4497M: spock@gentoo.org
4498L: linux-fbdev-devel@lists.sourceforge.net (moderated for non-subscribers)
4499W: http://dev.gentoo.org/~spock/projects/uvesafb/
4500S: Maintained
4501
4483VFAT/FAT/MSDOS FILESYSTEM 4502VFAT/FAT/MSDOS FILESYSTEM
4484P: OGAWA Hirofumi 4503P: OGAWA Hirofumi
4485M: hirofumi@mail.parknet.co.jp 4504M: hirofumi@mail.parknet.co.jp
@@ -4497,6 +4516,14 @@ M: khali@linux-fr.org
4497L: i2c@lm-sensors.org 4516L: i2c@lm-sensors.org
4498S: Maintained 4517S: Maintained
4499 4518
4519VIA UNICHROME(PRO)/CHROME9 FRAMEBUFFER DRIVER
4520P: Joseph Chan
4521M: JosephChan@via.com.tw
4522P: Scott Fang
4523M: ScottFang@viatech.com.cn
4524L: linux-fbdev-devel@lists.sourceforge.net (moderated for non-subscribers)
4525S: Maintained
4526
4500VIA VELOCITY NETWORK DRIVER 4527VIA VELOCITY NETWORK DRIVER
4501P: Francois Romieu 4528P: Francois Romieu
4502M: romieu@fr.zoreil.com 4529M: romieu@fr.zoreil.com
@@ -4598,7 +4625,7 @@ WM97XX TOUCHSCREEN DRIVERS
4598P: Mark Brown 4625P: Mark Brown
4599M: broonie@opensource.wolfsonmicro.com 4626M: broonie@opensource.wolfsonmicro.com
4600P: Liam Girdwood 4627P: Liam Girdwood
4601M: liam.girdwood@wolfsonmicro.com 4628M: lrg@slimlogic.co.uk
4602L: linux-input@vger.kernel.org 4629L: linux-input@vger.kernel.org
4603T: git git://opensource.wolfsonmicro.com/linux-2.6-touch 4630T: git git://opensource.wolfsonmicro.com/linux-2.6-touch
4604W: http://opensource.wolfsonmicro.com/node/7 4631W: http://opensource.wolfsonmicro.com/node/7
diff --git a/arch/Kconfig b/arch/Kconfig
index 0267babe5eb9..e6ab550bceb3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -28,7 +28,7 @@ config OPROFILE_IBS
28 If unsure, say N. 28 If unsure, say N.
29 29
30config HAVE_OPROFILE 30config HAVE_OPROFILE
31 def_bool n 31 bool
32 32
33config KPROBES 33config KPROBES
34 bool "Kprobes" 34 bool "Kprobes"
@@ -42,7 +42,7 @@ config KPROBES
42 If in doubt, say "N". 42 If in doubt, say "N".
43 43
44config HAVE_EFFICIENT_UNALIGNED_ACCESS 44config HAVE_EFFICIENT_UNALIGNED_ACCESS
45 def_bool n 45 bool
46 help 46 help
47 Some architectures are unable to perform unaligned accesses 47 Some architectures are unable to perform unaligned accesses
48 without the use of get_unaligned/put_unaligned. Others are 48 without the use of get_unaligned/put_unaligned. Others are
@@ -65,13 +65,13 @@ config KRETPROBES
65 depends on KPROBES && HAVE_KRETPROBES 65 depends on KPROBES && HAVE_KRETPROBES
66 66
67config HAVE_IOREMAP_PROT 67config HAVE_IOREMAP_PROT
68 def_bool n 68 bool
69 69
70config HAVE_KPROBES 70config HAVE_KPROBES
71 def_bool n 71 bool
72 72
73config HAVE_KRETPROBES 73config HAVE_KRETPROBES
74 def_bool n 74 bool
75 75
76# 76#
77# An arch should select this if it provides all these things: 77# An arch should select this if it provides all these things:
@@ -89,16 +89,16 @@ config HAVE_KRETPROBES
89# signal delivery calls tracehook_signal_handler() 89# signal delivery calls tracehook_signal_handler()
90# 90#
91config HAVE_ARCH_TRACEHOOK 91config HAVE_ARCH_TRACEHOOK
92 def_bool n 92 bool
93 93
94config HAVE_DMA_ATTRS 94config HAVE_DMA_ATTRS
95 def_bool n 95 bool
96 96
97config USE_GENERIC_SMP_HELPERS 97config USE_GENERIC_SMP_HELPERS
98 def_bool n 98 bool
99 99
100config HAVE_CLK 100config HAVE_CLK
101 def_bool n 101 bool
102 help 102 help
103 The <linux/clk.h> calls support software clock gating and 103 The <linux/clk.h> calls support software clock gating and
104 thus are a key power management tool on many systems. 104 thus are a key power management tool on many systems.
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index ee35226c44e9..a0f642b6a4b9 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -222,8 +222,7 @@ config ALPHA_MIATA
222 bool "Miata" 222 bool "Miata"
223 help 223 help
224 The Digital PersonalWorkStation (PWS 433a, 433au, 500a, 500au, 600a, 224 The Digital PersonalWorkStation (PWS 433a, 433au, 500a, 500au, 600a,
225 or 600au). There is an Installation HOWTO for this hardware at 225 or 600au).
226 <http://eijk.homelinux.org/~stefan/miata.html>.
227 226
228config ALPHA_MIKASA 227config ALPHA_MIKASA
229 bool "Mikasa" 228 bool "Mikasa"
diff --git a/arch/alpha/include/asm/a.out.h b/arch/alpha/include/asm/a.out.h
index 02ce8473870a..acdc681231cb 100644
--- a/arch/alpha/include/asm/a.out.h
+++ b/arch/alpha/include/asm/a.out.h
@@ -95,7 +95,7 @@ struct exec
95 Worse, we have to notice the start address before swapping to use 95 Worse, we have to notice the start address before swapping to use
96 /sbin/loader, which of course is _not_ a TASO application. */ 96 /sbin/loader, which of course is _not_ a TASO application. */
97#define SET_AOUT_PERSONALITY(BFPM, EX) \ 97#define SET_AOUT_PERSONALITY(BFPM, EX) \
98 set_personality (((BFPM->sh_bang || EX.ah.entry < 0x100000000L \ 98 set_personality (((BFPM->taso || EX.ah.entry < 0x100000000L \
99 ? ADDR_LIMIT_32BIT : 0) | PER_OSF4)) 99 ? ADDR_LIMIT_32BIT : 0) | PER_OSF4))
100 100
101#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
index fc1002ea1e0c..5c75c1b2352a 100644
--- a/arch/alpha/include/asm/elf.h
+++ b/arch/alpha/include/asm/elf.h
@@ -144,9 +144,9 @@ extern int dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task);
144 : amask (AMASK_CIX) ? "ev6" : "ev67"); \ 144 : amask (AMASK_CIX) ? "ev6" : "ev67"); \
145}) 145})
146 146
147#define SET_PERSONALITY(EX, IBCS2) \ 147#define SET_PERSONALITY(EX) \
148 set_personality(((EX).e_flags & EF_ALPHA_32BIT) \ 148 set_personality(((EX).e_flags & EF_ALPHA_32BIT) \
149 ? PER_LINUX_32BIT : (IBCS2) ? PER_SVR4 : PER_LINUX) 149 ? PER_LINUX_32BIT : PER_LINUX)
150 150
151extern int alpha_l1i_cacheshape; 151extern int alpha_l1i_cacheshape;
152extern int alpha_l1d_cacheshape; 152extern int alpha_l1d_cacheshape;
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 2179c602032a..b9094da05d7a 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -41,13 +41,6 @@ mk_iommu_pte(unsigned long paddr)
41 return (paddr >> (PAGE_SHIFT-1)) | 1; 41 return (paddr >> (PAGE_SHIFT-1)) | 1;
42} 42}
43 43
44static inline long
45calc_npages(long bytes)
46{
47 return (bytes + PAGE_SIZE - 1) >> PAGE_SHIFT;
48}
49
50
51/* Return the minimum of MAX or the first power of two larger 44/* Return the minimum of MAX or the first power of two larger
52 than main memory. */ 45 than main memory. */
53 46
@@ -287,7 +280,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
287 if (!arena || arena->dma_base + arena->size - 1 > max_dma) 280 if (!arena || arena->dma_base + arena->size - 1 > max_dma)
288 arena = hose->sg_isa; 281 arena = hose->sg_isa;
289 282
290 npages = calc_npages((paddr & ~PAGE_MASK) + size); 283 npages = iommu_num_pages(paddr, size, PAGE_SIZE);
291 284
292 /* Force allocation to 64KB boundary for ISA bridges. */ 285 /* Force allocation to 64KB boundary for ISA bridges. */
293 if (pdev && pdev == isa_bridge) 286 if (pdev && pdev == isa_bridge)
@@ -387,7 +380,7 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
387 BUG(); 380 BUG();
388 } 381 }
389 382
390 npages = calc_npages((dma_addr & ~PAGE_MASK) + size); 383 npages = iommu_num_pages(dma_addr, size, PAGE_SIZE);
391 384
392 spin_lock_irqsave(&arena->lock, flags); 385 spin_lock_irqsave(&arena->lock, flags);
393 386
@@ -580,7 +573,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end,
580 contiguous. */ 573 contiguous. */
581 574
582 paddr &= ~PAGE_MASK; 575 paddr &= ~PAGE_MASK;
583 npages = calc_npages(paddr + size); 576 npages = iommu_num_pages(paddr, size, PAGE_SIZE);
584 dma_ofs = iommu_arena_alloc(dev, arena, npages, 0); 577 dma_ofs = iommu_arena_alloc(dev, arena, npages, 0);
585 if (dma_ofs < 0) { 578 if (dma_ofs < 0) {
586 /* If we attempted a direct map above but failed, die. */ 579 /* If we attempted a direct map above but failed, die. */
@@ -616,7 +609,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end,
616 sg++; 609 sg++;
617 } 610 }
618 611
619 npages = calc_npages((paddr & ~PAGE_MASK) + size); 612 npages = iommu_num_pages(paddr, size, PAGE_SIZE);
620 613
621 paddr &= PAGE_MASK; 614 paddr &= PAGE_MASK;
622 for (i = 0; i < npages; ++i, paddr += PAGE_SIZE) 615 for (i = 0; i < npages; ++i, paddr += PAGE_SIZE)
@@ -775,7 +768,7 @@ pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
775 DBGA(" (%ld) sg [%lx,%lx]\n", 768 DBGA(" (%ld) sg [%lx,%lx]\n",
776 sg - end + nents, addr, size); 769 sg - end + nents, addr, size);
777 770
778 npages = calc_npages((addr & ~PAGE_MASK) + size); 771 npages = iommu_num_pages(addr, size, PAGE_SIZE);
779 ofs = (addr - arena->dma_base) >> PAGE_SHIFT; 772 ofs = (addr - arena->dma_base) >> PAGE_SHIFT;
780 iommu_arena_free(arena, ofs, npages); 773 iommu_arena_free(arena, ofs, npages);
781 774
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 06b6fdab639f..e657c45d91d2 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -27,6 +27,7 @@
27#include <linux/cache.h> 27#include <linux/cache.h>
28#include <linux/profile.h> 28#include <linux/profile.h>
29#include <linux/bitops.h> 29#include <linux/bitops.h>
30#include <linux/cpu.h>
30 31
31#include <asm/hwrpb.h> 32#include <asm/hwrpb.h>
32#include <asm/ptrace.h> 33#include <asm/ptrace.h>
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4853f9df37bd..6c73e963d976 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -354,7 +354,7 @@ config ARCH_IXP4XX
354 select GENERIC_GPIO 354 select GENERIC_GPIO
355 select GENERIC_TIME 355 select GENERIC_TIME
356 select GENERIC_CLOCKEVENTS 356 select GENERIC_CLOCKEVENTS
357 select ZONE_DMA if PCI 357 select DMABOUNCE if PCI
358 help 358 help
359 Support for Intel's IXP4XX (XScale) family of processors. 359 Support for Intel's IXP4XX (XScale) family of processors.
360 360
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index e2274bc0b544..7d5121260fda 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -118,9 +118,10 @@ endif
118 machine-$(CONFIG_ARCH_IXP23XX) := ixp23xx 118 machine-$(CONFIG_ARCH_IXP23XX) := ixp23xx
119 machine-$(CONFIG_ARCH_OMAP1) := omap1 119 machine-$(CONFIG_ARCH_OMAP1) := omap1
120 machine-$(CONFIG_ARCH_OMAP2) := omap2 120 machine-$(CONFIG_ARCH_OMAP2) := omap2
121 machine-$(CONFIG_ARCH_OMAP3) := omap2
121 plat-$(CONFIG_ARCH_OMAP) := omap 122 plat-$(CONFIG_ARCH_OMAP) := omap
122 machine-$(CONFIG_ARCH_S3C2410) := s3c2410 s3c2400 s3c2412 s3c2440 s3c2442 s3c2443 123 machine-$(CONFIG_ARCH_S3C2410) := s3c2410 s3c2400 s3c2412 s3c2440 s3c2442 s3c2443
123 plat-$(CONFIG_PLAT_S3C24XX) := s3c24xx 124 plat-$(CONFIG_PLAT_S3C24XX) := s3c24xx s3c
124 machine-$(CONFIG_ARCH_LH7A40X) := lh7a40x 125 machine-$(CONFIG_ARCH_LH7A40X) := lh7a40x
125 machine-$(CONFIG_ARCH_VERSATILE) := versatile 126 machine-$(CONFIG_ARCH_VERSATILE) := versatile
126 machine-$(CONFIG_ARCH_IMX) := imx 127 machine-$(CONFIG_ARCH_IMX) := imx
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 2e32acca02fb..86b5e6982660 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -13,10 +13,10 @@ config ICST307
13config SA1111 13config SA1111
14 bool 14 bool
15 select DMABOUNCE if !ARCH_PXA 15 select DMABOUNCE if !ARCH_PXA
16 select ZONE_DMA if !ARCH_PXA
17 16
18config DMABOUNCE 17config DMABOUNCE
19 bool 18 bool
19 select ZONE_DMA
20 20
21config TIMER_ACORN 21config TIMER_ACORN
22 bool 22 bool
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index fb86f248aab8..6094c34d9bae 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -581,6 +581,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
581 goto out; 581 goto out;
582 } 582 }
583 583
584#ifdef CONFIG_DMABOUNCE
584 /* 585 /*
585 * If the parent device has a DMA mask associated with it, 586 * If the parent device has a DMA mask associated with it,
586 * propagate it down to the children. 587 * propagate it down to the children.
@@ -598,6 +599,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
598 } 599 }
599 } 600 }
600 } 601 }
602#endif
601 603
602out: 604out:
603 return ret; 605 return ret;
diff --git a/arch/arm/configs/omap3_beagle_defconfig b/arch/arm/configs/omap3_beagle_defconfig
new file mode 100644
index 000000000000..e042d27eae16
--- /dev/null
+++ b/arch/arm/configs/omap3_beagle_defconfig
@@ -0,0 +1,1321 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc8
4# Wed Oct 1 17:14:22 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_INIT_ENV_ARG_LIMIT=32
37CONFIG_LOCALVERSION=""
38CONFIG_LOCALVERSION_AUTO=y
39CONFIG_SWAP=y
40CONFIG_SYSVIPC=y
41CONFIG_SYSVIPC_SYSCTL=y
42# CONFIG_POSIX_MQUEUE is not set
43CONFIG_BSD_PROCESS_ACCT=y
44# CONFIG_BSD_PROCESS_ACCT_V3 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
50CONFIG_GROUP_SCHED=y
51CONFIG_FAIR_GROUP_SCHED=y
52# CONFIG_RT_GROUP_SCHED is not set
53CONFIG_USER_SCHED=y
54# CONFIG_CGROUP_SCHED is not set
55CONFIG_SYSFS_DEPRECATED=y
56CONFIG_SYSFS_DEPRECATED_V2=y
57# CONFIG_RELAY is not set
58# CONFIG_NAMESPACES is not set
59CONFIG_BLK_DEV_INITRD=y
60CONFIG_INITRAMFS_SOURCE=""
61CONFIG_CC_OPTIMIZE_FOR_SIZE=y
62CONFIG_SYSCTL=y
63CONFIG_EMBEDDED=y
64CONFIG_UID16=y
65# CONFIG_SYSCTL_SYSCALL is not set
66CONFIG_KALLSYMS=y
67# CONFIG_KALLSYMS_ALL is not set
68CONFIG_KALLSYMS_EXTRA_PASS=y
69CONFIG_HOTPLUG=y
70CONFIG_PRINTK=y
71CONFIG_BUG=y
72CONFIG_ELF_CORE=y
73CONFIG_COMPAT_BRK=y
74CONFIG_BASE_FULL=y
75CONFIG_FUTEX=y
76CONFIG_ANON_INODES=y
77CONFIG_EPOLL=y
78CONFIG_SIGNALFD=y
79CONFIG_TIMERFD=y
80CONFIG_EVENTFD=y
81CONFIG_SHMEM=y
82CONFIG_VM_EVENT_COUNTERS=y
83CONFIG_SLAB=y
84# CONFIG_SLUB is not set
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
102# CONFIG_TINY_SHMEM is not set
103CONFIG_BASE_SMALL=0
104CONFIG_MODULES=y
105# CONFIG_MODULE_FORCE_LOAD is not set
106CONFIG_MODULE_UNLOAD=y
107# CONFIG_MODULE_FORCE_UNLOAD is not set
108CONFIG_MODVERSIONS=y
109CONFIG_MODULE_SRCVERSION_ALL=y
110CONFIG_KMOD=y
111CONFIG_BLOCK=y
112# CONFIG_LBD is not set
113# CONFIG_BLK_DEV_IO_TRACE is not set
114# CONFIG_LSF is not set
115# CONFIG_BLK_DEV_BSG is not set
116# CONFIG_BLK_DEV_INTEGRITY is not set
117
118#
119# IO Schedulers
120#
121CONFIG_IOSCHED_NOOP=y
122CONFIG_IOSCHED_AS=y
123CONFIG_IOSCHED_DEADLINE=y
124CONFIG_IOSCHED_CFQ=y
125CONFIG_DEFAULT_AS=y
126# CONFIG_DEFAULT_DEADLINE is not set
127# CONFIG_DEFAULT_CFQ is not set
128# CONFIG_DEFAULT_NOOP is not set
129CONFIG_DEFAULT_IOSCHED="anticipatory"
130CONFIG_CLASSIC_RCU=y
131
132#
133# System Type
134#
135# CONFIG_ARCH_AAEC2000 is not set
136# CONFIG_ARCH_INTEGRATOR is not set
137# CONFIG_ARCH_REALVIEW is not set
138# CONFIG_ARCH_VERSATILE is not set
139# CONFIG_ARCH_AT91 is not set
140# CONFIG_ARCH_CLPS7500 is not set
141# CONFIG_ARCH_CLPS711X is not set
142# CONFIG_ARCH_EBSA110 is not set
143# CONFIG_ARCH_EP93XX is not set
144# CONFIG_ARCH_FOOTBRIDGE is not set
145# CONFIG_ARCH_NETX is not set
146# CONFIG_ARCH_H720X is not set
147# CONFIG_ARCH_IMX is not set
148# CONFIG_ARCH_IOP13XX is not set
149# CONFIG_ARCH_IOP32X is not set
150# CONFIG_ARCH_IOP33X is not set
151# CONFIG_ARCH_IXP23XX is not set
152# CONFIG_ARCH_IXP2000 is not set
153# CONFIG_ARCH_IXP4XX is not set
154# CONFIG_ARCH_L7200 is not set
155# CONFIG_ARCH_KIRKWOOD is not set
156# CONFIG_ARCH_KS8695 is not set
157# CONFIG_ARCH_NS9XXX is not set
158# CONFIG_ARCH_LOKI is not set
159# CONFIG_ARCH_MV78XX0 is not set
160# CONFIG_ARCH_MXC is not set
161# CONFIG_ARCH_ORION5X is not set
162# CONFIG_ARCH_PNX4008 is not set
163# CONFIG_ARCH_PXA is not set
164# CONFIG_ARCH_RPC is not set
165# CONFIG_ARCH_SA1100 is not set
166# CONFIG_ARCH_S3C2410 is not set
167# CONFIG_ARCH_SHARK is not set
168# CONFIG_ARCH_LH7A40X is not set
169# CONFIG_ARCH_DAVINCI is not set
170CONFIG_ARCH_OMAP=y
171# CONFIG_ARCH_MSM7X00A is not set
172
173#
174# TI OMAP Implementations
175#
176CONFIG_ARCH_OMAP_OTG=y
177# CONFIG_ARCH_OMAP1 is not set
178# CONFIG_ARCH_OMAP2 is not set
179CONFIG_ARCH_OMAP3=y
180
181#
182# OMAP Feature Selections
183#
184# CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
185# CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
186# CONFIG_OMAP_RESET_CLOCKS is not set
187# CONFIG_OMAP_MUX is not set
188# CONFIG_OMAP_MCBSP is not set
189# CONFIG_OMAP_MPU_TIMER is not set
190CONFIG_OMAP_32K_TIMER=y
191CONFIG_OMAP_32K_TIMER_HZ=128
192CONFIG_OMAP_DM_TIMER=y
193# CONFIG_OMAP_LL_DEBUG_UART1 is not set
194# CONFIG_OMAP_LL_DEBUG_UART2 is not set
195CONFIG_OMAP_LL_DEBUG_UART3=y
196CONFIG_ARCH_OMAP34XX=y
197CONFIG_ARCH_OMAP3430=y
198
199#
200# OMAP Board Type
201#
202CONFIG_MACH_OMAP3_BEAGLE=y
203
204#
205# Boot options
206#
207
208#
209# Power management
210#
211
212#
213# Processor Type
214#
215CONFIG_CPU_32=y
216CONFIG_CPU_32v6K=y
217CONFIG_CPU_V7=y
218CONFIG_CPU_32v7=y
219CONFIG_CPU_ABRT_EV7=y
220CONFIG_CPU_PABRT_IFAR=y
221CONFIG_CPU_CACHE_V7=y
222CONFIG_CPU_CACHE_VIPT=y
223CONFIG_CPU_COPY_V6=y
224CONFIG_CPU_TLB_V7=y
225CONFIG_CPU_HAS_ASID=y
226CONFIG_CPU_CP15=y
227CONFIG_CPU_CP15_MMU=y
228
229#
230# Processor Features
231#
232CONFIG_ARM_THUMB=y
233# CONFIG_ARM_THUMBEE is not set
234# CONFIG_CPU_ICACHE_DISABLE is not set
235# CONFIG_CPU_DCACHE_DISABLE is not set
236# CONFIG_CPU_BPREDICT_DISABLE is not set
237CONFIG_HAS_TLS_REG=y
238# CONFIG_OUTER_CACHE is not set
239
240#
241# Bus support
242#
243# CONFIG_PCI_SYSCALL is not set
244# CONFIG_ARCH_SUPPORTS_MSI is not set
245# CONFIG_PCCARD is not set
246
247#
248# Kernel Features
249#
250CONFIG_TICK_ONESHOT=y
251CONFIG_NO_HZ=y
252CONFIG_HIGH_RES_TIMERS=y
253CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
254CONFIG_VMSPLIT_3G=y
255# CONFIG_VMSPLIT_2G is not set
256# CONFIG_VMSPLIT_1G is not set
257CONFIG_PAGE_OFFSET=0xC0000000
258# CONFIG_PREEMPT is not set
259CONFIG_HZ=128
260CONFIG_AEABI=y
261CONFIG_OABI_COMPAT=y
262CONFIG_ARCH_FLATMEM_HAS_HOLES=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=4
274# CONFIG_RESOURCES_64BIT is not set
275CONFIG_ZONE_DMA_FLAG=1
276CONFIG_BOUNCE=y
277CONFIG_VIRT_TO_BUS=y
278# CONFIG_LEDS is not set
279CONFIG_ALIGNMENT_TRAP=y
280
281#
282# Boot options
283#
284CONFIG_ZBOOT_ROM_TEXT=0x0
285CONFIG_ZBOOT_ROM_BSS=0x0
286CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.168.0.1:/home/user/buildroot ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0:tgt:eth0:off rw console=ttyS2,115200n8"
287# CONFIG_XIP_KERNEL is not set
288# CONFIG_KEXEC is not set
289
290#
291# CPU Power Management
292#
293# CONFIG_CPU_FREQ is not set
294# CONFIG_CPU_IDLE 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
306CONFIG_VFP=y
307CONFIG_VFPv3=y
308# CONFIG_NEON is not set
309
310#
311# Userspace binary formats
312#
313CONFIG_BINFMT_ELF=y
314# CONFIG_BINFMT_AOUT is not set
315CONFIG_BINFMT_MISC=y
316
317#
318# Power management options
319#
320# CONFIG_PM is not set
321CONFIG_ARCH_SUSPEND_POSSIBLE=y
322CONFIG_NET=y
323
324#
325# Networking options
326#
327CONFIG_PACKET=y
328# CONFIG_PACKET_MMAP is not set
329CONFIG_UNIX=y
330CONFIG_XFRM=y
331# CONFIG_XFRM_USER is not set
332# CONFIG_XFRM_SUB_POLICY is not set
333# CONFIG_XFRM_MIGRATE is not set
334# CONFIG_XFRM_STATISTICS is not set
335CONFIG_NET_KEY=y
336# CONFIG_NET_KEY_MIGRATE is not set
337CONFIG_INET=y
338# CONFIG_IP_MULTICAST is not set
339# CONFIG_IP_ADVANCED_ROUTER is not set
340CONFIG_IP_FIB_HASH=y
341CONFIG_IP_PNP=y
342CONFIG_IP_PNP_DHCP=y
343CONFIG_IP_PNP_BOOTP=y
344CONFIG_IP_PNP_RARP=y
345# CONFIG_NET_IPIP is not set
346# CONFIG_NET_IPGRE is not set
347# CONFIG_ARPD is not set
348# CONFIG_SYN_COOKIES is not set
349# CONFIG_INET_AH is not set
350# CONFIG_INET_ESP is not set
351# CONFIG_INET_IPCOMP is not set
352# CONFIG_INET_XFRM_TUNNEL is not set
353# CONFIG_INET_TUNNEL is not set
354CONFIG_INET_XFRM_MODE_TRANSPORT=y
355CONFIG_INET_XFRM_MODE_TUNNEL=y
356CONFIG_INET_XFRM_MODE_BEET=y
357# CONFIG_INET_LRO is not set
358CONFIG_INET_DIAG=y
359CONFIG_INET_TCP_DIAG=y
360# CONFIG_TCP_CONG_ADVANCED is not set
361CONFIG_TCP_CONG_CUBIC=y
362CONFIG_DEFAULT_TCP_CONG="cubic"
363# CONFIG_TCP_MD5SIG is not set
364# CONFIG_IPV6 is not set
365# CONFIG_NETWORK_SECMARK is not set
366# CONFIG_NETFILTER is not set
367# CONFIG_IP_DCCP is not set
368# CONFIG_IP_SCTP is not set
369# CONFIG_TIPC is not set
370# CONFIG_ATM is not set
371# CONFIG_BRIDGE is not set
372# CONFIG_VLAN_8021Q is not set
373# CONFIG_DECNET is not set
374# CONFIG_LLC2 is not set
375# CONFIG_IPX is not set
376# CONFIG_ATALK is not set
377# CONFIG_X25 is not set
378# CONFIG_LAPB is not set
379# CONFIG_ECONET is not set
380# CONFIG_WAN_ROUTER is not set
381# CONFIG_NET_SCHED is not set
382
383#
384# Network testing
385#
386# CONFIG_NET_PKTGEN is not set
387# CONFIG_HAMRADIO is not set
388# CONFIG_CAN is not set
389# CONFIG_IRDA is not set
390# CONFIG_BT is not set
391# CONFIG_AF_RXRPC is not set
392
393#
394# Wireless
395#
396# CONFIG_CFG80211 is not set
397# CONFIG_WIRELESS_EXT is not set
398# CONFIG_MAC80211 is not set
399# CONFIG_IEEE80211 is not set
400# CONFIG_RFKILL is not set
401# CONFIG_NET_9P is not set
402
403#
404# Device Drivers
405#
406
407#
408# Generic Driver Options
409#
410CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
411CONFIG_STANDALONE=y
412CONFIG_PREVENT_FIRMWARE_BUILD=y
413# CONFIG_FW_LOADER is not set
414# CONFIG_DEBUG_DRIVER is not set
415# CONFIG_DEBUG_DEVRES is not set
416# CONFIG_SYS_HYPERVISOR is not set
417# CONFIG_CONNECTOR is not set
418CONFIG_MTD=y
419# CONFIG_MTD_DEBUG is not set
420# CONFIG_MTD_CONCAT is not set
421CONFIG_MTD_PARTITIONS=y
422# CONFIG_MTD_REDBOOT_PARTS is not set
423# CONFIG_MTD_CMDLINE_PARTS is not set
424# CONFIG_MTD_AFS_PARTS is not set
425# CONFIG_MTD_AR7_PARTS is not set
426
427#
428# User Modules And Translation Layers
429#
430CONFIG_MTD_CHAR=y
431CONFIG_MTD_BLKDEVS=y
432CONFIG_MTD_BLOCK=y
433# CONFIG_FTL is not set
434# CONFIG_NFTL is not set
435# CONFIG_INFTL is not set
436# CONFIG_RFD_FTL is not set
437# CONFIG_SSFDC is not set
438# CONFIG_MTD_OOPS is not set
439
440#
441# RAM/ROM/Flash chip drivers
442#
443# CONFIG_MTD_CFI is not set
444# CONFIG_MTD_JEDECPROBE is not set
445CONFIG_MTD_MAP_BANK_WIDTH_1=y
446CONFIG_MTD_MAP_BANK_WIDTH_2=y
447CONFIG_MTD_MAP_BANK_WIDTH_4=y
448# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
449# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
450# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
451CONFIG_MTD_CFI_I1=y
452CONFIG_MTD_CFI_I2=y
453# CONFIG_MTD_CFI_I4 is not set
454# CONFIG_MTD_CFI_I8 is not set
455# CONFIG_MTD_RAM is not set
456# CONFIG_MTD_ROM is not set
457# CONFIG_MTD_ABSENT is not set
458
459#
460# Mapping drivers for chip access
461#
462# CONFIG_MTD_COMPLEX_MAPPINGS is not set
463# CONFIG_MTD_PLATRAM is not set
464
465#
466# Self-contained MTD device drivers
467#
468# CONFIG_MTD_SLRAM is not set
469# CONFIG_MTD_PHRAM is not set
470# CONFIG_MTD_MTDRAM is not set
471# CONFIG_MTD_BLOCK2MTD is not set
472
473#
474# Disk-On-Chip Device Drivers
475#
476# CONFIG_MTD_DOC2000 is not set
477# CONFIG_MTD_DOC2001 is not set
478# CONFIG_MTD_DOC2001PLUS is not set
479CONFIG_MTD_NAND=y
480# CONFIG_MTD_NAND_VERIFY_WRITE is not set
481# CONFIG_MTD_NAND_ECC_SMC is not set
482# CONFIG_MTD_NAND_MUSEUM_IDS is not set
483CONFIG_MTD_NAND_IDS=y
484# CONFIG_MTD_NAND_DISKONCHIP 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
497CONFIG_BLK_DEV_LOOP=y
498# CONFIG_BLK_DEV_CRYPTOLOOP is not set
499# CONFIG_BLK_DEV_NBD is not set
500# CONFIG_BLK_DEV_UB is not set
501CONFIG_BLK_DEV_RAM=y
502CONFIG_BLK_DEV_RAM_COUNT=16
503CONFIG_BLK_DEV_RAM_SIZE=16384
504# CONFIG_BLK_DEV_XIP is not set
505# CONFIG_CDROM_PKTCDVD is not set
506# CONFIG_ATA_OVER_ETH is not set
507# CONFIG_MISC_DEVICES is not set
508CONFIG_HAVE_IDE=y
509# CONFIG_IDE is not set
510
511#
512# SCSI device support
513#
514# CONFIG_RAID_ATTRS is not set
515CONFIG_SCSI=y
516CONFIG_SCSI_DMA=y
517# CONFIG_SCSI_TGT is not set
518# CONFIG_SCSI_NETLINK is not set
519CONFIG_SCSI_PROC_FS=y
520
521#
522# SCSI support type (disk, tape, CD-ROM)
523#
524CONFIG_BLK_DEV_SD=y
525# CONFIG_CHR_DEV_ST is not set
526# CONFIG_CHR_DEV_OSST is not set
527# CONFIG_BLK_DEV_SR is not set
528# CONFIG_CHR_DEV_SG is not set
529# CONFIG_CHR_DEV_SCH is not set
530
531#
532# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
533#
534# CONFIG_SCSI_MULTI_LUN is not set
535# CONFIG_SCSI_CONSTANTS is not set
536# CONFIG_SCSI_LOGGING is not set
537# CONFIG_SCSI_SCAN_ASYNC is not set
538CONFIG_SCSI_WAIT_SCAN=m
539
540#
541# SCSI Transports
542#
543# CONFIG_SCSI_SPI_ATTRS is not set
544# CONFIG_SCSI_FC_ATTRS is not set
545# CONFIG_SCSI_ISCSI_ATTRS is not set
546# CONFIG_SCSI_SAS_LIBSAS is not set
547# CONFIG_SCSI_SRP_ATTRS is not set
548CONFIG_SCSI_LOWLEVEL=y
549# CONFIG_ISCSI_TCP is not set
550# CONFIG_SCSI_DEBUG is not set
551# CONFIG_SCSI_DH is not set
552# CONFIG_ATA is not set
553# CONFIG_MD is not set
554CONFIG_NETDEVICES=y
555# CONFIG_DUMMY is not set
556# CONFIG_BONDING is not set
557# CONFIG_MACVLAN is not set
558# CONFIG_EQUALIZER is not set
559# CONFIG_TUN is not set
560# CONFIG_VETH is not set
561# CONFIG_NET_ETHERNET is not set
562# CONFIG_NETDEV_1000 is not set
563# CONFIG_NETDEV_10000 is not set
564
565#
566# Wireless LAN
567#
568# CONFIG_WLAN_PRE80211 is not set
569# CONFIG_WLAN_80211 is not set
570# CONFIG_IWLWIFI_LEDS is not set
571
572#
573# USB Network Adapters
574#
575# CONFIG_USB_CATC is not set
576# CONFIG_USB_KAWETH is not set
577# CONFIG_USB_PEGASUS is not set
578# CONFIG_USB_RTL8150 is not set
579# CONFIG_USB_USBNET is not set
580# CONFIG_WAN is not set
581# CONFIG_PPP is not set
582# CONFIG_SLIP is not set
583# CONFIG_NETCONSOLE is not set
584# CONFIG_NETPOLL is not set
585# CONFIG_NET_POLL_CONTROLLER is not set
586# CONFIG_ISDN is not set
587
588#
589# Input device support
590#
591CONFIG_INPUT=y
592# CONFIG_INPUT_FF_MEMLESS is not set
593# CONFIG_INPUT_POLLDEV is not set
594
595#
596# Userland interfaces
597#
598# CONFIG_INPUT_MOUSEDEV is not set
599# CONFIG_INPUT_JOYDEV is not set
600# CONFIG_INPUT_EVDEV is not set
601# CONFIG_INPUT_EVBUG is not set
602
603#
604# Input Device Drivers
605#
606# CONFIG_INPUT_KEYBOARD is not set
607# CONFIG_INPUT_MOUSE is not set
608# CONFIG_INPUT_JOYSTICK is not set
609# CONFIG_INPUT_TABLET is not set
610# CONFIG_INPUT_TOUCHSCREEN is not set
611# CONFIG_INPUT_MISC is not set
612
613#
614# Hardware I/O ports
615#
616# CONFIG_SERIO is not set
617# CONFIG_GAMEPORT is not set
618
619#
620# Character devices
621#
622CONFIG_VT=y
623CONFIG_CONSOLE_TRANSLATIONS=y
624CONFIG_VT_CONSOLE=y
625CONFIG_HW_CONSOLE=y
626# CONFIG_VT_HW_CONSOLE_BINDING is not set
627CONFIG_DEVKMEM=y
628# CONFIG_SERIAL_NONSTANDARD is not set
629
630#
631# Serial drivers
632#
633CONFIG_SERIAL_8250=y
634CONFIG_SERIAL_8250_CONSOLE=y
635CONFIG_SERIAL_8250_NR_UARTS=32
636CONFIG_SERIAL_8250_RUNTIME_UARTS=4
637CONFIG_SERIAL_8250_EXTENDED=y
638CONFIG_SERIAL_8250_MANY_PORTS=y
639CONFIG_SERIAL_8250_SHARE_IRQ=y
640CONFIG_SERIAL_8250_DETECT_IRQ=y
641CONFIG_SERIAL_8250_RSA=y
642
643#
644# Non-8250 serial port support
645#
646CONFIG_SERIAL_CORE=y
647CONFIG_SERIAL_CORE_CONSOLE=y
648CONFIG_UNIX98_PTYS=y
649# CONFIG_LEGACY_PTYS is not set
650# CONFIG_IPMI_HANDLER is not set
651CONFIG_HW_RANDOM=y
652# CONFIG_NVRAM is not set
653# CONFIG_R3964 is not set
654# CONFIG_RAW_DRIVER is not set
655# CONFIG_TCG_TPM is not set
656CONFIG_I2C=y
657CONFIG_I2C_BOARDINFO=y
658CONFIG_I2C_CHARDEV=y
659CONFIG_I2C_HELPER_AUTO=y
660
661#
662# I2C Hardware Bus support
663#
664
665#
666# I2C system bus drivers (mostly embedded / system-on-chip)
667#
668# CONFIG_I2C_GPIO is not set
669# CONFIG_I2C_OCORES is not set
670CONFIG_I2C_OMAP=y
671# CONFIG_I2C_SIMTEC is not set
672
673#
674# External I2C/SMBus adapter drivers
675#
676# CONFIG_I2C_PARPORT_LIGHT is not set
677# CONFIG_I2C_TAOS_EVM is not set
678# CONFIG_I2C_TINY_USB is not set
679
680#
681# Other I2C/SMBus bus drivers
682#
683# CONFIG_I2C_PCA_PLATFORM is not set
684# CONFIG_I2C_STUB is not set
685
686#
687# Miscellaneous I2C Chip support
688#
689# CONFIG_DS1682 is not set
690# CONFIG_AT24 is not set
691# CONFIG_SENSORS_EEPROM is not set
692# CONFIG_SENSORS_PCF8574 is not set
693# CONFIG_PCF8575 is not set
694# CONFIG_SENSORS_PCA9539 is not set
695# CONFIG_SENSORS_PCF8591 is not set
696# CONFIG_ISP1301_OMAP is not set
697# CONFIG_TPS65010 is not set
698# CONFIG_SENSORS_MAX6875 is not set
699# CONFIG_SENSORS_TSL2550 is not set
700# CONFIG_I2C_DEBUG_CORE is not set
701# CONFIG_I2C_DEBUG_ALGO is not set
702# CONFIG_I2C_DEBUG_BUS is not set
703# CONFIG_I2C_DEBUG_CHIP is not set
704# CONFIG_SPI is not set
705CONFIG_ARCH_REQUIRE_GPIOLIB=y
706CONFIG_GPIOLIB=y
707# CONFIG_DEBUG_GPIO is not set
708# CONFIG_GPIO_SYSFS is not set
709
710#
711# I2C GPIO expanders:
712#
713# CONFIG_GPIO_MAX732X is not set
714# CONFIG_GPIO_PCA953X is not set
715# CONFIG_GPIO_PCF857X is not set
716
717#
718# PCI GPIO expanders:
719#
720
721#
722# SPI GPIO expanders:
723#
724# CONFIG_W1 is not set
725# CONFIG_POWER_SUPPLY is not set
726# CONFIG_HWMON is not set
727# CONFIG_THERMAL is not set
728# CONFIG_THERMAL_HWMON is not set
729# CONFIG_WATCHDOG is not set
730
731#
732# Sonics Silicon Backplane
733#
734CONFIG_SSB_POSSIBLE=y
735# CONFIG_SSB is not set
736
737#
738# Multifunction device drivers
739#
740# CONFIG_MFD_CORE is not set
741# CONFIG_MFD_SM501 is not set
742# CONFIG_HTC_EGPIO is not set
743# CONFIG_HTC_PASIC3 is not set
744# CONFIG_UCB1400_CORE is not set
745# CONFIG_MFD_TMIO is not set
746# CONFIG_MFD_T7L66XB is not set
747# CONFIG_MFD_TC6387XB is not set
748# CONFIG_MFD_TC6393XB is not set
749
750#
751# Multimedia devices
752#
753
754#
755# Multimedia core support
756#
757# CONFIG_VIDEO_DEV is not set
758# CONFIG_DVB_CORE is not set
759# CONFIG_VIDEO_MEDIA is not set
760
761#
762# Multimedia drivers
763#
764CONFIG_DAB=y
765# CONFIG_USB_DABUSB is not set
766
767#
768# Graphics support
769#
770# CONFIG_VGASTATE is not set
771# CONFIG_VIDEO_OUTPUT_CONTROL is not set
772# CONFIG_FB is not set
773# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
774
775#
776# Display device support
777#
778# CONFIG_DISPLAY_SUPPORT is not set
779
780#
781# Console display driver support
782#
783# CONFIG_VGA_CONSOLE is not set
784CONFIG_DUMMY_CONSOLE=y
785# CONFIG_SOUND is not set
786# CONFIG_HID_SUPPORT is not set
787CONFIG_USB_SUPPORT=y
788CONFIG_USB_ARCH_HAS_HCD=y
789CONFIG_USB_ARCH_HAS_OHCI=y
790# CONFIG_USB_ARCH_HAS_EHCI is not set
791CONFIG_USB=y
792# CONFIG_USB_DEBUG is not set
793# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
794
795#
796# Miscellaneous USB options
797#
798CONFIG_USB_DEVICEFS=y
799CONFIG_USB_DEVICE_CLASS=y
800# CONFIG_USB_DYNAMIC_MINORS is not set
801# CONFIG_USB_OTG is not set
802# CONFIG_USB_OTG_WHITELIST is not set
803# CONFIG_USB_OTG_BLACKLIST_HUB is not set
804CONFIG_USB_MON=y
805
806#
807# USB Host Controller Drivers
808#
809# CONFIG_USB_C67X00_HCD is not set
810# CONFIG_USB_ISP116X_HCD is not set
811# CONFIG_USB_ISP1760_HCD is not set
812# CONFIG_USB_OHCI_HCD is not set
813# CONFIG_USB_SL811_HCD is not set
814# CONFIG_USB_R8A66597_HCD is not set
815CONFIG_USB_MUSB_HDRC=y
816CONFIG_USB_MUSB_SOC=y
817
818#
819# OMAP 343x high speed USB support
820#
821CONFIG_USB_MUSB_HOST=y
822# CONFIG_USB_MUSB_PERIPHERAL is not set
823# CONFIG_USB_MUSB_OTG is not set
824# CONFIG_USB_GADGET_MUSB_HDRC is not set
825CONFIG_USB_MUSB_HDRC_HCD=y
826# CONFIG_MUSB_PIO_ONLY is not set
827CONFIG_USB_INVENTRA_DMA=y
828# CONFIG_USB_TI_CPPI_DMA is not set
829# CONFIG_USB_MUSB_DEBUG is not set
830
831#
832# USB Device Class drivers
833#
834# CONFIG_USB_ACM is not set
835# CONFIG_USB_PRINTER is not set
836# CONFIG_USB_WDM is not set
837
838#
839# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
840#
841
842#
843# may also be needed; see USB_STORAGE Help for more information
844#
845# CONFIG_USB_STORAGE is not set
846# CONFIG_USB_LIBUSUAL is not set
847
848#
849# USB Imaging devices
850#
851# CONFIG_USB_MDC800 is not set
852# CONFIG_USB_MICROTEK is not set
853
854#
855# USB port drivers
856#
857# CONFIG_USB_SERIAL is not set
858
859#
860# USB Miscellaneous drivers
861#
862# CONFIG_USB_EMI62 is not set
863# CONFIG_USB_EMI26 is not set
864# CONFIG_USB_ADUTUX is not set
865# CONFIG_USB_RIO500 is not set
866# CONFIG_USB_LEGOTOWER is not set
867# CONFIG_USB_LCD is not set
868# CONFIG_USB_BERRY_CHARGE is not set
869# CONFIG_USB_LED is not set
870# CONFIG_USB_CYPRESS_CY7C63 is not set
871# CONFIG_USB_CYTHERM is not set
872# CONFIG_USB_PHIDGET is not set
873# CONFIG_USB_IDMOUSE is not set
874# CONFIG_USB_FTDI_ELAN is not set
875# CONFIG_USB_APPLEDISPLAY is not set
876# CONFIG_USB_LD is not set
877# CONFIG_USB_TRANCEVIBRATOR is not set
878# CONFIG_USB_IOWARRIOR is not set
879# CONFIG_USB_TEST is not set
880# CONFIG_USB_ISIGHTFW is not set
881CONFIG_USB_GADGET=y
882# CONFIG_USB_GADGET_DEBUG is not set
883# CONFIG_USB_GADGET_DEBUG_FILES is not set
884CONFIG_USB_GADGET_SELECTED=y
885# CONFIG_USB_GADGET_AMD5536UDC is not set
886# CONFIG_USB_GADGET_ATMEL_USBA is not set
887# CONFIG_USB_GADGET_FSL_USB2 is not set
888# CONFIG_USB_GADGET_NET2280 is not set
889# CONFIG_USB_GADGET_PXA25X is not set
890CONFIG_USB_GADGET_M66592=y
891CONFIG_USB_M66592=y
892# CONFIG_USB_GADGET_PXA27X is not set
893# CONFIG_USB_GADGET_GOKU is not set
894# CONFIG_USB_GADGET_LH7A40X is not set
895# CONFIG_USB_GADGET_OMAP is not set
896# CONFIG_USB_GADGET_S3C2410 is not set
897# CONFIG_USB_GADGET_AT91 is not set
898# CONFIG_USB_GADGET_DUMMY_HCD is not set
899CONFIG_USB_GADGET_DUALSPEED=y
900# CONFIG_USB_ZERO is not set
901CONFIG_USB_ETH=m
902CONFIG_USB_ETH_RNDIS=y
903# CONFIG_USB_GADGETFS is not set
904# CONFIG_USB_FILE_STORAGE is not set
905# CONFIG_USB_G_SERIAL is not set
906# CONFIG_USB_MIDI_GADGET is not set
907# CONFIG_USB_G_PRINTER is not set
908# CONFIG_USB_CDC_COMPOSITE is not set
909CONFIG_MMC=y
910# CONFIG_MMC_DEBUG is not set
911# CONFIG_MMC_UNSAFE_RESUME is not set
912
913#
914# MMC/SD Card Drivers
915#
916CONFIG_MMC_BLOCK=y
917CONFIG_MMC_BLOCK_BOUNCE=y
918# CONFIG_SDIO_UART is not set
919# CONFIG_MMC_TEST is not set
920
921#
922# MMC/SD Host Controller Drivers
923#
924# CONFIG_MMC_SDHCI is not set
925# CONFIG_MMC_OMAP is not set
926# CONFIG_MEMSTICK is not set
927# CONFIG_ACCESSIBILITY is not set
928# CONFIG_NEW_LEDS is not set
929CONFIG_RTC_LIB=y
930CONFIG_RTC_CLASS=y
931CONFIG_RTC_HCTOSYS=y
932CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
933# CONFIG_RTC_DEBUG is not set
934
935#
936# RTC interfaces
937#
938CONFIG_RTC_INTF_SYSFS=y
939CONFIG_RTC_INTF_PROC=y
940CONFIG_RTC_INTF_DEV=y
941# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
942# CONFIG_RTC_DRV_TEST is not set
943
944#
945# I2C RTC drivers
946#
947# CONFIG_RTC_DRV_DS1307 is not set
948# CONFIG_RTC_DRV_DS1374 is not set
949# CONFIG_RTC_DRV_DS1672 is not set
950# CONFIG_RTC_DRV_MAX6900 is not set
951# CONFIG_RTC_DRV_RS5C372 is not set
952# CONFIG_RTC_DRV_ISL1208 is not set
953# CONFIG_RTC_DRV_X1205 is not set
954# CONFIG_RTC_DRV_PCF8563 is not set
955# CONFIG_RTC_DRV_PCF8583 is not set
956# CONFIG_RTC_DRV_M41T80 is not set
957# CONFIG_RTC_DRV_S35390A is not set
958# CONFIG_RTC_DRV_FM3130 is not set
959
960#
961# SPI RTC drivers
962#
963
964#
965# Platform RTC drivers
966#
967# CONFIG_RTC_DRV_CMOS is not set
968# CONFIG_RTC_DRV_DS1511 is not set
969# CONFIG_RTC_DRV_DS1553 is not set
970# CONFIG_RTC_DRV_DS1742 is not set
971# CONFIG_RTC_DRV_STK17TA8 is not set
972# CONFIG_RTC_DRV_M48T86 is not set
973# CONFIG_RTC_DRV_M48T59 is not set
974# CONFIG_RTC_DRV_V3020 is not set
975
976#
977# on-CPU RTC drivers
978#
979# CONFIG_DMADEVICES is not set
980
981#
982# Voltage and Current regulators
983#
984# CONFIG_REGULATOR is not set
985# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
986# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
987# CONFIG_REGULATOR_BQ24022 is not set
988# CONFIG_UIO is not set
989
990#
991# File systems
992#
993CONFIG_EXT2_FS=y
994# CONFIG_EXT2_FS_XATTR is not set
995# CONFIG_EXT2_FS_XIP is not set
996CONFIG_EXT3_FS=y
997# CONFIG_EXT3_FS_XATTR is not set
998# CONFIG_EXT4DEV_FS is not set
999CONFIG_JBD=y
1000# CONFIG_REISERFS_FS is not set
1001# CONFIG_JFS_FS is not set
1002# CONFIG_FS_POSIX_ACL is not set
1003# CONFIG_XFS_FS is not set
1004# CONFIG_OCFS2_FS is not set
1005CONFIG_DNOTIFY=y
1006CONFIG_INOTIFY=y
1007CONFIG_INOTIFY_USER=y
1008CONFIG_QUOTA=y
1009# CONFIG_QUOTA_NETLINK_INTERFACE is not set
1010CONFIG_PRINT_QUOTA_WARNING=y
1011# CONFIG_QFMT_V1 is not set
1012CONFIG_QFMT_V2=y
1013CONFIG_QUOTACTL=y
1014# CONFIG_AUTOFS_FS is not set
1015# CONFIG_AUTOFS4_FS is not set
1016# CONFIG_FUSE_FS is not set
1017
1018#
1019# CD-ROM/DVD Filesystems
1020#
1021# CONFIG_ISO9660_FS is not set
1022# CONFIG_UDF_FS is not set
1023
1024#
1025# DOS/FAT/NT Filesystems
1026#
1027CONFIG_FAT_FS=y
1028CONFIG_MSDOS_FS=y
1029CONFIG_VFAT_FS=y
1030CONFIG_FAT_DEFAULT_CODEPAGE=437
1031CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1032# CONFIG_NTFS_FS is not set
1033
1034#
1035# Pseudo filesystems
1036#
1037CONFIG_PROC_FS=y
1038CONFIG_PROC_SYSCTL=y
1039CONFIG_SYSFS=y
1040CONFIG_TMPFS=y
1041# CONFIG_TMPFS_POSIX_ACL is not set
1042# CONFIG_HUGETLB_PAGE is not set
1043# CONFIG_CONFIGFS_FS is not set
1044
1045#
1046# Miscellaneous filesystems
1047#
1048# CONFIG_ADFS_FS is not set
1049# CONFIG_AFFS_FS is not set
1050# CONFIG_HFS_FS is not set
1051# CONFIG_HFSPLUS_FS is not set
1052# CONFIG_BEFS_FS is not set
1053# CONFIG_BFS_FS is not set
1054# CONFIG_EFS_FS is not set
1055CONFIG_JFFS2_FS=y
1056CONFIG_JFFS2_FS_DEBUG=0
1057CONFIG_JFFS2_FS_WRITEBUFFER=y
1058# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1059# CONFIG_JFFS2_SUMMARY is not set
1060# CONFIG_JFFS2_FS_XATTR is not set
1061# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1062CONFIG_JFFS2_ZLIB=y
1063# CONFIG_JFFS2_LZO is not set
1064CONFIG_JFFS2_RTIME=y
1065# CONFIG_JFFS2_RUBIN is not set
1066# CONFIG_CRAMFS is not set
1067# CONFIG_VXFS_FS is not set
1068# CONFIG_MINIX_FS is not set
1069# CONFIG_OMFS_FS is not set
1070# CONFIG_HPFS_FS is not set
1071# CONFIG_QNX4FS_FS is not set
1072# CONFIG_ROMFS_FS is not set
1073# CONFIG_SYSV_FS is not set
1074# CONFIG_UFS_FS is not set
1075CONFIG_NETWORK_FILESYSTEMS=y
1076CONFIG_NFS_FS=y
1077CONFIG_NFS_V3=y
1078# CONFIG_NFS_V3_ACL is not set
1079CONFIG_NFS_V4=y
1080CONFIG_ROOT_NFS=y
1081# CONFIG_NFSD is not set
1082CONFIG_LOCKD=y
1083CONFIG_LOCKD_V4=y
1084CONFIG_NFS_COMMON=y
1085CONFIG_SUNRPC=y
1086CONFIG_SUNRPC_GSS=y
1087CONFIG_RPCSEC_GSS_KRB5=y
1088# CONFIG_RPCSEC_GSS_SPKM3 is not set
1089# CONFIG_SMB_FS is not set
1090# CONFIG_CIFS is not set
1091# CONFIG_NCP_FS is not set
1092# CONFIG_CODA_FS is not set
1093# CONFIG_AFS_FS is not set
1094
1095#
1096# Partition Types
1097#
1098CONFIG_PARTITION_ADVANCED=y
1099# CONFIG_ACORN_PARTITION is not set
1100# CONFIG_OSF_PARTITION is not set
1101# CONFIG_AMIGA_PARTITION is not set
1102# CONFIG_ATARI_PARTITION is not set
1103# CONFIG_MAC_PARTITION is not set
1104CONFIG_MSDOS_PARTITION=y
1105# CONFIG_BSD_DISKLABEL is not set
1106# CONFIG_MINIX_SUBPARTITION is not set
1107# CONFIG_SOLARIS_X86_PARTITION is not set
1108# CONFIG_UNIXWARE_DISKLABEL is not set
1109# CONFIG_LDM_PARTITION is not set
1110# CONFIG_SGI_PARTITION is not set
1111# CONFIG_ULTRIX_PARTITION is not set
1112# CONFIG_SUN_PARTITION is not set
1113# CONFIG_KARMA_PARTITION is not set
1114# CONFIG_EFI_PARTITION is not set
1115# CONFIG_SYSV68_PARTITION is not set
1116CONFIG_NLS=y
1117CONFIG_NLS_DEFAULT="iso8859-1"
1118CONFIG_NLS_CODEPAGE_437=y
1119# CONFIG_NLS_CODEPAGE_737 is not set
1120# CONFIG_NLS_CODEPAGE_775 is not set
1121# CONFIG_NLS_CODEPAGE_850 is not set
1122# CONFIG_NLS_CODEPAGE_852 is not set
1123# CONFIG_NLS_CODEPAGE_855 is not set
1124# CONFIG_NLS_CODEPAGE_857 is not set
1125# CONFIG_NLS_CODEPAGE_860 is not set
1126# CONFIG_NLS_CODEPAGE_861 is not set
1127# CONFIG_NLS_CODEPAGE_862 is not set
1128# CONFIG_NLS_CODEPAGE_863 is not set
1129# CONFIG_NLS_CODEPAGE_864 is not set
1130# CONFIG_NLS_CODEPAGE_865 is not set
1131# CONFIG_NLS_CODEPAGE_866 is not set
1132# CONFIG_NLS_CODEPAGE_869 is not set
1133# CONFIG_NLS_CODEPAGE_936 is not set
1134# CONFIG_NLS_CODEPAGE_950 is not set
1135# CONFIG_NLS_CODEPAGE_932 is not set
1136# CONFIG_NLS_CODEPAGE_949 is not set
1137# CONFIG_NLS_CODEPAGE_874 is not set
1138# CONFIG_NLS_ISO8859_8 is not set
1139# CONFIG_NLS_CODEPAGE_1250 is not set
1140# CONFIG_NLS_CODEPAGE_1251 is not set
1141# CONFIG_NLS_ASCII is not set
1142CONFIG_NLS_ISO8859_1=y
1143# CONFIG_NLS_ISO8859_2 is not set
1144# CONFIG_NLS_ISO8859_3 is not set
1145# CONFIG_NLS_ISO8859_4 is not set
1146# CONFIG_NLS_ISO8859_5 is not set
1147# CONFIG_NLS_ISO8859_6 is not set
1148# CONFIG_NLS_ISO8859_7 is not set
1149# CONFIG_NLS_ISO8859_9 is not set
1150# CONFIG_NLS_ISO8859_13 is not set
1151# CONFIG_NLS_ISO8859_14 is not set
1152# CONFIG_NLS_ISO8859_15 is not set
1153# CONFIG_NLS_KOI8_R is not set
1154# CONFIG_NLS_KOI8_U is not set
1155# CONFIG_NLS_UTF8 is not set
1156# CONFIG_DLM is not set
1157
1158#
1159# Kernel hacking
1160#
1161# CONFIG_PRINTK_TIME is not set
1162CONFIG_ENABLE_WARN_DEPRECATED=y
1163CONFIG_ENABLE_MUST_CHECK=y
1164CONFIG_FRAME_WARN=1024
1165CONFIG_MAGIC_SYSRQ=y
1166# CONFIG_UNUSED_SYMBOLS is not set
1167# CONFIG_DEBUG_FS is not set
1168# CONFIG_HEADERS_CHECK is not set
1169CONFIG_DEBUG_KERNEL=y
1170# CONFIG_DEBUG_SHIRQ is not set
1171CONFIG_DETECT_SOFTLOCKUP=y
1172# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1173CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1174CONFIG_SCHED_DEBUG=y
1175# CONFIG_SCHEDSTATS is not set
1176# CONFIG_TIMER_STATS is not set
1177# CONFIG_DEBUG_OBJECTS is not set
1178# CONFIG_DEBUG_SLAB is not set
1179# CONFIG_DEBUG_RT_MUTEXES is not set
1180# CONFIG_RT_MUTEX_TESTER is not set
1181# CONFIG_DEBUG_SPINLOCK is not set
1182CONFIG_DEBUG_MUTEXES=y
1183# CONFIG_DEBUG_LOCK_ALLOC is not set
1184# CONFIG_PROVE_LOCKING is not set
1185# CONFIG_LOCK_STAT is not set
1186# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1187# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1188# CONFIG_DEBUG_KOBJECT is not set
1189# CONFIG_DEBUG_BUGVERBOSE is not set
1190CONFIG_DEBUG_INFO=y
1191# CONFIG_DEBUG_VM is not set
1192# CONFIG_DEBUG_WRITECOUNT is not set
1193# CONFIG_DEBUG_MEMORY_INIT is not set
1194# CONFIG_DEBUG_LIST is not set
1195# CONFIG_DEBUG_SG is not set
1196CONFIG_FRAME_POINTER=y
1197# CONFIG_BOOT_PRINTK_DELAY is not set
1198# CONFIG_RCU_TORTURE_TEST is not set
1199# CONFIG_BACKTRACE_SELF_TEST is not set
1200# CONFIG_FAULT_INJECTION is not set
1201# CONFIG_LATENCYTOP is not set
1202CONFIG_HAVE_FTRACE=y
1203CONFIG_HAVE_DYNAMIC_FTRACE=y
1204# CONFIG_FTRACE is not set
1205# CONFIG_IRQSOFF_TRACER is not set
1206# CONFIG_SCHED_TRACER is not set
1207# CONFIG_CONTEXT_SWITCH_TRACER is not set
1208# CONFIG_SAMPLES is not set
1209CONFIG_HAVE_ARCH_KGDB=y
1210# CONFIG_KGDB is not set
1211# CONFIG_DEBUG_USER is not set
1212# CONFIG_DEBUG_ERRORS is not set
1213# CONFIG_DEBUG_STACK_USAGE is not set
1214# CONFIG_DEBUG_LL is not set
1215
1216#
1217# Security options
1218#
1219# CONFIG_KEYS is not set
1220# CONFIG_SECURITY is not set
1221# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1222CONFIG_CRYPTO=y
1223
1224#
1225# Crypto core or helper
1226#
1227CONFIG_CRYPTO_ALGAPI=y
1228CONFIG_CRYPTO_BLKCIPHER=y
1229CONFIG_CRYPTO_MANAGER=y
1230# CONFIG_CRYPTO_GF128MUL is not set
1231# CONFIG_CRYPTO_NULL is not set
1232# CONFIG_CRYPTO_CRYPTD is not set
1233# CONFIG_CRYPTO_AUTHENC is not set
1234# CONFIG_CRYPTO_TEST is not set
1235
1236#
1237# Authenticated Encryption with Associated Data
1238#
1239# CONFIG_CRYPTO_CCM is not set
1240# CONFIG_CRYPTO_GCM is not set
1241# CONFIG_CRYPTO_SEQIV is not set
1242
1243#
1244# Block modes
1245#
1246CONFIG_CRYPTO_CBC=y
1247# CONFIG_CRYPTO_CTR is not set
1248# CONFIG_CRYPTO_CTS is not set
1249CONFIG_CRYPTO_ECB=m
1250# CONFIG_CRYPTO_LRW is not set
1251CONFIG_CRYPTO_PCBC=m
1252# CONFIG_CRYPTO_XTS is not set
1253
1254#
1255# Hash modes
1256#
1257# CONFIG_CRYPTO_HMAC is not set
1258# CONFIG_CRYPTO_XCBC is not set
1259
1260#
1261# Digest
1262#
1263# CONFIG_CRYPTO_CRC32C is not set
1264# CONFIG_CRYPTO_MD4 is not set
1265CONFIG_CRYPTO_MD5=y
1266# CONFIG_CRYPTO_MICHAEL_MIC is not set
1267# CONFIG_CRYPTO_RMD128 is not set
1268# CONFIG_CRYPTO_RMD160 is not set
1269# CONFIG_CRYPTO_RMD256 is not set
1270# CONFIG_CRYPTO_RMD320 is not set
1271# CONFIG_CRYPTO_SHA1 is not set
1272# CONFIG_CRYPTO_SHA256 is not set
1273# CONFIG_CRYPTO_SHA512 is not set
1274# CONFIG_CRYPTO_TGR192 is not set
1275# CONFIG_CRYPTO_WP512 is not set
1276
1277#
1278# Ciphers
1279#
1280# CONFIG_CRYPTO_AES is not set
1281# CONFIG_CRYPTO_ANUBIS is not set
1282# CONFIG_CRYPTO_ARC4 is not set
1283# CONFIG_CRYPTO_BLOWFISH is not set
1284# CONFIG_CRYPTO_CAMELLIA is not set
1285# CONFIG_CRYPTO_CAST5 is not set
1286# CONFIG_CRYPTO_CAST6 is not set
1287CONFIG_CRYPTO_DES=y
1288# CONFIG_CRYPTO_FCRYPT is not set
1289# CONFIG_CRYPTO_KHAZAD is not set
1290# CONFIG_CRYPTO_SALSA20 is not set
1291# CONFIG_CRYPTO_SEED is not set
1292# CONFIG_CRYPTO_SERPENT is not set
1293# CONFIG_CRYPTO_TEA is not set
1294# CONFIG_CRYPTO_TWOFISH is not set
1295
1296#
1297# Compression
1298#
1299# CONFIG_CRYPTO_DEFLATE is not set
1300# CONFIG_CRYPTO_LZO is not set
1301CONFIG_CRYPTO_HW=y
1302
1303#
1304# Library routines
1305#
1306CONFIG_BITREVERSE=y
1307# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1308# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1309CONFIG_CRC_CCITT=y
1310# CONFIG_CRC16 is not set
1311# CONFIG_CRC_T10DIF is not set
1312# CONFIG_CRC_ITU_T is not set
1313CONFIG_CRC32=y
1314# CONFIG_CRC7 is not set
1315CONFIG_LIBCRC32C=y
1316CONFIG_ZLIB_INFLATE=y
1317CONFIG_ZLIB_DEFLATE=y
1318CONFIG_PLIST=y
1319CONFIG_HAS_IOMEM=y
1320CONFIG_HAS_IOPORT=y
1321CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/omap_ldp_defconfig b/arch/arm/configs/omap_ldp_defconfig
new file mode 100644
index 000000000000..948a212fb1cc
--- /dev/null
+++ b/arch/arm/configs/omap_ldp_defconfig
@@ -0,0 +1,1044 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc5
4# Fri Oct 10 11:49:41 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_INIT_ENV_ARG_LIMIT=32
37CONFIG_LOCALVERSION=""
38CONFIG_LOCALVERSION_AUTO=y
39CONFIG_SWAP=y
40CONFIG_SYSVIPC=y
41CONFIG_SYSVIPC_SYSCTL=y
42CONFIG_BSD_PROCESS_ACCT=y
43# CONFIG_BSD_PROCESS_ACCT_V3 is not set
44# CONFIG_IKCONFIG is not set
45CONFIG_LOG_BUF_SHIFT=14
46# CONFIG_CGROUPS is not set
47CONFIG_GROUP_SCHED=y
48CONFIG_FAIR_GROUP_SCHED=y
49# CONFIG_RT_GROUP_SCHED is not set
50CONFIG_USER_SCHED=y
51# CONFIG_CGROUP_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
56CONFIG_BLK_DEV_INITRD=y
57CONFIG_INITRAMFS_SOURCE=""
58CONFIG_CC_OPTIMIZE_FOR_SIZE=y
59CONFIG_SYSCTL=y
60CONFIG_EMBEDDED=y
61CONFIG_UID16=y
62# CONFIG_SYSCTL_SYSCALL is not set
63CONFIG_KALLSYMS=y
64# CONFIG_KALLSYMS_ALL is not set
65CONFIG_KALLSYMS_EXTRA_PASS=y
66CONFIG_HOTPLUG=y
67CONFIG_PRINTK=y
68CONFIG_BUG=y
69CONFIG_ELF_CORE=y
70CONFIG_COMPAT_BRK=y
71CONFIG_BASE_FULL=y
72CONFIG_FUTEX=y
73CONFIG_ANON_INODES=y
74CONFIG_EPOLL=y
75CONFIG_SIGNALFD=y
76CONFIG_TIMERFD=y
77CONFIG_EVENTFD=y
78CONFIG_SHMEM=y
79CONFIG_VM_EVENT_COUNTERS=y
80CONFIG_SLAB=y
81# CONFIG_SLUB is not set
82# CONFIG_SLOB is not set
83# CONFIG_PROFILING is not set
84# CONFIG_MARKERS is not set
85CONFIG_HAVE_OPROFILE=y
86# CONFIG_KPROBES is not set
87# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
88# CONFIG_HAVE_IOREMAP_PROT is not set
89CONFIG_HAVE_KPROBES=y
90CONFIG_HAVE_KRETPROBES=y
91# CONFIG_HAVE_ARCH_TRACEHOOK is not set
92# CONFIG_HAVE_DMA_ATTRS is not set
93# CONFIG_USE_GENERIC_SMP_HELPERS is not set
94CONFIG_HAVE_CLK=y
95CONFIG_PROC_PAGE_MONITOR=y
96CONFIG_HAVE_GENERIC_DMA_COHERENT=y
97CONFIG_SLABINFO=y
98CONFIG_RT_MUTEXES=y
99# CONFIG_TINY_SHMEM is not set
100CONFIG_BASE_SMALL=0
101CONFIG_MODULES=y
102# CONFIG_MODULE_FORCE_LOAD is not set
103CONFIG_MODULE_UNLOAD=y
104# CONFIG_MODULE_FORCE_UNLOAD is not set
105CONFIG_MODVERSIONS=y
106CONFIG_MODULE_SRCVERSION_ALL=y
107CONFIG_KMOD=y
108CONFIG_BLOCK=y
109# CONFIG_LBD is not set
110# CONFIG_BLK_DEV_IO_TRACE is not set
111# CONFIG_LSF is not set
112# CONFIG_BLK_DEV_BSG is not set
113# CONFIG_BLK_DEV_INTEGRITY is not set
114
115#
116# IO Schedulers
117#
118CONFIG_IOSCHED_NOOP=y
119CONFIG_IOSCHED_AS=y
120CONFIG_IOSCHED_DEADLINE=y
121CONFIG_IOSCHED_CFQ=y
122CONFIG_DEFAULT_AS=y
123# CONFIG_DEFAULT_DEADLINE is not set
124# CONFIG_DEFAULT_CFQ is not set
125# CONFIG_DEFAULT_NOOP is not set
126CONFIG_DEFAULT_IOSCHED="anticipatory"
127CONFIG_CLASSIC_RCU=y
128
129#
130# System Type
131#
132# CONFIG_ARCH_AAEC2000 is not set
133# CONFIG_ARCH_INTEGRATOR is not set
134# CONFIG_ARCH_REALVIEW is not set
135# CONFIG_ARCH_VERSATILE is not set
136# CONFIG_ARCH_AT91 is not set
137# CONFIG_ARCH_CLPS7500 is not set
138# CONFIG_ARCH_CLPS711X is not set
139# CONFIG_ARCH_EBSA110 is not set
140# CONFIG_ARCH_EP93XX is not set
141# CONFIG_ARCH_FOOTBRIDGE is not set
142# CONFIG_ARCH_NETX is not set
143# CONFIG_ARCH_H720X is not set
144# CONFIG_ARCH_IMX is not set
145# CONFIG_ARCH_IOP13XX is not set
146# CONFIG_ARCH_IOP32X is not set
147# CONFIG_ARCH_IOP33X is not set
148# CONFIG_ARCH_IXP23XX is not set
149# CONFIG_ARCH_IXP2000 is not set
150# CONFIG_ARCH_IXP4XX is not set
151# CONFIG_ARCH_L7200 is not set
152# CONFIG_ARCH_KIRKWOOD is not set
153# CONFIG_ARCH_KS8695 is not set
154# CONFIG_ARCH_NS9XXX is not set
155# CONFIG_ARCH_LOKI is not set
156# CONFIG_ARCH_MV78XX0 is not set
157# CONFIG_ARCH_MXC is not set
158# CONFIG_ARCH_ORION5X is not set
159# CONFIG_ARCH_PNX4008 is not set
160# CONFIG_ARCH_PXA is not set
161# CONFIG_ARCH_RPC is not set
162# CONFIG_ARCH_SA1100 is not set
163# CONFIG_ARCH_S3C2410 is not set
164# CONFIG_ARCH_SHARK is not set
165# CONFIG_ARCH_LH7A40X is not set
166# CONFIG_ARCH_DAVINCI is not set
167CONFIG_ARCH_OMAP=y
168# CONFIG_ARCH_MSM7X00A is not set
169
170#
171# TI OMAP Implementations
172#
173CONFIG_ARCH_OMAP_OTG=y
174# CONFIG_ARCH_OMAP1 is not set
175# CONFIG_ARCH_OMAP2 is not set
176CONFIG_ARCH_OMAP3=y
177
178#
179# OMAP Feature Selections
180#
181# CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
182# CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
183# CONFIG_OMAP_RESET_CLOCKS is not set
184CONFIG_OMAP_MUX=y
185CONFIG_OMAP_MUX_DEBUG=y
186CONFIG_OMAP_MUX_WARNINGS=y
187CONFIG_OMAP_MCBSP=y
188# CONFIG_OMAP_MPU_TIMER is not set
189CONFIG_OMAP_32K_TIMER=y
190CONFIG_OMAP_32K_TIMER_HZ=128
191CONFIG_OMAP_DM_TIMER=y
192# CONFIG_OMAP_LL_DEBUG_UART1 is not set
193# CONFIG_OMAP_LL_DEBUG_UART2 is not set
194CONFIG_OMAP_LL_DEBUG_UART3=y
195CONFIG_OMAP_SERIAL_WAKE=y
196CONFIG_ARCH_OMAP34XX=y
197CONFIG_ARCH_OMAP3430=y
198
199#
200# OMAP Board Type
201#
202# CONFIG_MACH_OMAP3_BEAGLE is not set
203CONFIG_MACH_OMAP_LDP=y
204# CONFIG_MACH_OVERO is not set
205
206#
207# Boot options
208#
209
210#
211# Power management
212#
213
214#
215# Processor Type
216#
217CONFIG_CPU_32=y
218CONFIG_CPU_32v6K=y
219CONFIG_CPU_V7=y
220CONFIG_CPU_32v7=y
221CONFIG_CPU_ABRT_EV7=y
222CONFIG_CPU_PABRT_IFAR=y
223CONFIG_CPU_CACHE_V7=y
224CONFIG_CPU_CACHE_VIPT=y
225CONFIG_CPU_COPY_V6=y
226CONFIG_CPU_TLB_V7=y
227CONFIG_CPU_HAS_ASID=y
228CONFIG_CPU_CP15=y
229CONFIG_CPU_CP15_MMU=y
230
231#
232# Processor Features
233#
234CONFIG_ARM_THUMB=y
235# CONFIG_ARM_THUMBEE is not set
236# CONFIG_CPU_ICACHE_DISABLE is not set
237# CONFIG_CPU_DCACHE_DISABLE is not set
238# CONFIG_CPU_BPREDICT_DISABLE is not set
239CONFIG_HAS_TLS_REG=y
240# CONFIG_OUTER_CACHE is not set
241
242#
243# Bus support
244#
245# CONFIG_PCI_SYSCALL is not set
246# CONFIG_ARCH_SUPPORTS_MSI is not set
247# CONFIG_PCCARD is not set
248
249#
250# Kernel Features
251#
252CONFIG_TICK_ONESHOT=y
253CONFIG_NO_HZ=y
254CONFIG_HIGH_RES_TIMERS=y
255CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
256# CONFIG_PREEMPT is not set
257CONFIG_HZ=128
258CONFIG_AEABI=y
259CONFIG_OABI_COMPAT=y
260CONFIG_ARCH_FLATMEM_HAS_HOLES=y
261# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
262CONFIG_SELECT_MEMORY_MODEL=y
263CONFIG_FLATMEM_MANUAL=y
264# CONFIG_DISCONTIGMEM_MANUAL is not set
265# CONFIG_SPARSEMEM_MANUAL is not set
266CONFIG_FLATMEM=y
267CONFIG_FLAT_NODE_MEM_MAP=y
268# CONFIG_SPARSEMEM_STATIC is not set
269# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
270CONFIG_PAGEFLAGS_EXTENDED=y
271CONFIG_SPLIT_PTLOCK_CPUS=4
272# CONFIG_RESOURCES_64BIT is not set
273CONFIG_ZONE_DMA_FLAG=1
274CONFIG_BOUNCE=y
275CONFIG_VIRT_TO_BUS=y
276# CONFIG_LEDS is not set
277CONFIG_ALIGNMENT_TRAP=y
278
279#
280# Boot options
281#
282CONFIG_ZBOOT_ROM_TEXT=0x0
283CONFIG_ZBOOT_ROM_BSS=0x0
284CONFIG_CMDLINE="root=/dev/nfs nfsroot=192.168.0.1:/home/user/buildroot ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0:tgt:eth0:off rw console=ttyS2,115200n8"
285# CONFIG_XIP_KERNEL is not set
286# CONFIG_KEXEC is not set
287
288#
289# CPU Frequency scaling
290#
291# CONFIG_CPU_FREQ is not set
292
293#
294# Floating point emulation
295#
296
297#
298# At least one emulation must be selected
299#
300CONFIG_FPE_NWFPE=y
301# CONFIG_FPE_NWFPE_XP is not set
302# CONFIG_FPE_FASTFPE is not set
303CONFIG_VFP=y
304CONFIG_VFPv3=y
305# CONFIG_NEON is not set
306
307#
308# Userspace binary formats
309#
310CONFIG_BINFMT_ELF=y
311# CONFIG_BINFMT_AOUT is not set
312CONFIG_BINFMT_MISC=y
313
314#
315# Power management options
316#
317# CONFIG_PM is not set
318CONFIG_ARCH_SUSPEND_POSSIBLE=y
319# CONFIG_NET is not set
320
321#
322# Device Drivers
323#
324
325#
326# Generic Driver Options
327#
328CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
329CONFIG_STANDALONE=y
330CONFIG_PREVENT_FIRMWARE_BUILD=y
331# CONFIG_FW_LOADER is not set
332# CONFIG_DEBUG_DRIVER is not set
333# CONFIG_DEBUG_DEVRES is not set
334# CONFIG_SYS_HYPERVISOR is not set
335# CONFIG_MTD is not set
336# CONFIG_PARPORT is not set
337CONFIG_BLK_DEV=y
338# CONFIG_BLK_DEV_COW_COMMON is not set
339CONFIG_BLK_DEV_LOOP=y
340# CONFIG_BLK_DEV_CRYPTOLOOP is not set
341CONFIG_BLK_DEV_RAM=y
342CONFIG_BLK_DEV_RAM_COUNT=16
343CONFIG_BLK_DEV_RAM_SIZE=16384
344# CONFIG_BLK_DEV_XIP is not set
345# CONFIG_CDROM_PKTCDVD is not set
346CONFIG_MISC_DEVICES=y
347# CONFIG_EEPROM_93CX6 is not set
348# CONFIG_ENCLOSURE_SERVICES is not set
349CONFIG_HAVE_IDE=y
350# CONFIG_IDE is not set
351
352#
353# SCSI device support
354#
355# CONFIG_RAID_ATTRS is not set
356CONFIG_SCSI=y
357CONFIG_SCSI_DMA=y
358# CONFIG_SCSI_TGT is not set
359# CONFIG_SCSI_NETLINK is not set
360CONFIG_SCSI_PROC_FS=y
361
362#
363# SCSI support type (disk, tape, CD-ROM)
364#
365CONFIG_BLK_DEV_SD=y
366# CONFIG_CHR_DEV_ST is not set
367# CONFIG_CHR_DEV_OSST is not set
368# CONFIG_BLK_DEV_SR is not set
369# CONFIG_CHR_DEV_SG is not set
370# CONFIG_CHR_DEV_SCH is not set
371
372#
373# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
374#
375# CONFIG_SCSI_MULTI_LUN is not set
376# CONFIG_SCSI_CONSTANTS is not set
377# CONFIG_SCSI_LOGGING is not set
378# CONFIG_SCSI_SCAN_ASYNC is not set
379CONFIG_SCSI_WAIT_SCAN=m
380
381#
382# SCSI Transports
383#
384# CONFIG_SCSI_SPI_ATTRS is not set
385# CONFIG_SCSI_FC_ATTRS is not set
386# CONFIG_SCSI_SAS_LIBSAS is not set
387# CONFIG_SCSI_SRP_ATTRS is not set
388CONFIG_SCSI_LOWLEVEL=y
389# CONFIG_SCSI_DEBUG is not set
390# CONFIG_SCSI_DH is not set
391# CONFIG_ATA is not set
392# CONFIG_MD is not set
393
394#
395# Input device support
396#
397CONFIG_INPUT=y
398# CONFIG_INPUT_FF_MEMLESS is not set
399# CONFIG_INPUT_POLLDEV is not set
400
401#
402# Userland interfaces
403#
404# CONFIG_INPUT_MOUSEDEV is not set
405# CONFIG_INPUT_JOYDEV is not set
406CONFIG_INPUT_EVDEV=y
407# CONFIG_INPUT_EVBUG is not set
408
409#
410# Input Device Drivers
411#
412# CONFIG_INPUT_KEYBOARD is not set
413# CONFIG_INPUT_MOUSE is not set
414# CONFIG_INPUT_JOYSTICK is not set
415# CONFIG_INPUT_TABLET is not set
416CONFIG_INPUT_TOUCHSCREEN=y
417CONFIG_TOUCHSCREEN_ADS7846=y
418# CONFIG_TOUCHSCREEN_FUJITSU is not set
419# CONFIG_TOUCHSCREEN_GUNZE is not set
420# CONFIG_TOUCHSCREEN_ELO is not set
421# CONFIG_TOUCHSCREEN_MTOUCH is not set
422# CONFIG_TOUCHSCREEN_INEXIO is not set
423# CONFIG_TOUCHSCREEN_MK712 is not set
424# CONFIG_TOUCHSCREEN_PENMOUNT is not set
425# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
426# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
427# CONFIG_TOUCHSCREEN_UCB1400 is not set
428# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
429# CONFIG_INPUT_MISC is not set
430
431#
432# Hardware I/O ports
433#
434# CONFIG_SERIO is not set
435# CONFIG_GAMEPORT is not set
436
437#
438# Character devices
439#
440CONFIG_VT=y
441CONFIG_CONSOLE_TRANSLATIONS=y
442CONFIG_VT_CONSOLE=y
443CONFIG_HW_CONSOLE=y
444# CONFIG_VT_HW_CONSOLE_BINDING is not set
445CONFIG_DEVKMEM=y
446# CONFIG_SERIAL_NONSTANDARD is not set
447
448#
449# Serial drivers
450#
451CONFIG_SERIAL_8250=y
452CONFIG_SERIAL_8250_CONSOLE=y
453CONFIG_SERIAL_8250_NR_UARTS=32
454CONFIG_SERIAL_8250_RUNTIME_UARTS=4
455CONFIG_SERIAL_8250_EXTENDED=y
456CONFIG_SERIAL_8250_MANY_PORTS=y
457CONFIG_SERIAL_8250_SHARE_IRQ=y
458CONFIG_SERIAL_8250_DETECT_IRQ=y
459CONFIG_SERIAL_8250_RSA=y
460
461#
462# Non-8250 serial port support
463#
464CONFIG_SERIAL_CORE=y
465CONFIG_SERIAL_CORE_CONSOLE=y
466CONFIG_UNIX98_PTYS=y
467# CONFIG_LEGACY_PTYS is not set
468# CONFIG_IPMI_HANDLER is not set
469CONFIG_HW_RANDOM=y
470# CONFIG_NVRAM is not set
471# CONFIG_R3964 is not set
472# CONFIG_RAW_DRIVER is not set
473# CONFIG_TCG_TPM is not set
474CONFIG_I2C=y
475CONFIG_I2C_BOARDINFO=y
476CONFIG_I2C_CHARDEV=y
477CONFIG_I2C_HELPER_AUTO=y
478
479#
480# I2C Hardware Bus support
481#
482
483#
484# I2C system bus drivers (mostly embedded / system-on-chip)
485#
486# CONFIG_I2C_GPIO is not set
487# CONFIG_I2C_OCORES is not set
488CONFIG_I2C_OMAP=y
489# CONFIG_I2C_SIMTEC is not set
490
491#
492# External I2C/SMBus adapter drivers
493#
494# CONFIG_I2C_PARPORT_LIGHT is not set
495# CONFIG_I2C_TAOS_EVM is not set
496
497#
498# Other I2C/SMBus bus drivers
499#
500# CONFIG_I2C_PCA_PLATFORM is not set
501# CONFIG_I2C_STUB is not set
502
503#
504# Miscellaneous I2C Chip support
505#
506# CONFIG_DS1682 is not set
507# CONFIG_AT24 is not set
508# CONFIG_SENSORS_EEPROM is not set
509# CONFIG_SENSORS_PCF8574 is not set
510# CONFIG_PCF8575 is not set
511# CONFIG_SENSORS_PCA9539 is not set
512# CONFIG_SENSORS_PCF8591 is not set
513# CONFIG_ISP1301_OMAP is not set
514# CONFIG_TPS65010 is not set
515# CONFIG_SENSORS_MAX6875 is not set
516# CONFIG_SENSORS_TSL2550 is not set
517# CONFIG_I2C_DEBUG_CORE is not set
518# CONFIG_I2C_DEBUG_ALGO is not set
519# CONFIG_I2C_DEBUG_BUS is not set
520# CONFIG_I2C_DEBUG_CHIP is not set
521CONFIG_SPI=y
522# CONFIG_SPI_DEBUG is not set
523CONFIG_SPI_MASTER=y
524
525#
526# SPI Master Controller Drivers
527#
528# CONFIG_SPI_BITBANG is not set
529CONFIG_SPI_OMAP24XX=y
530
531#
532# SPI Protocol Masters
533#
534# CONFIG_SPI_AT25 is not set
535# CONFIG_SPI_SPIDEV is not set
536# CONFIG_SPI_TLE62X0 is not set
537CONFIG_ARCH_REQUIRE_GPIOLIB=y
538CONFIG_GPIOLIB=y
539# CONFIG_DEBUG_GPIO is not set
540# CONFIG_GPIO_SYSFS is not set
541
542#
543# I2C GPIO expanders:
544#
545# CONFIG_GPIO_MAX732X is not set
546# CONFIG_GPIO_PCA953X is not set
547# CONFIG_GPIO_PCF857X is not set
548
549#
550# PCI GPIO expanders:
551#
552
553#
554# SPI GPIO expanders:
555#
556# CONFIG_GPIO_MAX7301 is not set
557# CONFIG_GPIO_MCP23S08 is not set
558CONFIG_W1=y
559
560#
561# 1-wire Bus Masters
562#
563# CONFIG_W1_MASTER_DS2482 is not set
564# CONFIG_W1_MASTER_DS1WM is not set
565# CONFIG_W1_MASTER_GPIO is not set
566
567#
568# 1-wire Slaves
569#
570# CONFIG_W1_SLAVE_THERM is not set
571# CONFIG_W1_SLAVE_SMEM is not set
572# CONFIG_W1_SLAVE_DS2433 is not set
573# CONFIG_W1_SLAVE_DS2760 is not set
574CONFIG_POWER_SUPPLY=y
575# CONFIG_POWER_SUPPLY_DEBUG is not set
576# CONFIG_PDA_POWER is not set
577# CONFIG_BATTERY_DS2760 is not set
578# CONFIG_HWMON is not set
579CONFIG_WATCHDOG=y
580CONFIG_WATCHDOG_NOWAYOUT=y
581
582#
583# Watchdog Device Drivers
584#
585# CONFIG_SOFT_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_VIDEO_MEDIA is not set
614
615#
616# Multimedia drivers
617#
618CONFIG_DAB=y
619
620#
621# Graphics support
622#
623# CONFIG_VGASTATE is not set
624CONFIG_VIDEO_OUTPUT_CONTROL=m
625# CONFIG_FB is not set
626# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
627
628#
629# Display device support
630#
631# CONFIG_DISPLAY_SUPPORT is not set
632
633#
634# Console display driver support
635#
636# CONFIG_VGA_CONSOLE is not set
637CONFIG_DUMMY_CONSOLE=y
638CONFIG_SOUND=y
639CONFIG_SND=y
640# CONFIG_SND_SEQUENCER is not set
641# CONFIG_SND_MIXER_OSS is not set
642# CONFIG_SND_PCM_OSS is not set
643# CONFIG_SND_DYNAMIC_MINORS is not set
644CONFIG_SND_SUPPORT_OLD_API=y
645CONFIG_SND_VERBOSE_PROCFS=y
646# CONFIG_SND_VERBOSE_PRINTK is not set
647# CONFIG_SND_DEBUG is not set
648CONFIG_SND_DRIVERS=y
649# CONFIG_SND_DUMMY is not set
650# CONFIG_SND_MTPAV is not set
651# CONFIG_SND_SERIAL_U16550 is not set
652# CONFIG_SND_MPU401 is not set
653CONFIG_SND_ARM=y
654CONFIG_SND_SPI=y
655# CONFIG_SND_SOC is not set
656# CONFIG_SOUND_PRIME is not set
657CONFIG_HID_SUPPORT=y
658CONFIG_HID=y
659# CONFIG_HID_DEBUG is not set
660# CONFIG_HIDRAW is not set
661# CONFIG_USB_SUPPORT is not set
662CONFIG_MMC=y
663# CONFIG_MMC_DEBUG is not set
664# CONFIG_MMC_UNSAFE_RESUME is not set
665
666#
667# MMC/SD Card Drivers
668#
669CONFIG_MMC_BLOCK=y
670CONFIG_MMC_BLOCK_BOUNCE=y
671# CONFIG_SDIO_UART is not set
672# CONFIG_MMC_TEST is not set
673
674#
675# MMC/SD Host Controller Drivers
676#
677# CONFIG_MMC_SDHCI is not set
678# CONFIG_MMC_OMAP is not set
679# CONFIG_MMC_SPI is not set
680# CONFIG_NEW_LEDS is not set
681CONFIG_RTC_LIB=y
682CONFIG_RTC_CLASS=y
683CONFIG_RTC_HCTOSYS=y
684CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
685# CONFIG_RTC_DEBUG is not set
686
687#
688# RTC interfaces
689#
690CONFIG_RTC_INTF_SYSFS=y
691CONFIG_RTC_INTF_PROC=y
692CONFIG_RTC_INTF_DEV=y
693# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
694# CONFIG_RTC_DRV_TEST is not set
695
696#
697# I2C RTC drivers
698#
699# CONFIG_RTC_DRV_DS1307 is not set
700# CONFIG_RTC_DRV_DS1374 is not set
701# CONFIG_RTC_DRV_DS1672 is not set
702# CONFIG_RTC_DRV_MAX6900 is not set
703# CONFIG_RTC_DRV_RS5C372 is not set
704# CONFIG_RTC_DRV_ISL1208 is not set
705# CONFIG_RTC_DRV_X1205 is not set
706# CONFIG_RTC_DRV_PCF8563 is not set
707# CONFIG_RTC_DRV_PCF8583 is not set
708# CONFIG_RTC_DRV_M41T80 is not set
709# CONFIG_RTC_DRV_S35390A is not set
710# CONFIG_RTC_DRV_FM3130 is not set
711
712#
713# SPI RTC drivers
714#
715# CONFIG_RTC_DRV_M41T94 is not set
716# CONFIG_RTC_DRV_DS1305 is not set
717# CONFIG_RTC_DRV_MAX6902 is not set
718# CONFIG_RTC_DRV_R9701 is not set
719# CONFIG_RTC_DRV_RS5C348 is not set
720
721#
722# Platform RTC drivers
723#
724# CONFIG_RTC_DRV_CMOS is not set
725# CONFIG_RTC_DRV_DS1511 is not set
726# CONFIG_RTC_DRV_DS1553 is not set
727# CONFIG_RTC_DRV_DS1742 is not set
728# CONFIG_RTC_DRV_STK17TA8 is not set
729# CONFIG_RTC_DRV_M48T86 is not set
730# CONFIG_RTC_DRV_M48T59 is not set
731# CONFIG_RTC_DRV_V3020 is not set
732
733#
734# on-CPU RTC drivers
735#
736# CONFIG_DMADEVICES is not set
737
738#
739# Voltage and Current regulators
740#
741# CONFIG_REGULATOR is not set
742# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
743# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
744# CONFIG_REGULATOR_BQ24022 is not set
745# CONFIG_UIO is not set
746
747#
748# File systems
749#
750CONFIG_EXT2_FS=y
751# CONFIG_EXT2_FS_XATTR is not set
752# CONFIG_EXT2_FS_XIP is not set
753CONFIG_EXT3_FS=y
754# CONFIG_EXT3_FS_XATTR is not set
755# CONFIG_EXT4DEV_FS is not set
756CONFIG_JBD=y
757# CONFIG_REISERFS_FS is not set
758# CONFIG_JFS_FS is not set
759# CONFIG_FS_POSIX_ACL is not set
760# CONFIG_XFS_FS is not set
761CONFIG_DNOTIFY=y
762CONFIG_INOTIFY=y
763CONFIG_INOTIFY_USER=y
764CONFIG_QUOTA=y
765CONFIG_PRINT_QUOTA_WARNING=y
766# CONFIG_QFMT_V1 is not set
767CONFIG_QFMT_V2=y
768CONFIG_QUOTACTL=y
769# CONFIG_AUTOFS_FS is not set
770# CONFIG_AUTOFS4_FS is not set
771# CONFIG_FUSE_FS is not set
772
773#
774# CD-ROM/DVD Filesystems
775#
776# CONFIG_ISO9660_FS is not set
777# CONFIG_UDF_FS is not set
778
779#
780# DOS/FAT/NT Filesystems
781#
782CONFIG_FAT_FS=y
783CONFIG_MSDOS_FS=y
784CONFIG_VFAT_FS=y
785CONFIG_FAT_DEFAULT_CODEPAGE=437
786CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
787# CONFIG_NTFS_FS is not set
788
789#
790# Pseudo filesystems
791#
792CONFIG_PROC_FS=y
793CONFIG_PROC_SYSCTL=y
794CONFIG_SYSFS=y
795CONFIG_TMPFS=y
796# CONFIG_TMPFS_POSIX_ACL is not set
797# CONFIG_HUGETLB_PAGE is not set
798# CONFIG_CONFIGFS_FS is not set
799
800#
801# Miscellaneous filesystems
802#
803# CONFIG_ADFS_FS is not set
804# CONFIG_AFFS_FS is not set
805# CONFIG_HFS_FS is not set
806# CONFIG_HFSPLUS_FS is not set
807# CONFIG_BEFS_FS is not set
808# CONFIG_BFS_FS is not set
809# CONFIG_EFS_FS is not set
810# CONFIG_CRAMFS is not set
811# CONFIG_VXFS_FS is not set
812# CONFIG_MINIX_FS is not set
813# CONFIG_OMFS_FS is not set
814# CONFIG_HPFS_FS is not set
815# CONFIG_QNX4FS_FS is not set
816# CONFIG_ROMFS_FS is not set
817# CONFIG_SYSV_FS is not set
818# CONFIG_UFS_FS is not set
819
820#
821# Partition Types
822#
823CONFIG_PARTITION_ADVANCED=y
824# CONFIG_ACORN_PARTITION is not set
825# CONFIG_OSF_PARTITION is not set
826# CONFIG_AMIGA_PARTITION is not set
827# CONFIG_ATARI_PARTITION is not set
828# CONFIG_MAC_PARTITION is not set
829CONFIG_MSDOS_PARTITION=y
830# CONFIG_BSD_DISKLABEL is not set
831# CONFIG_MINIX_SUBPARTITION is not set
832# CONFIG_SOLARIS_X86_PARTITION is not set
833# CONFIG_UNIXWARE_DISKLABEL is not set
834# CONFIG_LDM_PARTITION is not set
835# CONFIG_SGI_PARTITION is not set
836# CONFIG_ULTRIX_PARTITION is not set
837# CONFIG_SUN_PARTITION is not set
838# CONFIG_KARMA_PARTITION is not set
839# CONFIG_EFI_PARTITION is not set
840# CONFIG_SYSV68_PARTITION is not set
841CONFIG_NLS=y
842CONFIG_NLS_DEFAULT="iso8859-1"
843CONFIG_NLS_CODEPAGE_437=y
844# CONFIG_NLS_CODEPAGE_737 is not set
845# CONFIG_NLS_CODEPAGE_775 is not set
846# CONFIG_NLS_CODEPAGE_850 is not set
847# CONFIG_NLS_CODEPAGE_852 is not set
848# CONFIG_NLS_CODEPAGE_855 is not set
849# CONFIG_NLS_CODEPAGE_857 is not set
850# CONFIG_NLS_CODEPAGE_860 is not set
851# CONFIG_NLS_CODEPAGE_861 is not set
852# CONFIG_NLS_CODEPAGE_862 is not set
853# CONFIG_NLS_CODEPAGE_863 is not set
854# CONFIG_NLS_CODEPAGE_864 is not set
855# CONFIG_NLS_CODEPAGE_865 is not set
856# CONFIG_NLS_CODEPAGE_866 is not set
857# CONFIG_NLS_CODEPAGE_869 is not set
858# CONFIG_NLS_CODEPAGE_936 is not set
859# CONFIG_NLS_CODEPAGE_950 is not set
860# CONFIG_NLS_CODEPAGE_932 is not set
861# CONFIG_NLS_CODEPAGE_949 is not set
862# CONFIG_NLS_CODEPAGE_874 is not set
863# CONFIG_NLS_ISO8859_8 is not set
864# CONFIG_NLS_CODEPAGE_1250 is not set
865# CONFIG_NLS_CODEPAGE_1251 is not set
866# CONFIG_NLS_ASCII is not set
867CONFIG_NLS_ISO8859_1=y
868# CONFIG_NLS_ISO8859_2 is not set
869# CONFIG_NLS_ISO8859_3 is not set
870# CONFIG_NLS_ISO8859_4 is not set
871# CONFIG_NLS_ISO8859_5 is not set
872# CONFIG_NLS_ISO8859_6 is not set
873# CONFIG_NLS_ISO8859_7 is not set
874# CONFIG_NLS_ISO8859_9 is not set
875# CONFIG_NLS_ISO8859_13 is not set
876# CONFIG_NLS_ISO8859_14 is not set
877# CONFIG_NLS_ISO8859_15 is not set
878# CONFIG_NLS_KOI8_R is not set
879# CONFIG_NLS_KOI8_U is not set
880# CONFIG_NLS_UTF8 is not set
881
882#
883# Kernel hacking
884#
885# CONFIG_PRINTK_TIME is not set
886CONFIG_ENABLE_WARN_DEPRECATED=y
887CONFIG_ENABLE_MUST_CHECK=y
888CONFIG_FRAME_WARN=1024
889CONFIG_MAGIC_SYSRQ=y
890# CONFIG_UNUSED_SYMBOLS is not set
891# CONFIG_DEBUG_FS is not set
892# CONFIG_HEADERS_CHECK is not set
893CONFIG_DEBUG_KERNEL=y
894# CONFIG_DEBUG_SHIRQ is not set
895CONFIG_DETECT_SOFTLOCKUP=y
896# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
897CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
898CONFIG_SCHED_DEBUG=y
899# CONFIG_SCHEDSTATS is not set
900# CONFIG_TIMER_STATS is not set
901# CONFIG_DEBUG_OBJECTS is not set
902# CONFIG_DEBUG_SLAB is not set
903# CONFIG_DEBUG_RT_MUTEXES is not set
904# CONFIG_RT_MUTEX_TESTER is not set
905# CONFIG_DEBUG_SPINLOCK is not set
906CONFIG_DEBUG_MUTEXES=y
907# CONFIG_DEBUG_LOCK_ALLOC is not set
908# CONFIG_PROVE_LOCKING is not set
909# CONFIG_LOCK_STAT is not set
910# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
911# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
912# CONFIG_DEBUG_KOBJECT is not set
913# CONFIG_DEBUG_BUGVERBOSE is not set
914CONFIG_DEBUG_INFO=y
915# CONFIG_DEBUG_VM is not set
916# CONFIG_DEBUG_WRITECOUNT is not set
917# CONFIG_DEBUG_MEMORY_INIT is not set
918# CONFIG_DEBUG_LIST is not set
919# CONFIG_DEBUG_SG is not set
920CONFIG_FRAME_POINTER=y
921# CONFIG_BOOT_PRINTK_DELAY is not set
922# CONFIG_RCU_TORTURE_TEST is not set
923# CONFIG_BACKTRACE_SELF_TEST is not set
924# CONFIG_FAULT_INJECTION is not set
925# CONFIG_LATENCYTOP is not set
926CONFIG_HAVE_FTRACE=y
927CONFIG_HAVE_DYNAMIC_FTRACE=y
928# CONFIG_FTRACE is not set
929# CONFIG_IRQSOFF_TRACER is not set
930# CONFIG_SCHED_TRACER is not set
931# CONFIG_CONTEXT_SWITCH_TRACER is not set
932# CONFIG_SAMPLES is not set
933CONFIG_HAVE_ARCH_KGDB=y
934# CONFIG_KGDB is not set
935# CONFIG_DEBUG_USER is not set
936# CONFIG_DEBUG_ERRORS is not set
937# CONFIG_DEBUG_STACK_USAGE is not set
938CONFIG_DEBUG_LL=y
939# CONFIG_DEBUG_ICEDCC is not set
940
941#
942# Security options
943#
944# CONFIG_KEYS is not set
945# CONFIG_SECURITY is not set
946# CONFIG_SECURITY_FILE_CAPABILITIES is not set
947CONFIG_CRYPTO=y
948
949#
950# Crypto core or helper
951#
952CONFIG_CRYPTO_ALGAPI=y
953CONFIG_CRYPTO_BLKCIPHER=y
954CONFIG_CRYPTO_MANAGER=y
955# CONFIG_CRYPTO_GF128MUL is not set
956# CONFIG_CRYPTO_NULL is not set
957# CONFIG_CRYPTO_CRYPTD is not set
958# CONFIG_CRYPTO_AUTHENC is not set
959# CONFIG_CRYPTO_TEST is not set
960
961#
962# Authenticated Encryption with Associated Data
963#
964# CONFIG_CRYPTO_CCM is not set
965# CONFIG_CRYPTO_GCM is not set
966# CONFIG_CRYPTO_SEQIV is not set
967
968#
969# Block modes
970#
971CONFIG_CRYPTO_CBC=y
972# CONFIG_CRYPTO_CTR is not set
973# CONFIG_CRYPTO_CTS is not set
974CONFIG_CRYPTO_ECB=m
975# CONFIG_CRYPTO_LRW is not set
976CONFIG_CRYPTO_PCBC=m
977# CONFIG_CRYPTO_XTS is not set
978
979#
980# Hash modes
981#
982# CONFIG_CRYPTO_HMAC is not set
983# CONFIG_CRYPTO_XCBC is not set
984
985#
986# Digest
987#
988# CONFIG_CRYPTO_CRC32C is not set
989# CONFIG_CRYPTO_MD4 is not set
990CONFIG_CRYPTO_MD5=y
991# CONFIG_CRYPTO_MICHAEL_MIC is not set
992# CONFIG_CRYPTO_RMD128 is not set
993# CONFIG_CRYPTO_RMD160 is not set
994# CONFIG_CRYPTO_RMD256 is not set
995# CONFIG_CRYPTO_RMD320 is not set
996# CONFIG_CRYPTO_SHA1 is not set
997# CONFIG_CRYPTO_SHA256 is not set
998# CONFIG_CRYPTO_SHA512 is not set
999# CONFIG_CRYPTO_TGR192 is not set
1000# CONFIG_CRYPTO_WP512 is not set
1001
1002#
1003# Ciphers
1004#
1005# CONFIG_CRYPTO_AES is not set
1006# CONFIG_CRYPTO_ANUBIS is not set
1007# CONFIG_CRYPTO_ARC4 is not set
1008# CONFIG_CRYPTO_BLOWFISH is not set
1009# CONFIG_CRYPTO_CAMELLIA is not set
1010# CONFIG_CRYPTO_CAST5 is not set
1011# CONFIG_CRYPTO_CAST6 is not set
1012CONFIG_CRYPTO_DES=y
1013# CONFIG_CRYPTO_FCRYPT is not set
1014# CONFIG_CRYPTO_KHAZAD is not set
1015# CONFIG_CRYPTO_SALSA20 is not set
1016# CONFIG_CRYPTO_SEED is not set
1017# CONFIG_CRYPTO_SERPENT is not set
1018# CONFIG_CRYPTO_TEA is not set
1019# CONFIG_CRYPTO_TWOFISH is not set
1020
1021#
1022# Compression
1023#
1024# CONFIG_CRYPTO_DEFLATE is not set
1025# CONFIG_CRYPTO_LZO is not set
1026CONFIG_CRYPTO_HW=y
1027
1028#
1029# Library routines
1030#
1031CONFIG_BITREVERSE=y
1032# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1033# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1034CONFIG_CRC_CCITT=y
1035# CONFIG_CRC16 is not set
1036CONFIG_CRC_T10DIF=y
1037# CONFIG_CRC_ITU_T is not set
1038CONFIG_CRC32=y
1039# CONFIG_CRC7 is not set
1040CONFIG_LIBCRC32C=y
1041CONFIG_PLIST=y
1042CONFIG_HAS_IOMEM=y
1043CONFIG_HAS_IOPORT=y
1044CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/overo_defconfig b/arch/arm/configs/overo_defconfig
new file mode 100644
index 000000000000..49200967a153
--- /dev/null
+++ b/arch/arm/configs/overo_defconfig
@@ -0,0 +1,1885 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc8
4# Fri Oct 3 11:50:34 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_OPROFILE_ARMV7=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=""
39CONFIG_LOCALVERSION_AUTO=y
40CONFIG_SWAP=y
41CONFIG_SYSVIPC=y
42CONFIG_SYSVIPC_SYSCTL=y
43# CONFIG_POSIX_MQUEUE is not set
44CONFIG_BSD_PROCESS_ACCT=y
45# CONFIG_BSD_PROCESS_ACCT_V3 is not set
46# CONFIG_TASKSTATS is not set
47# CONFIG_AUDIT is not set
48CONFIG_IKCONFIG=y
49CONFIG_IKCONFIG_PROC=y
50CONFIG_LOG_BUF_SHIFT=14
51# CONFIG_CGROUPS is not set
52CONFIG_GROUP_SCHED=y
53CONFIG_FAIR_GROUP_SCHED=y
54# CONFIG_RT_GROUP_SCHED is not set
55CONFIG_USER_SCHED=y
56# CONFIG_CGROUP_SCHED is not set
57CONFIG_SYSFS_DEPRECATED=y
58CONFIG_SYSFS_DEPRECATED_V2=y
59# CONFIG_RELAY is not set
60# CONFIG_NAMESPACES is not set
61CONFIG_BLK_DEV_INITRD=y
62CONFIG_INITRAMFS_SOURCE=""
63CONFIG_CC_OPTIMIZE_FOR_SIZE=y
64CONFIG_SYSCTL=y
65CONFIG_EMBEDDED=y
66CONFIG_UID16=y
67# CONFIG_SYSCTL_SYSCALL is not set
68CONFIG_KALLSYMS=y
69# CONFIG_KALLSYMS_ALL is not set
70# CONFIG_KALLSYMS_EXTRA_PASS is not set
71CONFIG_HOTPLUG=y
72CONFIG_PRINTK=y
73CONFIG_BUG=y
74# CONFIG_ELF_CORE is not set
75# CONFIG_COMPAT_BRK is not set
76CONFIG_BASE_FULL=y
77CONFIG_FUTEX=y
78CONFIG_ANON_INODES=y
79CONFIG_EPOLL=y
80CONFIG_SIGNALFD=y
81CONFIG_TIMERFD=y
82CONFIG_EVENTFD=y
83CONFIG_SHMEM=y
84CONFIG_VM_EVENT_COUNTERS=y
85CONFIG_SLUB_DEBUG=y
86# CONFIG_SLAB is not set
87CONFIG_SLUB=y
88# CONFIG_SLOB is not set
89CONFIG_PROFILING=y
90# CONFIG_MARKERS is not set
91CONFIG_OPROFILE=y
92CONFIG_HAVE_OPROFILE=y
93# CONFIG_KPROBES is not set
94# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
95# CONFIG_HAVE_IOREMAP_PROT is not set
96CONFIG_HAVE_KPROBES=y
97CONFIG_HAVE_KRETPROBES=y
98# CONFIG_HAVE_ARCH_TRACEHOOK is not set
99# CONFIG_HAVE_DMA_ATTRS is not set
100# CONFIG_USE_GENERIC_SMP_HELPERS is not set
101CONFIG_HAVE_CLK=y
102CONFIG_PROC_PAGE_MONITOR=y
103CONFIG_HAVE_GENERIC_DMA_COHERENT=y
104CONFIG_SLABINFO=y
105CONFIG_RT_MUTEXES=y
106# CONFIG_TINY_SHMEM is not set
107CONFIG_BASE_SMALL=0
108CONFIG_MODULES=y
109# CONFIG_MODULE_FORCE_LOAD is not set
110CONFIG_MODULE_UNLOAD=y
111CONFIG_MODULE_FORCE_UNLOAD=y
112CONFIG_MODVERSIONS=y
113CONFIG_MODULE_SRCVERSION_ALL=y
114CONFIG_KMOD=y
115CONFIG_BLOCK=y
116CONFIG_LBD=y
117# CONFIG_BLK_DEV_IO_TRACE is not set
118CONFIG_LSF=y
119# CONFIG_BLK_DEV_BSG is not set
120# CONFIG_BLK_DEV_INTEGRITY is not set
121
122#
123# IO Schedulers
124#
125CONFIG_IOSCHED_NOOP=y
126CONFIG_IOSCHED_AS=y
127CONFIG_IOSCHED_DEADLINE=y
128CONFIG_IOSCHED_CFQ=y
129# CONFIG_DEFAULT_AS is not set
130# CONFIG_DEFAULT_DEADLINE is not set
131CONFIG_DEFAULT_CFQ=y
132# CONFIG_DEFAULT_NOOP is not set
133CONFIG_DEFAULT_IOSCHED="cfq"
134CONFIG_CLASSIC_RCU=y
135
136#
137# System Type
138#
139# CONFIG_ARCH_AAEC2000 is not set
140# CONFIG_ARCH_INTEGRATOR is not set
141# CONFIG_ARCH_REALVIEW is not set
142# CONFIG_ARCH_VERSATILE is not set
143# CONFIG_ARCH_AT91 is not set
144# CONFIG_ARCH_CLPS7500 is not set
145# CONFIG_ARCH_CLPS711X is not set
146# CONFIG_ARCH_EBSA110 is not set
147# CONFIG_ARCH_EP93XX is not set
148# CONFIG_ARCH_FOOTBRIDGE is not set
149# CONFIG_ARCH_NETX is not set
150# CONFIG_ARCH_H720X is not set
151# CONFIG_ARCH_IMX is not set
152# CONFIG_ARCH_IOP13XX is not set
153# CONFIG_ARCH_IOP32X is not set
154# CONFIG_ARCH_IOP33X is not set
155# CONFIG_ARCH_IXP23XX is not set
156# CONFIG_ARCH_IXP2000 is not set
157# CONFIG_ARCH_IXP4XX is not set
158# CONFIG_ARCH_L7200 is not set
159# CONFIG_ARCH_KIRKWOOD is not set
160# CONFIG_ARCH_KS8695 is not set
161# CONFIG_ARCH_NS9XXX is not set
162# CONFIG_ARCH_LOKI is not set
163# CONFIG_ARCH_MV78XX0 is not set
164# CONFIG_ARCH_MXC is not set
165# CONFIG_ARCH_ORION5X is not set
166# CONFIG_ARCH_PNX4008 is not set
167# CONFIG_ARCH_PXA is not set
168# CONFIG_ARCH_RPC is not set
169# CONFIG_ARCH_SA1100 is not set
170# CONFIG_ARCH_S3C2410 is not set
171# CONFIG_ARCH_SHARK is not set
172# CONFIG_ARCH_LH7A40X is not set
173# CONFIG_ARCH_DAVINCI is not set
174CONFIG_ARCH_OMAP=y
175# CONFIG_ARCH_MSM7X00A is not set
176
177#
178# TI OMAP Implementations
179#
180CONFIG_ARCH_OMAP_OTG=y
181# CONFIG_ARCH_OMAP1 is not set
182# CONFIG_ARCH_OMAP2 is not set
183CONFIG_ARCH_OMAP3=y
184
185#
186# OMAP Feature Selections
187#
188# CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
189# CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
190# CONFIG_OMAP_RESET_CLOCKS is not set
191# CONFIG_OMAP_MUX is not set
192CONFIG_OMAP_MCBSP=y
193# CONFIG_OMAP_MPU_TIMER is not set
194CONFIG_OMAP_32K_TIMER=y
195CONFIG_OMAP_32K_TIMER_HZ=128
196CONFIG_OMAP_DM_TIMER=y
197# CONFIG_OMAP_LL_DEBUG_UART1 is not set
198# CONFIG_OMAP_LL_DEBUG_UART2 is not set
199CONFIG_OMAP_LL_DEBUG_UART3=y
200CONFIG_ARCH_OMAP34XX=y
201CONFIG_ARCH_OMAP3430=y
202
203#
204# OMAP Board Type
205#
206# CONFIG_MACH_OMAP3_BEAGLE is not set
207CONFIG_MACH_OVERO=y
208
209#
210# Boot options
211#
212
213#
214# Power management
215#
216
217#
218# Processor Type
219#
220CONFIG_CPU_32=y
221CONFIG_CPU_32v6K=y
222CONFIG_CPU_V7=y
223CONFIG_CPU_32v7=y
224CONFIG_CPU_ABRT_EV7=y
225CONFIG_CPU_PABRT_IFAR=y
226CONFIG_CPU_CACHE_V7=y
227CONFIG_CPU_CACHE_VIPT=y
228CONFIG_CPU_COPY_V6=y
229CONFIG_CPU_TLB_V7=y
230CONFIG_CPU_HAS_ASID=y
231CONFIG_CPU_CP15=y
232CONFIG_CPU_CP15_MMU=y
233
234#
235# Processor Features
236#
237CONFIG_ARM_THUMB=y
238CONFIG_ARM_THUMBEE=y
239# CONFIG_CPU_ICACHE_DISABLE is not set
240# CONFIG_CPU_DCACHE_DISABLE is not set
241# CONFIG_CPU_BPREDICT_DISABLE is not set
242CONFIG_HAS_TLS_REG=y
243# CONFIG_OUTER_CACHE is not set
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
257CONFIG_HIGH_RES_TIMERS=y
258CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
259CONFIG_VMSPLIT_3G=y
260# CONFIG_VMSPLIT_2G is not set
261# CONFIG_VMSPLIT_1G is not set
262CONFIG_PAGE_OFFSET=0xC0000000
263# CONFIG_PREEMPT is not set
264CONFIG_HZ=128
265CONFIG_AEABI=y
266# CONFIG_OABI_COMPAT is not set
267CONFIG_ARCH_FLATMEM_HAS_HOLES=y
268# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
269CONFIG_SELECT_MEMORY_MODEL=y
270CONFIG_FLATMEM_MANUAL=y
271# CONFIG_DISCONTIGMEM_MANUAL is not set
272# CONFIG_SPARSEMEM_MANUAL is not set
273CONFIG_FLATMEM=y
274CONFIG_FLAT_NODE_MEM_MAP=y
275# CONFIG_SPARSEMEM_STATIC is not set
276# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
277CONFIG_PAGEFLAGS_EXTENDED=y
278CONFIG_SPLIT_PTLOCK_CPUS=4
279# CONFIG_RESOURCES_64BIT is not set
280CONFIG_ZONE_DMA_FLAG=1
281CONFIG_BOUNCE=y
282CONFIG_VIRT_TO_BUS=y
283CONFIG_LEDS=y
284CONFIG_ALIGNMENT_TRAP=y
285
286#
287# Boot options
288#
289CONFIG_ZBOOT_ROM_TEXT=0x0
290CONFIG_ZBOOT_ROM_BSS=0x0
291CONFIG_CMDLINE=" debug "
292# CONFIG_XIP_KERNEL is not set
293CONFIG_KEXEC=y
294CONFIG_ATAGS_PROC=y
295
296#
297# CPU Power Management
298#
299CONFIG_CPU_FREQ=y
300CONFIG_CPU_FREQ_TABLE=y
301# CONFIG_CPU_FREQ_DEBUG is not set
302CONFIG_CPU_FREQ_STAT=y
303CONFIG_CPU_FREQ_STAT_DETAILS=y
304CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
305# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
306# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
307# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
308# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
309CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
310# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
311CONFIG_CPU_FREQ_GOV_USERSPACE=y
312CONFIG_CPU_FREQ_GOV_ONDEMAND=y
313# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
314# CONFIG_CPU_IDLE is not set
315
316#
317# Floating point emulation
318#
319
320#
321# At least one emulation must be selected
322#
323CONFIG_VFP=y
324CONFIG_VFPv3=y
325CONFIG_NEON=y
326
327#
328# Userspace binary formats
329#
330CONFIG_BINFMT_ELF=y
331CONFIG_BINFMT_AOUT=m
332CONFIG_BINFMT_MISC=y
333
334#
335# Power management options
336#
337# CONFIG_PM is not set
338CONFIG_ARCH_SUSPEND_POSSIBLE=y
339CONFIG_NET=y
340
341#
342# Networking options
343#
344CONFIG_PACKET=y
345CONFIG_PACKET_MMAP=y
346CONFIG_UNIX=y
347CONFIG_XFRM=y
348# CONFIG_XFRM_USER is not set
349# CONFIG_XFRM_SUB_POLICY is not set
350# CONFIG_XFRM_MIGRATE is not set
351# CONFIG_XFRM_STATISTICS is not set
352CONFIG_NET_KEY=y
353# CONFIG_NET_KEY_MIGRATE is not set
354CONFIG_INET=y
355# CONFIG_IP_MULTICAST is not set
356# CONFIG_IP_ADVANCED_ROUTER is not set
357CONFIG_IP_FIB_HASH=y
358CONFIG_IP_PNP=y
359CONFIG_IP_PNP_DHCP=y
360CONFIG_IP_PNP_BOOTP=y
361CONFIG_IP_PNP_RARP=y
362# CONFIG_NET_IPIP is not set
363# CONFIG_NET_IPGRE is not set
364# CONFIG_ARPD is not set
365# CONFIG_SYN_COOKIES is not set
366# CONFIG_INET_AH is not set
367# CONFIG_INET_ESP is not set
368# CONFIG_INET_IPCOMP is not set
369# CONFIG_INET_XFRM_TUNNEL is not set
370CONFIG_INET_TUNNEL=m
371CONFIG_INET_XFRM_MODE_TRANSPORT=y
372CONFIG_INET_XFRM_MODE_TUNNEL=y
373CONFIG_INET_XFRM_MODE_BEET=y
374# CONFIG_INET_LRO is not set
375CONFIG_INET_DIAG=y
376CONFIG_INET_TCP_DIAG=y
377# CONFIG_TCP_CONG_ADVANCED is not set
378CONFIG_TCP_CONG_CUBIC=y
379CONFIG_DEFAULT_TCP_CONG="cubic"
380# CONFIG_TCP_MD5SIG is not set
381CONFIG_IPV6=m
382# CONFIG_IPV6_PRIVACY is not set
383# CONFIG_IPV6_ROUTER_PREF is not set
384# CONFIG_IPV6_OPTIMISTIC_DAD is not set
385# CONFIG_INET6_AH is not set
386# CONFIG_INET6_ESP is not set
387# CONFIG_INET6_IPCOMP is not set
388# CONFIG_IPV6_MIP6 is not set
389# CONFIG_INET6_XFRM_TUNNEL is not set
390# CONFIG_INET6_TUNNEL is not set
391CONFIG_INET6_XFRM_MODE_TRANSPORT=m
392CONFIG_INET6_XFRM_MODE_TUNNEL=m
393CONFIG_INET6_XFRM_MODE_BEET=m
394# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
395CONFIG_IPV6_SIT=m
396CONFIG_IPV6_NDISC_NODETYPE=y
397# CONFIG_IPV6_TUNNEL is not set
398# CONFIG_IPV6_MULTIPLE_TABLES is not set
399# CONFIG_IPV6_MROUTE is not set
400# CONFIG_NETWORK_SECMARK is not set
401# CONFIG_NETFILTER is not set
402# CONFIG_IP_DCCP is not set
403# CONFIG_IP_SCTP is not set
404# CONFIG_TIPC is not set
405# CONFIG_ATM is not set
406# CONFIG_BRIDGE is not set
407# CONFIG_VLAN_8021Q is not set
408# CONFIG_DECNET is not set
409# CONFIG_LLC2 is not set
410# CONFIG_IPX is not set
411# CONFIG_ATALK is not set
412# CONFIG_X25 is not set
413# CONFIG_LAPB is not set
414# CONFIG_ECONET is not set
415# CONFIG_WAN_ROUTER is not set
416# CONFIG_NET_SCHED is not set
417
418#
419# Network testing
420#
421# CONFIG_NET_PKTGEN is not set
422# CONFIG_HAMRADIO is not set
423# CONFIG_CAN is not set
424# CONFIG_IRDA is not set
425CONFIG_BT=y
426CONFIG_BT_L2CAP=y
427CONFIG_BT_SCO=y
428CONFIG_BT_RFCOMM=y
429CONFIG_BT_RFCOMM_TTY=y
430CONFIG_BT_BNEP=y
431CONFIG_BT_BNEP_MC_FILTER=y
432CONFIG_BT_BNEP_PROTO_FILTER=y
433CONFIG_BT_HIDP=y
434
435#
436# Bluetooth device drivers
437#
438CONFIG_BT_HCIUSB=m
439CONFIG_BT_HCIUSB_SCO=y
440# CONFIG_BT_HCIBTUSB is not set
441# CONFIG_BT_HCIBTSDIO is not set
442CONFIG_BT_HCIUART=y
443CONFIG_BT_HCIUART_H4=y
444CONFIG_BT_HCIUART_BCSP=y
445# CONFIG_BT_HCIUART_LL is not set
446CONFIG_BT_HCIBCM203X=y
447CONFIG_BT_HCIBPA10X=y
448# CONFIG_BT_HCIBFUSB is not set
449# CONFIG_BT_HCIVHCI is not set
450# CONFIG_AF_RXRPC is not set
451
452#
453# Wireless
454#
455CONFIG_CFG80211=y
456CONFIG_NL80211=y
457CONFIG_WIRELESS_EXT=y
458CONFIG_WIRELESS_EXT_SYSFS=y
459CONFIG_MAC80211=y
460
461#
462# Rate control algorithm selection
463#
464CONFIG_MAC80211_RC_PID=y
465CONFIG_MAC80211_RC_DEFAULT_PID=y
466CONFIG_MAC80211_RC_DEFAULT="pid"
467# CONFIG_MAC80211_MESH is not set
468CONFIG_MAC80211_LEDS=y
469# CONFIG_MAC80211_DEBUGFS is not set
470# CONFIG_MAC80211_DEBUG_MENU is not set
471CONFIG_IEEE80211=y
472# CONFIG_IEEE80211_DEBUG is not set
473CONFIG_IEEE80211_CRYPT_WEP=y
474CONFIG_IEEE80211_CRYPT_CCMP=y
475CONFIG_IEEE80211_CRYPT_TKIP=y
476# CONFIG_RFKILL is not set
477# CONFIG_NET_9P is not set
478
479#
480# Device Drivers
481#
482
483#
484# Generic Driver Options
485#
486CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
487CONFIG_STANDALONE=y
488CONFIG_PREVENT_FIRMWARE_BUILD=y
489CONFIG_FW_LOADER=y
490CONFIG_FIRMWARE_IN_KERNEL=y
491CONFIG_EXTRA_FIRMWARE=""
492# CONFIG_DEBUG_DRIVER is not set
493# CONFIG_DEBUG_DEVRES is not set
494# CONFIG_SYS_HYPERVISOR is not set
495# CONFIG_CONNECTOR is not set
496CONFIG_MTD=y
497# CONFIG_MTD_DEBUG is not set
498CONFIG_MTD_CONCAT=y
499CONFIG_MTD_PARTITIONS=y
500# CONFIG_MTD_REDBOOT_PARTS is not set
501# CONFIG_MTD_CMDLINE_PARTS is not set
502# CONFIG_MTD_AFS_PARTS is not set
503# CONFIG_MTD_AR7_PARTS is not set
504
505#
506# User Modules And Translation Layers
507#
508CONFIG_MTD_CHAR=y
509CONFIG_MTD_BLKDEVS=y
510CONFIG_MTD_BLOCK=y
511# CONFIG_FTL is not set
512# CONFIG_NFTL is not set
513# CONFIG_INFTL is not set
514# CONFIG_RFD_FTL is not set
515# CONFIG_SSFDC is not set
516# CONFIG_MTD_OOPS is not set
517
518#
519# RAM/ROM/Flash chip drivers
520#
521# CONFIG_MTD_CFI is not set
522# CONFIG_MTD_JEDECPROBE is not set
523CONFIG_MTD_MAP_BANK_WIDTH_1=y
524CONFIG_MTD_MAP_BANK_WIDTH_2=y
525CONFIG_MTD_MAP_BANK_WIDTH_4=y
526# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
527# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
528# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
529CONFIG_MTD_CFI_I1=y
530CONFIG_MTD_CFI_I2=y
531# CONFIG_MTD_CFI_I4 is not set
532# CONFIG_MTD_CFI_I8 is not set
533# CONFIG_MTD_RAM is not set
534# CONFIG_MTD_ROM is not set
535# CONFIG_MTD_ABSENT is not set
536
537#
538# Mapping drivers for chip access
539#
540# CONFIG_MTD_COMPLEX_MAPPINGS is not set
541# CONFIG_MTD_PLATRAM is not set
542
543#
544# Self-contained MTD device drivers
545#
546# CONFIG_MTD_DATAFLASH is not set
547# CONFIG_MTD_M25P80 is not set
548# CONFIG_MTD_SLRAM is not set
549# CONFIG_MTD_PHRAM is not set
550# CONFIG_MTD_MTDRAM is not set
551# CONFIG_MTD_BLOCK2MTD is not set
552
553#
554# Disk-On-Chip Device Drivers
555#
556# CONFIG_MTD_DOC2000 is not set
557# CONFIG_MTD_DOC2001 is not set
558# CONFIG_MTD_DOC2001PLUS is not set
559CONFIG_MTD_NAND=y
560# CONFIG_MTD_NAND_VERIFY_WRITE is not set
561# CONFIG_MTD_NAND_ECC_SMC is not set
562# CONFIG_MTD_NAND_MUSEUM_IDS is not set
563CONFIG_MTD_NAND_IDS=y
564# CONFIG_MTD_NAND_DISKONCHIP is not set
565# CONFIG_MTD_NAND_NANDSIM is not set
566# CONFIG_MTD_NAND_PLATFORM is not set
567# CONFIG_MTD_ALAUDA is not set
568# CONFIG_MTD_ONENAND is not set
569
570#
571# UBI - Unsorted block images
572#
573# CONFIG_MTD_UBI is not set
574# CONFIG_PARPORT is not set
575CONFIG_BLK_DEV=y
576# CONFIG_BLK_DEV_COW_COMMON is not set
577CONFIG_BLK_DEV_LOOP=y
578CONFIG_BLK_DEV_CRYPTOLOOP=m
579# CONFIG_BLK_DEV_NBD is not set
580# CONFIG_BLK_DEV_UB is not set
581CONFIG_BLK_DEV_RAM=y
582CONFIG_BLK_DEV_RAM_COUNT=16
583CONFIG_BLK_DEV_RAM_SIZE=16384
584# CONFIG_BLK_DEV_XIP is not set
585CONFIG_CDROM_PKTCDVD=m
586CONFIG_CDROM_PKTCDVD_BUFFERS=8
587# CONFIG_CDROM_PKTCDVD_WCACHE is not set
588# CONFIG_ATA_OVER_ETH is not set
589CONFIG_MISC_DEVICES=y
590CONFIG_EEPROM_93CX6=m
591# CONFIG_ENCLOSURE_SERVICES is not set
592CONFIG_HAVE_IDE=y
593# CONFIG_IDE is not set
594
595#
596# SCSI device support
597#
598CONFIG_RAID_ATTRS=m
599CONFIG_SCSI=y
600CONFIG_SCSI_DMA=y
601# CONFIG_SCSI_TGT is not set
602# CONFIG_SCSI_NETLINK is not set
603CONFIG_SCSI_PROC_FS=y
604
605#
606# SCSI support type (disk, tape, CD-ROM)
607#
608CONFIG_BLK_DEV_SD=y
609# CONFIG_CHR_DEV_ST is not set
610# CONFIG_CHR_DEV_OSST is not set
611# CONFIG_BLK_DEV_SR is not set
612CONFIG_CHR_DEV_SG=m
613# CONFIG_CHR_DEV_SCH is not set
614
615#
616# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
617#
618CONFIG_SCSI_MULTI_LUN=y
619# CONFIG_SCSI_CONSTANTS is not set
620# CONFIG_SCSI_LOGGING is not set
621# CONFIG_SCSI_SCAN_ASYNC is not set
622CONFIG_SCSI_WAIT_SCAN=m
623
624#
625# SCSI Transports
626#
627# CONFIG_SCSI_SPI_ATTRS is not set
628# CONFIG_SCSI_FC_ATTRS is not set
629# CONFIG_SCSI_ISCSI_ATTRS is not set
630# CONFIG_SCSI_SAS_LIBSAS is not set
631# CONFIG_SCSI_SRP_ATTRS is not set
632CONFIG_SCSI_LOWLEVEL=y
633# CONFIG_ISCSI_TCP is not set
634# CONFIG_SCSI_DEBUG is not set
635# CONFIG_SCSI_DH is not set
636# CONFIG_ATA is not set
637CONFIG_MD=y
638CONFIG_BLK_DEV_MD=m
639CONFIG_MD_LINEAR=m
640CONFIG_MD_RAID0=m
641CONFIG_MD_RAID1=m
642CONFIG_MD_RAID10=m
643CONFIG_MD_RAID456=m
644CONFIG_MD_RAID5_RESHAPE=y
645CONFIG_MD_MULTIPATH=m
646CONFIG_MD_FAULTY=m
647CONFIG_BLK_DEV_DM=m
648# CONFIG_DM_DEBUG is not set
649CONFIG_DM_CRYPT=m
650CONFIG_DM_SNAPSHOT=m
651CONFIG_DM_MIRROR=m
652CONFIG_DM_ZERO=m
653CONFIG_DM_MULTIPATH=m
654CONFIG_DM_DELAY=m
655# CONFIG_DM_UEVENT is not set
656CONFIG_NETDEVICES=y
657CONFIG_DUMMY=m
658# CONFIG_BONDING is not set
659# CONFIG_MACVLAN is not set
660# CONFIG_EQUALIZER is not set
661CONFIG_TUN=m
662# CONFIG_VETH is not set
663# CONFIG_NET_ETHERNET is not set
664CONFIG_MII=y
665# CONFIG_NETDEV_1000 is not set
666# CONFIG_NETDEV_10000 is not set
667
668#
669# Wireless LAN
670#
671# CONFIG_WLAN_PRE80211 is not set
672CONFIG_WLAN_80211=y
673CONFIG_LIBERTAS=y
674CONFIG_LIBERTAS_USB=y
675CONFIG_LIBERTAS_SDIO=y
676CONFIG_LIBERTAS_DEBUG=y
677CONFIG_USB_ZD1201=m
678# CONFIG_USB_NET_RNDIS_WLAN is not set
679CONFIG_RTL8187=m
680# CONFIG_MAC80211_HWSIM is not set
681CONFIG_P54_COMMON=m
682CONFIG_P54_USB=m
683# CONFIG_IWLWIFI_LEDS is not set
684CONFIG_HOSTAP=m
685CONFIG_HOSTAP_FIRMWARE=y
686CONFIG_HOSTAP_FIRMWARE_NVRAM=y
687# CONFIG_B43 is not set
688# CONFIG_B43LEGACY is not set
689# CONFIG_ZD1211RW is not set
690# CONFIG_RT2X00 is not set
691
692#
693# USB Network Adapters
694#
695CONFIG_USB_CATC=m
696CONFIG_USB_KAWETH=m
697CONFIG_USB_PEGASUS=m
698CONFIG_USB_RTL8150=m
699CONFIG_USB_USBNET=y
700CONFIG_USB_NET_AX8817X=y
701CONFIG_USB_NET_CDCETHER=y
702CONFIG_USB_NET_DM9601=m
703CONFIG_USB_NET_GL620A=m
704CONFIG_USB_NET_NET1080=m
705CONFIG_USB_NET_PLUSB=m
706CONFIG_USB_NET_MCS7830=m
707CONFIG_USB_NET_RNDIS_HOST=m
708CONFIG_USB_NET_CDC_SUBSET=m
709CONFIG_USB_ALI_M5632=y
710CONFIG_USB_AN2720=y
711CONFIG_USB_BELKIN=y
712CONFIG_USB_ARMLINUX=y
713CONFIG_USB_EPSON2888=y
714CONFIG_USB_KC2190=y
715CONFIG_USB_NET_ZAURUS=m
716# CONFIG_WAN is not set
717CONFIG_PPP=m
718# CONFIG_PPP_MULTILINK is not set
719# CONFIG_PPP_FILTER is not set
720CONFIG_PPP_ASYNC=m
721CONFIG_PPP_SYNC_TTY=m
722CONFIG_PPP_DEFLATE=m
723CONFIG_PPP_BSDCOMP=m
724CONFIG_PPP_MPPE=m
725CONFIG_PPPOE=m
726# CONFIG_PPPOL2TP is not set
727# CONFIG_SLIP is not set
728CONFIG_SLHC=m
729# CONFIG_NETCONSOLE is not set
730# CONFIG_NETPOLL is not set
731# CONFIG_NET_POLL_CONTROLLER is not set
732# CONFIG_ISDN is not set
733
734#
735# Input device support
736#
737CONFIG_INPUT=y
738# CONFIG_INPUT_FF_MEMLESS is not set
739# CONFIG_INPUT_POLLDEV is not set
740
741#
742# Userland interfaces
743#
744CONFIG_INPUT_MOUSEDEV=y
745CONFIG_INPUT_MOUSEDEV_PSAUX=y
746CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
747CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
748# CONFIG_INPUT_JOYDEV is not set
749CONFIG_INPUT_EVDEV=y
750# CONFIG_INPUT_EVBUG is not set
751
752#
753# Input Device Drivers
754#
755CONFIG_INPUT_KEYBOARD=y
756# CONFIG_KEYBOARD_ATKBD is not set
757# CONFIG_KEYBOARD_SUNKBD is not set
758# CONFIG_KEYBOARD_LKKBD is not set
759# CONFIG_KEYBOARD_XTKBD is not set
760# CONFIG_KEYBOARD_NEWTON is not set
761# CONFIG_KEYBOARD_STOWAWAY is not set
762# CONFIG_KEYBOARD_GPIO is not set
763CONFIG_INPUT_MOUSE=y
764CONFIG_MOUSE_PS2=y
765CONFIG_MOUSE_PS2_ALPS=y
766CONFIG_MOUSE_PS2_LOGIPS2PP=y
767CONFIG_MOUSE_PS2_SYNAPTICS=y
768CONFIG_MOUSE_PS2_LIFEBOOK=y
769CONFIG_MOUSE_PS2_TRACKPOINT=y
770# CONFIG_MOUSE_PS2_TOUCHKIT is not set
771# CONFIG_MOUSE_SERIAL is not set
772# CONFIG_MOUSE_APPLETOUCH is not set
773# CONFIG_MOUSE_BCM5974 is not set
774# CONFIG_MOUSE_VSXXXAA is not set
775# CONFIG_MOUSE_GPIO is not set
776# CONFIG_INPUT_JOYSTICK is not set
777# CONFIG_INPUT_TABLET is not set
778# CONFIG_INPUT_TOUCHSCREEN is not set
779# CONFIG_INPUT_MISC is not set
780
781#
782# Hardware I/O ports
783#
784CONFIG_SERIO=y
785CONFIG_SERIO_SERPORT=y
786CONFIG_SERIO_LIBPS2=y
787# CONFIG_SERIO_RAW is not set
788# CONFIG_GAMEPORT is not set
789
790#
791# Character devices
792#
793CONFIG_VT=y
794CONFIG_CONSOLE_TRANSLATIONS=y
795CONFIG_VT_CONSOLE=y
796CONFIG_HW_CONSOLE=y
797CONFIG_VT_HW_CONSOLE_BINDING=y
798CONFIG_DEVKMEM=y
799# CONFIG_SERIAL_NONSTANDARD is not set
800
801#
802# Serial drivers
803#
804CONFIG_SERIAL_8250=y
805CONFIG_SERIAL_8250_CONSOLE=y
806CONFIG_SERIAL_8250_NR_UARTS=32
807CONFIG_SERIAL_8250_RUNTIME_UARTS=4
808CONFIG_SERIAL_8250_EXTENDED=y
809CONFIG_SERIAL_8250_MANY_PORTS=y
810CONFIG_SERIAL_8250_SHARE_IRQ=y
811CONFIG_SERIAL_8250_DETECT_IRQ=y
812CONFIG_SERIAL_8250_RSA=y
813
814#
815# Non-8250 serial port support
816#
817CONFIG_SERIAL_CORE=y
818CONFIG_SERIAL_CORE_CONSOLE=y
819CONFIG_UNIX98_PTYS=y
820# CONFIG_LEGACY_PTYS is not set
821# CONFIG_IPMI_HANDLER is not set
822CONFIG_HW_RANDOM=y
823# CONFIG_NVRAM is not set
824# CONFIG_R3964 is not set
825# CONFIG_RAW_DRIVER is not set
826# CONFIG_TCG_TPM is not set
827CONFIG_I2C=y
828CONFIG_I2C_BOARDINFO=y
829CONFIG_I2C_CHARDEV=y
830CONFIG_I2C_HELPER_AUTO=y
831
832#
833# I2C Hardware Bus support
834#
835
836#
837# I2C system bus drivers (mostly embedded / system-on-chip)
838#
839# CONFIG_I2C_GPIO is not set
840# CONFIG_I2C_OCORES is not set
841CONFIG_I2C_OMAP=y
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_PCA_PLATFORM is not set
855# CONFIG_I2C_STUB is not set
856
857#
858# Miscellaneous I2C Chip support
859#
860# CONFIG_DS1682 is not set
861# CONFIG_AT24 is not set
862CONFIG_SENSORS_EEPROM=y
863# CONFIG_SENSORS_PCF8574 is not set
864# CONFIG_PCF8575 is not set
865# CONFIG_SENSORS_PCA9539 is not set
866# CONFIG_SENSORS_PCF8591 is not set
867# CONFIG_ISP1301_OMAP is not set
868# CONFIG_TPS65010 is not set
869# CONFIG_SENSORS_MAX6875 is not set
870# CONFIG_SENSORS_TSL2550 is not set
871# CONFIG_I2C_DEBUG_CORE is not set
872# CONFIG_I2C_DEBUG_ALGO is not set
873# CONFIG_I2C_DEBUG_BUS is not set
874# CONFIG_I2C_DEBUG_CHIP is not set
875CONFIG_SPI=y
876# CONFIG_SPI_DEBUG is not set
877CONFIG_SPI_MASTER=y
878
879#
880# SPI Master Controller Drivers
881#
882# CONFIG_SPI_BITBANG is not set
883CONFIG_SPI_OMAP24XX=y
884
885#
886# SPI Protocol Masters
887#
888# CONFIG_SPI_AT25 is not set
889# CONFIG_SPI_SPIDEV is not set
890# CONFIG_SPI_TLE62X0 is not set
891CONFIG_ARCH_REQUIRE_GPIOLIB=y
892CONFIG_GPIOLIB=y
893CONFIG_DEBUG_GPIO=y
894CONFIG_GPIO_SYSFS=y
895
896#
897# I2C GPIO expanders:
898#
899# CONFIG_GPIO_MAX732X is not set
900# CONFIG_GPIO_PCA953X is not set
901# CONFIG_GPIO_PCF857X is not set
902
903#
904# PCI GPIO expanders:
905#
906
907#
908# SPI GPIO expanders:
909#
910# CONFIG_GPIO_MAX7301 is not set
911# CONFIG_GPIO_MCP23S08 is not set
912# CONFIG_W1 is not set
913CONFIG_POWER_SUPPLY=m
914# CONFIG_POWER_SUPPLY_DEBUG is not set
915# CONFIG_PDA_POWER is not set
916# CONFIG_BATTERY_DS2760 is not set
917CONFIG_HWMON=y
918# CONFIG_HWMON_VID is not set
919# CONFIG_SENSORS_AD7414 is not set
920# CONFIG_SENSORS_AD7418 is not set
921# CONFIG_SENSORS_ADCXX is not set
922# CONFIG_SENSORS_ADM1021 is not set
923# CONFIG_SENSORS_ADM1025 is not set
924# CONFIG_SENSORS_ADM1026 is not set
925# CONFIG_SENSORS_ADM1029 is not set
926# CONFIG_SENSORS_ADM1031 is not set
927# CONFIG_SENSORS_ADM9240 is not set
928# CONFIG_SENSORS_ADT7470 is not set
929# CONFIG_SENSORS_ADT7473 is not set
930# CONFIG_SENSORS_ATXP1 is not set
931# CONFIG_SENSORS_DS1621 is not set
932# CONFIG_SENSORS_F71805F is not set
933# CONFIG_SENSORS_F71882FG is not set
934# CONFIG_SENSORS_F75375S is not set
935# CONFIG_SENSORS_GL518SM is not set
936# CONFIG_SENSORS_GL520SM is not set
937# CONFIG_SENSORS_IT87 is not set
938# CONFIG_SENSORS_LM63 is not set
939# CONFIG_SENSORS_LM70 is not set
940# CONFIG_SENSORS_LM75 is not set
941# CONFIG_SENSORS_LM77 is not set
942# CONFIG_SENSORS_LM78 is not set
943# CONFIG_SENSORS_LM80 is not set
944# CONFIG_SENSORS_LM83 is not set
945# CONFIG_SENSORS_LM85 is not set
946# CONFIG_SENSORS_LM87 is not set
947# CONFIG_SENSORS_LM90 is not set
948# CONFIG_SENSORS_LM92 is not set
949# CONFIG_SENSORS_LM93 is not set
950# CONFIG_SENSORS_MAX1111 is not set
951# CONFIG_SENSORS_MAX1619 is not set
952# CONFIG_SENSORS_MAX6650 is not set
953# CONFIG_SENSORS_PC87360 is not set
954# CONFIG_SENSORS_PC87427 is not set
955# CONFIG_SENSORS_DME1737 is not set
956# CONFIG_SENSORS_SMSC47M1 is not set
957# CONFIG_SENSORS_SMSC47M192 is not set
958# CONFIG_SENSORS_SMSC47B397 is not set
959# CONFIG_SENSORS_ADS7828 is not set
960# CONFIG_SENSORS_THMC50 is not set
961# CONFIG_SENSORS_VT1211 is not set
962# CONFIG_SENSORS_W83781D is not set
963# CONFIG_SENSORS_W83791D is not set
964# CONFIG_SENSORS_W83792D is not set
965# CONFIG_SENSORS_W83793 is not set
966# CONFIG_SENSORS_W83L785TS is not set
967# CONFIG_SENSORS_W83L786NG is not set
968# CONFIG_SENSORS_W83627HF is not set
969# CONFIG_SENSORS_W83627EHF is not set
970# CONFIG_HWMON_DEBUG_CHIP is not set
971# CONFIG_THERMAL is not set
972# CONFIG_THERMAL_HWMON is not set
973CONFIG_WATCHDOG=y
974CONFIG_WATCHDOG_NOWAYOUT=y
975
976#
977# Watchdog Device Drivers
978#
979# CONFIG_SOFT_WATCHDOG is not set
980
981#
982# USB-based Watchdog Cards
983#
984# CONFIG_USBPCWATCHDOG is not set
985
986#
987# Sonics Silicon Backplane
988#
989CONFIG_SSB_POSSIBLE=y
990# CONFIG_SSB is not set
991
992#
993# Multifunction device drivers
994#
995# CONFIG_MFD_CORE is not set
996# CONFIG_MFD_SM501 is not set
997# CONFIG_HTC_EGPIO is not set
998# CONFIG_HTC_PASIC3 is not set
999# CONFIG_UCB1400_CORE is not set
1000# CONFIG_MFD_TMIO is not set
1001# CONFIG_MFD_T7L66XB is not set
1002# CONFIG_MFD_TC6387XB is not set
1003# CONFIG_MFD_TC6393XB is not set
1004
1005#
1006# Multimedia devices
1007#
1008
1009#
1010# Multimedia core support
1011#
1012CONFIG_VIDEO_DEV=m
1013CONFIG_VIDEO_V4L2_COMMON=m
1014CONFIG_VIDEO_ALLOW_V4L1=y
1015CONFIG_VIDEO_V4L1_COMPAT=y
1016CONFIG_DVB_CORE=m
1017CONFIG_VIDEO_MEDIA=m
1018
1019#
1020# Multimedia drivers
1021#
1022CONFIG_MEDIA_ATTACH=y
1023CONFIG_MEDIA_TUNER=m
1024# CONFIG_MEDIA_TUNER_CUSTOMIZE is not set
1025CONFIG_MEDIA_TUNER_SIMPLE=m
1026CONFIG_MEDIA_TUNER_TDA8290=m
1027CONFIG_MEDIA_TUNER_TDA827X=m
1028CONFIG_MEDIA_TUNER_TDA18271=m
1029CONFIG_MEDIA_TUNER_TDA9887=m
1030CONFIG_MEDIA_TUNER_TEA5761=m
1031CONFIG_MEDIA_TUNER_TEA5767=m
1032CONFIG_MEDIA_TUNER_MT20XX=m
1033CONFIG_MEDIA_TUNER_MT2060=m
1034CONFIG_MEDIA_TUNER_MT2266=m
1035CONFIG_MEDIA_TUNER_QT1010=m
1036CONFIG_MEDIA_TUNER_XC2028=m
1037CONFIG_MEDIA_TUNER_XC5000=m
1038CONFIG_MEDIA_TUNER_MXL5005S=m
1039CONFIG_VIDEO_V4L2=m
1040CONFIG_VIDEO_V4L1=m
1041CONFIG_VIDEO_TVEEPROM=m
1042CONFIG_VIDEO_TUNER=m
1043CONFIG_VIDEO_CAPTURE_DRIVERS=y
1044# CONFIG_VIDEO_ADV_DEBUG is not set
1045CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
1046CONFIG_VIDEO_MSP3400=m
1047CONFIG_VIDEO_CS53L32A=m
1048CONFIG_VIDEO_WM8775=m
1049CONFIG_VIDEO_SAA711X=m
1050CONFIG_VIDEO_CX25840=m
1051CONFIG_VIDEO_CX2341X=m
1052# CONFIG_VIDEO_VIVI is not set
1053# CONFIG_VIDEO_CPIA is not set
1054# CONFIG_VIDEO_CPIA2 is not set
1055# CONFIG_VIDEO_SAA5246A is not set
1056# CONFIG_VIDEO_SAA5249 is not set
1057# CONFIG_TUNER_3036 is not set
1058# CONFIG_VIDEO_AU0828 is not set
1059CONFIG_V4L_USB_DRIVERS=y
1060CONFIG_USB_VIDEO_CLASS=m
1061CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
1062# CONFIG_USB_GSPCA is not set
1063CONFIG_VIDEO_PVRUSB2=m
1064CONFIG_VIDEO_PVRUSB2_SYSFS=y
1065CONFIG_VIDEO_PVRUSB2_DVB=y
1066# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
1067# CONFIG_VIDEO_EM28XX is not set
1068CONFIG_VIDEO_USBVISION=m
1069CONFIG_VIDEO_USBVIDEO=m
1070CONFIG_USB_VICAM=m
1071CONFIG_USB_IBMCAM=m
1072CONFIG_USB_KONICAWC=m
1073CONFIG_USB_QUICKCAM_MESSENGER=m
1074# CONFIG_USB_ET61X251 is not set
1075CONFIG_VIDEO_OVCAMCHIP=m
1076CONFIG_USB_W9968CF=m
1077CONFIG_USB_OV511=m
1078CONFIG_USB_SE401=m
1079CONFIG_USB_SN9C102=m
1080CONFIG_USB_STV680=m
1081# CONFIG_USB_ZC0301 is not set
1082CONFIG_USB_PWC=m
1083# CONFIG_USB_PWC_DEBUG is not set
1084CONFIG_USB_ZR364XX=m
1085# CONFIG_USB_STKWEBCAM is not set
1086# CONFIG_USB_S2255 is not set
1087# CONFIG_SOC_CAMERA is not set
1088# CONFIG_VIDEO_SH_MOBILE_CEU is not set
1089CONFIG_RADIO_ADAPTERS=y
1090# CONFIG_USB_DSBR is not set
1091# CONFIG_USB_SI470X is not set
1092CONFIG_DVB_CAPTURE_DRIVERS=y
1093# CONFIG_TTPCI_EEPROM is not set
1094
1095#
1096# Supported USB Adapters
1097#
1098CONFIG_DVB_USB=m
1099# CONFIG_DVB_USB_DEBUG is not set
1100CONFIG_DVB_USB_A800=m
1101CONFIG_DVB_USB_DIBUSB_MB=m
1102# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
1103CONFIG_DVB_USB_DIBUSB_MC=m
1104CONFIG_DVB_USB_DIB0700=m
1105CONFIG_DVB_USB_UMT_010=m
1106CONFIG_DVB_USB_CXUSB=m
1107CONFIG_DVB_USB_M920X=m
1108CONFIG_DVB_USB_GL861=m
1109CONFIG_DVB_USB_AU6610=m
1110CONFIG_DVB_USB_DIGITV=m
1111CONFIG_DVB_USB_VP7045=m
1112CONFIG_DVB_USB_VP702X=m
1113CONFIG_DVB_USB_GP8PSK=m
1114CONFIG_DVB_USB_NOVA_T_USB2=m
1115CONFIG_DVB_USB_TTUSB2=m
1116CONFIG_DVB_USB_DTT200U=m
1117CONFIG_DVB_USB_OPERA1=m
1118CONFIG_DVB_USB_AF9005=m
1119CONFIG_DVB_USB_AF9005_REMOTE=m
1120# CONFIG_DVB_USB_DW2102 is not set
1121# CONFIG_DVB_USB_ANYSEE is not set
1122CONFIG_DVB_TTUSB_BUDGET=m
1123CONFIG_DVB_TTUSB_DEC=m
1124CONFIG_DVB_CINERGYT2=m
1125# CONFIG_DVB_CINERGYT2_TUNING is not set
1126# CONFIG_DVB_SIANO_SMS1XXX is not set
1127
1128#
1129# Supported FlexCopII (B2C2) Adapters
1130#
1131# CONFIG_DVB_B2C2_FLEXCOP is not set
1132
1133#
1134# Supported DVB Frontends
1135#
1136
1137#
1138# Customise DVB Frontends
1139#
1140# CONFIG_DVB_FE_CUSTOMISE is not set
1141
1142#
1143# DVB-S (satellite) frontends
1144#
1145CONFIG_DVB_CX24110=m
1146CONFIG_DVB_CX24123=m
1147CONFIG_DVB_MT312=m
1148CONFIG_DVB_S5H1420=m
1149CONFIG_DVB_STV0299=m
1150CONFIG_DVB_TDA8083=m
1151CONFIG_DVB_TDA10086=m
1152CONFIG_DVB_VES1X93=m
1153CONFIG_DVB_TUNER_ITD1000=m
1154CONFIG_DVB_TDA826X=m
1155CONFIG_DVB_TUA6100=m
1156
1157#
1158# DVB-T (terrestrial) frontends
1159#
1160CONFIG_DVB_SP8870=m
1161CONFIG_DVB_SP887X=m
1162CONFIG_DVB_CX22700=m
1163CONFIG_DVB_CX22702=m
1164# CONFIG_DVB_DRX397XD is not set
1165CONFIG_DVB_L64781=m
1166CONFIG_DVB_TDA1004X=m
1167CONFIG_DVB_NXT6000=m
1168CONFIG_DVB_MT352=m
1169CONFIG_DVB_ZL10353=m
1170CONFIG_DVB_DIB3000MB=m
1171CONFIG_DVB_DIB3000MC=m
1172CONFIG_DVB_DIB7000M=m
1173CONFIG_DVB_DIB7000P=m
1174CONFIG_DVB_TDA10048=m
1175
1176#
1177# DVB-C (cable) frontends
1178#
1179CONFIG_DVB_VES1820=m
1180CONFIG_DVB_TDA10021=m
1181CONFIG_DVB_TDA10023=m
1182CONFIG_DVB_STV0297=m
1183
1184#
1185# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
1186#
1187CONFIG_DVB_NXT200X=m
1188# CONFIG_DVB_OR51211 is not set
1189# CONFIG_DVB_OR51132 is not set
1190CONFIG_DVB_BCM3510=m
1191CONFIG_DVB_LGDT330X=m
1192CONFIG_DVB_S5H1409=m
1193CONFIG_DVB_AU8522=m
1194CONFIG_DVB_S5H1411=m
1195
1196#
1197# Digital terrestrial only tuners/PLL
1198#
1199CONFIG_DVB_PLL=m
1200CONFIG_DVB_TUNER_DIB0070=m
1201
1202#
1203# SEC control devices for DVB-S
1204#
1205CONFIG_DVB_LNBP21=m
1206# CONFIG_DVB_ISL6405 is not set
1207CONFIG_DVB_ISL6421=m
1208# CONFIG_DAB is not set
1209
1210#
1211# Graphics support
1212#
1213# CONFIG_VGASTATE is not set
1214# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1215# CONFIG_FB is not set
1216# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1217
1218#
1219# Display device support
1220#
1221CONFIG_DISPLAY_SUPPORT=y
1222
1223#
1224# Display hardware drivers
1225#
1226
1227#
1228# Console display driver support
1229#
1230# CONFIG_VGA_CONSOLE is not set
1231CONFIG_DUMMY_CONSOLE=y
1232CONFIG_SOUND=y
1233CONFIG_SND=y
1234CONFIG_SND_TIMER=y
1235CONFIG_SND_PCM=y
1236CONFIG_SND_HWDEP=y
1237CONFIG_SND_RAWMIDI=y
1238CONFIG_SND_SEQUENCER=m
1239# CONFIG_SND_SEQ_DUMMY is not set
1240CONFIG_SND_OSSEMUL=y
1241CONFIG_SND_MIXER_OSS=y
1242CONFIG_SND_PCM_OSS=y
1243CONFIG_SND_PCM_OSS_PLUGINS=y
1244CONFIG_SND_SEQUENCER_OSS=y
1245# CONFIG_SND_DYNAMIC_MINORS is not set
1246CONFIG_SND_SUPPORT_OLD_API=y
1247CONFIG_SND_VERBOSE_PROCFS=y
1248CONFIG_SND_VERBOSE_PRINTK=y
1249CONFIG_SND_DEBUG=y
1250# CONFIG_SND_DEBUG_VERBOSE is not set
1251# CONFIG_SND_PCM_XRUN_DEBUG is not set
1252CONFIG_SND_DRIVERS=y
1253# CONFIG_SND_DUMMY is not set
1254# CONFIG_SND_VIRMIDI is not set
1255# CONFIG_SND_MTPAV is not set
1256# CONFIG_SND_SERIAL_U16550 is not set
1257# CONFIG_SND_MPU401 is not set
1258CONFIG_SND_ARM=y
1259CONFIG_SND_SPI=y
1260CONFIG_SND_USB=y
1261CONFIG_SND_USB_AUDIO=y
1262CONFIG_SND_USB_CAIAQ=m
1263CONFIG_SND_USB_CAIAQ_INPUT=y
1264CONFIG_SND_SOC=y
1265CONFIG_SND_OMAP_SOC=y
1266# CONFIG_SOUND_PRIME is not set
1267CONFIG_HID_SUPPORT=y
1268CONFIG_HID=y
1269CONFIG_HID_DEBUG=y
1270# CONFIG_HIDRAW is not set
1271
1272#
1273# USB Input Devices
1274#
1275CONFIG_USB_HID=y
1276# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1277# CONFIG_HID_FF is not set
1278# CONFIG_USB_HIDDEV is not set
1279CONFIG_USB_SUPPORT=y
1280CONFIG_USB_ARCH_HAS_HCD=y
1281CONFIG_USB_ARCH_HAS_OHCI=y
1282# CONFIG_USB_ARCH_HAS_EHCI is not set
1283CONFIG_USB=y
1284CONFIG_USB_DEBUG=y
1285CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
1286
1287#
1288# Miscellaneous USB options
1289#
1290CONFIG_USB_DEVICEFS=y
1291CONFIG_USB_DEVICE_CLASS=y
1292# CONFIG_USB_DYNAMIC_MINORS is not set
1293# CONFIG_USB_OTG is not set
1294# CONFIG_USB_OTG_WHITELIST is not set
1295# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1296CONFIG_USB_MON=y
1297
1298#
1299# USB Host Controller Drivers
1300#
1301# CONFIG_USB_C67X00_HCD is not set
1302# CONFIG_USB_ISP116X_HCD is not set
1303# CONFIG_USB_ISP1760_HCD is not set
1304# CONFIG_USB_OHCI_HCD is not set
1305# CONFIG_USB_SL811_HCD is not set
1306# CONFIG_USB_R8A66597_HCD is not set
1307CONFIG_USB_MUSB_HDRC=y
1308CONFIG_USB_MUSB_SOC=y
1309
1310#
1311# OMAP 343x high speed USB support
1312#
1313CONFIG_USB_MUSB_HOST=y
1314# CONFIG_USB_MUSB_PERIPHERAL is not set
1315# CONFIG_USB_MUSB_OTG is not set
1316CONFIG_USB_MUSB_HDRC_HCD=y
1317CONFIG_MUSB_PIO_ONLY=y
1318# CONFIG_USB_MUSB_DEBUG is not set
1319
1320#
1321# USB Device Class drivers
1322#
1323CONFIG_USB_ACM=m
1324CONFIG_USB_PRINTER=m
1325CONFIG_USB_WDM=y
1326
1327#
1328# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1329#
1330
1331#
1332# may also be needed; see USB_STORAGE Help for more information
1333#
1334CONFIG_USB_STORAGE=y
1335# CONFIG_USB_STORAGE_DEBUG is not set
1336# CONFIG_USB_STORAGE_DATAFAB is not set
1337# CONFIG_USB_STORAGE_FREECOM is not set
1338# CONFIG_USB_STORAGE_ISD200 is not set
1339# CONFIG_USB_STORAGE_DPCM is not set
1340# CONFIG_USB_STORAGE_USBAT is not set
1341# CONFIG_USB_STORAGE_SDDR09 is not set
1342# CONFIG_USB_STORAGE_SDDR55 is not set
1343# CONFIG_USB_STORAGE_JUMPSHOT is not set
1344# CONFIG_USB_STORAGE_ALAUDA is not set
1345# CONFIG_USB_STORAGE_ONETOUCH is not set
1346# CONFIG_USB_STORAGE_KARMA is not set
1347# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
1348# CONFIG_USB_LIBUSUAL is not set
1349
1350#
1351# USB Imaging devices
1352#
1353# CONFIG_USB_MDC800 is not set
1354# CONFIG_USB_MICROTEK is not set
1355
1356#
1357# USB port drivers
1358#
1359CONFIG_USB_SERIAL=m
1360# CONFIG_USB_EZUSB is not set
1361# CONFIG_USB_SERIAL_GENERIC is not set
1362# CONFIG_USB_SERIAL_AIRCABLE is not set
1363# CONFIG_USB_SERIAL_ARK3116 is not set
1364# CONFIG_USB_SERIAL_BELKIN is not set
1365# CONFIG_USB_SERIAL_CH341 is not set
1366# CONFIG_USB_SERIAL_WHITEHEAT is not set
1367# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
1368# CONFIG_USB_SERIAL_CP2101 is not set
1369# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
1370# CONFIG_USB_SERIAL_EMPEG is not set
1371# CONFIG_USB_SERIAL_FTDI_SIO is not set
1372# CONFIG_USB_SERIAL_FUNSOFT is not set
1373# CONFIG_USB_SERIAL_VISOR is not set
1374# CONFIG_USB_SERIAL_IPAQ is not set
1375# CONFIG_USB_SERIAL_IR is not set
1376# CONFIG_USB_SERIAL_EDGEPORT is not set
1377# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1378# CONFIG_USB_SERIAL_GARMIN is not set
1379# CONFIG_USB_SERIAL_IPW is not set
1380# CONFIG_USB_SERIAL_IUU is not set
1381# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1382# CONFIG_USB_SERIAL_KEYSPAN is not set
1383# CONFIG_USB_SERIAL_KLSI is not set
1384# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1385# CONFIG_USB_SERIAL_MCT_U232 is not set
1386# CONFIG_USB_SERIAL_MOS7720 is not set
1387# CONFIG_USB_SERIAL_MOS7840 is not set
1388# CONFIG_USB_SERIAL_MOTOROLA is not set
1389# CONFIG_USB_SERIAL_NAVMAN is not set
1390# CONFIG_USB_SERIAL_PL2303 is not set
1391# CONFIG_USB_SERIAL_OTI6858 is not set
1392# CONFIG_USB_SERIAL_SPCP8X5 is not set
1393# CONFIG_USB_SERIAL_HP4X is not set
1394# CONFIG_USB_SERIAL_SAFE is not set
1395# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
1396# CONFIG_USB_SERIAL_TI is not set
1397# CONFIG_USB_SERIAL_CYBERJACK is not set
1398# CONFIG_USB_SERIAL_XIRCOM is not set
1399# CONFIG_USB_SERIAL_OPTION is not set
1400# CONFIG_USB_SERIAL_OMNINET is not set
1401# CONFIG_USB_SERIAL_DEBUG is not set
1402
1403#
1404# USB Miscellaneous drivers
1405#
1406CONFIG_USB_EMI62=m
1407CONFIG_USB_EMI26=m
1408# CONFIG_USB_ADUTUX is not set
1409# CONFIG_USB_RIO500 is not set
1410CONFIG_USB_LEGOTOWER=m
1411CONFIG_USB_LCD=m
1412# CONFIG_USB_BERRY_CHARGE is not set
1413CONFIG_USB_LED=m
1414# CONFIG_USB_CYPRESS_CY7C63 is not set
1415# CONFIG_USB_CYTHERM is not set
1416# CONFIG_USB_PHIDGET is not set
1417# CONFIG_USB_IDMOUSE is not set
1418# CONFIG_USB_FTDI_ELAN is not set
1419# CONFIG_USB_APPLEDISPLAY is not set
1420# CONFIG_USB_LD is not set
1421# CONFIG_USB_TRANCEVIBRATOR is not set
1422# CONFIG_USB_IOWARRIOR is not set
1423# CONFIG_USB_TEST is not set
1424# CONFIG_USB_ISIGHTFW is not set
1425# CONFIG_USB_GADGET is not set
1426CONFIG_MMC=y
1427# CONFIG_MMC_DEBUG is not set
1428CONFIG_MMC_UNSAFE_RESUME=y
1429
1430#
1431# MMC/SD Card Drivers
1432#
1433CONFIG_MMC_BLOCK=y
1434CONFIG_MMC_BLOCK_BOUNCE=y
1435CONFIG_SDIO_UART=y
1436# CONFIG_MMC_TEST is not set
1437
1438#
1439# MMC/SD Host Controller Drivers
1440#
1441# CONFIG_MMC_SDHCI is not set
1442# CONFIG_MMC_OMAP is not set
1443# CONFIG_MMC_SPI is not set
1444# CONFIG_MEMSTICK is not set
1445# CONFIG_ACCESSIBILITY is not set
1446CONFIG_NEW_LEDS=y
1447CONFIG_LEDS_CLASS=y
1448
1449#
1450# LED drivers
1451#
1452# CONFIG_LEDS_PCA9532 is not set
1453CONFIG_LEDS_GPIO=y
1454# CONFIG_LEDS_PCA955X is not set
1455
1456#
1457# LED Triggers
1458#
1459CONFIG_LEDS_TRIGGERS=y
1460CONFIG_LEDS_TRIGGER_TIMER=y
1461CONFIG_LEDS_TRIGGER_HEARTBEAT=y
1462# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
1463CONFIG_RTC_LIB=y
1464CONFIG_RTC_CLASS=y
1465CONFIG_RTC_HCTOSYS=y
1466CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1467# CONFIG_RTC_DEBUG is not set
1468
1469#
1470# RTC interfaces
1471#
1472CONFIG_RTC_INTF_SYSFS=y
1473CONFIG_RTC_INTF_PROC=y
1474CONFIG_RTC_INTF_DEV=y
1475# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1476# CONFIG_RTC_DRV_TEST is not set
1477
1478#
1479# I2C RTC drivers
1480#
1481# CONFIG_RTC_DRV_DS1307 is not set
1482# CONFIG_RTC_DRV_DS1374 is not set
1483# CONFIG_RTC_DRV_DS1672 is not set
1484# CONFIG_RTC_DRV_MAX6900 is not set
1485# CONFIG_RTC_DRV_RS5C372 is not set
1486# CONFIG_RTC_DRV_ISL1208 is not set
1487# CONFIG_RTC_DRV_X1205 is not set
1488# CONFIG_RTC_DRV_PCF8563 is not set
1489# CONFIG_RTC_DRV_PCF8583 is not set
1490# CONFIG_RTC_DRV_M41T80 is not set
1491# CONFIG_RTC_DRV_S35390A is not set
1492# CONFIG_RTC_DRV_FM3130 is not set
1493
1494#
1495# SPI RTC drivers
1496#
1497# CONFIG_RTC_DRV_M41T94 is not set
1498# CONFIG_RTC_DRV_DS1305 is not set
1499# CONFIG_RTC_DRV_MAX6902 is not set
1500# CONFIG_RTC_DRV_R9701 is not set
1501# CONFIG_RTC_DRV_RS5C348 is not set
1502
1503#
1504# Platform RTC drivers
1505#
1506# CONFIG_RTC_DRV_CMOS is not set
1507# CONFIG_RTC_DRV_DS1511 is not set
1508# CONFIG_RTC_DRV_DS1553 is not set
1509# CONFIG_RTC_DRV_DS1742 is not set
1510# CONFIG_RTC_DRV_STK17TA8 is not set
1511# CONFIG_RTC_DRV_M48T86 is not set
1512# CONFIG_RTC_DRV_M48T59 is not set
1513# CONFIG_RTC_DRV_V3020 is not set
1514
1515#
1516# on-CPU RTC drivers
1517#
1518# CONFIG_DMADEVICES is not set
1519
1520#
1521# Voltage and Current regulators
1522#
1523# CONFIG_REGULATOR is not set
1524# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
1525# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
1526# CONFIG_REGULATOR_BQ24022 is not set
1527# CONFIG_UIO is not set
1528
1529#
1530# File systems
1531#
1532CONFIG_EXT2_FS=y
1533# CONFIG_EXT2_FS_XATTR is not set
1534# CONFIG_EXT2_FS_XIP is not set
1535CONFIG_EXT3_FS=y
1536# CONFIG_EXT3_FS_XATTR is not set
1537# CONFIG_EXT4DEV_FS is not set
1538CONFIG_JBD=y
1539# CONFIG_JBD_DEBUG is not set
1540# CONFIG_REISERFS_FS is not set
1541# CONFIG_JFS_FS is not set
1542CONFIG_FS_POSIX_ACL=y
1543CONFIG_XFS_FS=m
1544# CONFIG_XFS_QUOTA is not set
1545# CONFIG_XFS_POSIX_ACL is not set
1546# CONFIG_XFS_RT is not set
1547# CONFIG_XFS_DEBUG is not set
1548# CONFIG_GFS2_FS is not set
1549# CONFIG_OCFS2_FS is not set
1550CONFIG_DNOTIFY=y
1551CONFIG_INOTIFY=y
1552CONFIG_INOTIFY_USER=y
1553CONFIG_QUOTA=y
1554# CONFIG_QUOTA_NETLINK_INTERFACE is not set
1555CONFIG_PRINT_QUOTA_WARNING=y
1556# CONFIG_QFMT_V1 is not set
1557CONFIG_QFMT_V2=y
1558CONFIG_QUOTACTL=y
1559# CONFIG_AUTOFS_FS is not set
1560# CONFIG_AUTOFS4_FS is not set
1561CONFIG_FUSE_FS=m
1562
1563#
1564# CD-ROM/DVD Filesystems
1565#
1566CONFIG_ISO9660_FS=m
1567CONFIG_JOLIET=y
1568CONFIG_ZISOFS=y
1569CONFIG_UDF_FS=m
1570CONFIG_UDF_NLS=y
1571
1572#
1573# DOS/FAT/NT Filesystems
1574#
1575CONFIG_FAT_FS=y
1576CONFIG_MSDOS_FS=y
1577CONFIG_VFAT_FS=y
1578CONFIG_FAT_DEFAULT_CODEPAGE=437
1579CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1580# CONFIG_NTFS_FS is not set
1581
1582#
1583# Pseudo filesystems
1584#
1585CONFIG_PROC_FS=y
1586CONFIG_PROC_SYSCTL=y
1587CONFIG_SYSFS=y
1588CONFIG_TMPFS=y
1589# CONFIG_TMPFS_POSIX_ACL is not set
1590# CONFIG_HUGETLB_PAGE is not set
1591# CONFIG_CONFIGFS_FS is not set
1592
1593#
1594# Miscellaneous filesystems
1595#
1596# CONFIG_ADFS_FS is not set
1597# CONFIG_AFFS_FS is not set
1598# CONFIG_HFS_FS is not set
1599# CONFIG_HFSPLUS_FS is not set
1600# CONFIG_BEFS_FS is not set
1601# CONFIG_BFS_FS is not set
1602# CONFIG_EFS_FS is not set
1603CONFIG_JFFS2_FS=y
1604CONFIG_JFFS2_FS_DEBUG=0
1605CONFIG_JFFS2_FS_WRITEBUFFER=y
1606# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1607CONFIG_JFFS2_SUMMARY=y
1608CONFIG_JFFS2_FS_XATTR=y
1609CONFIG_JFFS2_FS_POSIX_ACL=y
1610CONFIG_JFFS2_FS_SECURITY=y
1611CONFIG_JFFS2_COMPRESSION_OPTIONS=y
1612CONFIG_JFFS2_ZLIB=y
1613CONFIG_JFFS2_LZO=y
1614CONFIG_JFFS2_RTIME=y
1615CONFIG_JFFS2_RUBIN=y
1616# CONFIG_JFFS2_CMODE_NONE is not set
1617CONFIG_JFFS2_CMODE_PRIORITY=y
1618# CONFIG_JFFS2_CMODE_SIZE is not set
1619# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
1620# CONFIG_CRAMFS is not set
1621# CONFIG_VXFS_FS is not set
1622# CONFIG_MINIX_FS is not set
1623# CONFIG_OMFS_FS is not set
1624# CONFIG_HPFS_FS is not set
1625# CONFIG_QNX4FS_FS is not set
1626# CONFIG_ROMFS_FS is not set
1627# CONFIG_SYSV_FS is not set
1628# CONFIG_UFS_FS is not set
1629CONFIG_NETWORK_FILESYSTEMS=y
1630CONFIG_NFS_FS=y
1631CONFIG_NFS_V3=y
1632# CONFIG_NFS_V3_ACL is not set
1633CONFIG_NFS_V4=y
1634CONFIG_ROOT_NFS=y
1635# CONFIG_NFSD is not set
1636CONFIG_LOCKD=y
1637CONFIG_LOCKD_V4=y
1638CONFIG_NFS_COMMON=y
1639CONFIG_SUNRPC=y
1640CONFIG_SUNRPC_GSS=y
1641CONFIG_RPCSEC_GSS_KRB5=y
1642# CONFIG_RPCSEC_GSS_SPKM3 is not set
1643# CONFIG_SMB_FS is not set
1644# CONFIG_CIFS is not set
1645# CONFIG_NCP_FS is not set
1646# CONFIG_CODA_FS is not set
1647# CONFIG_AFS_FS is not set
1648
1649#
1650# Partition Types
1651#
1652CONFIG_PARTITION_ADVANCED=y
1653# CONFIG_ACORN_PARTITION is not set
1654# CONFIG_OSF_PARTITION is not set
1655# CONFIG_AMIGA_PARTITION is not set
1656# CONFIG_ATARI_PARTITION is not set
1657# CONFIG_MAC_PARTITION is not set
1658CONFIG_MSDOS_PARTITION=y
1659# CONFIG_BSD_DISKLABEL is not set
1660# CONFIG_MINIX_SUBPARTITION is not set
1661# CONFIG_SOLARIS_X86_PARTITION is not set
1662# CONFIG_UNIXWARE_DISKLABEL is not set
1663# CONFIG_LDM_PARTITION is not set
1664# CONFIG_SGI_PARTITION is not set
1665# CONFIG_ULTRIX_PARTITION is not set
1666# CONFIG_SUN_PARTITION is not set
1667# CONFIG_KARMA_PARTITION is not set
1668# CONFIG_EFI_PARTITION is not set
1669# CONFIG_SYSV68_PARTITION is not set
1670CONFIG_NLS=y
1671CONFIG_NLS_DEFAULT="iso8859-1"
1672CONFIG_NLS_CODEPAGE_437=y
1673# CONFIG_NLS_CODEPAGE_737 is not set
1674# CONFIG_NLS_CODEPAGE_775 is not set
1675# CONFIG_NLS_CODEPAGE_850 is not set
1676# CONFIG_NLS_CODEPAGE_852 is not set
1677# CONFIG_NLS_CODEPAGE_855 is not set
1678# CONFIG_NLS_CODEPAGE_857 is not set
1679# CONFIG_NLS_CODEPAGE_860 is not set
1680# CONFIG_NLS_CODEPAGE_861 is not set
1681# CONFIG_NLS_CODEPAGE_862 is not set
1682# CONFIG_NLS_CODEPAGE_863 is not set
1683# CONFIG_NLS_CODEPAGE_864 is not set
1684# CONFIG_NLS_CODEPAGE_865 is not set
1685# CONFIG_NLS_CODEPAGE_866 is not set
1686# CONFIG_NLS_CODEPAGE_869 is not set
1687# CONFIG_NLS_CODEPAGE_936 is not set
1688# CONFIG_NLS_CODEPAGE_950 is not set
1689# CONFIG_NLS_CODEPAGE_932 is not set
1690# CONFIG_NLS_CODEPAGE_949 is not set
1691# CONFIG_NLS_CODEPAGE_874 is not set
1692# CONFIG_NLS_ISO8859_8 is not set
1693# CONFIG_NLS_CODEPAGE_1250 is not set
1694# CONFIG_NLS_CODEPAGE_1251 is not set
1695# CONFIG_NLS_ASCII is not set
1696CONFIG_NLS_ISO8859_1=y
1697# CONFIG_NLS_ISO8859_2 is not set
1698# CONFIG_NLS_ISO8859_3 is not set
1699# CONFIG_NLS_ISO8859_4 is not set
1700# CONFIG_NLS_ISO8859_5 is not set
1701# CONFIG_NLS_ISO8859_6 is not set
1702# CONFIG_NLS_ISO8859_7 is not set
1703# CONFIG_NLS_ISO8859_9 is not set
1704# CONFIG_NLS_ISO8859_13 is not set
1705# CONFIG_NLS_ISO8859_14 is not set
1706# CONFIG_NLS_ISO8859_15 is not set
1707# CONFIG_NLS_KOI8_R is not set
1708# CONFIG_NLS_KOI8_U is not set
1709# CONFIG_NLS_UTF8 is not set
1710# CONFIG_DLM is not set
1711
1712#
1713# Kernel hacking
1714#
1715# CONFIG_PRINTK_TIME is not set
1716CONFIG_ENABLE_WARN_DEPRECATED=y
1717CONFIG_ENABLE_MUST_CHECK=y
1718CONFIG_FRAME_WARN=1024
1719CONFIG_MAGIC_SYSRQ=y
1720# CONFIG_UNUSED_SYMBOLS is not set
1721CONFIG_DEBUG_FS=y
1722# CONFIG_HEADERS_CHECK is not set
1723CONFIG_DEBUG_KERNEL=y
1724# CONFIG_DEBUG_SHIRQ is not set
1725CONFIG_DETECT_SOFTLOCKUP=y
1726# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1727CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1728CONFIG_SCHED_DEBUG=y
1729CONFIG_SCHEDSTATS=y
1730CONFIG_TIMER_STATS=y
1731# CONFIG_DEBUG_OBJECTS is not set
1732# CONFIG_SLUB_DEBUG_ON is not set
1733# CONFIG_SLUB_STATS is not set
1734# CONFIG_DEBUG_RT_MUTEXES is not set
1735# CONFIG_RT_MUTEX_TESTER is not set
1736# CONFIG_DEBUG_SPINLOCK is not set
1737CONFIG_DEBUG_MUTEXES=y
1738# CONFIG_DEBUG_LOCK_ALLOC is not set
1739# CONFIG_PROVE_LOCKING is not set
1740# CONFIG_LOCK_STAT is not set
1741# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1742# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1743# CONFIG_DEBUG_KOBJECT is not set
1744# CONFIG_DEBUG_BUGVERBOSE is not set
1745# CONFIG_DEBUG_INFO is not set
1746# CONFIG_DEBUG_VM is not set
1747# CONFIG_DEBUG_WRITECOUNT is not set
1748# CONFIG_DEBUG_MEMORY_INIT is not set
1749# CONFIG_DEBUG_LIST is not set
1750# CONFIG_DEBUG_SG is not set
1751CONFIG_FRAME_POINTER=y
1752# CONFIG_BOOT_PRINTK_DELAY is not set
1753# CONFIG_RCU_TORTURE_TEST is not set
1754# CONFIG_BACKTRACE_SELF_TEST is not set
1755# CONFIG_FAULT_INJECTION is not set
1756# CONFIG_LATENCYTOP is not set
1757CONFIG_HAVE_FTRACE=y
1758CONFIG_HAVE_DYNAMIC_FTRACE=y
1759# CONFIG_FTRACE is not set
1760# CONFIG_IRQSOFF_TRACER is not set
1761# CONFIG_SCHED_TRACER is not set
1762# CONFIG_CONTEXT_SWITCH_TRACER is not set
1763# CONFIG_SAMPLES is not set
1764CONFIG_HAVE_ARCH_KGDB=y
1765# CONFIG_KGDB is not set
1766# CONFIG_DEBUG_USER is not set
1767# CONFIG_DEBUG_ERRORS is not set
1768# CONFIG_DEBUG_STACK_USAGE is not set
1769# CONFIG_DEBUG_LL is not set
1770
1771#
1772# Security options
1773#
1774# CONFIG_KEYS is not set
1775# CONFIG_SECURITY is not set
1776# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1777CONFIG_XOR_BLOCKS=m
1778CONFIG_ASYNC_CORE=m
1779CONFIG_ASYNC_MEMCPY=m
1780CONFIG_ASYNC_XOR=m
1781CONFIG_CRYPTO=y
1782
1783#
1784# Crypto core or helper
1785#
1786CONFIG_CRYPTO_ALGAPI=y
1787CONFIG_CRYPTO_AEAD=m
1788CONFIG_CRYPTO_BLKCIPHER=y
1789CONFIG_CRYPTO_HASH=m
1790CONFIG_CRYPTO_MANAGER=y
1791CONFIG_CRYPTO_GF128MUL=m
1792CONFIG_CRYPTO_NULL=m
1793CONFIG_CRYPTO_CRYPTD=m
1794# CONFIG_CRYPTO_AUTHENC is not set
1795CONFIG_CRYPTO_TEST=m
1796
1797#
1798# Authenticated Encryption with Associated Data
1799#
1800# CONFIG_CRYPTO_CCM is not set
1801# CONFIG_CRYPTO_GCM is not set
1802# CONFIG_CRYPTO_SEQIV is not set
1803
1804#
1805# Block modes
1806#
1807CONFIG_CRYPTO_CBC=y
1808# CONFIG_CRYPTO_CTR is not set
1809# CONFIG_CRYPTO_CTS is not set
1810CONFIG_CRYPTO_ECB=y
1811CONFIG_CRYPTO_LRW=m
1812CONFIG_CRYPTO_PCBC=m
1813# CONFIG_CRYPTO_XTS is not set
1814
1815#
1816# Hash modes
1817#
1818CONFIG_CRYPTO_HMAC=m
1819CONFIG_CRYPTO_XCBC=m
1820
1821#
1822# Digest
1823#
1824CONFIG_CRYPTO_CRC32C=m
1825CONFIG_CRYPTO_MD4=m
1826CONFIG_CRYPTO_MD5=y
1827CONFIG_CRYPTO_MICHAEL_MIC=y
1828# CONFIG_CRYPTO_RMD128 is not set
1829# CONFIG_CRYPTO_RMD160 is not set
1830# CONFIG_CRYPTO_RMD256 is not set
1831# CONFIG_CRYPTO_RMD320 is not set
1832CONFIG_CRYPTO_SHA1=m
1833CONFIG_CRYPTO_SHA256=m
1834CONFIG_CRYPTO_SHA512=m
1835CONFIG_CRYPTO_TGR192=m
1836CONFIG_CRYPTO_WP512=m
1837
1838#
1839# Ciphers
1840#
1841CONFIG_CRYPTO_AES=y
1842CONFIG_CRYPTO_ANUBIS=m
1843CONFIG_CRYPTO_ARC4=y
1844CONFIG_CRYPTO_BLOWFISH=m
1845CONFIG_CRYPTO_CAMELLIA=m
1846CONFIG_CRYPTO_CAST5=m
1847CONFIG_CRYPTO_CAST6=m
1848CONFIG_CRYPTO_DES=y
1849CONFIG_CRYPTO_FCRYPT=m
1850CONFIG_CRYPTO_KHAZAD=m
1851# CONFIG_CRYPTO_SALSA20 is not set
1852# CONFIG_CRYPTO_SEED is not set
1853CONFIG_CRYPTO_SERPENT=m
1854CONFIG_CRYPTO_TEA=m
1855CONFIG_CRYPTO_TWOFISH=m
1856CONFIG_CRYPTO_TWOFISH_COMMON=m
1857
1858#
1859# Compression
1860#
1861CONFIG_CRYPTO_DEFLATE=m
1862# CONFIG_CRYPTO_LZO is not set
1863CONFIG_CRYPTO_HW=y
1864
1865#
1866# Library routines
1867#
1868CONFIG_BITREVERSE=y
1869# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1870# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1871CONFIG_CRC_CCITT=y
1872CONFIG_CRC16=m
1873CONFIG_CRC_T10DIF=y
1874CONFIG_CRC_ITU_T=y
1875CONFIG_CRC32=y
1876CONFIG_CRC7=y
1877CONFIG_LIBCRC32C=y
1878CONFIG_ZLIB_INFLATE=y
1879CONFIG_ZLIB_DEFLATE=y
1880CONFIG_LZO_COMPRESS=y
1881CONFIG_LZO_DECOMPRESS=y
1882CONFIG_PLIST=y
1883CONFIG_HAS_IOMEM=y
1884CONFIG_HAS_IOPORT=y
1885CONFIG_HAS_DMA=y
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 5be016980c19..a58378c343b9 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -107,6 +107,6 @@ extern int arm_elf_read_implies_exec(const struct elf32_hdr *, int);
107#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0 107#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
108 108
109extern void elf_set_personality(const struct elf32_hdr *); 109extern void elf_set_personality(const struct elf32_hdr *);
110#define SET_PERSONALITY(ex, ibcs2) elf_set_personality(&(ex)) 110#define SET_PERSONALITY(ex) elf_set_personality(&(ex))
111 111
112#endif 112#endif
diff --git a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c
index e4f72d202cc0..44d4c2e8207b 100644
--- a/arch/arm/mach-integrator/cpu.c
+++ b/arch/arm/mach-integrator/cpu.c
@@ -184,7 +184,6 @@ static int integrator_cpufreq_init(struct cpufreq_policy *policy)
184{ 184{
185 185
186 /* set default policy and cpuinfo */ 186 /* set default policy and cpuinfo */
187 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
188 policy->cpuinfo.max_freq = 160000; 187 policy->cpuinfo.max_freq = 160000;
189 policy->cpuinfo.min_freq = 12000; 188 policy->cpuinfo.min_freq = 12000;
190 policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */ 189 policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */
diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
index db8b5fe06c0d..2c5a02b8520e 100644
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -167,11 +167,6 @@ config MACH_GTWX5715
167 167
168comment "IXP4xx Options" 168comment "IXP4xx Options"
169 169
170config DMABOUNCE
171 bool
172 default y
173 depends on PCI
174
175config IXP4XX_INDIRECT_PCI 170config IXP4XX_INDIRECT_PCI
176 bool "Use indirect PCI memory access" 171 bool "Use indirect PCI memory access"
177 depends on PCI 172 depends on PCI
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 478c2c9a22cb..5fba20731710 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -201,7 +201,7 @@ static int calc_dsor_exp(struct clk *clk, unsigned long rate)
201 return -EINVAL; 201 return -EINVAL;
202 202
203 parent = clk->parent; 203 parent = clk->parent;
204 if (unlikely(parent == 0)) 204 if (unlikely(parent == NULL))
205 return -EIO; 205 return -EIO;
206 206
207 realrate = parent->rate; 207 realrate = parent->rate;
@@ -499,7 +499,7 @@ static int omap1_clk_enable_generic(struct clk *clk)
499 if (clk->flags & ALWAYS_ENABLED) 499 if (clk->flags & ALWAYS_ENABLED)
500 return 0; 500 return 0;
501 501
502 if (unlikely(clk->enable_reg == 0)) { 502 if (unlikely(clk->enable_reg == NULL)) {
503 printk(KERN_ERR "clock.c: Enable for %s without enable code\n", 503 printk(KERN_ERR "clock.c: Enable for %s without enable code\n",
504 clk->name); 504 clk->name);
505 return -EINVAL; 505 return -EINVAL;
@@ -535,7 +535,7 @@ static void omap1_clk_disable_generic(struct clk *clk)
535 __u16 regval16; 535 __u16 regval16;
536 __u32 regval32; 536 __u32 regval32;
537 537
538 if (clk->enable_reg == 0) 538 if (clk->enable_reg == NULL)
539 return; 539 return;
540 540
541 if (clk->flags & ENABLE_REG_32BIT) { 541 if (clk->flags & ENABLE_REG_32BIT) {
@@ -577,7 +577,7 @@ static long omap1_clk_round_rate(struct clk *clk, unsigned long rate)
577 return clk->parent->rate / (1 << dsor_exp); 577 return clk->parent->rate / (1 << dsor_exp);
578 } 578 }
579 579
580 if(clk->round_rate != 0) 580 if (clk->round_rate != NULL)
581 return clk->round_rate(clk, rate); 581 return clk->round_rate(clk, rate);
582 582
583 return clk->rate; 583 return clk->rate;
@@ -625,7 +625,7 @@ static void __init omap1_clk_disable_unused(struct clk *clk)
625 625
626 /* Clocks in the DSP domain need api_ck. Just assume bootloader 626 /* Clocks in the DSP domain need api_ck. Just assume bootloader
627 * has not enabled any DSP clocks */ 627 * has not enabled any DSP clocks */
628 if ((u32)clk->enable_reg == DSP_IDLECT2) { 628 if (clk->enable_reg == DSP_IDLECT2) {
629 printk(KERN_INFO "Skipping reset check for DSP domain " 629 printk(KERN_INFO "Skipping reset check for DSP domain "
630 "clock \"%s\"\n", clk->name); 630 "clock \"%s\"\n", clk->name);
631 return; 631 return;
diff --git a/arch/arm/mach-omap1/clock.h b/arch/arm/mach-omap1/clock.h
index 6eadf72828d8..5635b511ab6f 100644
--- a/arch/arm/mach-omap1/clock.h
+++ b/arch/arm/mach-omap1/clock.h
@@ -324,7 +324,7 @@ static struct clk dspper_ck = {
324 .parent = &ck_dpll1, 324 .parent = &ck_dpll1,
325 .flags = CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | 325 .flags = CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
326 RATE_CKCTL | VIRTUAL_IO_ADDRESS, 326 RATE_CKCTL | VIRTUAL_IO_ADDRESS,
327 .enable_reg = (void __iomem *)DSP_IDLECT2, 327 .enable_reg = DSP_IDLECT2,
328 .enable_bit = EN_PERCK, 328 .enable_bit = EN_PERCK,
329 .rate_offset = CKCTL_PERDIV_OFFSET, 329 .rate_offset = CKCTL_PERDIV_OFFSET,
330 .recalc = &omap1_ckctl_recalc_dsp_domain, 330 .recalc = &omap1_ckctl_recalc_dsp_domain,
@@ -338,7 +338,7 @@ static struct clk dspxor_ck = {
338 .parent = &ck_ref, 338 .parent = &ck_ref,
339 .flags = CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | 339 .flags = CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
340 VIRTUAL_IO_ADDRESS, 340 VIRTUAL_IO_ADDRESS,
341 .enable_reg = (void __iomem *)DSP_IDLECT2, 341 .enable_reg = DSP_IDLECT2,
342 .enable_bit = EN_XORPCK, 342 .enable_bit = EN_XORPCK,
343 .recalc = &followparent_recalc, 343 .recalc = &followparent_recalc,
344 .enable = &omap1_clk_enable_dsp_domain, 344 .enable = &omap1_clk_enable_dsp_domain,
@@ -350,7 +350,7 @@ static struct clk dsptim_ck = {
350 .parent = &ck_ref, 350 .parent = &ck_ref,
351 .flags = CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | 351 .flags = CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
352 VIRTUAL_IO_ADDRESS, 352 VIRTUAL_IO_ADDRESS,
353 .enable_reg = (void __iomem *)DSP_IDLECT2, 353 .enable_reg = DSP_IDLECT2,
354 .enable_bit = EN_DSPTIMCK, 354 .enable_bit = EN_DSPTIMCK,
355 .recalc = &followparent_recalc, 355 .recalc = &followparent_recalc,
356 .enable = &omap1_clk_enable_dsp_domain, 356 .enable = &omap1_clk_enable_dsp_domain,
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 99982d3380c9..e382b438c64e 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -101,7 +101,7 @@ static inline void omap_init_mbox(void) { }
101 101
102#if defined(CONFIG_OMAP_STI) 102#if defined(CONFIG_OMAP_STI)
103 103
104#define OMAP1_STI_BASE IO_ADDRESS(0xfffea000) 104#define OMAP1_STI_BASE 0xfffea000
105#define OMAP1_STI_CHANNEL_BASE (OMAP1_STI_BASE + 0x400) 105#define OMAP1_STI_CHANNEL_BASE (OMAP1_STI_BASE + 0x400)
106 106
107static struct resource sti_resources[] = { 107static struct resource sti_resources[] = {
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
index 2baeaeb0c900..7de7c6915584 100644
--- a/arch/arm/mach-omap1/mcbsp.c
+++ b/arch/arm/mach-omap1/mcbsp.c
@@ -103,30 +103,6 @@ static inline void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk)
103{ } 103{ }
104#endif 104#endif
105 105
106static int omap1_mcbsp_check(unsigned int id)
107{
108 /* REVISIT: Check correctly for number of registered McBSPs */
109 if (cpu_is_omap730()) {
110 if (id > OMAP_MAX_MCBSP_COUNT - 2) {
111 printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
112 id + 1);
113 return -ENODEV;
114 }
115 return 0;
116 }
117
118 if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
119 if (id > OMAP_MAX_MCBSP_COUNT - 1) {
120 printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
121 id + 1);
122 return -ENODEV;
123 }
124 return 0;
125 }
126
127 return -ENODEV;
128}
129
130static void omap1_mcbsp_request(unsigned int id) 106static void omap1_mcbsp_request(unsigned int id)
131{ 107{
132 /* 108 /*
@@ -151,7 +127,6 @@ static void omap1_mcbsp_free(unsigned int id)
151} 127}
152 128
153static struct omap_mcbsp_ops omap1_mcbsp_ops = { 129static struct omap_mcbsp_ops omap1_mcbsp_ops = {
154 .check = omap1_mcbsp_check,
155 .request = omap1_mcbsp_request, 130 .request = omap1_mcbsp_request,
156 .free = omap1_mcbsp_free, 131 .free = omap1_mcbsp_free,
157}; 132};
@@ -160,7 +135,6 @@ static struct omap_mcbsp_ops omap1_mcbsp_ops = {
160static struct omap_mcbsp_platform_data omap730_mcbsp_pdata[] = { 135static struct omap_mcbsp_platform_data omap730_mcbsp_pdata[] = {
161 { 136 {
162 .phys_base = OMAP730_MCBSP1_BASE, 137 .phys_base = OMAP730_MCBSP1_BASE,
163 .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
164 .dma_rx_sync = OMAP_DMA_MCBSP1_RX, 138 .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
165 .dma_tx_sync = OMAP_DMA_MCBSP1_TX, 139 .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
166 .rx_irq = INT_730_McBSP1RX, 140 .rx_irq = INT_730_McBSP1RX,
@@ -169,7 +143,6 @@ static struct omap_mcbsp_platform_data omap730_mcbsp_pdata[] = {
169 }, 143 },
170 { 144 {
171 .phys_base = OMAP730_MCBSP2_BASE, 145 .phys_base = OMAP730_MCBSP2_BASE,
172 .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
173 .dma_rx_sync = OMAP_DMA_MCBSP3_RX, 146 .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
174 .dma_tx_sync = OMAP_DMA_MCBSP3_TX, 147 .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
175 .rx_irq = INT_730_McBSP2RX, 148 .rx_irq = INT_730_McBSP2RX,
@@ -187,7 +160,6 @@ static struct omap_mcbsp_platform_data omap730_mcbsp_pdata[] = {
187static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = { 160static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
188 { 161 {
189 .phys_base = OMAP1510_MCBSP1_BASE, 162 .phys_base = OMAP1510_MCBSP1_BASE,
190 .virt_base = OMAP1510_MCBSP1_BASE,
191 .dma_rx_sync = OMAP_DMA_MCBSP1_RX, 163 .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
192 .dma_tx_sync = OMAP_DMA_MCBSP1_TX, 164 .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
193 .rx_irq = INT_McBSP1RX, 165 .rx_irq = INT_McBSP1RX,
@@ -197,7 +169,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
197 }, 169 },
198 { 170 {
199 .phys_base = OMAP1510_MCBSP2_BASE, 171 .phys_base = OMAP1510_MCBSP2_BASE,
200 .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
201 .dma_rx_sync = OMAP_DMA_MCBSP2_RX, 172 .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
202 .dma_tx_sync = OMAP_DMA_MCBSP2_TX, 173 .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
203 .rx_irq = INT_1510_SPI_RX, 174 .rx_irq = INT_1510_SPI_RX,
@@ -206,7 +177,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
206 }, 177 },
207 { 178 {
208 .phys_base = OMAP1510_MCBSP3_BASE, 179 .phys_base = OMAP1510_MCBSP3_BASE,
209 .virt_base = OMAP1510_MCBSP3_BASE,
210 .dma_rx_sync = OMAP_DMA_MCBSP3_RX, 180 .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
211 .dma_tx_sync = OMAP_DMA_MCBSP3_TX, 181 .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
212 .rx_irq = INT_McBSP3RX, 182 .rx_irq = INT_McBSP3RX,
@@ -225,7 +195,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
225static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = { 195static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
226 { 196 {
227 .phys_base = OMAP1610_MCBSP1_BASE, 197 .phys_base = OMAP1610_MCBSP1_BASE,
228 .virt_base = OMAP1610_MCBSP1_BASE,
229 .dma_rx_sync = OMAP_DMA_MCBSP1_RX, 198 .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
230 .dma_tx_sync = OMAP_DMA_MCBSP1_TX, 199 .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
231 .rx_irq = INT_McBSP1RX, 200 .rx_irq = INT_McBSP1RX,
@@ -235,7 +204,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
235 }, 204 },
236 { 205 {
237 .phys_base = OMAP1610_MCBSP2_BASE, 206 .phys_base = OMAP1610_MCBSP2_BASE,
238 .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
239 .dma_rx_sync = OMAP_DMA_MCBSP2_RX, 207 .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
240 .dma_tx_sync = OMAP_DMA_MCBSP2_TX, 208 .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
241 .rx_irq = INT_1610_McBSP2_RX, 209 .rx_irq = INT_1610_McBSP2_RX,
@@ -244,7 +212,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
244 }, 212 },
245 { 213 {
246 .phys_base = OMAP1610_MCBSP3_BASE, 214 .phys_base = OMAP1610_MCBSP3_BASE,
247 .virt_base = OMAP1610_MCBSP3_BASE,
248 .dma_rx_sync = OMAP_DMA_MCBSP3_RX, 215 .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
249 .dma_tx_sync = OMAP_DMA_MCBSP3_TX, 216 .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
250 .rx_irq = INT_McBSP3RX, 217 .rx_irq = INT_McBSP3RX,
@@ -271,6 +238,18 @@ int __init omap1_mcbsp_init(void)
271 } 238 }
272 239
273 if (cpu_is_omap730()) 240 if (cpu_is_omap730())
241 omap_mcbsp_count = OMAP730_MCBSP_PDATA_SZ;
242 if (cpu_is_omap15xx())
243 omap_mcbsp_count = OMAP15XX_MCBSP_PDATA_SZ;
244 if (cpu_is_omap16xx())
245 omap_mcbsp_count = OMAP16XX_MCBSP_PDATA_SZ;
246
247 mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
248 GFP_KERNEL);
249 if (!mcbsp_ptr)
250 return -ENOMEM;
251
252 if (cpu_is_omap730())
274 omap_mcbsp_register_board_cfg(omap730_mcbsp_pdata, 253 omap_mcbsp_register_board_cfg(omap730_mcbsp_pdata,
275 OMAP730_MCBSP_PDATA_SZ); 254 OMAP730_MCBSP_PDATA_SZ);
276 255
diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c
index aefc967fc003..528691d5cb51 100644
--- a/arch/arm/mach-omap1/serial.c
+++ b/arch/arm/mach-omap1/serial.c
@@ -67,8 +67,8 @@ static void __init omap_serial_reset(struct plat_serial8250_port *p)
67 67
68static struct plat_serial8250_port serial_platform_data[] = { 68static struct plat_serial8250_port serial_platform_data[] = {
69 { 69 {
70 .membase = (char*)IO_ADDRESS(OMAP_UART1_BASE), 70 .membase = IO_ADDRESS(OMAP_UART1_BASE),
71 .mapbase = (unsigned long)OMAP_UART1_BASE, 71 .mapbase = OMAP_UART1_BASE,
72 .irq = INT_UART1, 72 .irq = INT_UART1,
73 .flags = UPF_BOOT_AUTOCONF, 73 .flags = UPF_BOOT_AUTOCONF,
74 .iotype = UPIO_MEM, 74 .iotype = UPIO_MEM,
@@ -76,8 +76,8 @@ static struct plat_serial8250_port serial_platform_data[] = {
76 .uartclk = OMAP16XX_BASE_BAUD * 16, 76 .uartclk = OMAP16XX_BASE_BAUD * 16,
77 }, 77 },
78 { 78 {
79 .membase = (char*)IO_ADDRESS(OMAP_UART2_BASE), 79 .membase = IO_ADDRESS(OMAP_UART2_BASE),
80 .mapbase = (unsigned long)OMAP_UART2_BASE, 80 .mapbase = OMAP_UART2_BASE,
81 .irq = INT_UART2, 81 .irq = INT_UART2,
82 .flags = UPF_BOOT_AUTOCONF, 82 .flags = UPF_BOOT_AUTOCONF,
83 .iotype = UPIO_MEM, 83 .iotype = UPIO_MEM,
@@ -85,8 +85,8 @@ static struct plat_serial8250_port serial_platform_data[] = {
85 .uartclk = OMAP16XX_BASE_BAUD * 16, 85 .uartclk = OMAP16XX_BASE_BAUD * 16,
86 }, 86 },
87 { 87 {
88 .membase = (char*)IO_ADDRESS(OMAP_UART3_BASE), 88 .membase = IO_ADDRESS(OMAP_UART3_BASE),
89 .mapbase = (unsigned long)OMAP_UART3_BASE, 89 .mapbase = OMAP_UART3_BASE,
90 .irq = INT_UART3, 90 .irq = INT_UART3,
91 .flags = UPF_BOOT_AUTOCONF, 91 .flags = UPF_BOOT_AUTOCONF,
92 .iotype = UPIO_MEM, 92 .iotype = UPIO_MEM,
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 7069c9d536f1..4832fcc7d04a 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -15,8 +15,17 @@ config ARCH_OMAP2430
15 bool "OMAP2430 support" 15 bool "OMAP2430 support"
16 depends on ARCH_OMAP24XX 16 depends on ARCH_OMAP24XX
17 17
18config ARCH_OMAP34XX
19 bool "OMAP34xx Based System"
20 depends on ARCH_OMAP3
21
22config ARCH_OMAP3430
23 bool "OMAP3430 support"
24 depends on ARCH_OMAP3 && ARCH_OMAP34XX
25 select ARCH_OMAP_OTG
26
18comment "OMAP Board Type" 27comment "OMAP Board Type"
19 depends on ARCH_OMAP2 28 depends on ARCH_OMAP2 || ARCH_OMAP3
20 29
21config MACH_OMAP_GENERIC 30config MACH_OMAP_GENERIC
22 bool "Generic OMAP board" 31 bool "Generic OMAP board"
@@ -35,3 +44,14 @@ config MACH_OMAP_2430SDP
35 bool "OMAP 2430 SDP board" 44 bool "OMAP 2430 SDP board"
36 depends on ARCH_OMAP2 && ARCH_OMAP24XX 45 depends on ARCH_OMAP2 && ARCH_OMAP24XX
37 46
47config MACH_OMAP3_BEAGLE
48 bool "OMAP3 BEAGLE board"
49 depends on ARCH_OMAP3 && ARCH_OMAP34XX
50
51config MACH_OMAP_LDP
52 bool "OMAP3 LDP board"
53 depends on ARCH_OMAP3 && ARCH_OMAP34XX
54
55config MACH_OVERO
56 bool "Gumstix Overo board"
57 depends on ARCH_OMAP3 && ARCH_OMAP34XX
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 93ee990618ef..c69392372c99 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -4,16 +4,21 @@
4 4
5# Common support 5# Common support
6obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \ 6obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
7 devices.o serial.o gpmc.o timer-gp.o 7 devices.o serial.o gpmc.o timer-gp.o powerdomain.o \
8 clockdomain.o
8 9
9obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o 10obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
10 11
11# Functions loaded to SRAM 12# Functions loaded to SRAM
12obj-$(CONFIG_ARCH_OMAP2420) += sram242x.o 13obj-$(CONFIG_ARCH_OMAP2420) += sram242x.o
13obj-$(CONFIG_ARCH_OMAP2430) += sram243x.o 14obj-$(CONFIG_ARCH_OMAP2430) += sram243x.o
15obj-$(CONFIG_ARCH_OMAP3) += sram34xx.o
14 16
15# Power Management 17# Power Management
16obj-$(CONFIG_PM) += pm.o sleep.o 18ifeq ($(CONFIG_PM),y)
19obj-y += pm.o
20obj-$(CONFIG_ARCH_OMAP24XX) += sleep24xx.o
21endif
17 22
18# Clock framework 23# Clock framework
19obj-$(CONFIG_ARCH_OMAP2) += clock24xx.o 24obj-$(CONFIG_ARCH_OMAP2) += clock24xx.o
@@ -24,4 +29,7 @@ obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o
24obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o 29obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o
25obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o 30obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o
26obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o 31obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o
32obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o
33obj-$(CONFIG_MACH_OMAP_LDP) += board-ldp.o
34obj-$(CONFIG_MACH_OVERO) += board-overo.o
27 35
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
new file mode 100644
index 000000000000..1ea59986aa7a
--- /dev/null
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -0,0 +1,86 @@
1/*
2 * linux/arch/arm/mach-omap2/board-ldp.c
3 *
4 * Copyright (C) 2008 Texas Instruments Inc.
5 * Nishant Kamat <nskamat@ti.com>
6 *
7 * Modified from mach-omap2/board-3430sdp.c
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#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/input.h>
19#include <linux/workqueue.h>
20#include <linux/err.h>
21#include <linux/clk.h>
22#include <linux/spi/spi.h>
23#include <linux/spi/ads7846.h>
24
25#include <mach/hardware.h>
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/mach/map.h>
29
30#include <mach/board-ldp.h>
31#include <mach/mcspi.h>
32#include <mach/gpio.h>
33#include <mach/board.h>
34#include <mach/common.h>
35#include <mach/gpmc.h>
36
37#include <asm/io.h>
38#include <asm/delay.h>
39#include <mach/control.h>
40
41static void __init omap_ldp_init_irq(void)
42{
43 omap2_init_common_hw();
44 omap_init_irq();
45 omap_gpio_init();
46}
47
48static struct omap_uart_config ldp_uart_config __initdata = {
49 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
50};
51
52static struct omap_board_config_kernel ldp_config[] __initdata = {
53 { OMAP_TAG_UART, &ldp_uart_config },
54};
55
56static int __init omap_i2c_init(void)
57{
58 omap_register_i2c_bus(1, 2600, NULL, 0);
59 omap_register_i2c_bus(2, 400, NULL, 0);
60 omap_register_i2c_bus(3, 400, NULL, 0);
61 return 0;
62}
63
64static void __init omap_ldp_init(void)
65{
66 omap_i2c_init();
67 omap_board_config = ldp_config;
68 omap_board_config_size = ARRAY_SIZE(ldp_config);
69 omap_serial_init();
70}
71
72static void __init omap_ldp_map_io(void)
73{
74 omap2_set_globals_343x();
75 omap2_map_common_io();
76}
77
78MACHINE_START(OMAP_LDP, "OMAP LDP board")
79 .phys_io = 0x48000000,
80 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
81 .boot_params = 0x80000100,
82 .map_io = omap_ldp_map_io,
83 .init_irq = omap_ldp_init_irq,
84 .init_machine = omap_ldp_init,
85 .timer = &omap_timer,
86MACHINE_END
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
new file mode 100644
index 000000000000..baa79674e9d5
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -0,0 +1,244 @@
1/*
2 * linux/arch/arm/mach-omap2/board-omap3beagle.c
3 *
4 * Copyright (C) 2008 Texas Instruments
5 *
6 * Modified from mach-omap2/board-3430sdp.c
7 *
8 * Initial code: Syed Mohammed Khasim
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/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/clk.h>
21#include <linux/io.h>
22#include <linux/leds.h>
23#include <linux/gpio.h>
24#include <linux/input.h>
25#include <linux/gpio_keys.h>
26
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h>
29#include <linux/mtd/nand.h>
30
31#include <mach/hardware.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35#include <asm/mach/flash.h>
36
37#include <mach/board.h>
38#include <mach/common.h>
39#include <mach/gpmc.h>
40#include <mach/nand.h>
41
42
43#define GPMC_CS0_BASE 0x60
44#define GPMC_CS_SIZE 0x30
45
46#define NAND_BLOCK_SIZE SZ_128K
47
48static struct mtd_partition omap3beagle_nand_partitions[] = {
49 /* All the partition sizes are listed in terms of NAND block size */
50 {
51 .name = "X-Loader",
52 .offset = 0,
53 .size = 4 * NAND_BLOCK_SIZE,
54 .mask_flags = MTD_WRITEABLE, /* force read-only */
55 },
56 {
57 .name = "U-Boot",
58 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
59 .size = 15 * NAND_BLOCK_SIZE,
60 .mask_flags = MTD_WRITEABLE, /* force read-only */
61 },
62 {
63 .name = "U-Boot Env",
64 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
65 .size = 1 * NAND_BLOCK_SIZE,
66 },
67 {
68 .name = "Kernel",
69 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
70 .size = 32 * NAND_BLOCK_SIZE,
71 },
72 {
73 .name = "File System",
74 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
75 .size = MTDPART_SIZ_FULL,
76 },
77};
78
79static struct omap_nand_platform_data omap3beagle_nand_data = {
80 .options = NAND_BUSWIDTH_16,
81 .parts = omap3beagle_nand_partitions,
82 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
83 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
84 .nand_setup = NULL,
85 .dev_ready = NULL,
86};
87
88static struct resource omap3beagle_nand_resource = {
89 .flags = IORESOURCE_MEM,
90};
91
92static struct platform_device omap3beagle_nand_device = {
93 .name = "omap2-nand",
94 .id = -1,
95 .dev = {
96 .platform_data = &omap3beagle_nand_data,
97 },
98 .num_resources = 1,
99 .resource = &omap3beagle_nand_resource,
100};
101
102static struct omap_uart_config omap3_beagle_uart_config __initdata = {
103 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
104};
105
106static void __init omap3_beagle_init_irq(void)
107{
108 omap2_init_common_hw();
109 omap_init_irq();
110 omap_gpio_init();
111}
112
113static struct platform_device omap3_beagle_lcd_device = {
114 .name = "omap3beagle_lcd",
115 .id = -1,
116};
117
118static struct omap_lcd_config omap3_beagle_lcd_config __initdata = {
119 .ctrl_name = "internal",
120};
121
122static struct gpio_led gpio_leds[] = {
123 {
124 .name = "beagleboard::usr0",
125 .default_trigger = "heartbeat",
126 .gpio = 150,
127 },
128 {
129 .name = "beagleboard::usr1",
130 .default_trigger = "mmc0",
131 .gpio = 149,
132 },
133};
134
135static struct gpio_led_platform_data gpio_led_info = {
136 .leds = gpio_leds,
137 .num_leds = ARRAY_SIZE(gpio_leds),
138};
139
140static struct platform_device leds_gpio = {
141 .name = "leds-gpio",
142 .id = -1,
143 .dev = {
144 .platform_data = &gpio_led_info,
145 },
146};
147
148static struct gpio_keys_button gpio_buttons[] = {
149 {
150 .code = BTN_EXTRA,
151 .gpio = 7,
152 .desc = "user",
153 .wakeup = 1,
154 },
155};
156
157static struct gpio_keys_platform_data gpio_key_info = {
158 .buttons = gpio_buttons,
159 .nbuttons = ARRAY_SIZE(gpio_buttons),
160};
161
162static struct platform_device keys_gpio = {
163 .name = "gpio-keys",
164 .id = -1,
165 .dev = {
166 .platform_data = &gpio_key_info,
167 },
168};
169
170static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
171 { OMAP_TAG_UART, &omap3_beagle_uart_config },
172 { OMAP_TAG_LCD, &omap3_beagle_lcd_config },
173};
174
175static struct platform_device *omap3_beagle_devices[] __initdata = {
176 &omap3_beagle_lcd_device,
177 &leds_gpio,
178 &keys_gpio,
179};
180
181static void __init omap3beagle_flash_init(void)
182{
183 u8 cs = 0;
184 u8 nandcs = GPMC_CS_NUM + 1;
185
186 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
187
188 /* find out the chip-select on which NAND exists */
189 while (cs < GPMC_CS_NUM) {
190 u32 ret = 0;
191 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
192
193 if ((ret & 0xC00) == 0x800) {
194 printk(KERN_INFO "Found NAND on CS%d\n", cs);
195 if (nandcs > GPMC_CS_NUM)
196 nandcs = cs;
197 }
198 cs++;
199 }
200
201 if (nandcs > GPMC_CS_NUM) {
202 printk(KERN_INFO "NAND: Unable to find configuration "
203 "in GPMC\n ");
204 return;
205 }
206
207 if (nandcs < GPMC_CS_NUM) {
208 omap3beagle_nand_data.cs = nandcs;
209 omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
210 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
211 omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
212
213 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
214 if (platform_device_register(&omap3beagle_nand_device) < 0)
215 printk(KERN_ERR "Unable to register NAND device\n");
216 }
217}
218
219static void __init omap3_beagle_init(void)
220{
221 platform_add_devices(omap3_beagle_devices,
222 ARRAY_SIZE(omap3_beagle_devices));
223 omap_board_config = omap3_beagle_config;
224 omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
225 omap_serial_init();
226 omap3beagle_flash_init();
227}
228
229static void __init omap3_beagle_map_io(void)
230{
231 omap2_set_globals_343x();
232 omap2_map_common_io();
233}
234
235MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
236 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
237 .phys_io = 0x48000000,
238 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
239 .boot_params = 0x80000100,
240 .map_io = omap3_beagle_map_io,
241 .init_irq = omap3_beagle_init_irq,
242 .init_machine = omap3_beagle_init,
243 .timer = &omap_timer,
244MACHINE_END
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
new file mode 100644
index 000000000000..e09aa59a399c
--- /dev/null
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -0,0 +1,242 @@
1/*
2 * board-overo.c (Gumstix Overo)
3 *
4 * Initial code: Steve Sakoman <steve@sakoman.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 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 *
20 */
21
22#include <linux/clk.h>
23#include <linux/delay.h>
24#include <linux/err.h>
25#include <linux/init.h>
26#include <linux/io.h>
27#include <linux/kernel.h>
28#include <linux/platform_device.h>
29
30#include <linux/mtd/mtd.h>
31#include <linux/mtd/nand.h>
32#include <linux/mtd/partitions.h>
33
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/flash.h>
37#include <asm/mach/map.h>
38
39#include <mach/board-overo.h>
40#include <mach/board.h>
41#include <mach/common.h>
42#include <mach/gpio.h>
43#include <mach/gpmc.h>
44#include <mach/hardware.h>
45#include <mach/nand.h>
46
47#define NAND_BLOCK_SIZE SZ_128K
48#define GPMC_CS0_BASE 0x60
49#define GPMC_CS_SIZE 0x30
50
51static struct mtd_partition overo_nand_partitions[] = {
52 {
53 .name = "xloader",
54 .offset = 0, /* Offset = 0x00000 */
55 .size = 4 * NAND_BLOCK_SIZE,
56 .mask_flags = MTD_WRITEABLE
57 },
58 {
59 .name = "uboot",
60 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
61 .size = 14 * NAND_BLOCK_SIZE,
62 },
63 {
64 .name = "uboot environment",
65 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
66 .size = 2 * NAND_BLOCK_SIZE,
67 },
68 {
69 .name = "linux",
70 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
71 .size = 32 * NAND_BLOCK_SIZE,
72 },
73 {
74 .name = "rootfs",
75 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
76 .size = MTDPART_SIZ_FULL,
77 },
78};
79
80static struct omap_nand_platform_data overo_nand_data = {
81 .parts = overo_nand_partitions,
82 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
83 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
84};
85
86static struct resource overo_nand_resource = {
87 .flags = IORESOURCE_MEM,
88};
89
90static struct platform_device overo_nand_device = {
91 .name = "omap2-nand",
92 .id = -1,
93 .dev = {
94 .platform_data = &overo_nand_data,
95 },
96 .num_resources = 1,
97 .resource = &overo_nand_resource,
98};
99
100
101static void __init overo_flash_init(void)
102{
103 u8 cs = 0;
104 u8 nandcs = GPMC_CS_NUM + 1;
105
106 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
107
108 /* find out the chip-select on which NAND exists */
109 while (cs < GPMC_CS_NUM) {
110 u32 ret = 0;
111 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
112
113 if ((ret & 0xC00) == 0x800) {
114 printk(KERN_INFO "Found NAND on CS%d\n", cs);
115 if (nandcs > GPMC_CS_NUM)
116 nandcs = cs;
117 }
118 cs++;
119 }
120
121 if (nandcs > GPMC_CS_NUM) {
122 printk(KERN_INFO "NAND: Unable to find configuration "
123 "in GPMC\n ");
124 return;
125 }
126
127 if (nandcs < GPMC_CS_NUM) {
128 overo_nand_data.cs = nandcs;
129 overo_nand_data.gpmc_cs_baseaddr = (void *)
130 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
131 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
132
133 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
134 if (platform_device_register(&overo_nand_device) < 0)
135 printk(KERN_ERR "Unable to register NAND device\n");
136 }
137}
138static struct omap_uart_config overo_uart_config __initdata = {
139 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
140};
141
142static int __init overo_i2c_init(void)
143{
144 /* i2c2 pins are used for gpio */
145 omap_register_i2c_bus(3, 400, NULL, 0);
146 return 0;
147}
148
149static void __init overo_init_irq(void)
150{
151 omap2_init_common_hw();
152 omap_init_irq();
153 omap_gpio_init();
154}
155
156static struct platform_device overo_lcd_device = {
157 .name = "overo_lcd",
158 .id = -1,
159};
160
161static struct omap_lcd_config overo_lcd_config __initdata = {
162 .ctrl_name = "internal",
163};
164
165static struct omap_board_config_kernel overo_config[] __initdata = {
166 { OMAP_TAG_UART, &overo_uart_config },
167 { OMAP_TAG_LCD, &overo_lcd_config },
168};
169
170static struct platform_device *overo_devices[] __initdata = {
171 &overo_lcd_device,
172};
173
174static void __init overo_init(void)
175{
176 overo_i2c_init();
177 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
178 omap_board_config = overo_config;
179 omap_board_config_size = ARRAY_SIZE(overo_config);
180 omap_serial_init();
181 overo_flash_init();
182
183 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
184 "OVERO_GPIO_W2W_NRESET") == 0) &&
185 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
186 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
187 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
188 udelay(10);
189 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
190 } else {
191 printk(KERN_ERR "could not obtain gpio for "
192 "OVERO_GPIO_W2W_NRESET\n");
193 }
194
195 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
196 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
197 gpio_export(OVERO_GPIO_BT_XGATE, 0);
198 else
199 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
200
201 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
202 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
203 gpio_export(OVERO_GPIO_BT_NRESET, 0);
204 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
205 mdelay(6);
206 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
207 } else {
208 printk(KERN_ERR "could not obtain gpio for "
209 "OVERO_GPIO_BT_NRESET\n");
210 }
211
212 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
213 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
214 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
215 else
216 printk(KERN_ERR "could not obtain gpio for "
217 "OVERO_GPIO_USBH_CPEN\n");
218
219 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
220 "OVERO_GPIO_USBH_NRESET") == 0) &&
221 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
222 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
223 else
224 printk(KERN_ERR "could not obtain gpio for "
225 "OVERO_GPIO_USBH_NRESET\n");
226}
227
228static void __init overo_map_io(void)
229{
230 omap2_set_globals_343x();
231 omap2_map_common_io();
232}
233
234MACHINE_START(OVERO, "Gumstix Overo")
235 .phys_io = 0x48000000,
236 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
237 .boot_params = 0x80000100,
238 .map_io = overo_map_io,
239 .init_irq = overo_init_irq,
240 .init_machine = overo_init,
241 .timer = &omap_timer,
242MACHINE_END
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 97cde3d3611d..ad721e0cbf7a 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -25,6 +25,7 @@
25#include <linux/bitops.h> 25#include <linux/bitops.h>
26 26
27#include <mach/clock.h> 27#include <mach/clock.h>
28#include <mach/clockdomain.h>
28#include <mach/sram.h> 29#include <mach/sram.h>
29#include <mach/cpu.h> 30#include <mach/cpu.h>
30#include <asm/div64.h> 31#include <asm/div64.h>
@@ -61,10 +62,36 @@
61u8 cpu_mask; 62u8 cpu_mask;
62 63
63/*------------------------------------------------------------------------- 64/*-------------------------------------------------------------------------
64 * Omap2 specific clock functions 65 * OMAP2/3 specific clock functions
65 *-------------------------------------------------------------------------*/ 66 *-------------------------------------------------------------------------*/
66 67
67/** 68/**
69 * omap2_init_clk_clkdm - look up a clockdomain name, store pointer in clk
70 * @clk: OMAP clock struct ptr to use
71 *
72 * Convert a clockdomain name stored in a struct clk 'clk' into a
73 * clockdomain pointer, and save it into the struct clk. Intended to be
74 * called during clk_register(). No return value.
75 */
76void omap2_init_clk_clkdm(struct clk *clk)
77{
78 struct clockdomain *clkdm;
79
80 if (!clk->clkdm_name)
81 return;
82
83 clkdm = clkdm_lookup(clk->clkdm_name);
84 if (clkdm) {
85 pr_debug("clock: associated clk %s to clkdm %s\n",
86 clk->name, clk->clkdm_name);
87 clk->clkdm = clkdm;
88 } else {
89 pr_debug("clock: could not associate clk %s to "
90 "clkdm %s\n", clk->name, clk->clkdm_name);
91 }
92}
93
94/**
68 * omap2_init_clksel_parent - set a clksel clk's parent field from the hardware 95 * omap2_init_clksel_parent - set a clksel clk's parent field from the hardware
69 * @clk: OMAP clock struct ptr to use 96 * @clk: OMAP clock struct ptr to use
70 * 97 *
@@ -250,7 +277,7 @@ int _omap2_clk_enable(struct clk *clk)
250 if (clk->enable) 277 if (clk->enable)
251 return clk->enable(clk); 278 return clk->enable(clk);
252 279
253 if (unlikely(clk->enable_reg == 0)) { 280 if (unlikely(clk->enable_reg == NULL)) {
254 printk(KERN_ERR "clock.c: Enable for %s without enable code\n", 281 printk(KERN_ERR "clock.c: Enable for %s without enable code\n",
255 clk->name); 282 clk->name);
256 return 0; /* REVISIT: -EINVAL */ 283 return 0; /* REVISIT: -EINVAL */
@@ -282,7 +309,7 @@ void _omap2_clk_disable(struct clk *clk)
282 return; 309 return;
283 } 310 }
284 311
285 if (clk->enable_reg == 0) { 312 if (clk->enable_reg == NULL) {
286 /* 313 /*
287 * 'Independent' here refers to a clock which is not 314 * 'Independent' here refers to a clock which is not
288 * controlled by its parent. 315 * controlled by its parent.
@@ -307,6 +334,9 @@ void omap2_clk_disable(struct clk *clk)
307 _omap2_clk_disable(clk); 334 _omap2_clk_disable(clk);
308 if (likely((u32)clk->parent)) 335 if (likely((u32)clk->parent))
309 omap2_clk_disable(clk->parent); 336 omap2_clk_disable(clk->parent);
337 if (clk->clkdm)
338 omap2_clkdm_clk_disable(clk->clkdm, clk);
339
310 } 340 }
311} 341}
312 342
@@ -323,11 +353,19 @@ int omap2_clk_enable(struct clk *clk)
323 return ret; 353 return ret;
324 } 354 }
325 355
356 if (clk->clkdm)
357 omap2_clkdm_clk_enable(clk->clkdm, clk);
358
326 ret = _omap2_clk_enable(clk); 359 ret = _omap2_clk_enable(clk);
327 360
328 if (unlikely(ret != 0) && clk->parent) { 361 if (unlikely(ret != 0)) {
329 omap2_clk_disable(clk->parent); 362 if (clk->clkdm)
330 clk->usecount--; 363 omap2_clkdm_clk_disable(clk->clkdm, clk);
364
365 if (clk->parent) {
366 omap2_clk_disable(clk->parent);
367 clk->usecount--;
368 }
331 } 369 }
332 } 370 }
333 371
@@ -476,7 +514,7 @@ long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate)
476/* Given a clock and a rate apply a clock specific rounding function */ 514/* Given a clock and a rate apply a clock specific rounding function */
477long omap2_clk_round_rate(struct clk *clk, unsigned long rate) 515long omap2_clk_round_rate(struct clk *clk, unsigned long rate)
478{ 516{
479 if (clk->round_rate != 0) 517 if (clk->round_rate != NULL)
480 return clk->round_rate(clk, rate); 518 return clk->round_rate(clk, rate);
481 519
482 if (clk->flags & RATE_FIXED) 520 if (clk->flags & RATE_FIXED)
@@ -565,7 +603,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
565 */ 603 */
566void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask) 604void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask)
567{ 605{
568 if (unlikely((clk->clksel_reg == 0) || (clk->clksel_mask == 0))) 606 if (unlikely((clk->clksel_reg == NULL) || (clk->clksel_mask == NULL)))
569 return NULL; 607 return NULL;
570 608
571 *field_mask = clk->clksel_mask; 609 *field_mask = clk->clksel_mask;
@@ -585,7 +623,7 @@ u32 omap2_clksel_get_divisor(struct clk *clk)
585 void __iomem *div_addr; 623 void __iomem *div_addr;
586 624
587 div_addr = omap2_get_clksel(clk, &field_mask); 625 div_addr = omap2_get_clksel(clk, &field_mask);
588 if (div_addr == 0) 626 if (div_addr == NULL)
589 return 0; 627 return 0;
590 628
591 field_val = __raw_readl(div_addr) & field_mask; 629 field_val = __raw_readl(div_addr) & field_mask;
@@ -604,7 +642,7 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate)
604 return -EINVAL; 642 return -EINVAL;
605 643
606 div_addr = omap2_get_clksel(clk, &field_mask); 644 div_addr = omap2_get_clksel(clk, &field_mask);
607 if (div_addr == 0) 645 if (div_addr == NULL)
608 return -EINVAL; 646 return -EINVAL;
609 647
610 field_val = omap2_divisor_to_clksel(clk, new_div); 648 field_val = omap2_divisor_to_clksel(clk, new_div);
@@ -642,7 +680,7 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate)
642 return -EINVAL; 680 return -EINVAL;
643 681
644 /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */ 682 /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */
645 if (clk->set_rate != 0) 683 if (clk->set_rate != NULL)
646 ret = clk->set_rate(clk, rate); 684 ret = clk->set_rate(clk, rate);
647 685
648 if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES))) 686 if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES)))
@@ -663,7 +701,7 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr,
663 const struct clksel_rate *clkr; 701 const struct clksel_rate *clkr;
664 702
665 *parent_div = 0; 703 *parent_div = 0;
666 *src_addr = 0; 704 *src_addr = NULL;
667 705
668 clks = omap2_get_clksel_by_parent(clk, src_clk); 706 clks = omap2_get_clksel_by_parent(clk, src_clk);
669 if (clks == NULL) 707 if (clks == NULL)
@@ -704,7 +742,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
704 742
705 field_val = omap2_clksel_get_src_field(&src_addr, new_parent, 743 field_val = omap2_clksel_get_src_field(&src_addr, new_parent,
706 &field_mask, clk, &parent_div); 744 &field_mask, clk, &parent_div);
707 if (src_addr == 0) 745 if (src_addr == NULL)
708 return -EINVAL; 746 return -EINVAL;
709 747
710 if (clk->usecount > 0) 748 if (clk->usecount > 0)
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 626e5fa93b6a..1fb330e0847d 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -21,6 +21,7 @@
21/* The maximum error between a target DPLL rate and the rounded rate in Hz */ 21/* The maximum error between a target DPLL rate and the rounded rate in Hz */
22#define DEFAULT_DPLL_RATE_TOLERANCE 50000 22#define DEFAULT_DPLL_RATE_TOLERANCE 50000
23 23
24int omap2_clk_init(void);
24int omap2_clk_enable(struct clk *clk); 25int omap2_clk_enable(struct clk *clk);
25void omap2_clk_disable(struct clk *clk); 26void omap2_clk_disable(struct clk *clk);
26long omap2_clk_round_rate(struct clk *clk, unsigned long rate); 27long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
@@ -36,6 +37,7 @@ void omap2_clk_disable_unused(struct clk *clk);
36#endif 37#endif
37 38
38void omap2_clksel_recalc(struct clk *clk); 39void omap2_clksel_recalc(struct clk *clk);
40void omap2_init_clk_clkdm(struct clk *clk);
39void omap2_init_clksel_parent(struct clk *clk); 41void omap2_init_clksel_parent(struct clk *clk);
40u32 omap2_clksel_get_divisor(struct clk *clk); 42u32 omap2_clksel_get_divisor(struct clk *clk);
41u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, 43u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h
index be4e25554e05..242a19d86ccd 100644
--- a/arch/arm/mach-omap2/clock24xx.h
+++ b/arch/arm/mach-omap2/clock24xx.h
@@ -626,6 +626,7 @@ static struct clk func_32k_ck = {
626 .rate = 32000, 626 .rate = 32000,
627 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 627 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
628 RATE_FIXED | ALWAYS_ENABLED | RATE_PROPAGATES, 628 RATE_FIXED | ALWAYS_ENABLED | RATE_PROPAGATES,
629 .clkdm_name = "wkup_clkdm",
629 .recalc = &propagate_rate, 630 .recalc = &propagate_rate,
630}; 631};
631 632
@@ -634,17 +635,19 @@ static struct clk osc_ck = { /* (*12, *13, 19.2, *26, 38.4)MHz */
634 .name = "osc_ck", 635 .name = "osc_ck",
635 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 636 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
636 RATE_PROPAGATES, 637 RATE_PROPAGATES,
638 .clkdm_name = "wkup_clkdm",
637 .enable = &omap2_enable_osc_ck, 639 .enable = &omap2_enable_osc_ck,
638 .disable = &omap2_disable_osc_ck, 640 .disable = &omap2_disable_osc_ck,
639 .recalc = &omap2_osc_clk_recalc, 641 .recalc = &omap2_osc_clk_recalc,
640}; 642};
641 643
642/* With out modem likely 12MHz, with modem likely 13MHz */ 644/* Without modem likely 12MHz, with modem likely 13MHz */
643static struct clk sys_ck = { /* (*12, *13, 19.2, 26, 38.4)MHz */ 645static struct clk sys_ck = { /* (*12, *13, 19.2, 26, 38.4)MHz */
644 .name = "sys_ck", /* ~ ref_clk also */ 646 .name = "sys_ck", /* ~ ref_clk also */
645 .parent = &osc_ck, 647 .parent = &osc_ck,
646 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 648 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
647 ALWAYS_ENABLED | RATE_PROPAGATES, 649 ALWAYS_ENABLED | RATE_PROPAGATES,
650 .clkdm_name = "wkup_clkdm",
648 .recalc = &omap2_sys_clk_recalc, 651 .recalc = &omap2_sys_clk_recalc,
649}; 652};
650 653
@@ -653,6 +656,7 @@ static struct clk alt_ck = { /* Typical 54M or 48M, may not exist */
653 .rate = 54000000, 656 .rate = 54000000,
654 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 657 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
655 RATE_FIXED | ALWAYS_ENABLED | RATE_PROPAGATES, 658 RATE_FIXED | ALWAYS_ENABLED | RATE_PROPAGATES,
659 .clkdm_name = "wkup_clkdm",
656 .recalc = &propagate_rate, 660 .recalc = &propagate_rate,
657}; 661};
658 662
@@ -684,6 +688,7 @@ static struct clk dpll_ck = {
684 .dpll_data = &dpll_dd, 688 .dpll_data = &dpll_dd,
685 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 689 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
686 RATE_PROPAGATES | ALWAYS_ENABLED, 690 RATE_PROPAGATES | ALWAYS_ENABLED,
691 .clkdm_name = "wkup_clkdm",
687 .recalc = &omap2_dpllcore_recalc, 692 .recalc = &omap2_dpllcore_recalc,
688 .set_rate = &omap2_reprogram_dpllcore, 693 .set_rate = &omap2_reprogram_dpllcore,
689}; 694};
@@ -694,6 +699,7 @@ static struct clk apll96_ck = {
694 .rate = 96000000, 699 .rate = 96000000,
695 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 700 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
696 RATE_FIXED | RATE_PROPAGATES | ENABLE_ON_INIT, 701 RATE_FIXED | RATE_PROPAGATES | ENABLE_ON_INIT,
702 .clkdm_name = "wkup_clkdm",
697 .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), 703 .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN),
698 .enable_bit = OMAP24XX_EN_96M_PLL_SHIFT, 704 .enable_bit = OMAP24XX_EN_96M_PLL_SHIFT,
699 .enable = &omap2_clk_fixed_enable, 705 .enable = &omap2_clk_fixed_enable,
@@ -707,6 +713,7 @@ static struct clk apll54_ck = {
707 .rate = 54000000, 713 .rate = 54000000,
708 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 714 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
709 RATE_FIXED | RATE_PROPAGATES | ENABLE_ON_INIT, 715 RATE_FIXED | RATE_PROPAGATES | ENABLE_ON_INIT,
716 .clkdm_name = "wkup_clkdm",
710 .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), 717 .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN),
711 .enable_bit = OMAP24XX_EN_54M_PLL_SHIFT, 718 .enable_bit = OMAP24XX_EN_54M_PLL_SHIFT,
712 .enable = &omap2_clk_fixed_enable, 719 .enable = &omap2_clk_fixed_enable,
@@ -741,6 +748,7 @@ static struct clk func_54m_ck = {
741 .parent = &apll54_ck, /* can also be alt_clk */ 748 .parent = &apll54_ck, /* can also be alt_clk */
742 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 749 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
743 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK, 750 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK,
751 .clkdm_name = "wkup_clkdm",
744 .init = &omap2_init_clksel_parent, 752 .init = &omap2_init_clksel_parent,
745 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), 753 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1),
746 .clksel_mask = OMAP24XX_54M_SOURCE, 754 .clksel_mask = OMAP24XX_54M_SOURCE,
@@ -753,6 +761,7 @@ static struct clk core_ck = {
753 .parent = &dpll_ck, /* can also be 32k */ 761 .parent = &dpll_ck, /* can also be 32k */
754 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 762 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
755 ALWAYS_ENABLED | RATE_PROPAGATES, 763 ALWAYS_ENABLED | RATE_PROPAGATES,
764 .clkdm_name = "wkup_clkdm",
756 .recalc = &followparent_recalc, 765 .recalc = &followparent_recalc,
757}; 766};
758 767
@@ -779,6 +788,7 @@ static struct clk func_96m_ck = {
779 .parent = &apll96_ck, 788 .parent = &apll96_ck,
780 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 789 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
781 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK, 790 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK,
791 .clkdm_name = "wkup_clkdm",
782 .init = &omap2_init_clksel_parent, 792 .init = &omap2_init_clksel_parent,
783 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), 793 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1),
784 .clksel_mask = OMAP2430_96M_SOURCE, 794 .clksel_mask = OMAP2430_96M_SOURCE,
@@ -811,6 +821,7 @@ static struct clk func_48m_ck = {
811 .parent = &apll96_ck, /* 96M or Alt */ 821 .parent = &apll96_ck, /* 96M or Alt */
812 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 822 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
813 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK, 823 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK,
824 .clkdm_name = "wkup_clkdm",
814 .init = &omap2_init_clksel_parent, 825 .init = &omap2_init_clksel_parent,
815 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), 826 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1),
816 .clksel_mask = OMAP24XX_48M_SOURCE, 827 .clksel_mask = OMAP24XX_48M_SOURCE,
@@ -826,6 +837,7 @@ static struct clk func_12m_ck = {
826 .fixed_div = 4, 837 .fixed_div = 4,
827 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 838 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
828 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK, 839 RATE_PROPAGATES | PARENT_CONTROLS_CLOCK,
840 .clkdm_name = "wkup_clkdm",
829 .recalc = &omap2_fixed_divisor_recalc, 841 .recalc = &omap2_fixed_divisor_recalc,
830}; 842};
831 843
@@ -878,6 +890,7 @@ static struct clk sys_clkout_src = {
878 .parent = &func_54m_ck, 890 .parent = &func_54m_ck,
879 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 891 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
880 RATE_PROPAGATES, 892 RATE_PROPAGATES,
893 .clkdm_name = "wkup_clkdm",
881 .enable_reg = OMAP24XX_PRCM_CLKOUT_CTRL, 894 .enable_reg = OMAP24XX_PRCM_CLKOUT_CTRL,
882 .enable_bit = OMAP24XX_CLKOUT_EN_SHIFT, 895 .enable_bit = OMAP24XX_CLKOUT_EN_SHIFT,
883 .init = &omap2_init_clksel_parent, 896 .init = &omap2_init_clksel_parent,
@@ -908,6 +921,7 @@ static struct clk sys_clkout = {
908 .parent = &sys_clkout_src, 921 .parent = &sys_clkout_src,
909 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 922 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
910 PARENT_CONTROLS_CLOCK, 923 PARENT_CONTROLS_CLOCK,
924 .clkdm_name = "wkup_clkdm",
911 .clksel_reg = OMAP24XX_PRCM_CLKOUT_CTRL, 925 .clksel_reg = OMAP24XX_PRCM_CLKOUT_CTRL,
912 .clksel_mask = OMAP24XX_CLKOUT_DIV_MASK, 926 .clksel_mask = OMAP24XX_CLKOUT_DIV_MASK,
913 .clksel = sys_clkout_clksel, 927 .clksel = sys_clkout_clksel,
@@ -921,6 +935,7 @@ static struct clk sys_clkout2_src = {
921 .name = "sys_clkout2_src", 935 .name = "sys_clkout2_src",
922 .parent = &func_54m_ck, 936 .parent = &func_54m_ck,
923 .flags = CLOCK_IN_OMAP242X | RATE_PROPAGATES, 937 .flags = CLOCK_IN_OMAP242X | RATE_PROPAGATES,
938 .clkdm_name = "wkup_clkdm",
924 .enable_reg = OMAP24XX_PRCM_CLKOUT_CTRL, 939 .enable_reg = OMAP24XX_PRCM_CLKOUT_CTRL,
925 .enable_bit = OMAP2420_CLKOUT2_EN_SHIFT, 940 .enable_bit = OMAP2420_CLKOUT2_EN_SHIFT,
926 .init = &omap2_init_clksel_parent, 941 .init = &omap2_init_clksel_parent,
@@ -942,6 +957,7 @@ static struct clk sys_clkout2 = {
942 .name = "sys_clkout2", 957 .name = "sys_clkout2",
943 .parent = &sys_clkout2_src, 958 .parent = &sys_clkout2_src,
944 .flags = CLOCK_IN_OMAP242X | PARENT_CONTROLS_CLOCK, 959 .flags = CLOCK_IN_OMAP242X | PARENT_CONTROLS_CLOCK,
960 .clkdm_name = "wkup_clkdm",
945 .clksel_reg = OMAP24XX_PRCM_CLKOUT_CTRL, 961 .clksel_reg = OMAP24XX_PRCM_CLKOUT_CTRL,
946 .clksel_mask = OMAP2420_CLKOUT2_DIV_MASK, 962 .clksel_mask = OMAP2420_CLKOUT2_DIV_MASK,
947 .clksel = sys_clkout2_clksel, 963 .clksel = sys_clkout2_clksel,
@@ -954,6 +970,7 @@ static struct clk emul_ck = {
954 .name = "emul_ck", 970 .name = "emul_ck",
955 .parent = &func_54m_ck, 971 .parent = &func_54m_ck,
956 .flags = CLOCK_IN_OMAP242X, 972 .flags = CLOCK_IN_OMAP242X,
973 .clkdm_name = "wkup_clkdm",
957 .enable_reg = OMAP24XX_PRCM_CLKEMUL_CTRL, 974 .enable_reg = OMAP24XX_PRCM_CLKEMUL_CTRL,
958 .enable_bit = OMAP24XX_EMULATION_EN_SHIFT, 975 .enable_bit = OMAP24XX_EMULATION_EN_SHIFT,
959 .recalc = &followparent_recalc, 976 .recalc = &followparent_recalc,
@@ -990,12 +1007,13 @@ static struct clk mpu_ck = { /* Control cpu */
990 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 1007 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
991 ALWAYS_ENABLED | DELAYED_APP | 1008 ALWAYS_ENABLED | DELAYED_APP |
992 CONFIG_PARTICIPANT | RATE_PROPAGATES, 1009 CONFIG_PARTICIPANT | RATE_PROPAGATES,
1010 .clkdm_name = "mpu_clkdm",
993 .init = &omap2_init_clksel_parent, 1011 .init = &omap2_init_clksel_parent,
994 .clksel_reg = OMAP_CM_REGADDR(MPU_MOD, CM_CLKSEL), 1012 .clksel_reg = OMAP_CM_REGADDR(MPU_MOD, CM_CLKSEL),
995 .clksel_mask = OMAP24XX_CLKSEL_MPU_MASK, 1013 .clksel_mask = OMAP24XX_CLKSEL_MPU_MASK,
996 .clksel = mpu_clksel, 1014 .clksel = mpu_clksel,
997 .recalc = &omap2_clksel_recalc, 1015 .recalc = &omap2_clksel_recalc,
998 .round_rate = &omap2_clksel_round_rate, 1016 .round_rate = &omap2_clksel_round_rate,
999 .set_rate = &omap2_clksel_set_rate 1017 .set_rate = &omap2_clksel_set_rate
1000}; 1018};
1001 1019
@@ -1031,6 +1049,7 @@ static struct clk dsp_fck = {
1031 .parent = &core_ck, 1049 .parent = &core_ck,
1032 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | DELAYED_APP | 1050 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | DELAYED_APP |
1033 CONFIG_PARTICIPANT | RATE_PROPAGATES, 1051 CONFIG_PARTICIPANT | RATE_PROPAGATES,
1052 .clkdm_name = "dsp_clkdm",
1034 .enable_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_FCLKEN), 1053 .enable_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_FCLKEN),
1035 .enable_bit = OMAP24XX_CM_FCLKEN_DSP_EN_DSP_SHIFT, 1054 .enable_bit = OMAP24XX_CM_FCLKEN_DSP_EN_DSP_SHIFT,
1036 .clksel_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_CLKSEL), 1055 .clksel_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_CLKSEL),
@@ -1054,10 +1073,7 @@ static const struct clksel dsp_irate_ick_clksel[] = {
1054 { .parent = NULL } 1073 { .parent = NULL }
1055}; 1074};
1056 1075
1057/* 1076/* This clock does not exist as such in the TRM. */
1058 * This clock does not exist as such in the TRM, but is added to
1059 * separate source selection from XXX
1060 */
1061static struct clk dsp_irate_ick = { 1077static struct clk dsp_irate_ick = {
1062 .name = "dsp_irate_ick", 1078 .name = "dsp_irate_ick",
1063 .parent = &dsp_fck, 1079 .parent = &dsp_fck,
@@ -1089,11 +1105,17 @@ static struct clk iva2_1_ick = {
1089 .enable_bit = OMAP24XX_CM_FCLKEN_DSP_EN_DSP_SHIFT, 1105 .enable_bit = OMAP24XX_CM_FCLKEN_DSP_EN_DSP_SHIFT,
1090}; 1106};
1091 1107
1108/*
1109 * The IVA1 is an ARM7 core on the 2420 that has nothing to do with
1110 * the C54x, but which is contained in the DSP powerdomain. Does not
1111 * exist on later OMAPs.
1112 */
1092static struct clk iva1_ifck = { 1113static struct clk iva1_ifck = {
1093 .name = "iva1_ifck", 1114 .name = "iva1_ifck",
1094 .parent = &core_ck, 1115 .parent = &core_ck,
1095 .flags = CLOCK_IN_OMAP242X | CONFIG_PARTICIPANT | 1116 .flags = CLOCK_IN_OMAP242X | CONFIG_PARTICIPANT |
1096 RATE_PROPAGATES | DELAYED_APP, 1117 RATE_PROPAGATES | DELAYED_APP,
1118 .clkdm_name = "iva1_clkdm",
1097 .enable_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_FCLKEN), 1119 .enable_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_FCLKEN),
1098 .enable_bit = OMAP2420_EN_IVA_COP_SHIFT, 1120 .enable_bit = OMAP2420_EN_IVA_COP_SHIFT,
1099 .clksel_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_CLKSEL), 1121 .clksel_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_CLKSEL),
@@ -1109,6 +1131,7 @@ static struct clk iva1_mpu_int_ifck = {
1109 .name = "iva1_mpu_int_ifck", 1131 .name = "iva1_mpu_int_ifck",
1110 .parent = &iva1_ifck, 1132 .parent = &iva1_ifck,
1111 .flags = CLOCK_IN_OMAP242X, 1133 .flags = CLOCK_IN_OMAP242X,
1134 .clkdm_name = "iva1_clkdm",
1112 .enable_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_FCLKEN), 1135 .enable_reg = OMAP_CM_REGADDR(OMAP24XX_DSP_MOD, CM_FCLKEN),
1113 .enable_bit = OMAP2420_EN_IVA_MPU_SHIFT, 1136 .enable_bit = OMAP2420_EN_IVA_MPU_SHIFT,
1114 .fixed_div = 2, 1137 .fixed_div = 2,
@@ -1156,6 +1179,7 @@ static struct clk core_l3_ck = { /* Used for ick and fck, interconnect */
1156 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 1179 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1157 ALWAYS_ENABLED | DELAYED_APP | 1180 ALWAYS_ENABLED | DELAYED_APP |
1158 CONFIG_PARTICIPANT | RATE_PROPAGATES, 1181 CONFIG_PARTICIPANT | RATE_PROPAGATES,
1182 .clkdm_name = "core_l3_clkdm",
1159 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1), 1183 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1),
1160 .clksel_mask = OMAP24XX_CLKSEL_L3_MASK, 1184 .clksel_mask = OMAP24XX_CLKSEL_L3_MASK,
1161 .clksel = core_l3_clksel, 1185 .clksel = core_l3_clksel,
@@ -1177,11 +1201,13 @@ static const struct clksel usb_l4_ick_clksel[] = {
1177 { .parent = NULL }, 1201 { .parent = NULL },
1178}; 1202};
1179 1203
1204/* It is unclear from TRM whether usb_l4_ick is really in L3 or L4 clkdm */
1180static struct clk usb_l4_ick = { /* FS-USB interface clock */ 1205static struct clk usb_l4_ick = { /* FS-USB interface clock */
1181 .name = "usb_l4_ick", 1206 .name = "usb_l4_ick",
1182 .parent = &core_l3_ck, 1207 .parent = &core_l3_ck,
1183 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 1208 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1184 DELAYED_APP | CONFIG_PARTICIPANT, 1209 DELAYED_APP | CONFIG_PARTICIPANT,
1210 .clkdm_name = "core_l4_clkdm",
1185 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 1211 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1186 .enable_bit = OMAP24XX_EN_USB_SHIFT, 1212 .enable_bit = OMAP24XX_EN_USB_SHIFT,
1187 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1), 1213 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1),
@@ -1193,10 +1219,42 @@ static struct clk usb_l4_ick = { /* FS-USB interface clock */
1193}; 1219};
1194 1220
1195/* 1221/*
1222 * L4 clock management domain
1223 *
1224 * This domain contains lots of interface clocks from the L4 interface, some
1225 * functional clocks. Fixed APLL functional source clocks are managed in
1226 * this domain.
1227 */
1228static const struct clksel_rate l4_core_l3_rates[] = {
1229 { .div = 1, .val = 1, .flags = RATE_IN_24XX | DEFAULT_RATE },
1230 { .div = 2, .val = 2, .flags = RATE_IN_24XX },
1231 { .div = 0 }
1232};
1233
1234static const struct clksel l4_clksel[] = {
1235 { .parent = &core_l3_ck, .rates = l4_core_l3_rates },
1236 { .parent = NULL }
1237};
1238
1239static struct clk l4_ck = { /* used both as an ick and fck */
1240 .name = "l4_ck",
1241 .parent = &core_l3_ck,
1242 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1243 ALWAYS_ENABLED | DELAYED_APP | RATE_PROPAGATES,
1244 .clkdm_name = "core_l4_clkdm",
1245 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1),
1246 .clksel_mask = OMAP24XX_CLKSEL_L4_MASK,
1247 .clksel = l4_clksel,
1248 .recalc = &omap2_clksel_recalc,
1249 .round_rate = &omap2_clksel_round_rate,
1250 .set_rate = &omap2_clksel_set_rate
1251};
1252
1253/*
1196 * SSI is in L3 management domain, its direct parent is core not l3, 1254 * SSI is in L3 management domain, its direct parent is core not l3,
1197 * many core power domain entities are grouped into the L3 clock 1255 * many core power domain entities are grouped into the L3 clock
1198 * domain. 1256 * domain.
1199 * SSI_SSR_FCLK, SSI_SST_FCLK, SSI_L4_CLIK 1257 * SSI_SSR_FCLK, SSI_SST_FCLK, SSI_L4_ICLK
1200 * 1258 *
1201 * ssr = core/1/2/3/4/5, sst = 1/2 ssr. 1259 * ssr = core/1/2/3/4/5, sst = 1/2 ssr.
1202 */ 1260 */
@@ -1221,6 +1279,7 @@ static struct clk ssi_ssr_sst_fck = {
1221 .parent = &core_ck, 1279 .parent = &core_ck,
1222 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 1280 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1223 DELAYED_APP, 1281 DELAYED_APP,
1282 .clkdm_name = "core_l3_clkdm",
1224 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1283 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1225 .enable_bit = OMAP24XX_EN_SSI_SHIFT, 1284 .enable_bit = OMAP24XX_EN_SSI_SHIFT,
1226 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1), 1285 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1),
@@ -1231,6 +1290,7 @@ static struct clk ssi_ssr_sst_fck = {
1231 .set_rate = &omap2_clksel_set_rate 1290 .set_rate = &omap2_clksel_set_rate
1232}; 1291};
1233 1292
1293
1234/* 1294/*
1235 * GFX clock domain 1295 * GFX clock domain
1236 * Clocks: 1296 * Clocks:
@@ -1254,6 +1314,7 @@ static struct clk gfx_3d_fck = {
1254 .name = "gfx_3d_fck", 1314 .name = "gfx_3d_fck",
1255 .parent = &core_l3_ck, 1315 .parent = &core_l3_ck,
1256 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1316 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1317 .clkdm_name = "gfx_clkdm",
1257 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN), 1318 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN),
1258 .enable_bit = OMAP24XX_EN_3D_SHIFT, 1319 .enable_bit = OMAP24XX_EN_3D_SHIFT,
1259 .clksel_reg = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL), 1320 .clksel_reg = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL),
@@ -1268,6 +1329,7 @@ static struct clk gfx_2d_fck = {
1268 .name = "gfx_2d_fck", 1329 .name = "gfx_2d_fck",
1269 .parent = &core_l3_ck, 1330 .parent = &core_l3_ck,
1270 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1331 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1332 .clkdm_name = "gfx_clkdm",
1271 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN), 1333 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN),
1272 .enable_bit = OMAP24XX_EN_2D_SHIFT, 1334 .enable_bit = OMAP24XX_EN_2D_SHIFT,
1273 .clksel_reg = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL), 1335 .clksel_reg = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL),
@@ -1282,6 +1344,7 @@ static struct clk gfx_ick = {
1282 .name = "gfx_ick", /* From l3 */ 1344 .name = "gfx_ick", /* From l3 */
1283 .parent = &core_l3_ck, 1345 .parent = &core_l3_ck,
1284 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1346 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1347 .clkdm_name = "gfx_clkdm",
1285 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_ICLKEN), 1348 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_ICLKEN),
1286 .enable_bit = OMAP_EN_GFX_SHIFT, 1349 .enable_bit = OMAP_EN_GFX_SHIFT,
1287 .recalc = &followparent_recalc, 1350 .recalc = &followparent_recalc,
@@ -1311,6 +1374,7 @@ static struct clk mdm_ick = { /* used both as a ick and fck */
1311 .name = "mdm_ick", 1374 .name = "mdm_ick",
1312 .parent = &core_ck, 1375 .parent = &core_ck,
1313 .flags = CLOCK_IN_OMAP243X | DELAYED_APP | CONFIG_PARTICIPANT, 1376 .flags = CLOCK_IN_OMAP243X | DELAYED_APP | CONFIG_PARTICIPANT,
1377 .clkdm_name = "mdm_clkdm",
1314 .enable_reg = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_ICLKEN), 1378 .enable_reg = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_ICLKEN),
1315 .enable_bit = OMAP2430_CM_ICLKEN_MDM_EN_MDM_SHIFT, 1379 .enable_bit = OMAP2430_CM_ICLKEN_MDM_EN_MDM_SHIFT,
1316 .clksel_reg = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_CLKSEL), 1380 .clksel_reg = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_CLKSEL),
@@ -1325,52 +1389,13 @@ static struct clk mdm_osc_ck = {
1325 .name = "mdm_osc_ck", 1389 .name = "mdm_osc_ck",
1326 .parent = &osc_ck, 1390 .parent = &osc_ck,
1327 .flags = CLOCK_IN_OMAP243X, 1391 .flags = CLOCK_IN_OMAP243X,
1392 .clkdm_name = "mdm_clkdm",
1328 .enable_reg = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_FCLKEN), 1393 .enable_reg = OMAP_CM_REGADDR(OMAP2430_MDM_MOD, CM_FCLKEN),
1329 .enable_bit = OMAP2430_EN_OSC_SHIFT, 1394 .enable_bit = OMAP2430_EN_OSC_SHIFT,
1330 .recalc = &followparent_recalc, 1395 .recalc = &followparent_recalc,
1331}; 1396};
1332 1397
1333/* 1398/*
1334 * L4 clock management domain
1335 *
1336 * This domain contains lots of interface clocks from the L4 interface, some
1337 * functional clocks. Fixed APLL functional source clocks are managed in
1338 * this domain.
1339 */
1340static const struct clksel_rate l4_core_l3_rates[] = {
1341 { .div = 1, .val = 1, .flags = RATE_IN_24XX | DEFAULT_RATE },
1342 { .div = 2, .val = 2, .flags = RATE_IN_24XX },
1343 { .div = 0 }
1344};
1345
1346static const struct clksel l4_clksel[] = {
1347 { .parent = &core_l3_ck, .rates = l4_core_l3_rates },
1348 { .parent = NULL }
1349};
1350
1351static struct clk l4_ck = { /* used both as an ick and fck */
1352 .name = "l4_ck",
1353 .parent = &core_l3_ck,
1354 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1355 ALWAYS_ENABLED | DELAYED_APP | RATE_PROPAGATES,
1356 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL1),
1357 .clksel_mask = OMAP24XX_CLKSEL_L4_MASK,
1358 .clksel = l4_clksel,
1359 .recalc = &omap2_clksel_recalc,
1360 .round_rate = &omap2_clksel_round_rate,
1361 .set_rate = &omap2_clksel_set_rate
1362};
1363
1364static struct clk ssi_l4_ick = {
1365 .name = "ssi_l4_ick",
1366 .parent = &l4_ck,
1367 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1368 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1369 .enable_bit = OMAP24XX_EN_SSI_SHIFT,
1370 .recalc = &followparent_recalc,
1371};
1372
1373/*
1374 * DSS clock domain 1399 * DSS clock domain
1375 * CLOCKs: 1400 * CLOCKs:
1376 * DSS_L4_ICLK, DSS_L3_ICLK, 1401 * DSS_L4_ICLK, DSS_L3_ICLK,
@@ -1409,6 +1434,7 @@ static struct clk dss_ick = { /* Enables both L3,L4 ICLK's */
1409 .name = "dss_ick", 1434 .name = "dss_ick",
1410 .parent = &l4_ck, /* really both l3 and l4 */ 1435 .parent = &l4_ck, /* really both l3 and l4 */
1411 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1436 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1437 .clkdm_name = "dss_clkdm",
1412 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1438 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1413 .enable_bit = OMAP24XX_EN_DSS1_SHIFT, 1439 .enable_bit = OMAP24XX_EN_DSS1_SHIFT,
1414 .recalc = &followparent_recalc, 1440 .recalc = &followparent_recalc,
@@ -1419,6 +1445,7 @@ static struct clk dss1_fck = {
1419 .parent = &core_ck, /* Core or sys */ 1445 .parent = &core_ck, /* Core or sys */
1420 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 1446 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1421 DELAYED_APP, 1447 DELAYED_APP,
1448 .clkdm_name = "dss_clkdm",
1422 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1449 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1423 .enable_bit = OMAP24XX_EN_DSS1_SHIFT, 1450 .enable_bit = OMAP24XX_EN_DSS1_SHIFT,
1424 .init = &omap2_init_clksel_parent, 1451 .init = &omap2_init_clksel_parent,
@@ -1451,6 +1478,7 @@ static struct clk dss2_fck = { /* Alt clk used in power management */
1451 .parent = &sys_ck, /* fixed at sys_ck or 48MHz */ 1478 .parent = &sys_ck, /* fixed at sys_ck or 48MHz */
1452 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | 1479 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
1453 DELAYED_APP, 1480 DELAYED_APP,
1481 .clkdm_name = "dss_clkdm",
1454 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1482 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1455 .enable_bit = OMAP24XX_EN_DSS2_SHIFT, 1483 .enable_bit = OMAP24XX_EN_DSS2_SHIFT,
1456 .init = &omap2_init_clksel_parent, 1484 .init = &omap2_init_clksel_parent,
@@ -1464,6 +1492,7 @@ static struct clk dss_54m_fck = { /* Alt clk used in power management */
1464 .name = "dss_54m_fck", /* 54m tv clk */ 1492 .name = "dss_54m_fck", /* 54m tv clk */
1465 .parent = &func_54m_ck, 1493 .parent = &func_54m_ck,
1466 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1494 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1495 .clkdm_name = "dss_clkdm",
1467 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1496 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1468 .enable_bit = OMAP24XX_EN_TV_SHIFT, 1497 .enable_bit = OMAP24XX_EN_TV_SHIFT,
1469 .recalc = &followparent_recalc, 1498 .recalc = &followparent_recalc,
@@ -1491,6 +1520,7 @@ static struct clk gpt1_ick = {
1491 .name = "gpt1_ick", 1520 .name = "gpt1_ick",
1492 .parent = &l4_ck, 1521 .parent = &l4_ck,
1493 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1522 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1523 .clkdm_name = "core_l4_clkdm",
1494 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 1524 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
1495 .enable_bit = OMAP24XX_EN_GPT1_SHIFT, 1525 .enable_bit = OMAP24XX_EN_GPT1_SHIFT,
1496 .recalc = &followparent_recalc, 1526 .recalc = &followparent_recalc,
@@ -1500,6 +1530,7 @@ static struct clk gpt1_fck = {
1500 .name = "gpt1_fck", 1530 .name = "gpt1_fck",
1501 .parent = &func_32k_ck, 1531 .parent = &func_32k_ck,
1502 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1532 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1533 .clkdm_name = "core_l4_clkdm",
1503 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN), 1534 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN),
1504 .enable_bit = OMAP24XX_EN_GPT1_SHIFT, 1535 .enable_bit = OMAP24XX_EN_GPT1_SHIFT,
1505 .init = &omap2_init_clksel_parent, 1536 .init = &omap2_init_clksel_parent,
@@ -1515,6 +1546,7 @@ static struct clk gpt2_ick = {
1515 .name = "gpt2_ick", 1546 .name = "gpt2_ick",
1516 .parent = &l4_ck, 1547 .parent = &l4_ck,
1517 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1548 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1549 .clkdm_name = "core_l4_clkdm",
1518 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1550 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1519 .enable_bit = OMAP24XX_EN_GPT2_SHIFT, 1551 .enable_bit = OMAP24XX_EN_GPT2_SHIFT,
1520 .recalc = &followparent_recalc, 1552 .recalc = &followparent_recalc,
@@ -1524,6 +1556,7 @@ static struct clk gpt2_fck = {
1524 .name = "gpt2_fck", 1556 .name = "gpt2_fck",
1525 .parent = &func_32k_ck, 1557 .parent = &func_32k_ck,
1526 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1558 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1559 .clkdm_name = "core_l4_clkdm",
1527 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1560 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1528 .enable_bit = OMAP24XX_EN_GPT2_SHIFT, 1561 .enable_bit = OMAP24XX_EN_GPT2_SHIFT,
1529 .init = &omap2_init_clksel_parent, 1562 .init = &omap2_init_clksel_parent,
@@ -1537,6 +1570,7 @@ static struct clk gpt3_ick = {
1537 .name = "gpt3_ick", 1570 .name = "gpt3_ick",
1538 .parent = &l4_ck, 1571 .parent = &l4_ck,
1539 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1572 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1573 .clkdm_name = "core_l4_clkdm",
1540 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1574 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1541 .enable_bit = OMAP24XX_EN_GPT3_SHIFT, 1575 .enable_bit = OMAP24XX_EN_GPT3_SHIFT,
1542 .recalc = &followparent_recalc, 1576 .recalc = &followparent_recalc,
@@ -1546,6 +1580,7 @@ static struct clk gpt3_fck = {
1546 .name = "gpt3_fck", 1580 .name = "gpt3_fck",
1547 .parent = &func_32k_ck, 1581 .parent = &func_32k_ck,
1548 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1582 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1583 .clkdm_name = "core_l4_clkdm",
1549 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1584 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1550 .enable_bit = OMAP24XX_EN_GPT3_SHIFT, 1585 .enable_bit = OMAP24XX_EN_GPT3_SHIFT,
1551 .init = &omap2_init_clksel_parent, 1586 .init = &omap2_init_clksel_parent,
@@ -1559,6 +1594,7 @@ static struct clk gpt4_ick = {
1559 .name = "gpt4_ick", 1594 .name = "gpt4_ick",
1560 .parent = &l4_ck, 1595 .parent = &l4_ck,
1561 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1596 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1597 .clkdm_name = "core_l4_clkdm",
1562 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1598 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1563 .enable_bit = OMAP24XX_EN_GPT4_SHIFT, 1599 .enable_bit = OMAP24XX_EN_GPT4_SHIFT,
1564 .recalc = &followparent_recalc, 1600 .recalc = &followparent_recalc,
@@ -1568,6 +1604,7 @@ static struct clk gpt4_fck = {
1568 .name = "gpt4_fck", 1604 .name = "gpt4_fck",
1569 .parent = &func_32k_ck, 1605 .parent = &func_32k_ck,
1570 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1606 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1607 .clkdm_name = "core_l4_clkdm",
1571 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1608 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1572 .enable_bit = OMAP24XX_EN_GPT4_SHIFT, 1609 .enable_bit = OMAP24XX_EN_GPT4_SHIFT,
1573 .init = &omap2_init_clksel_parent, 1610 .init = &omap2_init_clksel_parent,
@@ -1581,6 +1618,7 @@ static struct clk gpt5_ick = {
1581 .name = "gpt5_ick", 1618 .name = "gpt5_ick",
1582 .parent = &l4_ck, 1619 .parent = &l4_ck,
1583 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1620 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1621 .clkdm_name = "core_l4_clkdm",
1584 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1622 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1585 .enable_bit = OMAP24XX_EN_GPT5_SHIFT, 1623 .enable_bit = OMAP24XX_EN_GPT5_SHIFT,
1586 .recalc = &followparent_recalc, 1624 .recalc = &followparent_recalc,
@@ -1590,6 +1628,7 @@ static struct clk gpt5_fck = {
1590 .name = "gpt5_fck", 1628 .name = "gpt5_fck",
1591 .parent = &func_32k_ck, 1629 .parent = &func_32k_ck,
1592 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1630 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1631 .clkdm_name = "core_l4_clkdm",
1593 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1632 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1594 .enable_bit = OMAP24XX_EN_GPT5_SHIFT, 1633 .enable_bit = OMAP24XX_EN_GPT5_SHIFT,
1595 .init = &omap2_init_clksel_parent, 1634 .init = &omap2_init_clksel_parent,
@@ -1603,6 +1642,7 @@ static struct clk gpt6_ick = {
1603 .name = "gpt6_ick", 1642 .name = "gpt6_ick",
1604 .parent = &l4_ck, 1643 .parent = &l4_ck,
1605 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1644 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1645 .clkdm_name = "core_l4_clkdm",
1606 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1646 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1607 .enable_bit = OMAP24XX_EN_GPT6_SHIFT, 1647 .enable_bit = OMAP24XX_EN_GPT6_SHIFT,
1608 .recalc = &followparent_recalc, 1648 .recalc = &followparent_recalc,
@@ -1612,6 +1652,7 @@ static struct clk gpt6_fck = {
1612 .name = "gpt6_fck", 1652 .name = "gpt6_fck",
1613 .parent = &func_32k_ck, 1653 .parent = &func_32k_ck,
1614 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1654 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1655 .clkdm_name = "core_l4_clkdm",
1615 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1656 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1616 .enable_bit = OMAP24XX_EN_GPT6_SHIFT, 1657 .enable_bit = OMAP24XX_EN_GPT6_SHIFT,
1617 .init = &omap2_init_clksel_parent, 1658 .init = &omap2_init_clksel_parent,
@@ -1634,6 +1675,7 @@ static struct clk gpt7_fck = {
1634 .name = "gpt7_fck", 1675 .name = "gpt7_fck",
1635 .parent = &func_32k_ck, 1676 .parent = &func_32k_ck,
1636 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1677 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1678 .clkdm_name = "core_l4_clkdm",
1637 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1679 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1638 .enable_bit = OMAP24XX_EN_GPT7_SHIFT, 1680 .enable_bit = OMAP24XX_EN_GPT7_SHIFT,
1639 .init = &omap2_init_clksel_parent, 1681 .init = &omap2_init_clksel_parent,
@@ -1647,6 +1689,7 @@ static struct clk gpt8_ick = {
1647 .name = "gpt8_ick", 1689 .name = "gpt8_ick",
1648 .parent = &l4_ck, 1690 .parent = &l4_ck,
1649 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1691 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1692 .clkdm_name = "core_l4_clkdm",
1650 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1693 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1651 .enable_bit = OMAP24XX_EN_GPT8_SHIFT, 1694 .enable_bit = OMAP24XX_EN_GPT8_SHIFT,
1652 .recalc = &followparent_recalc, 1695 .recalc = &followparent_recalc,
@@ -1656,6 +1699,7 @@ static struct clk gpt8_fck = {
1656 .name = "gpt8_fck", 1699 .name = "gpt8_fck",
1657 .parent = &func_32k_ck, 1700 .parent = &func_32k_ck,
1658 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1701 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1702 .clkdm_name = "core_l4_clkdm",
1659 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1703 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1660 .enable_bit = OMAP24XX_EN_GPT8_SHIFT, 1704 .enable_bit = OMAP24XX_EN_GPT8_SHIFT,
1661 .init = &omap2_init_clksel_parent, 1705 .init = &omap2_init_clksel_parent,
@@ -1669,6 +1713,7 @@ static struct clk gpt9_ick = {
1669 .name = "gpt9_ick", 1713 .name = "gpt9_ick",
1670 .parent = &l4_ck, 1714 .parent = &l4_ck,
1671 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1715 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1716 .clkdm_name = "core_l4_clkdm",
1672 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1717 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1673 .enable_bit = OMAP24XX_EN_GPT9_SHIFT, 1718 .enable_bit = OMAP24XX_EN_GPT9_SHIFT,
1674 .recalc = &followparent_recalc, 1719 .recalc = &followparent_recalc,
@@ -1678,6 +1723,7 @@ static struct clk gpt9_fck = {
1678 .name = "gpt9_fck", 1723 .name = "gpt9_fck",
1679 .parent = &func_32k_ck, 1724 .parent = &func_32k_ck,
1680 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1725 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1726 .clkdm_name = "core_l4_clkdm",
1681 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1727 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1682 .enable_bit = OMAP24XX_EN_GPT9_SHIFT, 1728 .enable_bit = OMAP24XX_EN_GPT9_SHIFT,
1683 .init = &omap2_init_clksel_parent, 1729 .init = &omap2_init_clksel_parent,
@@ -1691,6 +1737,7 @@ static struct clk gpt10_ick = {
1691 .name = "gpt10_ick", 1737 .name = "gpt10_ick",
1692 .parent = &l4_ck, 1738 .parent = &l4_ck,
1693 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1739 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1740 .clkdm_name = "core_l4_clkdm",
1694 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1741 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1695 .enable_bit = OMAP24XX_EN_GPT10_SHIFT, 1742 .enable_bit = OMAP24XX_EN_GPT10_SHIFT,
1696 .recalc = &followparent_recalc, 1743 .recalc = &followparent_recalc,
@@ -1700,6 +1747,7 @@ static struct clk gpt10_fck = {
1700 .name = "gpt10_fck", 1747 .name = "gpt10_fck",
1701 .parent = &func_32k_ck, 1748 .parent = &func_32k_ck,
1702 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1749 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1750 .clkdm_name = "core_l4_clkdm",
1703 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1751 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1704 .enable_bit = OMAP24XX_EN_GPT10_SHIFT, 1752 .enable_bit = OMAP24XX_EN_GPT10_SHIFT,
1705 .init = &omap2_init_clksel_parent, 1753 .init = &omap2_init_clksel_parent,
@@ -1713,6 +1761,7 @@ static struct clk gpt11_ick = {
1713 .name = "gpt11_ick", 1761 .name = "gpt11_ick",
1714 .parent = &l4_ck, 1762 .parent = &l4_ck,
1715 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1763 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1764 .clkdm_name = "core_l4_clkdm",
1716 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1765 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1717 .enable_bit = OMAP24XX_EN_GPT11_SHIFT, 1766 .enable_bit = OMAP24XX_EN_GPT11_SHIFT,
1718 .recalc = &followparent_recalc, 1767 .recalc = &followparent_recalc,
@@ -1722,6 +1771,7 @@ static struct clk gpt11_fck = {
1722 .name = "gpt11_fck", 1771 .name = "gpt11_fck",
1723 .parent = &func_32k_ck, 1772 .parent = &func_32k_ck,
1724 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1773 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1774 .clkdm_name = "core_l4_clkdm",
1725 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1775 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1726 .enable_bit = OMAP24XX_EN_GPT11_SHIFT, 1776 .enable_bit = OMAP24XX_EN_GPT11_SHIFT,
1727 .init = &omap2_init_clksel_parent, 1777 .init = &omap2_init_clksel_parent,
@@ -1735,6 +1785,7 @@ static struct clk gpt12_ick = {
1735 .name = "gpt12_ick", 1785 .name = "gpt12_ick",
1736 .parent = &l4_ck, 1786 .parent = &l4_ck,
1737 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1787 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1788 .clkdm_name = "core_l4_clkdm",
1738 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1789 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1739 .enable_bit = OMAP24XX_EN_GPT12_SHIFT, 1790 .enable_bit = OMAP24XX_EN_GPT12_SHIFT,
1740 .recalc = &followparent_recalc, 1791 .recalc = &followparent_recalc,
@@ -1744,6 +1795,7 @@ static struct clk gpt12_fck = {
1744 .name = "gpt12_fck", 1795 .name = "gpt12_fck",
1745 .parent = &func_32k_ck, 1796 .parent = &func_32k_ck,
1746 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1797 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1798 .clkdm_name = "core_l4_clkdm",
1747 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1799 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1748 .enable_bit = OMAP24XX_EN_GPT12_SHIFT, 1800 .enable_bit = OMAP24XX_EN_GPT12_SHIFT,
1749 .init = &omap2_init_clksel_parent, 1801 .init = &omap2_init_clksel_parent,
@@ -1758,6 +1810,7 @@ static struct clk mcbsp1_ick = {
1758 .id = 1, 1810 .id = 1,
1759 .parent = &l4_ck, 1811 .parent = &l4_ck,
1760 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1812 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1813 .clkdm_name = "core_l4_clkdm",
1761 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1814 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1762 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT, 1815 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT,
1763 .recalc = &followparent_recalc, 1816 .recalc = &followparent_recalc,
@@ -1768,6 +1821,7 @@ static struct clk mcbsp1_fck = {
1768 .id = 1, 1821 .id = 1,
1769 .parent = &func_96m_ck, 1822 .parent = &func_96m_ck,
1770 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1823 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1824 .clkdm_name = "core_l4_clkdm",
1771 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1825 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1772 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT, 1826 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT,
1773 .recalc = &followparent_recalc, 1827 .recalc = &followparent_recalc,
@@ -1778,6 +1832,7 @@ static struct clk mcbsp2_ick = {
1778 .id = 2, 1832 .id = 2,
1779 .parent = &l4_ck, 1833 .parent = &l4_ck,
1780 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1834 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1835 .clkdm_name = "core_l4_clkdm",
1781 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1836 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1782 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT, 1837 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT,
1783 .recalc = &followparent_recalc, 1838 .recalc = &followparent_recalc,
@@ -1788,6 +1843,7 @@ static struct clk mcbsp2_fck = {
1788 .id = 2, 1843 .id = 2,
1789 .parent = &func_96m_ck, 1844 .parent = &func_96m_ck,
1790 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1845 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1846 .clkdm_name = "core_l4_clkdm",
1791 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1847 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1792 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT, 1848 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT,
1793 .recalc = &followparent_recalc, 1849 .recalc = &followparent_recalc,
@@ -1798,6 +1854,7 @@ static struct clk mcbsp3_ick = {
1798 .id = 3, 1854 .id = 3,
1799 .parent = &l4_ck, 1855 .parent = &l4_ck,
1800 .flags = CLOCK_IN_OMAP243X, 1856 .flags = CLOCK_IN_OMAP243X,
1857 .clkdm_name = "core_l4_clkdm",
1801 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 1858 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1802 .enable_bit = OMAP2430_EN_MCBSP3_SHIFT, 1859 .enable_bit = OMAP2430_EN_MCBSP3_SHIFT,
1803 .recalc = &followparent_recalc, 1860 .recalc = &followparent_recalc,
@@ -1808,6 +1865,7 @@ static struct clk mcbsp3_fck = {
1808 .id = 3, 1865 .id = 3,
1809 .parent = &func_96m_ck, 1866 .parent = &func_96m_ck,
1810 .flags = CLOCK_IN_OMAP243X, 1867 .flags = CLOCK_IN_OMAP243X,
1868 .clkdm_name = "core_l4_clkdm",
1811 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1869 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1812 .enable_bit = OMAP2430_EN_MCBSP3_SHIFT, 1870 .enable_bit = OMAP2430_EN_MCBSP3_SHIFT,
1813 .recalc = &followparent_recalc, 1871 .recalc = &followparent_recalc,
@@ -1818,6 +1876,7 @@ static struct clk mcbsp4_ick = {
1818 .id = 4, 1876 .id = 4,
1819 .parent = &l4_ck, 1877 .parent = &l4_ck,
1820 .flags = CLOCK_IN_OMAP243X, 1878 .flags = CLOCK_IN_OMAP243X,
1879 .clkdm_name = "core_l4_clkdm",
1821 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 1880 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1822 .enable_bit = OMAP2430_EN_MCBSP4_SHIFT, 1881 .enable_bit = OMAP2430_EN_MCBSP4_SHIFT,
1823 .recalc = &followparent_recalc, 1882 .recalc = &followparent_recalc,
@@ -1828,6 +1887,7 @@ static struct clk mcbsp4_fck = {
1828 .id = 4, 1887 .id = 4,
1829 .parent = &func_96m_ck, 1888 .parent = &func_96m_ck,
1830 .flags = CLOCK_IN_OMAP243X, 1889 .flags = CLOCK_IN_OMAP243X,
1890 .clkdm_name = "core_l4_clkdm",
1831 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1891 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1832 .enable_bit = OMAP2430_EN_MCBSP4_SHIFT, 1892 .enable_bit = OMAP2430_EN_MCBSP4_SHIFT,
1833 .recalc = &followparent_recalc, 1893 .recalc = &followparent_recalc,
@@ -1838,6 +1898,7 @@ static struct clk mcbsp5_ick = {
1838 .id = 5, 1898 .id = 5,
1839 .parent = &l4_ck, 1899 .parent = &l4_ck,
1840 .flags = CLOCK_IN_OMAP243X, 1900 .flags = CLOCK_IN_OMAP243X,
1901 .clkdm_name = "core_l4_clkdm",
1841 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 1902 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1842 .enable_bit = OMAP2430_EN_MCBSP5_SHIFT, 1903 .enable_bit = OMAP2430_EN_MCBSP5_SHIFT,
1843 .recalc = &followparent_recalc, 1904 .recalc = &followparent_recalc,
@@ -1848,6 +1909,7 @@ static struct clk mcbsp5_fck = {
1848 .id = 5, 1909 .id = 5,
1849 .parent = &func_96m_ck, 1910 .parent = &func_96m_ck,
1850 .flags = CLOCK_IN_OMAP243X, 1911 .flags = CLOCK_IN_OMAP243X,
1912 .clkdm_name = "core_l4_clkdm",
1851 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1913 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1852 .enable_bit = OMAP2430_EN_MCBSP5_SHIFT, 1914 .enable_bit = OMAP2430_EN_MCBSP5_SHIFT,
1853 .recalc = &followparent_recalc, 1915 .recalc = &followparent_recalc,
@@ -1857,6 +1919,7 @@ static struct clk mcspi1_ick = {
1857 .name = "mcspi_ick", 1919 .name = "mcspi_ick",
1858 .id = 1, 1920 .id = 1,
1859 .parent = &l4_ck, 1921 .parent = &l4_ck,
1922 .clkdm_name = "core_l4_clkdm",
1860 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1923 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1861 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1924 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1862 .enable_bit = OMAP24XX_EN_MCSPI1_SHIFT, 1925 .enable_bit = OMAP24XX_EN_MCSPI1_SHIFT,
@@ -1868,6 +1931,7 @@ static struct clk mcspi1_fck = {
1868 .id = 1, 1931 .id = 1,
1869 .parent = &func_48m_ck, 1932 .parent = &func_48m_ck,
1870 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1933 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1934 .clkdm_name = "core_l4_clkdm",
1871 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1935 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1872 .enable_bit = OMAP24XX_EN_MCSPI1_SHIFT, 1936 .enable_bit = OMAP24XX_EN_MCSPI1_SHIFT,
1873 .recalc = &followparent_recalc, 1937 .recalc = &followparent_recalc,
@@ -1878,6 +1942,7 @@ static struct clk mcspi2_ick = {
1878 .id = 2, 1942 .id = 2,
1879 .parent = &l4_ck, 1943 .parent = &l4_ck,
1880 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1944 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1945 .clkdm_name = "core_l4_clkdm",
1881 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1946 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1882 .enable_bit = OMAP24XX_EN_MCSPI2_SHIFT, 1947 .enable_bit = OMAP24XX_EN_MCSPI2_SHIFT,
1883 .recalc = &followparent_recalc, 1948 .recalc = &followparent_recalc,
@@ -1888,6 +1953,7 @@ static struct clk mcspi2_fck = {
1888 .id = 2, 1953 .id = 2,
1889 .parent = &func_48m_ck, 1954 .parent = &func_48m_ck,
1890 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1955 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1956 .clkdm_name = "core_l4_clkdm",
1891 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1957 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1892 .enable_bit = OMAP24XX_EN_MCSPI2_SHIFT, 1958 .enable_bit = OMAP24XX_EN_MCSPI2_SHIFT,
1893 .recalc = &followparent_recalc, 1959 .recalc = &followparent_recalc,
@@ -1898,6 +1964,7 @@ static struct clk mcspi3_ick = {
1898 .id = 3, 1964 .id = 3,
1899 .parent = &l4_ck, 1965 .parent = &l4_ck,
1900 .flags = CLOCK_IN_OMAP243X, 1966 .flags = CLOCK_IN_OMAP243X,
1967 .clkdm_name = "core_l4_clkdm",
1901 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 1968 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1902 .enable_bit = OMAP2430_EN_MCSPI3_SHIFT, 1969 .enable_bit = OMAP2430_EN_MCSPI3_SHIFT,
1903 .recalc = &followparent_recalc, 1970 .recalc = &followparent_recalc,
@@ -1908,6 +1975,7 @@ static struct clk mcspi3_fck = {
1908 .id = 3, 1975 .id = 3,
1909 .parent = &func_48m_ck, 1976 .parent = &func_48m_ck,
1910 .flags = CLOCK_IN_OMAP243X, 1977 .flags = CLOCK_IN_OMAP243X,
1978 .clkdm_name = "core_l4_clkdm",
1911 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1979 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1912 .enable_bit = OMAP2430_EN_MCSPI3_SHIFT, 1980 .enable_bit = OMAP2430_EN_MCSPI3_SHIFT,
1913 .recalc = &followparent_recalc, 1981 .recalc = &followparent_recalc,
@@ -1917,6 +1985,7 @@ static struct clk uart1_ick = {
1917 .name = "uart1_ick", 1985 .name = "uart1_ick",
1918 .parent = &l4_ck, 1986 .parent = &l4_ck,
1919 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1987 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1988 .clkdm_name = "core_l4_clkdm",
1920 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1989 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1921 .enable_bit = OMAP24XX_EN_UART1_SHIFT, 1990 .enable_bit = OMAP24XX_EN_UART1_SHIFT,
1922 .recalc = &followparent_recalc, 1991 .recalc = &followparent_recalc,
@@ -1926,6 +1995,7 @@ static struct clk uart1_fck = {
1926 .name = "uart1_fck", 1995 .name = "uart1_fck",
1927 .parent = &func_48m_ck, 1996 .parent = &func_48m_ck,
1928 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 1997 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
1998 .clkdm_name = "core_l4_clkdm",
1929 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1999 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1930 .enable_bit = OMAP24XX_EN_UART1_SHIFT, 2000 .enable_bit = OMAP24XX_EN_UART1_SHIFT,
1931 .recalc = &followparent_recalc, 2001 .recalc = &followparent_recalc,
@@ -1935,6 +2005,7 @@ static struct clk uart2_ick = {
1935 .name = "uart2_ick", 2005 .name = "uart2_ick",
1936 .parent = &l4_ck, 2006 .parent = &l4_ck,
1937 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2007 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2008 .clkdm_name = "core_l4_clkdm",
1938 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2009 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1939 .enable_bit = OMAP24XX_EN_UART2_SHIFT, 2010 .enable_bit = OMAP24XX_EN_UART2_SHIFT,
1940 .recalc = &followparent_recalc, 2011 .recalc = &followparent_recalc,
@@ -1944,6 +2015,7 @@ static struct clk uart2_fck = {
1944 .name = "uart2_fck", 2015 .name = "uart2_fck",
1945 .parent = &func_48m_ck, 2016 .parent = &func_48m_ck,
1946 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2017 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2018 .clkdm_name = "core_l4_clkdm",
1947 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2019 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1948 .enable_bit = OMAP24XX_EN_UART2_SHIFT, 2020 .enable_bit = OMAP24XX_EN_UART2_SHIFT,
1949 .recalc = &followparent_recalc, 2021 .recalc = &followparent_recalc,
@@ -1953,6 +2025,7 @@ static struct clk uart3_ick = {
1953 .name = "uart3_ick", 2025 .name = "uart3_ick",
1954 .parent = &l4_ck, 2026 .parent = &l4_ck,
1955 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2027 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2028 .clkdm_name = "core_l4_clkdm",
1956 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 2029 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
1957 .enable_bit = OMAP24XX_EN_UART3_SHIFT, 2030 .enable_bit = OMAP24XX_EN_UART3_SHIFT,
1958 .recalc = &followparent_recalc, 2031 .recalc = &followparent_recalc,
@@ -1962,6 +2035,7 @@ static struct clk uart3_fck = {
1962 .name = "uart3_fck", 2035 .name = "uart3_fck",
1963 .parent = &func_48m_ck, 2036 .parent = &func_48m_ck,
1964 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2037 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2038 .clkdm_name = "core_l4_clkdm",
1965 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2039 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1966 .enable_bit = OMAP24XX_EN_UART3_SHIFT, 2040 .enable_bit = OMAP24XX_EN_UART3_SHIFT,
1967 .recalc = &followparent_recalc, 2041 .recalc = &followparent_recalc,
@@ -1971,6 +2045,7 @@ static struct clk gpios_ick = {
1971 .name = "gpios_ick", 2045 .name = "gpios_ick",
1972 .parent = &l4_ck, 2046 .parent = &l4_ck,
1973 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2047 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2048 .clkdm_name = "core_l4_clkdm",
1974 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2049 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
1975 .enable_bit = OMAP24XX_EN_GPIOS_SHIFT, 2050 .enable_bit = OMAP24XX_EN_GPIOS_SHIFT,
1976 .recalc = &followparent_recalc, 2051 .recalc = &followparent_recalc,
@@ -1980,6 +2055,7 @@ static struct clk gpios_fck = {
1980 .name = "gpios_fck", 2055 .name = "gpios_fck",
1981 .parent = &func_32k_ck, 2056 .parent = &func_32k_ck,
1982 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2057 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2058 .clkdm_name = "wkup_clkdm",
1983 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN), 2059 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN),
1984 .enable_bit = OMAP24XX_EN_GPIOS_SHIFT, 2060 .enable_bit = OMAP24XX_EN_GPIOS_SHIFT,
1985 .recalc = &followparent_recalc, 2061 .recalc = &followparent_recalc,
@@ -1989,6 +2065,7 @@ static struct clk mpu_wdt_ick = {
1989 .name = "mpu_wdt_ick", 2065 .name = "mpu_wdt_ick",
1990 .parent = &l4_ck, 2066 .parent = &l4_ck,
1991 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2067 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2068 .clkdm_name = "core_l4_clkdm",
1992 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2069 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
1993 .enable_bit = OMAP24XX_EN_MPU_WDT_SHIFT, 2070 .enable_bit = OMAP24XX_EN_MPU_WDT_SHIFT,
1994 .recalc = &followparent_recalc, 2071 .recalc = &followparent_recalc,
@@ -1998,6 +2075,7 @@ static struct clk mpu_wdt_fck = {
1998 .name = "mpu_wdt_fck", 2075 .name = "mpu_wdt_fck",
1999 .parent = &func_32k_ck, 2076 .parent = &func_32k_ck,
2000 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2077 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2078 .clkdm_name = "wkup_clkdm",
2001 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN), 2079 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN),
2002 .enable_bit = OMAP24XX_EN_MPU_WDT_SHIFT, 2080 .enable_bit = OMAP24XX_EN_MPU_WDT_SHIFT,
2003 .recalc = &followparent_recalc, 2081 .recalc = &followparent_recalc,
@@ -2006,31 +2084,40 @@ static struct clk mpu_wdt_fck = {
2006static struct clk sync_32k_ick = { 2084static struct clk sync_32k_ick = {
2007 .name = "sync_32k_ick", 2085 .name = "sync_32k_ick",
2008 .parent = &l4_ck, 2086 .parent = &l4_ck,
2009 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ENABLE_ON_INIT, 2087 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
2088 ENABLE_ON_INIT,
2089 .clkdm_name = "core_l4_clkdm",
2010 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2090 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2011 .enable_bit = OMAP24XX_EN_32KSYNC_SHIFT, 2091 .enable_bit = OMAP24XX_EN_32KSYNC_SHIFT,
2012 .recalc = &followparent_recalc, 2092 .recalc = &followparent_recalc,
2013}; 2093};
2094
2014static struct clk wdt1_ick = { 2095static struct clk wdt1_ick = {
2015 .name = "wdt1_ick", 2096 .name = "wdt1_ick",
2016 .parent = &l4_ck, 2097 .parent = &l4_ck,
2017 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2098 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2099 .clkdm_name = "core_l4_clkdm",
2018 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2100 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2019 .enable_bit = OMAP24XX_EN_WDT1_SHIFT, 2101 .enable_bit = OMAP24XX_EN_WDT1_SHIFT,
2020 .recalc = &followparent_recalc, 2102 .recalc = &followparent_recalc,
2021}; 2103};
2104
2022static struct clk omapctrl_ick = { 2105static struct clk omapctrl_ick = {
2023 .name = "omapctrl_ick", 2106 .name = "omapctrl_ick",
2024 .parent = &l4_ck, 2107 .parent = &l4_ck,
2025 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ENABLE_ON_INIT, 2108 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
2109 ENABLE_ON_INIT,
2110 .clkdm_name = "core_l4_clkdm",
2026 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2111 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2027 .enable_bit = OMAP24XX_EN_OMAPCTRL_SHIFT, 2112 .enable_bit = OMAP24XX_EN_OMAPCTRL_SHIFT,
2028 .recalc = &followparent_recalc, 2113 .recalc = &followparent_recalc,
2029}; 2114};
2115
2030static struct clk icr_ick = { 2116static struct clk icr_ick = {
2031 .name = "icr_ick", 2117 .name = "icr_ick",
2032 .parent = &l4_ck, 2118 .parent = &l4_ck,
2033 .flags = CLOCK_IN_OMAP243X, 2119 .flags = CLOCK_IN_OMAP243X,
2120 .clkdm_name = "core_l4_clkdm",
2034 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2121 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2035 .enable_bit = OMAP2430_EN_ICR_SHIFT, 2122 .enable_bit = OMAP2430_EN_ICR_SHIFT,
2036 .recalc = &followparent_recalc, 2123 .recalc = &followparent_recalc,
@@ -2040,15 +2127,22 @@ static struct clk cam_ick = {
2040 .name = "cam_ick", 2127 .name = "cam_ick",
2041 .parent = &l4_ck, 2128 .parent = &l4_ck,
2042 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2129 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2130 .clkdm_name = "core_l4_clkdm",
2043 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2131 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2044 .enable_bit = OMAP24XX_EN_CAM_SHIFT, 2132 .enable_bit = OMAP24XX_EN_CAM_SHIFT,
2045 .recalc = &followparent_recalc, 2133 .recalc = &followparent_recalc,
2046}; 2134};
2047 2135
2136/*
2137 * cam_fck controls both CAM_MCLK and CAM_FCLK. It should probably be
2138 * split into two separate clocks, since the parent clocks are different
2139 * and the clockdomains are also different.
2140 */
2048static struct clk cam_fck = { 2141static struct clk cam_fck = {
2049 .name = "cam_fck", 2142 .name = "cam_fck",
2050 .parent = &func_96m_ck, 2143 .parent = &func_96m_ck,
2051 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2144 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2145 .clkdm_name = "core_l3_clkdm",
2052 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2146 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2053 .enable_bit = OMAP24XX_EN_CAM_SHIFT, 2147 .enable_bit = OMAP24XX_EN_CAM_SHIFT,
2054 .recalc = &followparent_recalc, 2148 .recalc = &followparent_recalc,
@@ -2058,6 +2152,7 @@ static struct clk mailboxes_ick = {
2058 .name = "mailboxes_ick", 2152 .name = "mailboxes_ick",
2059 .parent = &l4_ck, 2153 .parent = &l4_ck,
2060 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2154 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2155 .clkdm_name = "core_l4_clkdm",
2061 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2156 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2062 .enable_bit = OMAP24XX_EN_MAILBOXES_SHIFT, 2157 .enable_bit = OMAP24XX_EN_MAILBOXES_SHIFT,
2063 .recalc = &followparent_recalc, 2158 .recalc = &followparent_recalc,
@@ -2067,6 +2162,7 @@ static struct clk wdt4_ick = {
2067 .name = "wdt4_ick", 2162 .name = "wdt4_ick",
2068 .parent = &l4_ck, 2163 .parent = &l4_ck,
2069 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2164 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2165 .clkdm_name = "core_l4_clkdm",
2070 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2166 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2071 .enable_bit = OMAP24XX_EN_WDT4_SHIFT, 2167 .enable_bit = OMAP24XX_EN_WDT4_SHIFT,
2072 .recalc = &followparent_recalc, 2168 .recalc = &followparent_recalc,
@@ -2076,6 +2172,7 @@ static struct clk wdt4_fck = {
2076 .name = "wdt4_fck", 2172 .name = "wdt4_fck",
2077 .parent = &func_32k_ck, 2173 .parent = &func_32k_ck,
2078 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2174 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2175 .clkdm_name = "core_l4_clkdm",
2079 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2176 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2080 .enable_bit = OMAP24XX_EN_WDT4_SHIFT, 2177 .enable_bit = OMAP24XX_EN_WDT4_SHIFT,
2081 .recalc = &followparent_recalc, 2178 .recalc = &followparent_recalc,
@@ -2085,6 +2182,7 @@ static struct clk wdt3_ick = {
2085 .name = "wdt3_ick", 2182 .name = "wdt3_ick",
2086 .parent = &l4_ck, 2183 .parent = &l4_ck,
2087 .flags = CLOCK_IN_OMAP242X, 2184 .flags = CLOCK_IN_OMAP242X,
2185 .clkdm_name = "core_l4_clkdm",
2088 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2186 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2089 .enable_bit = OMAP2420_EN_WDT3_SHIFT, 2187 .enable_bit = OMAP2420_EN_WDT3_SHIFT,
2090 .recalc = &followparent_recalc, 2188 .recalc = &followparent_recalc,
@@ -2094,6 +2192,7 @@ static struct clk wdt3_fck = {
2094 .name = "wdt3_fck", 2192 .name = "wdt3_fck",
2095 .parent = &func_32k_ck, 2193 .parent = &func_32k_ck,
2096 .flags = CLOCK_IN_OMAP242X, 2194 .flags = CLOCK_IN_OMAP242X,
2195 .clkdm_name = "core_l4_clkdm",
2097 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2196 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2098 .enable_bit = OMAP2420_EN_WDT3_SHIFT, 2197 .enable_bit = OMAP2420_EN_WDT3_SHIFT,
2099 .recalc = &followparent_recalc, 2198 .recalc = &followparent_recalc,
@@ -2103,6 +2202,7 @@ static struct clk mspro_ick = {
2103 .name = "mspro_ick", 2202 .name = "mspro_ick",
2104 .parent = &l4_ck, 2203 .parent = &l4_ck,
2105 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2204 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2205 .clkdm_name = "core_l4_clkdm",
2106 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2206 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2107 .enable_bit = OMAP24XX_EN_MSPRO_SHIFT, 2207 .enable_bit = OMAP24XX_EN_MSPRO_SHIFT,
2108 .recalc = &followparent_recalc, 2208 .recalc = &followparent_recalc,
@@ -2112,6 +2212,7 @@ static struct clk mspro_fck = {
2112 .name = "mspro_fck", 2212 .name = "mspro_fck",
2113 .parent = &func_96m_ck, 2213 .parent = &func_96m_ck,
2114 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2214 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2215 .clkdm_name = "core_l4_clkdm",
2115 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2216 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2116 .enable_bit = OMAP24XX_EN_MSPRO_SHIFT, 2217 .enable_bit = OMAP24XX_EN_MSPRO_SHIFT,
2117 .recalc = &followparent_recalc, 2218 .recalc = &followparent_recalc,
@@ -2121,6 +2222,7 @@ static struct clk mmc_ick = {
2121 .name = "mmc_ick", 2222 .name = "mmc_ick",
2122 .parent = &l4_ck, 2223 .parent = &l4_ck,
2123 .flags = CLOCK_IN_OMAP242X, 2224 .flags = CLOCK_IN_OMAP242X,
2225 .clkdm_name = "core_l4_clkdm",
2124 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2226 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2125 .enable_bit = OMAP2420_EN_MMC_SHIFT, 2227 .enable_bit = OMAP2420_EN_MMC_SHIFT,
2126 .recalc = &followparent_recalc, 2228 .recalc = &followparent_recalc,
@@ -2130,6 +2232,7 @@ static struct clk mmc_fck = {
2130 .name = "mmc_fck", 2232 .name = "mmc_fck",
2131 .parent = &func_96m_ck, 2233 .parent = &func_96m_ck,
2132 .flags = CLOCK_IN_OMAP242X, 2234 .flags = CLOCK_IN_OMAP242X,
2235 .clkdm_name = "core_l4_clkdm",
2133 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2236 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2134 .enable_bit = OMAP2420_EN_MMC_SHIFT, 2237 .enable_bit = OMAP2420_EN_MMC_SHIFT,
2135 .recalc = &followparent_recalc, 2238 .recalc = &followparent_recalc,
@@ -2139,6 +2242,7 @@ static struct clk fac_ick = {
2139 .name = "fac_ick", 2242 .name = "fac_ick",
2140 .parent = &l4_ck, 2243 .parent = &l4_ck,
2141 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2244 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2245 .clkdm_name = "core_l4_clkdm",
2142 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2246 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2143 .enable_bit = OMAP24XX_EN_FAC_SHIFT, 2247 .enable_bit = OMAP24XX_EN_FAC_SHIFT,
2144 .recalc = &followparent_recalc, 2248 .recalc = &followparent_recalc,
@@ -2148,6 +2252,7 @@ static struct clk fac_fck = {
2148 .name = "fac_fck", 2252 .name = "fac_fck",
2149 .parent = &func_12m_ck, 2253 .parent = &func_12m_ck,
2150 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2254 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2255 .clkdm_name = "core_l4_clkdm",
2151 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2256 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2152 .enable_bit = OMAP24XX_EN_FAC_SHIFT, 2257 .enable_bit = OMAP24XX_EN_FAC_SHIFT,
2153 .recalc = &followparent_recalc, 2258 .recalc = &followparent_recalc,
@@ -2157,6 +2262,7 @@ static struct clk eac_ick = {
2157 .name = "eac_ick", 2262 .name = "eac_ick",
2158 .parent = &l4_ck, 2263 .parent = &l4_ck,
2159 .flags = CLOCK_IN_OMAP242X, 2264 .flags = CLOCK_IN_OMAP242X,
2265 .clkdm_name = "core_l4_clkdm",
2160 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2266 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2161 .enable_bit = OMAP2420_EN_EAC_SHIFT, 2267 .enable_bit = OMAP2420_EN_EAC_SHIFT,
2162 .recalc = &followparent_recalc, 2268 .recalc = &followparent_recalc,
@@ -2166,6 +2272,7 @@ static struct clk eac_fck = {
2166 .name = "eac_fck", 2272 .name = "eac_fck",
2167 .parent = &func_96m_ck, 2273 .parent = &func_96m_ck,
2168 .flags = CLOCK_IN_OMAP242X, 2274 .flags = CLOCK_IN_OMAP242X,
2275 .clkdm_name = "core_l4_clkdm",
2169 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2276 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2170 .enable_bit = OMAP2420_EN_EAC_SHIFT, 2277 .enable_bit = OMAP2420_EN_EAC_SHIFT,
2171 .recalc = &followparent_recalc, 2278 .recalc = &followparent_recalc,
@@ -2175,6 +2282,7 @@ static struct clk hdq_ick = {
2175 .name = "hdq_ick", 2282 .name = "hdq_ick",
2176 .parent = &l4_ck, 2283 .parent = &l4_ck,
2177 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2284 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2285 .clkdm_name = "core_l4_clkdm",
2178 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2286 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2179 .enable_bit = OMAP24XX_EN_HDQ_SHIFT, 2287 .enable_bit = OMAP24XX_EN_HDQ_SHIFT,
2180 .recalc = &followparent_recalc, 2288 .recalc = &followparent_recalc,
@@ -2184,6 +2292,7 @@ static struct clk hdq_fck = {
2184 .name = "hdq_fck", 2292 .name = "hdq_fck",
2185 .parent = &func_12m_ck, 2293 .parent = &func_12m_ck,
2186 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2294 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2295 .clkdm_name = "core_l4_clkdm",
2187 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2296 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2188 .enable_bit = OMAP24XX_EN_HDQ_SHIFT, 2297 .enable_bit = OMAP24XX_EN_HDQ_SHIFT,
2189 .recalc = &followparent_recalc, 2298 .recalc = &followparent_recalc,
@@ -2194,6 +2303,7 @@ static struct clk i2c2_ick = {
2194 .id = 2, 2303 .id = 2,
2195 .parent = &l4_ck, 2304 .parent = &l4_ck,
2196 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2305 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2306 .clkdm_name = "core_l4_clkdm",
2197 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2307 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2198 .enable_bit = OMAP2420_EN_I2C2_SHIFT, 2308 .enable_bit = OMAP2420_EN_I2C2_SHIFT,
2199 .recalc = &followparent_recalc, 2309 .recalc = &followparent_recalc,
@@ -2204,6 +2314,7 @@ static struct clk i2c2_fck = {
2204 .id = 2, 2314 .id = 2,
2205 .parent = &func_12m_ck, 2315 .parent = &func_12m_ck,
2206 .flags = CLOCK_IN_OMAP242X, 2316 .flags = CLOCK_IN_OMAP242X,
2317 .clkdm_name = "core_l4_clkdm",
2207 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2318 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2208 .enable_bit = OMAP2420_EN_I2C2_SHIFT, 2319 .enable_bit = OMAP2420_EN_I2C2_SHIFT,
2209 .recalc = &followparent_recalc, 2320 .recalc = &followparent_recalc,
@@ -2214,6 +2325,7 @@ static struct clk i2chs2_fck = {
2214 .id = 2, 2325 .id = 2,
2215 .parent = &func_96m_ck, 2326 .parent = &func_96m_ck,
2216 .flags = CLOCK_IN_OMAP243X, 2327 .flags = CLOCK_IN_OMAP243X,
2328 .clkdm_name = "core_l4_clkdm",
2217 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2329 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2218 .enable_bit = OMAP2430_EN_I2CHS2_SHIFT, 2330 .enable_bit = OMAP2430_EN_I2CHS2_SHIFT,
2219 .recalc = &followparent_recalc, 2331 .recalc = &followparent_recalc,
@@ -2224,6 +2336,7 @@ static struct clk i2c1_ick = {
2224 .id = 1, 2336 .id = 1,
2225 .parent = &l4_ck, 2337 .parent = &l4_ck,
2226 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2338 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2339 .clkdm_name = "core_l4_clkdm",
2227 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2340 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2228 .enable_bit = OMAP2420_EN_I2C1_SHIFT, 2341 .enable_bit = OMAP2420_EN_I2C1_SHIFT,
2229 .recalc = &followparent_recalc, 2342 .recalc = &followparent_recalc,
@@ -2234,6 +2347,7 @@ static struct clk i2c1_fck = {
2234 .id = 1, 2347 .id = 1,
2235 .parent = &func_12m_ck, 2348 .parent = &func_12m_ck,
2236 .flags = CLOCK_IN_OMAP242X, 2349 .flags = CLOCK_IN_OMAP242X,
2350 .clkdm_name = "core_l4_clkdm",
2237 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2351 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2238 .enable_bit = OMAP2420_EN_I2C1_SHIFT, 2352 .enable_bit = OMAP2420_EN_I2C1_SHIFT,
2239 .recalc = &followparent_recalc, 2353 .recalc = &followparent_recalc,
@@ -2244,6 +2358,7 @@ static struct clk i2chs1_fck = {
2244 .id = 1, 2358 .id = 1,
2245 .parent = &func_96m_ck, 2359 .parent = &func_96m_ck,
2246 .flags = CLOCK_IN_OMAP243X, 2360 .flags = CLOCK_IN_OMAP243X,
2361 .clkdm_name = "core_l4_clkdm",
2247 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2362 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2248 .enable_bit = OMAP2430_EN_I2CHS1_SHIFT, 2363 .enable_bit = OMAP2430_EN_I2CHS1_SHIFT,
2249 .recalc = &followparent_recalc, 2364 .recalc = &followparent_recalc,
@@ -2252,7 +2367,9 @@ static struct clk i2chs1_fck = {
2252static struct clk gpmc_fck = { 2367static struct clk gpmc_fck = {
2253 .name = "gpmc_fck", 2368 .name = "gpmc_fck",
2254 .parent = &core_l3_ck, 2369 .parent = &core_l3_ck,
2255 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ENABLE_ON_INIT, 2370 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X |
2371 ENABLE_ON_INIT,
2372 .clkdm_name = "core_l3_clkdm",
2256 .recalc = &followparent_recalc, 2373 .recalc = &followparent_recalc,
2257}; 2374};
2258 2375
@@ -2260,6 +2377,7 @@ static struct clk sdma_fck = {
2260 .name = "sdma_fck", 2377 .name = "sdma_fck",
2261 .parent = &core_l3_ck, 2378 .parent = &core_l3_ck,
2262 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2379 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2380 .clkdm_name = "core_l3_clkdm",
2263 .recalc = &followparent_recalc, 2381 .recalc = &followparent_recalc,
2264}; 2382};
2265 2383
@@ -2267,6 +2385,7 @@ static struct clk sdma_ick = {
2267 .name = "sdma_ick", 2385 .name = "sdma_ick",
2268 .parent = &l4_ck, 2386 .parent = &l4_ck,
2269 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X, 2387 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
2388 .clkdm_name = "core_l3_clkdm",
2270 .recalc = &followparent_recalc, 2389 .recalc = &followparent_recalc,
2271}; 2390};
2272 2391
@@ -2274,6 +2393,7 @@ static struct clk vlynq_ick = {
2274 .name = "vlynq_ick", 2393 .name = "vlynq_ick",
2275 .parent = &core_l3_ck, 2394 .parent = &core_l3_ck,
2276 .flags = CLOCK_IN_OMAP242X, 2395 .flags = CLOCK_IN_OMAP242X,
2396 .clkdm_name = "core_l3_clkdm",
2277 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 2397 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
2278 .enable_bit = OMAP2420_EN_VLYNQ_SHIFT, 2398 .enable_bit = OMAP2420_EN_VLYNQ_SHIFT,
2279 .recalc = &followparent_recalc, 2399 .recalc = &followparent_recalc,
@@ -2308,6 +2428,7 @@ static struct clk vlynq_fck = {
2308 .name = "vlynq_fck", 2428 .name = "vlynq_fck",
2309 .parent = &func_96m_ck, 2429 .parent = &func_96m_ck,
2310 .flags = CLOCK_IN_OMAP242X | DELAYED_APP, 2430 .flags = CLOCK_IN_OMAP242X | DELAYED_APP,
2431 .clkdm_name = "core_l3_clkdm",
2311 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2432 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2312 .enable_bit = OMAP2420_EN_VLYNQ_SHIFT, 2433 .enable_bit = OMAP2420_EN_VLYNQ_SHIFT,
2313 .init = &omap2_init_clksel_parent, 2434 .init = &omap2_init_clksel_parent,
@@ -2323,6 +2444,7 @@ static struct clk sdrc_ick = {
2323 .name = "sdrc_ick", 2444 .name = "sdrc_ick",
2324 .parent = &l4_ck, 2445 .parent = &l4_ck,
2325 .flags = CLOCK_IN_OMAP243X | ENABLE_ON_INIT, 2446 .flags = CLOCK_IN_OMAP243X | ENABLE_ON_INIT,
2447 .clkdm_name = "core_l4_clkdm",
2326 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN3), 2448 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN3),
2327 .enable_bit = OMAP2430_EN_SDRC_SHIFT, 2449 .enable_bit = OMAP2430_EN_SDRC_SHIFT,
2328 .recalc = &followparent_recalc, 2450 .recalc = &followparent_recalc,
@@ -2332,6 +2454,7 @@ static struct clk des_ick = {
2332 .name = "des_ick", 2454 .name = "des_ick",
2333 .parent = &l4_ck, 2455 .parent = &l4_ck,
2334 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X, 2456 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X,
2457 .clkdm_name = "core_l4_clkdm",
2335 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4), 2458 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4),
2336 .enable_bit = OMAP24XX_EN_DES_SHIFT, 2459 .enable_bit = OMAP24XX_EN_DES_SHIFT,
2337 .recalc = &followparent_recalc, 2460 .recalc = &followparent_recalc,
@@ -2341,6 +2464,7 @@ static struct clk sha_ick = {
2341 .name = "sha_ick", 2464 .name = "sha_ick",
2342 .parent = &l4_ck, 2465 .parent = &l4_ck,
2343 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X, 2466 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X,
2467 .clkdm_name = "core_l4_clkdm",
2344 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4), 2468 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4),
2345 .enable_bit = OMAP24XX_EN_SHA_SHIFT, 2469 .enable_bit = OMAP24XX_EN_SHA_SHIFT,
2346 .recalc = &followparent_recalc, 2470 .recalc = &followparent_recalc,
@@ -2350,6 +2474,7 @@ static struct clk rng_ick = {
2350 .name = "rng_ick", 2474 .name = "rng_ick",
2351 .parent = &l4_ck, 2475 .parent = &l4_ck,
2352 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X, 2476 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X,
2477 .clkdm_name = "core_l4_clkdm",
2353 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4), 2478 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4),
2354 .enable_bit = OMAP24XX_EN_RNG_SHIFT, 2479 .enable_bit = OMAP24XX_EN_RNG_SHIFT,
2355 .recalc = &followparent_recalc, 2480 .recalc = &followparent_recalc,
@@ -2359,6 +2484,7 @@ static struct clk aes_ick = {
2359 .name = "aes_ick", 2484 .name = "aes_ick",
2360 .parent = &l4_ck, 2485 .parent = &l4_ck,
2361 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X, 2486 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X,
2487 .clkdm_name = "core_l4_clkdm",
2362 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4), 2488 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4),
2363 .enable_bit = OMAP24XX_EN_AES_SHIFT, 2489 .enable_bit = OMAP24XX_EN_AES_SHIFT,
2364 .recalc = &followparent_recalc, 2490 .recalc = &followparent_recalc,
@@ -2368,6 +2494,7 @@ static struct clk pka_ick = {
2368 .name = "pka_ick", 2494 .name = "pka_ick",
2369 .parent = &l4_ck, 2495 .parent = &l4_ck,
2370 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X, 2496 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X,
2497 .clkdm_name = "core_l4_clkdm",
2371 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4), 2498 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_ICLKEN4),
2372 .enable_bit = OMAP24XX_EN_PKA_SHIFT, 2499 .enable_bit = OMAP24XX_EN_PKA_SHIFT,
2373 .recalc = &followparent_recalc, 2500 .recalc = &followparent_recalc,
@@ -2377,6 +2504,7 @@ static struct clk usb_fck = {
2377 .name = "usb_fck", 2504 .name = "usb_fck",
2378 .parent = &func_48m_ck, 2505 .parent = &func_48m_ck,
2379 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X, 2506 .flags = CLOCK_IN_OMAP243X | CLOCK_IN_OMAP242X,
2507 .clkdm_name = "core_l3_clkdm",
2380 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2508 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2381 .enable_bit = OMAP24XX_EN_USB_SHIFT, 2509 .enable_bit = OMAP24XX_EN_USB_SHIFT,
2382 .recalc = &followparent_recalc, 2510 .recalc = &followparent_recalc,
@@ -2386,6 +2514,7 @@ static struct clk usbhs_ick = {
2386 .name = "usbhs_ick", 2514 .name = "usbhs_ick",
2387 .parent = &core_l3_ck, 2515 .parent = &core_l3_ck,
2388 .flags = CLOCK_IN_OMAP243X, 2516 .flags = CLOCK_IN_OMAP243X,
2517 .clkdm_name = "core_l3_clkdm",
2389 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 2518 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
2390 .enable_bit = OMAP2430_EN_USBHS_SHIFT, 2519 .enable_bit = OMAP2430_EN_USBHS_SHIFT,
2391 .recalc = &followparent_recalc, 2520 .recalc = &followparent_recalc,
@@ -2396,6 +2525,7 @@ static struct clk mmchs1_ick = {
2396 .id = 1, 2525 .id = 1,
2397 .parent = &l4_ck, 2526 .parent = &l4_ck,
2398 .flags = CLOCK_IN_OMAP243X, 2527 .flags = CLOCK_IN_OMAP243X,
2528 .clkdm_name = "core_l4_clkdm",
2399 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 2529 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
2400 .enable_bit = OMAP2430_EN_MMCHS1_SHIFT, 2530 .enable_bit = OMAP2430_EN_MMCHS1_SHIFT,
2401 .recalc = &followparent_recalc, 2531 .recalc = &followparent_recalc,
@@ -2406,6 +2536,7 @@ static struct clk mmchs1_fck = {
2406 .id = 1, 2536 .id = 1,
2407 .parent = &func_96m_ck, 2537 .parent = &func_96m_ck,
2408 .flags = CLOCK_IN_OMAP243X, 2538 .flags = CLOCK_IN_OMAP243X,
2539 .clkdm_name = "core_l3_clkdm",
2409 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2540 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2410 .enable_bit = OMAP2430_EN_MMCHS1_SHIFT, 2541 .enable_bit = OMAP2430_EN_MMCHS1_SHIFT,
2411 .recalc = &followparent_recalc, 2542 .recalc = &followparent_recalc,
@@ -2416,6 +2547,7 @@ static struct clk mmchs2_ick = {
2416 .id = 2, 2547 .id = 2,
2417 .parent = &l4_ck, 2548 .parent = &l4_ck,
2418 .flags = CLOCK_IN_OMAP243X, 2549 .flags = CLOCK_IN_OMAP243X,
2550 .clkdm_name = "core_l4_clkdm",
2419 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 2551 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
2420 .enable_bit = OMAP2430_EN_MMCHS2_SHIFT, 2552 .enable_bit = OMAP2430_EN_MMCHS2_SHIFT,
2421 .recalc = &followparent_recalc, 2553 .recalc = &followparent_recalc,
@@ -2435,6 +2567,7 @@ static struct clk gpio5_ick = {
2435 .name = "gpio5_ick", 2567 .name = "gpio5_ick",
2436 .parent = &l4_ck, 2568 .parent = &l4_ck,
2437 .flags = CLOCK_IN_OMAP243X, 2569 .flags = CLOCK_IN_OMAP243X,
2570 .clkdm_name = "core_l4_clkdm",
2438 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 2571 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
2439 .enable_bit = OMAP2430_EN_GPIO5_SHIFT, 2572 .enable_bit = OMAP2430_EN_GPIO5_SHIFT,
2440 .recalc = &followparent_recalc, 2573 .recalc = &followparent_recalc,
@@ -2444,6 +2577,7 @@ static struct clk gpio5_fck = {
2444 .name = "gpio5_fck", 2577 .name = "gpio5_fck",
2445 .parent = &func_32k_ck, 2578 .parent = &func_32k_ck,
2446 .flags = CLOCK_IN_OMAP243X, 2579 .flags = CLOCK_IN_OMAP243X,
2580 .clkdm_name = "core_l4_clkdm",
2447 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2581 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2448 .enable_bit = OMAP2430_EN_GPIO5_SHIFT, 2582 .enable_bit = OMAP2430_EN_GPIO5_SHIFT,
2449 .recalc = &followparent_recalc, 2583 .recalc = &followparent_recalc,
@@ -2453,6 +2587,7 @@ static struct clk mdm_intc_ick = {
2453 .name = "mdm_intc_ick", 2587 .name = "mdm_intc_ick",
2454 .parent = &l4_ck, 2588 .parent = &l4_ck,
2455 .flags = CLOCK_IN_OMAP243X, 2589 .flags = CLOCK_IN_OMAP243X,
2590 .clkdm_name = "core_l4_clkdm",
2456 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2), 2591 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN2),
2457 .enable_bit = OMAP2430_EN_MDM_INTC_SHIFT, 2592 .enable_bit = OMAP2430_EN_MDM_INTC_SHIFT,
2458 .recalc = &followparent_recalc, 2593 .recalc = &followparent_recalc,
@@ -2463,6 +2598,7 @@ static struct clk mmchsdb1_fck = {
2463 .id = 1, 2598 .id = 1,
2464 .parent = &func_32k_ck, 2599 .parent = &func_32k_ck,
2465 .flags = CLOCK_IN_OMAP243X, 2600 .flags = CLOCK_IN_OMAP243X,
2601 .clkdm_name = "core_l4_clkdm",
2466 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2602 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2467 .enable_bit = OMAP2430_EN_MMCHSDB1_SHIFT, 2603 .enable_bit = OMAP2430_EN_MMCHSDB1_SHIFT,
2468 .recalc = &followparent_recalc, 2604 .recalc = &followparent_recalc,
@@ -2473,6 +2609,7 @@ static struct clk mmchsdb2_fck = {
2473 .id = 2, 2609 .id = 2,
2474 .parent = &func_32k_ck, 2610 .parent = &func_32k_ck,
2475 .flags = CLOCK_IN_OMAP243X, 2611 .flags = CLOCK_IN_OMAP243X,
2612 .clkdm_name = "core_l4_clkdm",
2476 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 2613 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
2477 .enable_bit = OMAP2430_EN_MMCHSDB2_SHIFT, 2614 .enable_bit = OMAP2430_EN_MMCHSDB2_SHIFT,
2478 .recalc = &followparent_recalc, 2615 .recalc = &followparent_recalc,
@@ -2551,7 +2688,6 @@ static struct clk *onchip_24xx_clks[] __initdata = {
2551 &usb_l4_ick, 2688 &usb_l4_ick,
2552 /* L4 domain clocks */ 2689 /* L4 domain clocks */
2553 &l4_ck, /* used as both core_l4 and wu_l4 */ 2690 &l4_ck, /* used as both core_l4 and wu_l4 */
2554 &ssi_l4_ick,
2555 /* virtual meta-group clock */ 2691 /* virtual meta-group clock */
2556 &virt_prcm_set, 2692 &virt_prcm_set,
2557 /* general l4 interface ck, multi-parent functional clk */ 2693 /* general l4 interface ck, multi-parent functional clk */
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index e5b475f21081..084e11082f80 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -62,11 +62,14 @@ static void omap3_dpll_recalc(struct clk *clk)
62static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits) 62static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits)
63{ 63{
64 const struct dpll_data *dd; 64 const struct dpll_data *dd;
65 u32 v;
65 66
66 dd = clk->dpll_data; 67 dd = clk->dpll_data;
67 68
68 cm_rmw_reg_bits(dd->enable_mask, clken_bits << __ffs(dd->enable_mask), 69 v = __raw_readl(dd->control_reg);
69 dd->control_reg); 70 v &= ~dd->enable_mask;
71 v |= clken_bits << __ffs(dd->enable_mask);
72 __raw_writel(v, dd->control_reg);
70} 73}
71 74
72/* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */ 75/* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */
@@ -82,7 +85,7 @@ static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
82 state <<= dd->idlest_bit; 85 state <<= dd->idlest_bit;
83 idlest_mask = 1 << dd->idlest_bit; 86 idlest_mask = 1 << dd->idlest_bit;
84 87
85 while (((cm_read_reg(dd->idlest_reg) & idlest_mask) != state) && 88 while (((__raw_readl(dd->idlest_reg) & idlest_mask) != state) &&
86 i < MAX_DPLL_WAIT_TRIES) { 89 i < MAX_DPLL_WAIT_TRIES) {
87 i++; 90 i++;
88 udelay(1); 91 udelay(1);
@@ -285,7 +288,7 @@ static u32 omap3_dpll_autoidle_read(struct clk *clk)
285 288
286 dd = clk->dpll_data; 289 dd = clk->dpll_data;
287 290
288 v = cm_read_reg(dd->autoidle_reg); 291 v = __raw_readl(dd->autoidle_reg);
289 v &= dd->autoidle_mask; 292 v &= dd->autoidle_mask;
290 v >>= __ffs(dd->autoidle_mask); 293 v >>= __ffs(dd->autoidle_mask);
291 294
@@ -304,6 +307,7 @@ static u32 omap3_dpll_autoidle_read(struct clk *clk)
304static void omap3_dpll_allow_idle(struct clk *clk) 307static void omap3_dpll_allow_idle(struct clk *clk)
305{ 308{
306 const struct dpll_data *dd; 309 const struct dpll_data *dd;
310 u32 v;
307 311
308 if (!clk || !clk->dpll_data) 312 if (!clk || !clk->dpll_data)
309 return; 313 return;
@@ -315,9 +319,10 @@ static void omap3_dpll_allow_idle(struct clk *clk)
315 * by writing 0x5 instead of 0x1. Add some mechanism to 319 * by writing 0x5 instead of 0x1. Add some mechanism to
316 * optionally enter this mode. 320 * optionally enter this mode.
317 */ 321 */
318 cm_rmw_reg_bits(dd->autoidle_mask, 322 v = __raw_readl(dd->autoidle_reg);
319 DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask), 323 v &= ~dd->autoidle_mask;
320 dd->autoidle_reg); 324 v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask);
325 __raw_writel(v, dd->autoidle_reg);
321} 326}
322 327
323/** 328/**
@@ -329,15 +334,17 @@ static void omap3_dpll_allow_idle(struct clk *clk)
329static void omap3_dpll_deny_idle(struct clk *clk) 334static void omap3_dpll_deny_idle(struct clk *clk)
330{ 335{
331 const struct dpll_data *dd; 336 const struct dpll_data *dd;
337 u32 v;
332 338
333 if (!clk || !clk->dpll_data) 339 if (!clk || !clk->dpll_data)
334 return; 340 return;
335 341
336 dd = clk->dpll_data; 342 dd = clk->dpll_data;
337 343
338 cm_rmw_reg_bits(dd->autoidle_mask, 344 v = __raw_readl(dd->autoidle_reg);
339 DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask), 345 v &= ~dd->autoidle_mask;
340 dd->autoidle_reg); 346 v |= DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask);
347 __raw_writel(v, dd->autoidle_reg);
341} 348}
342 349
343/* Clock control for DPLL outputs */ 350/* Clock control for DPLL outputs */
@@ -482,8 +489,10 @@ int __init omap2_clk_init(void)
482 for (clkp = onchip_34xx_clks; 489 for (clkp = onchip_34xx_clks;
483 clkp < onchip_34xx_clks + ARRAY_SIZE(onchip_34xx_clks); 490 clkp < onchip_34xx_clks + ARRAY_SIZE(onchip_34xx_clks);
484 clkp++) { 491 clkp++) {
485 if ((*clkp)->flags & cpu_clkflg) 492 if ((*clkp)->flags & cpu_clkflg) {
486 clk_register(*clkp); 493 clk_register(*clkp);
494 omap2_init_clk_clkdm(*clkp);
495 }
487 } 496 }
488 497
489 /* REVISIT: Not yet ready for OMAP3 */ 498 /* REVISIT: Not yet ready for OMAP3 */
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index ec664457a11a..c38a8a09692f 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -478,7 +478,7 @@ static struct clk dpll3_m2_ck = {
478}; 478};
479 479
480static const struct clksel core_ck_clksel[] = { 480static const struct clksel core_ck_clksel[] = {
481 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 481 { .parent = &sys_ck, .rates = dpll_bypass_rates },
482 { .parent = &dpll3_m2_ck, .rates = dpll_locked_rates }, 482 { .parent = &dpll3_m2_ck, .rates = dpll_locked_rates },
483 { .parent = NULL } 483 { .parent = NULL }
484}; 484};
@@ -495,7 +495,7 @@ static struct clk core_ck = {
495}; 495};
496 496
497static const struct clksel dpll3_m2x2_ck_clksel[] = { 497static const struct clksel dpll3_m2x2_ck_clksel[] = {
498 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 498 { .parent = &sys_ck, .rates = dpll_bypass_rates },
499 { .parent = &dpll3_x2_ck, .rates = dpll_locked_rates }, 499 { .parent = &dpll3_x2_ck, .rates = dpll_locked_rates },
500 { .parent = NULL } 500 { .parent = NULL }
501}; 501};
@@ -541,7 +541,7 @@ static struct clk dpll3_m3x2_ck = {
541}; 541};
542 542
543static const struct clksel emu_core_alwon_ck_clksel[] = { 543static const struct clksel emu_core_alwon_ck_clksel[] = {
544 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 544 { .parent = &sys_ck, .rates = dpll_bypass_rates },
545 { .parent = &dpll3_m3x2_ck, .rates = dpll_locked_rates }, 545 { .parent = &dpll3_m3x2_ck, .rates = dpll_locked_rates },
546 { .parent = NULL } 546 { .parent = NULL }
547}; 547};
@@ -633,7 +633,7 @@ static struct clk dpll4_m2x2_ck = {
633}; 633};
634 634
635static const struct clksel omap_96m_alwon_fck_clksel[] = { 635static const struct clksel omap_96m_alwon_fck_clksel[] = {
636 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 636 { .parent = &sys_ck, .rates = dpll_bypass_rates },
637 { .parent = &dpll4_m2x2_ck, .rates = dpll_locked_rates }, 637 { .parent = &dpll4_m2x2_ck, .rates = dpll_locked_rates },
638 { .parent = NULL } 638 { .parent = NULL }
639}; 639};
@@ -659,7 +659,7 @@ static struct clk omap_96m_fck = {
659}; 659};
660 660
661static const struct clksel cm_96m_fck_clksel[] = { 661static const struct clksel cm_96m_fck_clksel[] = {
662 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 662 { .parent = &sys_ck, .rates = dpll_bypass_rates },
663 { .parent = &dpll4_m2x2_ck, .rates = dpll_locked_rates }, 663 { .parent = &dpll4_m2x2_ck, .rates = dpll_locked_rates },
664 { .parent = NULL } 664 { .parent = NULL }
665}; 665};
@@ -701,7 +701,7 @@ static struct clk dpll4_m3x2_ck = {
701}; 701};
702 702
703static const struct clksel virt_omap_54m_fck_clksel[] = { 703static const struct clksel virt_omap_54m_fck_clksel[] = {
704 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 704 { .parent = &sys_ck, .rates = dpll_bypass_rates },
705 { .parent = &dpll4_m3x2_ck, .rates = dpll_locked_rates }, 705 { .parent = &dpll4_m3x2_ck, .rates = dpll_locked_rates },
706 { .parent = NULL } 706 { .parent = NULL }
707}; 707};
@@ -911,7 +911,7 @@ static struct clk dpll5_m2_ck = {
911}; 911};
912 912
913static const struct clksel omap_120m_fck_clksel[] = { 913static const struct clksel omap_120m_fck_clksel[] = {
914 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 914 { .parent = &sys_ck, .rates = dpll_bypass_rates },
915 { .parent = &dpll5_m2_ck, .rates = dpll_locked_rates }, 915 { .parent = &dpll5_m2_ck, .rates = dpll_locked_rates },
916 { .parent = NULL } 916 { .parent = NULL }
917}; 917};
@@ -919,13 +919,13 @@ static const struct clksel omap_120m_fck_clksel[] = {
919static struct clk omap_120m_fck = { 919static struct clk omap_120m_fck = {
920 .name = "omap_120m_fck", 920 .name = "omap_120m_fck",
921 .parent = &dpll5_m2_ck, 921 .parent = &dpll5_m2_ck,
922 .init = &omap2_init_clksel_parent, 922 .init = &omap2_init_clksel_parent,
923 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST2), 923 .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST2),
924 .clksel_mask = OMAP3430ES2_ST_PERIPH2_CLK_MASK, 924 .clksel_mask = OMAP3430ES2_ST_PERIPH2_CLK_MASK,
925 .clksel = omap_120m_fck_clksel, 925 .clksel = omap_120m_fck_clksel,
926 .flags = CLOCK_IN_OMAP3430ES2 | RATE_PROPAGATES | 926 .flags = CLOCK_IN_OMAP3430ES2 | RATE_PROPAGATES |
927 PARENT_CONTROLS_CLOCK, 927 PARENT_CONTROLS_CLOCK,
928 .recalc = &omap2_clksel_recalc, 928 .recalc = &omap2_clksel_recalc,
929}; 929};
930 930
931/* CM EXTERNAL CLOCK OUTPUTS */ 931/* CM EXTERNAL CLOCK OUTPUTS */
@@ -1034,7 +1034,7 @@ static struct clk dpll1_fck = {
1034 * called 'dpll1_fck' 1034 * called 'dpll1_fck'
1035 */ 1035 */
1036static const struct clksel mpu_clksel[] = { 1036static const struct clksel mpu_clksel[] = {
1037 { .parent = &dpll1_fck, .rates = dpll_bypass_rates }, 1037 { .parent = &dpll1_fck, .rates = dpll_bypass_rates },
1038 { .parent = &dpll1_x2m2_ck, .rates = dpll_locked_rates }, 1038 { .parent = &dpll1_x2m2_ck, .rates = dpll_locked_rates },
1039 { .parent = NULL } 1039 { .parent = NULL }
1040}; 1040};
@@ -1048,6 +1048,7 @@ static struct clk mpu_ck = {
1048 .clksel = mpu_clksel, 1048 .clksel = mpu_clksel,
1049 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1049 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1050 PARENT_CONTROLS_CLOCK, 1050 PARENT_CONTROLS_CLOCK,
1051 .clkdm_name = "mpu_clkdm",
1051 .recalc = &omap2_clksel_recalc, 1052 .recalc = &omap2_clksel_recalc,
1052}; 1053};
1053 1054
@@ -1075,6 +1076,8 @@ static struct clk arm_fck = {
1075 .recalc = &omap2_clksel_recalc, 1076 .recalc = &omap2_clksel_recalc,
1076}; 1077};
1077 1078
1079/* XXX What about neon_clkdm ? */
1080
1078/* 1081/*
1079 * REVISIT: This clock is never specifically defined in the 3430 TRM, 1082 * REVISIT: This clock is never specifically defined in the 3430 TRM,
1080 * although it is referenced - so this is a guess 1083 * although it is referenced - so this is a guess
@@ -1107,7 +1110,7 @@ static struct clk dpll2_fck = {
1107 */ 1110 */
1108 1111
1109static const struct clksel iva2_clksel[] = { 1112static const struct clksel iva2_clksel[] = {
1110 { .parent = &dpll2_fck, .rates = dpll_bypass_rates }, 1113 { .parent = &dpll2_fck, .rates = dpll_bypass_rates },
1111 { .parent = &dpll2_m2_ck, .rates = dpll_locked_rates }, 1114 { .parent = &dpll2_m2_ck, .rates = dpll_locked_rates },
1112 { .parent = NULL } 1115 { .parent = NULL }
1113}; 1116};
@@ -1123,6 +1126,7 @@ static struct clk iva2_ck = {
1123 .clksel_mask = OMAP3430_ST_IVA2_CLK_MASK, 1126 .clksel_mask = OMAP3430_ST_IVA2_CLK_MASK,
1124 .clksel = iva2_clksel, 1127 .clksel = iva2_clksel,
1125 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES, 1128 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES,
1129 .clkdm_name = "iva2_clkdm",
1126 .recalc = &omap2_clksel_recalc, 1130 .recalc = &omap2_clksel_recalc,
1127}; 1131};
1128 1132
@@ -1137,6 +1141,7 @@ static struct clk l3_ick = {
1137 .clksel = div2_core_clksel, 1141 .clksel = div2_core_clksel,
1138 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1142 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1139 PARENT_CONTROLS_CLOCK, 1143 PARENT_CONTROLS_CLOCK,
1144 .clkdm_name = "core_l3_clkdm",
1140 .recalc = &omap2_clksel_recalc, 1145 .recalc = &omap2_clksel_recalc,
1141}; 1146};
1142 1147
@@ -1154,6 +1159,7 @@ static struct clk l4_ick = {
1154 .clksel = div2_l3_clksel, 1159 .clksel = div2_l3_clksel,
1155 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1160 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1156 PARENT_CONTROLS_CLOCK, 1161 PARENT_CONTROLS_CLOCK,
1162 .clkdm_name = "core_l4_clkdm",
1157 .recalc = &omap2_clksel_recalc, 1163 .recalc = &omap2_clksel_recalc,
1158 1164
1159}; 1165};
@@ -1183,43 +1189,57 @@ static const struct clksel gfx_l3_clksel[] = {
1183 { .parent = NULL } 1189 { .parent = NULL }
1184}; 1190};
1185 1191
1186static struct clk gfx_l3_fck = { 1192/* Virtual parent clock for gfx_l3_ick and gfx_l3_fck */
1187 .name = "gfx_l3_fck", 1193static struct clk gfx_l3_ck = {
1194 .name = "gfx_l3_ck",
1188 .parent = &l3_ick, 1195 .parent = &l3_ick,
1189 .init = &omap2_init_clksel_parent, 1196 .init = &omap2_init_clksel_parent,
1190 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_ICLKEN), 1197 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_ICLKEN),
1191 .enable_bit = OMAP_EN_GFX_SHIFT, 1198 .enable_bit = OMAP_EN_GFX_SHIFT,
1199 .flags = CLOCK_IN_OMAP3430ES1,
1200 .recalc = &followparent_recalc,
1201};
1202
1203static struct clk gfx_l3_fck = {
1204 .name = "gfx_l3_fck",
1205 .parent = &gfx_l3_ck,
1206 .init = &omap2_init_clksel_parent,
1192 .clksel_reg = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL), 1207 .clksel_reg = OMAP_CM_REGADDR(GFX_MOD, CM_CLKSEL),
1193 .clksel_mask = OMAP_CLKSEL_GFX_MASK, 1208 .clksel_mask = OMAP_CLKSEL_GFX_MASK,
1194 .clksel = gfx_l3_clksel, 1209 .clksel = gfx_l3_clksel,
1195 .flags = CLOCK_IN_OMAP3430ES1 | RATE_PROPAGATES, 1210 .flags = CLOCK_IN_OMAP3430ES1 | RATE_PROPAGATES |
1211 PARENT_CONTROLS_CLOCK,
1212 .clkdm_name = "gfx_3430es1_clkdm",
1196 .recalc = &omap2_clksel_recalc, 1213 .recalc = &omap2_clksel_recalc,
1197}; 1214};
1198 1215
1199static struct clk gfx_l3_ick = { 1216static struct clk gfx_l3_ick = {
1200 .name = "gfx_l3_ick", 1217 .name = "gfx_l3_ick",
1201 .parent = &l3_ick, 1218 .parent = &gfx_l3_ck,
1202 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_ICLKEN), 1219 .flags = CLOCK_IN_OMAP3430ES1 | PARENT_CONTROLS_CLOCK,
1203 .enable_bit = OMAP_EN_GFX_SHIFT, 1220 .clkdm_name = "gfx_3430es1_clkdm",
1204 .flags = CLOCK_IN_OMAP3430ES1,
1205 .recalc = &followparent_recalc, 1221 .recalc = &followparent_recalc,
1206}; 1222};
1207 1223
1208static struct clk gfx_cg1_ck = { 1224static struct clk gfx_cg1_ck = {
1209 .name = "gfx_cg1_ck", 1225 .name = "gfx_cg1_ck",
1210 .parent = &gfx_l3_fck, /* REVISIT: correct? */ 1226 .parent = &gfx_l3_fck, /* REVISIT: correct? */
1227 .init = &omap2_init_clk_clkdm,
1211 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN), 1228 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN),
1212 .enable_bit = OMAP3430ES1_EN_2D_SHIFT, 1229 .enable_bit = OMAP3430ES1_EN_2D_SHIFT,
1213 .flags = CLOCK_IN_OMAP3430ES1, 1230 .flags = CLOCK_IN_OMAP3430ES1,
1231 .clkdm_name = "gfx_3430es1_clkdm",
1214 .recalc = &followparent_recalc, 1232 .recalc = &followparent_recalc,
1215}; 1233};
1216 1234
1217static struct clk gfx_cg2_ck = { 1235static struct clk gfx_cg2_ck = {
1218 .name = "gfx_cg2_ck", 1236 .name = "gfx_cg2_ck",
1219 .parent = &gfx_l3_fck, /* REVISIT: correct? */ 1237 .parent = &gfx_l3_fck, /* REVISIT: correct? */
1238 .init = &omap2_init_clk_clkdm,
1220 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN), 1239 .enable_reg = OMAP_CM_REGADDR(GFX_MOD, CM_FCLKEN),
1221 .enable_bit = OMAP3430ES1_EN_3D_SHIFT, 1240 .enable_bit = OMAP3430ES1_EN_3D_SHIFT,
1222 .flags = CLOCK_IN_OMAP3430ES1, 1241 .flags = CLOCK_IN_OMAP3430ES1,
1242 .clkdm_name = "gfx_3430es1_clkdm",
1223 .recalc = &followparent_recalc, 1243 .recalc = &followparent_recalc,
1224}; 1244};
1225 1245
@@ -1252,15 +1272,18 @@ static struct clk sgx_fck = {
1252 .clksel_mask = OMAP3430ES2_CLKSEL_SGX_MASK, 1272 .clksel_mask = OMAP3430ES2_CLKSEL_SGX_MASK,
1253 .clksel = sgx_clksel, 1273 .clksel = sgx_clksel,
1254 .flags = CLOCK_IN_OMAP3430ES2, 1274 .flags = CLOCK_IN_OMAP3430ES2,
1275 .clkdm_name = "sgx_clkdm",
1255 .recalc = &omap2_clksel_recalc, 1276 .recalc = &omap2_clksel_recalc,
1256}; 1277};
1257 1278
1258static struct clk sgx_ick = { 1279static struct clk sgx_ick = {
1259 .name = "sgx_ick", 1280 .name = "sgx_ick",
1260 .parent = &l3_ick, 1281 .parent = &l3_ick,
1282 .init = &omap2_init_clk_clkdm,
1261 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_SGX_MOD, CM_ICLKEN), 1283 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_SGX_MOD, CM_ICLKEN),
1262 .enable_bit = OMAP3430ES2_EN_SGX_SHIFT, 1284 .enable_bit = OMAP3430ES2_EN_SGX_SHIFT,
1263 .flags = CLOCK_IN_OMAP3430ES2, 1285 .flags = CLOCK_IN_OMAP3430ES2,
1286 .clkdm_name = "sgx_clkdm",
1264 .recalc = &followparent_recalc, 1287 .recalc = &followparent_recalc,
1265}; 1288};
1266 1289
@@ -1269,9 +1292,11 @@ static struct clk sgx_ick = {
1269static struct clk d2d_26m_fck = { 1292static struct clk d2d_26m_fck = {
1270 .name = "d2d_26m_fck", 1293 .name = "d2d_26m_fck",
1271 .parent = &sys_ck, 1294 .parent = &sys_ck,
1295 .init = &omap2_init_clk_clkdm,
1272 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1296 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1273 .enable_bit = OMAP3430ES1_EN_D2D_SHIFT, 1297 .enable_bit = OMAP3430ES1_EN_D2D_SHIFT,
1274 .flags = CLOCK_IN_OMAP3430ES1, 1298 .flags = CLOCK_IN_OMAP3430ES1,
1299 .clkdm_name = "d2d_clkdm",
1275 .recalc = &followparent_recalc, 1300 .recalc = &followparent_recalc,
1276}; 1301};
1277 1302
@@ -1291,6 +1316,7 @@ static struct clk gpt10_fck = {
1291 .clksel_mask = OMAP3430_CLKSEL_GPT10_MASK, 1316 .clksel_mask = OMAP3430_CLKSEL_GPT10_MASK,
1292 .clksel = omap343x_gpt_clksel, 1317 .clksel = omap343x_gpt_clksel,
1293 .flags = CLOCK_IN_OMAP343X, 1318 .flags = CLOCK_IN_OMAP343X,
1319 .clkdm_name = "core_l4_clkdm",
1294 .recalc = &omap2_clksel_recalc, 1320 .recalc = &omap2_clksel_recalc,
1295}; 1321};
1296 1322
@@ -1304,6 +1330,7 @@ static struct clk gpt11_fck = {
1304 .clksel_mask = OMAP3430_CLKSEL_GPT11_MASK, 1330 .clksel_mask = OMAP3430_CLKSEL_GPT11_MASK,
1305 .clksel = omap343x_gpt_clksel, 1331 .clksel = omap343x_gpt_clksel,
1306 .flags = CLOCK_IN_OMAP343X, 1332 .flags = CLOCK_IN_OMAP343X,
1333 .clkdm_name = "core_l4_clkdm",
1307 .recalc = &omap2_clksel_recalc, 1334 .recalc = &omap2_clksel_recalc,
1308}; 1335};
1309 1336
@@ -1341,6 +1368,7 @@ static struct clk core_96m_fck = {
1341 .parent = &omap_96m_fck, 1368 .parent = &omap_96m_fck,
1342 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1369 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1343 PARENT_CONTROLS_CLOCK, 1370 PARENT_CONTROLS_CLOCK,
1371 .clkdm_name = "core_l4_clkdm",
1344 .recalc = &followparent_recalc, 1372 .recalc = &followparent_recalc,
1345}; 1373};
1346 1374
@@ -1351,6 +1379,7 @@ static struct clk mmchs3_fck = {
1351 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1379 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1352 .enable_bit = OMAP3430ES2_EN_MMC3_SHIFT, 1380 .enable_bit = OMAP3430ES2_EN_MMC3_SHIFT,
1353 .flags = CLOCK_IN_OMAP3430ES2, 1381 .flags = CLOCK_IN_OMAP3430ES2,
1382 .clkdm_name = "core_l4_clkdm",
1354 .recalc = &followparent_recalc, 1383 .recalc = &followparent_recalc,
1355}; 1384};
1356 1385
@@ -1361,6 +1390,7 @@ static struct clk mmchs2_fck = {
1361 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1390 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1362 .enable_bit = OMAP3430_EN_MMC2_SHIFT, 1391 .enable_bit = OMAP3430_EN_MMC2_SHIFT,
1363 .flags = CLOCK_IN_OMAP343X, 1392 .flags = CLOCK_IN_OMAP343X,
1393 .clkdm_name = "core_l4_clkdm",
1364 .recalc = &followparent_recalc, 1394 .recalc = &followparent_recalc,
1365}; 1395};
1366 1396
@@ -1370,6 +1400,7 @@ static struct clk mspro_fck = {
1370 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1400 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1371 .enable_bit = OMAP3430_EN_MSPRO_SHIFT, 1401 .enable_bit = OMAP3430_EN_MSPRO_SHIFT,
1372 .flags = CLOCK_IN_OMAP343X, 1402 .flags = CLOCK_IN_OMAP343X,
1403 .clkdm_name = "core_l4_clkdm",
1373 .recalc = &followparent_recalc, 1404 .recalc = &followparent_recalc,
1374}; 1405};
1375 1406
@@ -1380,6 +1411,7 @@ static struct clk mmchs1_fck = {
1380 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1411 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1381 .enable_bit = OMAP3430_EN_MMC1_SHIFT, 1412 .enable_bit = OMAP3430_EN_MMC1_SHIFT,
1382 .flags = CLOCK_IN_OMAP343X, 1413 .flags = CLOCK_IN_OMAP343X,
1414 .clkdm_name = "core_l4_clkdm",
1383 .recalc = &followparent_recalc, 1415 .recalc = &followparent_recalc,
1384}; 1416};
1385 1417
@@ -1390,16 +1422,18 @@ static struct clk i2c3_fck = {
1390 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1422 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1391 .enable_bit = OMAP3430_EN_I2C3_SHIFT, 1423 .enable_bit = OMAP3430_EN_I2C3_SHIFT,
1392 .flags = CLOCK_IN_OMAP343X, 1424 .flags = CLOCK_IN_OMAP343X,
1425 .clkdm_name = "core_l4_clkdm",
1393 .recalc = &followparent_recalc, 1426 .recalc = &followparent_recalc,
1394}; 1427};
1395 1428
1396static struct clk i2c2_fck = { 1429static struct clk i2c2_fck = {
1397 .name = "i2c_fck", 1430 .name = "i2c_fck",
1398 .id = 2, 1431 .id = 2,
1399 .parent = &core_96m_fck, 1432 .parent = &core_96m_fck,
1400 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1433 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1401 .enable_bit = OMAP3430_EN_I2C2_SHIFT, 1434 .enable_bit = OMAP3430_EN_I2C2_SHIFT,
1402 .flags = CLOCK_IN_OMAP343X, 1435 .flags = CLOCK_IN_OMAP343X,
1436 .clkdm_name = "core_l4_clkdm",
1403 .recalc = &followparent_recalc, 1437 .recalc = &followparent_recalc,
1404}; 1438};
1405 1439
@@ -1410,6 +1444,7 @@ static struct clk i2c1_fck = {
1410 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1444 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1411 .enable_bit = OMAP3430_EN_I2C1_SHIFT, 1445 .enable_bit = OMAP3430_EN_I2C1_SHIFT,
1412 .flags = CLOCK_IN_OMAP343X, 1446 .flags = CLOCK_IN_OMAP343X,
1447 .clkdm_name = "core_l4_clkdm",
1413 .recalc = &followparent_recalc, 1448 .recalc = &followparent_recalc,
1414}; 1449};
1415 1450
@@ -1443,6 +1478,7 @@ static struct clk mcbsp5_fck = {
1443 .clksel_mask = OMAP2_MCBSP5_CLKS_MASK, 1478 .clksel_mask = OMAP2_MCBSP5_CLKS_MASK,
1444 .clksel = mcbsp_15_clksel, 1479 .clksel = mcbsp_15_clksel,
1445 .flags = CLOCK_IN_OMAP343X, 1480 .flags = CLOCK_IN_OMAP343X,
1481 .clkdm_name = "core_l4_clkdm",
1446 .recalc = &omap2_clksel_recalc, 1482 .recalc = &omap2_clksel_recalc,
1447}; 1483};
1448 1484
@@ -1456,6 +1492,7 @@ static struct clk mcbsp1_fck = {
1456 .clksel_mask = OMAP2_MCBSP1_CLKS_MASK, 1492 .clksel_mask = OMAP2_MCBSP1_CLKS_MASK,
1457 .clksel = mcbsp_15_clksel, 1493 .clksel = mcbsp_15_clksel,
1458 .flags = CLOCK_IN_OMAP343X, 1494 .flags = CLOCK_IN_OMAP343X,
1495 .clkdm_name = "core_l4_clkdm",
1459 .recalc = &omap2_clksel_recalc, 1496 .recalc = &omap2_clksel_recalc,
1460}; 1497};
1461 1498
@@ -1466,6 +1503,7 @@ static struct clk core_48m_fck = {
1466 .parent = &omap_48m_fck, 1503 .parent = &omap_48m_fck,
1467 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1504 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1468 PARENT_CONTROLS_CLOCK, 1505 PARENT_CONTROLS_CLOCK,
1506 .clkdm_name = "core_l4_clkdm",
1469 .recalc = &followparent_recalc, 1507 .recalc = &followparent_recalc,
1470}; 1508};
1471 1509
@@ -1543,6 +1581,7 @@ static struct clk core_12m_fck = {
1543 .parent = &omap_12m_fck, 1581 .parent = &omap_12m_fck,
1544 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1582 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1545 PARENT_CONTROLS_CLOCK, 1583 PARENT_CONTROLS_CLOCK,
1584 .clkdm_name = "core_l4_clkdm",
1546 .recalc = &followparent_recalc, 1585 .recalc = &followparent_recalc,
1547}; 1586};
1548 1587
@@ -1581,6 +1620,7 @@ static struct clk ssi_ssr_fck = {
1581 .clksel_mask = OMAP3430_CLKSEL_SSI_MASK, 1620 .clksel_mask = OMAP3430_CLKSEL_SSI_MASK,
1582 .clksel = ssi_ssr_clksel, 1621 .clksel = ssi_ssr_clksel,
1583 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES, 1622 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES,
1623 .clkdm_name = "core_l4_clkdm",
1584 .recalc = &omap2_clksel_recalc, 1624 .recalc = &omap2_clksel_recalc,
1585}; 1625};
1586 1626
@@ -1596,11 +1636,17 @@ static struct clk ssi_sst_fck = {
1596 1636
1597/* CORE_L3_ICK based clocks */ 1637/* CORE_L3_ICK based clocks */
1598 1638
1639/*
1640 * XXX must add clk_enable/clk_disable for these if standard code won't
1641 * handle it
1642 */
1599static struct clk core_l3_ick = { 1643static struct clk core_l3_ick = {
1600 .name = "core_l3_ick", 1644 .name = "core_l3_ick",
1601 .parent = &l3_ick, 1645 .parent = &l3_ick,
1646 .init = &omap2_init_clk_clkdm,
1602 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1647 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1603 PARENT_CONTROLS_CLOCK, 1648 PARENT_CONTROLS_CLOCK,
1649 .clkdm_name = "core_l3_clkdm",
1604 .recalc = &followparent_recalc, 1650 .recalc = &followparent_recalc,
1605}; 1651};
1606 1652
@@ -1610,6 +1656,7 @@ static struct clk hsotgusb_ick = {
1610 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1656 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1611 .enable_bit = OMAP3430_EN_HSOTGUSB_SHIFT, 1657 .enable_bit = OMAP3430_EN_HSOTGUSB_SHIFT,
1612 .flags = CLOCK_IN_OMAP343X, 1658 .flags = CLOCK_IN_OMAP343X,
1659 .clkdm_name = "core_l3_clkdm",
1613 .recalc = &followparent_recalc, 1660 .recalc = &followparent_recalc,
1614}; 1661};
1615 1662
@@ -1619,6 +1666,7 @@ static struct clk sdrc_ick = {
1619 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1666 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1620 .enable_bit = OMAP3430_EN_SDRC_SHIFT, 1667 .enable_bit = OMAP3430_EN_SDRC_SHIFT,
1621 .flags = CLOCK_IN_OMAP343X | ENABLE_ON_INIT, 1668 .flags = CLOCK_IN_OMAP343X | ENABLE_ON_INIT,
1669 .clkdm_name = "core_l3_clkdm",
1622 .recalc = &followparent_recalc, 1670 .recalc = &followparent_recalc,
1623}; 1671};
1624 1672
@@ -1627,6 +1675,7 @@ static struct clk gpmc_fck = {
1627 .parent = &core_l3_ick, 1675 .parent = &core_l3_ick,
1628 .flags = CLOCK_IN_OMAP343X | PARENT_CONTROLS_CLOCK | 1676 .flags = CLOCK_IN_OMAP343X | PARENT_CONTROLS_CLOCK |
1629 ENABLE_ON_INIT, 1677 ENABLE_ON_INIT,
1678 .clkdm_name = "core_l3_clkdm",
1630 .recalc = &followparent_recalc, 1679 .recalc = &followparent_recalc,
1631}; 1680};
1632 1681
@@ -1654,8 +1703,10 @@ static struct clk pka_ick = {
1654static struct clk core_l4_ick = { 1703static struct clk core_l4_ick = {
1655 .name = "core_l4_ick", 1704 .name = "core_l4_ick",
1656 .parent = &l4_ick, 1705 .parent = &l4_ick,
1706 .init = &omap2_init_clk_clkdm,
1657 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1707 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1658 PARENT_CONTROLS_CLOCK, 1708 PARENT_CONTROLS_CLOCK,
1709 .clkdm_name = "core_l4_clkdm",
1659 .recalc = &followparent_recalc, 1710 .recalc = &followparent_recalc,
1660}; 1711};
1661 1712
@@ -1665,6 +1716,7 @@ static struct clk usbtll_ick = {
1665 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN3), 1716 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN3),
1666 .enable_bit = OMAP3430ES2_EN_USBTLL_SHIFT, 1717 .enable_bit = OMAP3430ES2_EN_USBTLL_SHIFT,
1667 .flags = CLOCK_IN_OMAP3430ES2, 1718 .flags = CLOCK_IN_OMAP3430ES2,
1719 .clkdm_name = "core_l4_clkdm",
1668 .recalc = &followparent_recalc, 1720 .recalc = &followparent_recalc,
1669}; 1721};
1670 1722
@@ -1675,6 +1727,7 @@ static struct clk mmchs3_ick = {
1675 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1727 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1676 .enable_bit = OMAP3430ES2_EN_MMC3_SHIFT, 1728 .enable_bit = OMAP3430ES2_EN_MMC3_SHIFT,
1677 .flags = CLOCK_IN_OMAP3430ES2, 1729 .flags = CLOCK_IN_OMAP3430ES2,
1730 .clkdm_name = "core_l4_clkdm",
1678 .recalc = &followparent_recalc, 1731 .recalc = &followparent_recalc,
1679}; 1732};
1680 1733
@@ -1685,6 +1738,7 @@ static struct clk icr_ick = {
1685 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1738 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1686 .enable_bit = OMAP3430_EN_ICR_SHIFT, 1739 .enable_bit = OMAP3430_EN_ICR_SHIFT,
1687 .flags = CLOCK_IN_OMAP343X, 1740 .flags = CLOCK_IN_OMAP343X,
1741 .clkdm_name = "core_l4_clkdm",
1688 .recalc = &followparent_recalc, 1742 .recalc = &followparent_recalc,
1689}; 1743};
1690 1744
@@ -1694,6 +1748,7 @@ static struct clk aes2_ick = {
1694 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1748 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1695 .enable_bit = OMAP3430_EN_AES2_SHIFT, 1749 .enable_bit = OMAP3430_EN_AES2_SHIFT,
1696 .flags = CLOCK_IN_OMAP343X, 1750 .flags = CLOCK_IN_OMAP343X,
1751 .clkdm_name = "core_l4_clkdm",
1697 .recalc = &followparent_recalc, 1752 .recalc = &followparent_recalc,
1698}; 1753};
1699 1754
@@ -1703,6 +1758,7 @@ static struct clk sha12_ick = {
1703 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1758 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1704 .enable_bit = OMAP3430_EN_SHA12_SHIFT, 1759 .enable_bit = OMAP3430_EN_SHA12_SHIFT,
1705 .flags = CLOCK_IN_OMAP343X, 1760 .flags = CLOCK_IN_OMAP343X,
1761 .clkdm_name = "core_l4_clkdm",
1706 .recalc = &followparent_recalc, 1762 .recalc = &followparent_recalc,
1707}; 1763};
1708 1764
@@ -1712,6 +1768,7 @@ static struct clk des2_ick = {
1712 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1768 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1713 .enable_bit = OMAP3430_EN_DES2_SHIFT, 1769 .enable_bit = OMAP3430_EN_DES2_SHIFT,
1714 .flags = CLOCK_IN_OMAP343X, 1770 .flags = CLOCK_IN_OMAP343X,
1771 .clkdm_name = "core_l4_clkdm",
1715 .recalc = &followparent_recalc, 1772 .recalc = &followparent_recalc,
1716}; 1773};
1717 1774
@@ -1722,6 +1779,7 @@ static struct clk mmchs2_ick = {
1722 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1779 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1723 .enable_bit = OMAP3430_EN_MMC2_SHIFT, 1780 .enable_bit = OMAP3430_EN_MMC2_SHIFT,
1724 .flags = CLOCK_IN_OMAP343X, 1781 .flags = CLOCK_IN_OMAP343X,
1782 .clkdm_name = "core_l4_clkdm",
1725 .recalc = &followparent_recalc, 1783 .recalc = &followparent_recalc,
1726}; 1784};
1727 1785
@@ -1732,6 +1790,7 @@ static struct clk mmchs1_ick = {
1732 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1790 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1733 .enable_bit = OMAP3430_EN_MMC1_SHIFT, 1791 .enable_bit = OMAP3430_EN_MMC1_SHIFT,
1734 .flags = CLOCK_IN_OMAP343X, 1792 .flags = CLOCK_IN_OMAP343X,
1793 .clkdm_name = "core_l4_clkdm",
1735 .recalc = &followparent_recalc, 1794 .recalc = &followparent_recalc,
1736}; 1795};
1737 1796
@@ -1741,6 +1800,7 @@ static struct clk mspro_ick = {
1741 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1800 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1742 .enable_bit = OMAP3430_EN_MSPRO_SHIFT, 1801 .enable_bit = OMAP3430_EN_MSPRO_SHIFT,
1743 .flags = CLOCK_IN_OMAP343X, 1802 .flags = CLOCK_IN_OMAP343X,
1803 .clkdm_name = "core_l4_clkdm",
1744 .recalc = &followparent_recalc, 1804 .recalc = &followparent_recalc,
1745}; 1805};
1746 1806
@@ -1750,6 +1810,7 @@ static struct clk hdq_ick = {
1750 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1810 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1751 .enable_bit = OMAP3430_EN_HDQ_SHIFT, 1811 .enable_bit = OMAP3430_EN_HDQ_SHIFT,
1752 .flags = CLOCK_IN_OMAP343X, 1812 .flags = CLOCK_IN_OMAP343X,
1813 .clkdm_name = "core_l4_clkdm",
1753 .recalc = &followparent_recalc, 1814 .recalc = &followparent_recalc,
1754}; 1815};
1755 1816
@@ -1760,6 +1821,7 @@ static struct clk mcspi4_ick = {
1760 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1821 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1761 .enable_bit = OMAP3430_EN_MCSPI4_SHIFT, 1822 .enable_bit = OMAP3430_EN_MCSPI4_SHIFT,
1762 .flags = CLOCK_IN_OMAP343X, 1823 .flags = CLOCK_IN_OMAP343X,
1824 .clkdm_name = "core_l4_clkdm",
1763 .recalc = &followparent_recalc, 1825 .recalc = &followparent_recalc,
1764}; 1826};
1765 1827
@@ -1770,6 +1832,7 @@ static struct clk mcspi3_ick = {
1770 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1832 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1771 .enable_bit = OMAP3430_EN_MCSPI3_SHIFT, 1833 .enable_bit = OMAP3430_EN_MCSPI3_SHIFT,
1772 .flags = CLOCK_IN_OMAP343X, 1834 .flags = CLOCK_IN_OMAP343X,
1835 .clkdm_name = "core_l4_clkdm",
1773 .recalc = &followparent_recalc, 1836 .recalc = &followparent_recalc,
1774}; 1837};
1775 1838
@@ -1780,6 +1843,7 @@ static struct clk mcspi2_ick = {
1780 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1843 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1781 .enable_bit = OMAP3430_EN_MCSPI2_SHIFT, 1844 .enable_bit = OMAP3430_EN_MCSPI2_SHIFT,
1782 .flags = CLOCK_IN_OMAP343X, 1845 .flags = CLOCK_IN_OMAP343X,
1846 .clkdm_name = "core_l4_clkdm",
1783 .recalc = &followparent_recalc, 1847 .recalc = &followparent_recalc,
1784}; 1848};
1785 1849
@@ -1790,6 +1854,7 @@ static struct clk mcspi1_ick = {
1790 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1854 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1791 .enable_bit = OMAP3430_EN_MCSPI1_SHIFT, 1855 .enable_bit = OMAP3430_EN_MCSPI1_SHIFT,
1792 .flags = CLOCK_IN_OMAP343X, 1856 .flags = CLOCK_IN_OMAP343X,
1857 .clkdm_name = "core_l4_clkdm",
1793 .recalc = &followparent_recalc, 1858 .recalc = &followparent_recalc,
1794}; 1859};
1795 1860
@@ -1800,6 +1865,7 @@ static struct clk i2c3_ick = {
1800 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1865 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1801 .enable_bit = OMAP3430_EN_I2C3_SHIFT, 1866 .enable_bit = OMAP3430_EN_I2C3_SHIFT,
1802 .flags = CLOCK_IN_OMAP343X, 1867 .flags = CLOCK_IN_OMAP343X,
1868 .clkdm_name = "core_l4_clkdm",
1803 .recalc = &followparent_recalc, 1869 .recalc = &followparent_recalc,
1804}; 1870};
1805 1871
@@ -1810,6 +1876,7 @@ static struct clk i2c2_ick = {
1810 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1876 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1811 .enable_bit = OMAP3430_EN_I2C2_SHIFT, 1877 .enable_bit = OMAP3430_EN_I2C2_SHIFT,
1812 .flags = CLOCK_IN_OMAP343X, 1878 .flags = CLOCK_IN_OMAP343X,
1879 .clkdm_name = "core_l4_clkdm",
1813 .recalc = &followparent_recalc, 1880 .recalc = &followparent_recalc,
1814}; 1881};
1815 1882
@@ -1820,6 +1887,7 @@ static struct clk i2c1_ick = {
1820 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1887 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1821 .enable_bit = OMAP3430_EN_I2C1_SHIFT, 1888 .enable_bit = OMAP3430_EN_I2C1_SHIFT,
1822 .flags = CLOCK_IN_OMAP343X, 1889 .flags = CLOCK_IN_OMAP343X,
1890 .clkdm_name = "core_l4_clkdm",
1823 .recalc = &followparent_recalc, 1891 .recalc = &followparent_recalc,
1824}; 1892};
1825 1893
@@ -1829,6 +1897,7 @@ static struct clk uart2_ick = {
1829 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1897 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1830 .enable_bit = OMAP3430_EN_UART2_SHIFT, 1898 .enable_bit = OMAP3430_EN_UART2_SHIFT,
1831 .flags = CLOCK_IN_OMAP343X, 1899 .flags = CLOCK_IN_OMAP343X,
1900 .clkdm_name = "core_l4_clkdm",
1832 .recalc = &followparent_recalc, 1901 .recalc = &followparent_recalc,
1833}; 1902};
1834 1903
@@ -1838,6 +1907,7 @@ static struct clk uart1_ick = {
1838 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1907 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1839 .enable_bit = OMAP3430_EN_UART1_SHIFT, 1908 .enable_bit = OMAP3430_EN_UART1_SHIFT,
1840 .flags = CLOCK_IN_OMAP343X, 1909 .flags = CLOCK_IN_OMAP343X,
1910 .clkdm_name = "core_l4_clkdm",
1841 .recalc = &followparent_recalc, 1911 .recalc = &followparent_recalc,
1842}; 1912};
1843 1913
@@ -1847,6 +1917,7 @@ static struct clk gpt11_ick = {
1847 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1917 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1848 .enable_bit = OMAP3430_EN_GPT11_SHIFT, 1918 .enable_bit = OMAP3430_EN_GPT11_SHIFT,
1849 .flags = CLOCK_IN_OMAP343X, 1919 .flags = CLOCK_IN_OMAP343X,
1920 .clkdm_name = "core_l4_clkdm",
1850 .recalc = &followparent_recalc, 1921 .recalc = &followparent_recalc,
1851}; 1922};
1852 1923
@@ -1856,6 +1927,7 @@ static struct clk gpt10_ick = {
1856 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1927 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1857 .enable_bit = OMAP3430_EN_GPT10_SHIFT, 1928 .enable_bit = OMAP3430_EN_GPT10_SHIFT,
1858 .flags = CLOCK_IN_OMAP343X, 1929 .flags = CLOCK_IN_OMAP343X,
1930 .clkdm_name = "core_l4_clkdm",
1859 .recalc = &followparent_recalc, 1931 .recalc = &followparent_recalc,
1860}; 1932};
1861 1933
@@ -1866,6 +1938,7 @@ static struct clk mcbsp5_ick = {
1866 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1938 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1867 .enable_bit = OMAP3430_EN_MCBSP5_SHIFT, 1939 .enable_bit = OMAP3430_EN_MCBSP5_SHIFT,
1868 .flags = CLOCK_IN_OMAP343X, 1940 .flags = CLOCK_IN_OMAP343X,
1941 .clkdm_name = "core_l4_clkdm",
1869 .recalc = &followparent_recalc, 1942 .recalc = &followparent_recalc,
1870}; 1943};
1871 1944
@@ -1876,6 +1949,7 @@ static struct clk mcbsp1_ick = {
1876 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1949 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1877 .enable_bit = OMAP3430_EN_MCBSP1_SHIFT, 1950 .enable_bit = OMAP3430_EN_MCBSP1_SHIFT,
1878 .flags = CLOCK_IN_OMAP343X, 1951 .flags = CLOCK_IN_OMAP343X,
1952 .clkdm_name = "core_l4_clkdm",
1879 .recalc = &followparent_recalc, 1953 .recalc = &followparent_recalc,
1880}; 1954};
1881 1955
@@ -1885,6 +1959,7 @@ static struct clk fac_ick = {
1885 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1959 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1886 .enable_bit = OMAP3430ES1_EN_FAC_SHIFT, 1960 .enable_bit = OMAP3430ES1_EN_FAC_SHIFT,
1887 .flags = CLOCK_IN_OMAP3430ES1, 1961 .flags = CLOCK_IN_OMAP3430ES1,
1962 .clkdm_name = "core_l4_clkdm",
1888 .recalc = &followparent_recalc, 1963 .recalc = &followparent_recalc,
1889}; 1964};
1890 1965
@@ -1894,6 +1969,7 @@ static struct clk mailboxes_ick = {
1894 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1969 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1895 .enable_bit = OMAP3430_EN_MAILBOXES_SHIFT, 1970 .enable_bit = OMAP3430_EN_MAILBOXES_SHIFT,
1896 .flags = CLOCK_IN_OMAP343X, 1971 .flags = CLOCK_IN_OMAP343X,
1972 .clkdm_name = "core_l4_clkdm",
1897 .recalc = &followparent_recalc, 1973 .recalc = &followparent_recalc,
1898}; 1974};
1899 1975
@@ -1913,6 +1989,7 @@ static struct clk ssi_l4_ick = {
1913 .parent = &l4_ick, 1989 .parent = &l4_ick,
1914 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 1990 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
1915 PARENT_CONTROLS_CLOCK, 1991 PARENT_CONTROLS_CLOCK,
1992 .clkdm_name = "core_l4_clkdm",
1916 .recalc = &followparent_recalc, 1993 .recalc = &followparent_recalc,
1917}; 1994};
1918 1995
@@ -1922,6 +1999,7 @@ static struct clk ssi_ick = {
1922 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1999 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1923 .enable_bit = OMAP3430_EN_SSI_SHIFT, 2000 .enable_bit = OMAP3430_EN_SSI_SHIFT,
1924 .flags = CLOCK_IN_OMAP343X, 2001 .flags = CLOCK_IN_OMAP343X,
2002 .clkdm_name = "core_l4_clkdm",
1925 .recalc = &followparent_recalc, 2003 .recalc = &followparent_recalc,
1926}; 2004};
1927 2005
@@ -1996,7 +2074,7 @@ static struct clk des1_ick = {
1996 2074
1997/* DSS */ 2075/* DSS */
1998static const struct clksel dss1_alwon_fck_clksel[] = { 2076static const struct clksel dss1_alwon_fck_clksel[] = {
1999 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 2077 { .parent = &sys_ck, .rates = dpll_bypass_rates },
2000 { .parent = &dpll4_m4x2_ck, .rates = dpll_locked_rates }, 2078 { .parent = &dpll4_m4x2_ck, .rates = dpll_locked_rates },
2001 { .parent = NULL } 2079 { .parent = NULL }
2002}; 2080};
@@ -2011,33 +2089,40 @@ static struct clk dss1_alwon_fck = {
2011 .clksel_mask = OMAP3430_ST_PERIPH_CLK_MASK, 2089 .clksel_mask = OMAP3430_ST_PERIPH_CLK_MASK,
2012 .clksel = dss1_alwon_fck_clksel, 2090 .clksel = dss1_alwon_fck_clksel,
2013 .flags = CLOCK_IN_OMAP343X, 2091 .flags = CLOCK_IN_OMAP343X,
2092 .clkdm_name = "dss_clkdm",
2014 .recalc = &omap2_clksel_recalc, 2093 .recalc = &omap2_clksel_recalc,
2015}; 2094};
2016 2095
2017static struct clk dss_tv_fck = { 2096static struct clk dss_tv_fck = {
2018 .name = "dss_tv_fck", 2097 .name = "dss_tv_fck",
2019 .parent = &omap_54m_fck, 2098 .parent = &omap_54m_fck,
2099 .init = &omap2_init_clk_clkdm,
2020 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN), 2100 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN),
2021 .enable_bit = OMAP3430_EN_TV_SHIFT, 2101 .enable_bit = OMAP3430_EN_TV_SHIFT,
2022 .flags = CLOCK_IN_OMAP343X, 2102 .flags = CLOCK_IN_OMAP343X,
2103 .clkdm_name = "dss_clkdm",
2023 .recalc = &followparent_recalc, 2104 .recalc = &followparent_recalc,
2024}; 2105};
2025 2106
2026static struct clk dss_96m_fck = { 2107static struct clk dss_96m_fck = {
2027 .name = "dss_96m_fck", 2108 .name = "dss_96m_fck",
2028 .parent = &omap_96m_fck, 2109 .parent = &omap_96m_fck,
2110 .init = &omap2_init_clk_clkdm,
2029 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN), 2111 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN),
2030 .enable_bit = OMAP3430_EN_TV_SHIFT, 2112 .enable_bit = OMAP3430_EN_TV_SHIFT,
2031 .flags = CLOCK_IN_OMAP343X, 2113 .flags = CLOCK_IN_OMAP343X,
2114 .clkdm_name = "dss_clkdm",
2032 .recalc = &followparent_recalc, 2115 .recalc = &followparent_recalc,
2033}; 2116};
2034 2117
2035static struct clk dss2_alwon_fck = { 2118static struct clk dss2_alwon_fck = {
2036 .name = "dss2_alwon_fck", 2119 .name = "dss2_alwon_fck",
2037 .parent = &sys_ck, 2120 .parent = &sys_ck,
2121 .init = &omap2_init_clk_clkdm,
2038 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN), 2122 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN),
2039 .enable_bit = OMAP3430_EN_DSS2_SHIFT, 2123 .enable_bit = OMAP3430_EN_DSS2_SHIFT,
2040 .flags = CLOCK_IN_OMAP343X, 2124 .flags = CLOCK_IN_OMAP343X,
2125 .clkdm_name = "dss_clkdm",
2041 .recalc = &followparent_recalc, 2126 .recalc = &followparent_recalc,
2042}; 2127};
2043 2128
@@ -2045,16 +2130,18 @@ static struct clk dss_ick = {
2045 /* Handles both L3 and L4 clocks */ 2130 /* Handles both L3 and L4 clocks */
2046 .name = "dss_ick", 2131 .name = "dss_ick",
2047 .parent = &l4_ick, 2132 .parent = &l4_ick,
2133 .init = &omap2_init_clk_clkdm,
2048 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_ICLKEN), 2134 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_ICLKEN),
2049 .enable_bit = OMAP3430_CM_ICLKEN_DSS_EN_DSS_SHIFT, 2135 .enable_bit = OMAP3430_CM_ICLKEN_DSS_EN_DSS_SHIFT,
2050 .flags = CLOCK_IN_OMAP343X, 2136 .flags = CLOCK_IN_OMAP343X,
2137 .clkdm_name = "dss_clkdm",
2051 .recalc = &followparent_recalc, 2138 .recalc = &followparent_recalc,
2052}; 2139};
2053 2140
2054/* CAM */ 2141/* CAM */
2055 2142
2056static const struct clksel cam_mclk_clksel[] = { 2143static const struct clksel cam_mclk_clksel[] = {
2057 { .parent = &sys_ck, .rates = dpll_bypass_rates }, 2144 { .parent = &sys_ck, .rates = dpll_bypass_rates },
2058 { .parent = &dpll4_m5x2_ck, .rates = dpll_locked_rates }, 2145 { .parent = &dpll4_m5x2_ck, .rates = dpll_locked_rates },
2059 { .parent = NULL } 2146 { .parent = NULL }
2060}; 2147};
@@ -2069,24 +2156,19 @@ static struct clk cam_mclk = {
2069 .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_FCLKEN), 2156 .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_FCLKEN),
2070 .enable_bit = OMAP3430_EN_CAM_SHIFT, 2157 .enable_bit = OMAP3430_EN_CAM_SHIFT,
2071 .flags = CLOCK_IN_OMAP343X, 2158 .flags = CLOCK_IN_OMAP343X,
2159 .clkdm_name = "cam_clkdm",
2072 .recalc = &omap2_clksel_recalc, 2160 .recalc = &omap2_clksel_recalc,
2073}; 2161};
2074 2162
2075static struct clk cam_l3_ick = { 2163static struct clk cam_ick = {
2076 .name = "cam_l3_ick", 2164 /* Handles both L3 and L4 clocks */
2077 .parent = &l3_ick, 2165 .name = "cam_ick",
2078 .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_ICLKEN),
2079 .enable_bit = OMAP3430_EN_CAM_SHIFT,
2080 .flags = CLOCK_IN_OMAP343X,
2081 .recalc = &followparent_recalc,
2082};
2083
2084static struct clk cam_l4_ick = {
2085 .name = "cam_l4_ick",
2086 .parent = &l4_ick, 2166 .parent = &l4_ick,
2167 .init = &omap2_init_clk_clkdm,
2087 .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_ICLKEN), 2168 .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_ICLKEN),
2088 .enable_bit = OMAP3430_EN_CAM_SHIFT, 2169 .enable_bit = OMAP3430_EN_CAM_SHIFT,
2089 .flags = CLOCK_IN_OMAP343X, 2170 .flags = CLOCK_IN_OMAP343X,
2171 .clkdm_name = "cam_clkdm",
2090 .recalc = &followparent_recalc, 2172 .recalc = &followparent_recalc,
2091}; 2173};
2092 2174
@@ -2095,45 +2177,45 @@ static struct clk cam_l4_ick = {
2095static struct clk usbhost_120m_fck = { 2177static struct clk usbhost_120m_fck = {
2096 .name = "usbhost_120m_fck", 2178 .name = "usbhost_120m_fck",
2097 .parent = &omap_120m_fck, 2179 .parent = &omap_120m_fck,
2180 .init = &omap2_init_clk_clkdm,
2098 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN), 2181 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN),
2099 .enable_bit = OMAP3430ES2_EN_USBHOST2_SHIFT, 2182 .enable_bit = OMAP3430ES2_EN_USBHOST2_SHIFT,
2100 .flags = CLOCK_IN_OMAP3430ES2, 2183 .flags = CLOCK_IN_OMAP3430ES2,
2184 .clkdm_name = "usbhost_clkdm",
2101 .recalc = &followparent_recalc, 2185 .recalc = &followparent_recalc,
2102}; 2186};
2103 2187
2104static struct clk usbhost_48m_fck = { 2188static struct clk usbhost_48m_fck = {
2105 .name = "usbhost_48m_fck", 2189 .name = "usbhost_48m_fck",
2106 .parent = &omap_48m_fck, 2190 .parent = &omap_48m_fck,
2191 .init = &omap2_init_clk_clkdm,
2107 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN), 2192 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN),
2108 .enable_bit = OMAP3430ES2_EN_USBHOST1_SHIFT, 2193 .enable_bit = OMAP3430ES2_EN_USBHOST1_SHIFT,
2109 .flags = CLOCK_IN_OMAP3430ES2, 2194 .flags = CLOCK_IN_OMAP3430ES2,
2195 .clkdm_name = "usbhost_clkdm",
2110 .recalc = &followparent_recalc, 2196 .recalc = &followparent_recalc,
2111}; 2197};
2112 2198
2113static struct clk usbhost_l3_ick = { 2199static struct clk usbhost_ick = {
2114 .name = "usbhost_l3_ick", 2200 /* Handles both L3 and L4 clocks */
2115 .parent = &l3_ick, 2201 .name = "usbhost_ick",
2116 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN),
2117 .enable_bit = OMAP3430ES2_EN_USBHOST_SHIFT,
2118 .flags = CLOCK_IN_OMAP3430ES2,
2119 .recalc = &followparent_recalc,
2120};
2121
2122static struct clk usbhost_l4_ick = {
2123 .name = "usbhost_l4_ick",
2124 .parent = &l4_ick, 2202 .parent = &l4_ick,
2203 .init = &omap2_init_clk_clkdm,
2125 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN), 2204 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN),
2126 .enable_bit = OMAP3430ES2_EN_USBHOST_SHIFT, 2205 .enable_bit = OMAP3430ES2_EN_USBHOST_SHIFT,
2127 .flags = CLOCK_IN_OMAP3430ES2, 2206 .flags = CLOCK_IN_OMAP3430ES2,
2207 .clkdm_name = "usbhost_clkdm",
2128 .recalc = &followparent_recalc, 2208 .recalc = &followparent_recalc,
2129}; 2209};
2130 2210
2131static struct clk usbhost_sar_fck = { 2211static struct clk usbhost_sar_fck = {
2132 .name = "usbhost_sar_fck", 2212 .name = "usbhost_sar_fck",
2133 .parent = &osc_sys_ck, 2213 .parent = &osc_sys_ck,
2214 .init = &omap2_init_clk_clkdm,
2134 .enable_reg = OMAP_PRM_REGADDR(OMAP3430ES2_USBHOST_MOD, PM_PWSTCTRL), 2215 .enable_reg = OMAP_PRM_REGADDR(OMAP3430ES2_USBHOST_MOD, PM_PWSTCTRL),
2135 .enable_bit = OMAP3430ES2_SAVEANDRESTORE_SHIFT, 2216 .enable_bit = OMAP3430ES2_SAVEANDRESTORE_SHIFT,
2136 .flags = CLOCK_IN_OMAP3430ES2, 2217 .flags = CLOCK_IN_OMAP3430ES2,
2218 .clkdm_name = "usbhost_clkdm",
2137 .recalc = &followparent_recalc, 2219 .recalc = &followparent_recalc,
2138}; 2220};
2139 2221
@@ -2175,6 +2257,7 @@ static struct clk usim_fck = {
2175 .recalc = &omap2_clksel_recalc, 2257 .recalc = &omap2_clksel_recalc,
2176}; 2258};
2177 2259
2260/* XXX should gpt1's clksel have wkup_32k_fck as the 32k opt? */
2178static struct clk gpt1_fck = { 2261static struct clk gpt1_fck = {
2179 .name = "gpt1_fck", 2262 .name = "gpt1_fck",
2180 .init = &omap2_init_clksel_parent, 2263 .init = &omap2_init_clksel_parent,
@@ -2184,13 +2267,16 @@ static struct clk gpt1_fck = {
2184 .clksel_mask = OMAP3430_CLKSEL_GPT1_MASK, 2267 .clksel_mask = OMAP3430_CLKSEL_GPT1_MASK,
2185 .clksel = omap343x_gpt_clksel, 2268 .clksel = omap343x_gpt_clksel,
2186 .flags = CLOCK_IN_OMAP343X, 2269 .flags = CLOCK_IN_OMAP343X,
2270 .clkdm_name = "wkup_clkdm",
2187 .recalc = &omap2_clksel_recalc, 2271 .recalc = &omap2_clksel_recalc,
2188}; 2272};
2189 2273
2190static struct clk wkup_32k_fck = { 2274static struct clk wkup_32k_fck = {
2191 .name = "wkup_32k_fck", 2275 .name = "wkup_32k_fck",
2276 .init = &omap2_init_clk_clkdm,
2192 .parent = &omap_32k_fck, 2277 .parent = &omap_32k_fck,
2193 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2278 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2279 .clkdm_name = "wkup_clkdm",
2194 .recalc = &followparent_recalc, 2280 .recalc = &followparent_recalc,
2195}; 2281};
2196 2282
@@ -2200,6 +2286,7 @@ static struct clk gpio1_fck = {
2200 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN), 2286 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN),
2201 .enable_bit = OMAP3430_EN_GPIO1_SHIFT, 2287 .enable_bit = OMAP3430_EN_GPIO1_SHIFT,
2202 .flags = CLOCK_IN_OMAP343X, 2288 .flags = CLOCK_IN_OMAP343X,
2289 .clkdm_name = "wkup_clkdm",
2203 .recalc = &followparent_recalc, 2290 .recalc = &followparent_recalc,
2204}; 2291};
2205 2292
@@ -2209,6 +2296,7 @@ static struct clk wdt2_fck = {
2209 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN), 2296 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_FCLKEN),
2210 .enable_bit = OMAP3430_EN_WDT2_SHIFT, 2297 .enable_bit = OMAP3430_EN_WDT2_SHIFT,
2211 .flags = CLOCK_IN_OMAP343X, 2298 .flags = CLOCK_IN_OMAP343X,
2299 .clkdm_name = "wkup_clkdm",
2212 .recalc = &followparent_recalc, 2300 .recalc = &followparent_recalc,
2213}; 2301};
2214 2302
@@ -2216,6 +2304,7 @@ static struct clk wkup_l4_ick = {
2216 .name = "wkup_l4_ick", 2304 .name = "wkup_l4_ick",
2217 .parent = &sys_ck, 2305 .parent = &sys_ck,
2218 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2306 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2307 .clkdm_name = "wkup_clkdm",
2219 .recalc = &followparent_recalc, 2308 .recalc = &followparent_recalc,
2220}; 2309};
2221 2310
@@ -2227,6 +2316,7 @@ static struct clk usim_ick = {
2227 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2316 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2228 .enable_bit = OMAP3430ES2_EN_USIMOCP_SHIFT, 2317 .enable_bit = OMAP3430ES2_EN_USIMOCP_SHIFT,
2229 .flags = CLOCK_IN_OMAP3430ES2, 2318 .flags = CLOCK_IN_OMAP3430ES2,
2319 .clkdm_name = "wkup_clkdm",
2230 .recalc = &followparent_recalc, 2320 .recalc = &followparent_recalc,
2231}; 2321};
2232 2322
@@ -2236,6 +2326,7 @@ static struct clk wdt2_ick = {
2236 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2326 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2237 .enable_bit = OMAP3430_EN_WDT2_SHIFT, 2327 .enable_bit = OMAP3430_EN_WDT2_SHIFT,
2238 .flags = CLOCK_IN_OMAP343X, 2328 .flags = CLOCK_IN_OMAP343X,
2329 .clkdm_name = "wkup_clkdm",
2239 .recalc = &followparent_recalc, 2330 .recalc = &followparent_recalc,
2240}; 2331};
2241 2332
@@ -2245,6 +2336,7 @@ static struct clk wdt1_ick = {
2245 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2336 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2246 .enable_bit = OMAP3430_EN_WDT1_SHIFT, 2337 .enable_bit = OMAP3430_EN_WDT1_SHIFT,
2247 .flags = CLOCK_IN_OMAP343X, 2338 .flags = CLOCK_IN_OMAP343X,
2339 .clkdm_name = "wkup_clkdm",
2248 .recalc = &followparent_recalc, 2340 .recalc = &followparent_recalc,
2249}; 2341};
2250 2342
@@ -2254,6 +2346,7 @@ static struct clk gpio1_ick = {
2254 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2346 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2255 .enable_bit = OMAP3430_EN_GPIO1_SHIFT, 2347 .enable_bit = OMAP3430_EN_GPIO1_SHIFT,
2256 .flags = CLOCK_IN_OMAP343X, 2348 .flags = CLOCK_IN_OMAP343X,
2349 .clkdm_name = "wkup_clkdm",
2257 .recalc = &followparent_recalc, 2350 .recalc = &followparent_recalc,
2258}; 2351};
2259 2352
@@ -2263,15 +2356,18 @@ static struct clk omap_32ksync_ick = {
2263 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2356 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2264 .enable_bit = OMAP3430_EN_32KSYNC_SHIFT, 2357 .enable_bit = OMAP3430_EN_32KSYNC_SHIFT,
2265 .flags = CLOCK_IN_OMAP343X, 2358 .flags = CLOCK_IN_OMAP343X,
2359 .clkdm_name = "wkup_clkdm",
2266 .recalc = &followparent_recalc, 2360 .recalc = &followparent_recalc,
2267}; 2361};
2268 2362
2363/* XXX This clock no longer exists in 3430 TRM rev F */
2269static struct clk gpt12_ick = { 2364static struct clk gpt12_ick = {
2270 .name = "gpt12_ick", 2365 .name = "gpt12_ick",
2271 .parent = &wkup_l4_ick, 2366 .parent = &wkup_l4_ick,
2272 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2367 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2273 .enable_bit = OMAP3430_EN_GPT12_SHIFT, 2368 .enable_bit = OMAP3430_EN_GPT12_SHIFT,
2274 .flags = CLOCK_IN_OMAP343X, 2369 .flags = CLOCK_IN_OMAP343X,
2370 .clkdm_name = "wkup_clkdm",
2275 .recalc = &followparent_recalc, 2371 .recalc = &followparent_recalc,
2276}; 2372};
2277 2373
@@ -2281,6 +2377,7 @@ static struct clk gpt1_ick = {
2281 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN), 2377 .enable_reg = OMAP_CM_REGADDR(WKUP_MOD, CM_ICLKEN),
2282 .enable_bit = OMAP3430_EN_GPT1_SHIFT, 2378 .enable_bit = OMAP3430_EN_GPT1_SHIFT,
2283 .flags = CLOCK_IN_OMAP343X, 2379 .flags = CLOCK_IN_OMAP343X,
2380 .clkdm_name = "wkup_clkdm",
2284 .recalc = &followparent_recalc, 2381 .recalc = &followparent_recalc,
2285}; 2382};
2286 2383
@@ -2291,16 +2388,20 @@ static struct clk gpt1_ick = {
2291static struct clk per_96m_fck = { 2388static struct clk per_96m_fck = {
2292 .name = "per_96m_fck", 2389 .name = "per_96m_fck",
2293 .parent = &omap_96m_alwon_fck, 2390 .parent = &omap_96m_alwon_fck,
2391 .init = &omap2_init_clk_clkdm,
2294 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 2392 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
2295 PARENT_CONTROLS_CLOCK, 2393 PARENT_CONTROLS_CLOCK,
2394 .clkdm_name = "per_clkdm",
2296 .recalc = &followparent_recalc, 2395 .recalc = &followparent_recalc,
2297}; 2396};
2298 2397
2299static struct clk per_48m_fck = { 2398static struct clk per_48m_fck = {
2300 .name = "per_48m_fck", 2399 .name = "per_48m_fck",
2301 .parent = &omap_48m_fck, 2400 .parent = &omap_48m_fck,
2401 .init = &omap2_init_clk_clkdm,
2302 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 2402 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
2303 PARENT_CONTROLS_CLOCK, 2403 PARENT_CONTROLS_CLOCK,
2404 .clkdm_name = "per_clkdm",
2304 .recalc = &followparent_recalc, 2405 .recalc = &followparent_recalc,
2305}; 2406};
2306 2407
@@ -2310,6 +2411,7 @@ static struct clk uart3_fck = {
2310 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2411 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2311 .enable_bit = OMAP3430_EN_UART3_SHIFT, 2412 .enable_bit = OMAP3430_EN_UART3_SHIFT,
2312 .flags = CLOCK_IN_OMAP343X, 2413 .flags = CLOCK_IN_OMAP343X,
2414 .clkdm_name = "per_clkdm",
2313 .recalc = &followparent_recalc, 2415 .recalc = &followparent_recalc,
2314}; 2416};
2315 2417
@@ -2322,6 +2424,7 @@ static struct clk gpt2_fck = {
2322 .clksel_mask = OMAP3430_CLKSEL_GPT2_MASK, 2424 .clksel_mask = OMAP3430_CLKSEL_GPT2_MASK,
2323 .clksel = omap343x_gpt_clksel, 2425 .clksel = omap343x_gpt_clksel,
2324 .flags = CLOCK_IN_OMAP343X, 2426 .flags = CLOCK_IN_OMAP343X,
2427 .clkdm_name = "per_clkdm",
2325 .recalc = &omap2_clksel_recalc, 2428 .recalc = &omap2_clksel_recalc,
2326}; 2429};
2327 2430
@@ -2334,6 +2437,7 @@ static struct clk gpt3_fck = {
2334 .clksel_mask = OMAP3430_CLKSEL_GPT3_MASK, 2437 .clksel_mask = OMAP3430_CLKSEL_GPT3_MASK,
2335 .clksel = omap343x_gpt_clksel, 2438 .clksel = omap343x_gpt_clksel,
2336 .flags = CLOCK_IN_OMAP343X, 2439 .flags = CLOCK_IN_OMAP343X,
2440 .clkdm_name = "per_clkdm",
2337 .recalc = &omap2_clksel_recalc, 2441 .recalc = &omap2_clksel_recalc,
2338}; 2442};
2339 2443
@@ -2346,6 +2450,7 @@ static struct clk gpt4_fck = {
2346 .clksel_mask = OMAP3430_CLKSEL_GPT4_MASK, 2450 .clksel_mask = OMAP3430_CLKSEL_GPT4_MASK,
2347 .clksel = omap343x_gpt_clksel, 2451 .clksel = omap343x_gpt_clksel,
2348 .flags = CLOCK_IN_OMAP343X, 2452 .flags = CLOCK_IN_OMAP343X,
2453 .clkdm_name = "per_clkdm",
2349 .recalc = &omap2_clksel_recalc, 2454 .recalc = &omap2_clksel_recalc,
2350}; 2455};
2351 2456
@@ -2358,6 +2463,7 @@ static struct clk gpt5_fck = {
2358 .clksel_mask = OMAP3430_CLKSEL_GPT5_MASK, 2463 .clksel_mask = OMAP3430_CLKSEL_GPT5_MASK,
2359 .clksel = omap343x_gpt_clksel, 2464 .clksel = omap343x_gpt_clksel,
2360 .flags = CLOCK_IN_OMAP343X, 2465 .flags = CLOCK_IN_OMAP343X,
2466 .clkdm_name = "per_clkdm",
2361 .recalc = &omap2_clksel_recalc, 2467 .recalc = &omap2_clksel_recalc,
2362}; 2468};
2363 2469
@@ -2370,6 +2476,7 @@ static struct clk gpt6_fck = {
2370 .clksel_mask = OMAP3430_CLKSEL_GPT6_MASK, 2476 .clksel_mask = OMAP3430_CLKSEL_GPT6_MASK,
2371 .clksel = omap343x_gpt_clksel, 2477 .clksel = omap343x_gpt_clksel,
2372 .flags = CLOCK_IN_OMAP343X, 2478 .flags = CLOCK_IN_OMAP343X,
2479 .clkdm_name = "per_clkdm",
2373 .recalc = &omap2_clksel_recalc, 2480 .recalc = &omap2_clksel_recalc,
2374}; 2481};
2375 2482
@@ -2382,6 +2489,7 @@ static struct clk gpt7_fck = {
2382 .clksel_mask = OMAP3430_CLKSEL_GPT7_MASK, 2489 .clksel_mask = OMAP3430_CLKSEL_GPT7_MASK,
2383 .clksel = omap343x_gpt_clksel, 2490 .clksel = omap343x_gpt_clksel,
2384 .flags = CLOCK_IN_OMAP343X, 2491 .flags = CLOCK_IN_OMAP343X,
2492 .clkdm_name = "per_clkdm",
2385 .recalc = &omap2_clksel_recalc, 2493 .recalc = &omap2_clksel_recalc,
2386}; 2494};
2387 2495
@@ -2394,6 +2502,7 @@ static struct clk gpt8_fck = {
2394 .clksel_mask = OMAP3430_CLKSEL_GPT8_MASK, 2502 .clksel_mask = OMAP3430_CLKSEL_GPT8_MASK,
2395 .clksel = omap343x_gpt_clksel, 2503 .clksel = omap343x_gpt_clksel,
2396 .flags = CLOCK_IN_OMAP343X, 2504 .flags = CLOCK_IN_OMAP343X,
2505 .clkdm_name = "per_clkdm",
2397 .recalc = &omap2_clksel_recalc, 2506 .recalc = &omap2_clksel_recalc,
2398}; 2507};
2399 2508
@@ -2406,12 +2515,14 @@ static struct clk gpt9_fck = {
2406 .clksel_mask = OMAP3430_CLKSEL_GPT9_MASK, 2515 .clksel_mask = OMAP3430_CLKSEL_GPT9_MASK,
2407 .clksel = omap343x_gpt_clksel, 2516 .clksel = omap343x_gpt_clksel,
2408 .flags = CLOCK_IN_OMAP343X, 2517 .flags = CLOCK_IN_OMAP343X,
2518 .clkdm_name = "per_clkdm",
2409 .recalc = &omap2_clksel_recalc, 2519 .recalc = &omap2_clksel_recalc,
2410}; 2520};
2411 2521
2412static struct clk per_32k_alwon_fck = { 2522static struct clk per_32k_alwon_fck = {
2413 .name = "per_32k_alwon_fck", 2523 .name = "per_32k_alwon_fck",
2414 .parent = &omap_32k_fck, 2524 .parent = &omap_32k_fck,
2525 .clkdm_name = "per_clkdm",
2415 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2526 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2416 .recalc = &followparent_recalc, 2527 .recalc = &followparent_recalc,
2417}; 2528};
@@ -2422,6 +2533,7 @@ static struct clk gpio6_fck = {
2422 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2533 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2423 .enable_bit = OMAP3430_EN_GPIO6_SHIFT, 2534 .enable_bit = OMAP3430_EN_GPIO6_SHIFT,
2424 .flags = CLOCK_IN_OMAP343X, 2535 .flags = CLOCK_IN_OMAP343X,
2536 .clkdm_name = "per_clkdm",
2425 .recalc = &followparent_recalc, 2537 .recalc = &followparent_recalc,
2426}; 2538};
2427 2539
@@ -2431,6 +2543,7 @@ static struct clk gpio5_fck = {
2431 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2543 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2432 .enable_bit = OMAP3430_EN_GPIO5_SHIFT, 2544 .enable_bit = OMAP3430_EN_GPIO5_SHIFT,
2433 .flags = CLOCK_IN_OMAP343X, 2545 .flags = CLOCK_IN_OMAP343X,
2546 .clkdm_name = "per_clkdm",
2434 .recalc = &followparent_recalc, 2547 .recalc = &followparent_recalc,
2435}; 2548};
2436 2549
@@ -2440,6 +2553,7 @@ static struct clk gpio4_fck = {
2440 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2553 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2441 .enable_bit = OMAP3430_EN_GPIO4_SHIFT, 2554 .enable_bit = OMAP3430_EN_GPIO4_SHIFT,
2442 .flags = CLOCK_IN_OMAP343X, 2555 .flags = CLOCK_IN_OMAP343X,
2556 .clkdm_name = "per_clkdm",
2443 .recalc = &followparent_recalc, 2557 .recalc = &followparent_recalc,
2444}; 2558};
2445 2559
@@ -2449,6 +2563,7 @@ static struct clk gpio3_fck = {
2449 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2563 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2450 .enable_bit = OMAP3430_EN_GPIO3_SHIFT, 2564 .enable_bit = OMAP3430_EN_GPIO3_SHIFT,
2451 .flags = CLOCK_IN_OMAP343X, 2565 .flags = CLOCK_IN_OMAP343X,
2566 .clkdm_name = "per_clkdm",
2452 .recalc = &followparent_recalc, 2567 .recalc = &followparent_recalc,
2453}; 2568};
2454 2569
@@ -2458,6 +2573,7 @@ static struct clk gpio2_fck = {
2458 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2573 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2459 .enable_bit = OMAP3430_EN_GPIO2_SHIFT, 2574 .enable_bit = OMAP3430_EN_GPIO2_SHIFT,
2460 .flags = CLOCK_IN_OMAP343X, 2575 .flags = CLOCK_IN_OMAP343X,
2576 .clkdm_name = "per_clkdm",
2461 .recalc = &followparent_recalc, 2577 .recalc = &followparent_recalc,
2462}; 2578};
2463 2579
@@ -2467,6 +2583,7 @@ static struct clk wdt3_fck = {
2467 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN), 2583 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2468 .enable_bit = OMAP3430_EN_WDT3_SHIFT, 2584 .enable_bit = OMAP3430_EN_WDT3_SHIFT,
2469 .flags = CLOCK_IN_OMAP343X, 2585 .flags = CLOCK_IN_OMAP343X,
2586 .clkdm_name = "per_clkdm",
2470 .recalc = &followparent_recalc, 2587 .recalc = &followparent_recalc,
2471}; 2588};
2472 2589
@@ -2475,6 +2592,7 @@ static struct clk per_l4_ick = {
2475 .parent = &l4_ick, 2592 .parent = &l4_ick,
2476 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | 2593 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES |
2477 PARENT_CONTROLS_CLOCK, 2594 PARENT_CONTROLS_CLOCK,
2595 .clkdm_name = "per_clkdm",
2478 .recalc = &followparent_recalc, 2596 .recalc = &followparent_recalc,
2479}; 2597};
2480 2598
@@ -2484,6 +2602,7 @@ static struct clk gpio6_ick = {
2484 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2602 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2485 .enable_bit = OMAP3430_EN_GPIO6_SHIFT, 2603 .enable_bit = OMAP3430_EN_GPIO6_SHIFT,
2486 .flags = CLOCK_IN_OMAP343X, 2604 .flags = CLOCK_IN_OMAP343X,
2605 .clkdm_name = "per_clkdm",
2487 .recalc = &followparent_recalc, 2606 .recalc = &followparent_recalc,
2488}; 2607};
2489 2608
@@ -2493,6 +2612,7 @@ static struct clk gpio5_ick = {
2493 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2612 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2494 .enable_bit = OMAP3430_EN_GPIO5_SHIFT, 2613 .enable_bit = OMAP3430_EN_GPIO5_SHIFT,
2495 .flags = CLOCK_IN_OMAP343X, 2614 .flags = CLOCK_IN_OMAP343X,
2615 .clkdm_name = "per_clkdm",
2496 .recalc = &followparent_recalc, 2616 .recalc = &followparent_recalc,
2497}; 2617};
2498 2618
@@ -2502,6 +2622,7 @@ static struct clk gpio4_ick = {
2502 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2622 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2503 .enable_bit = OMAP3430_EN_GPIO4_SHIFT, 2623 .enable_bit = OMAP3430_EN_GPIO4_SHIFT,
2504 .flags = CLOCK_IN_OMAP343X, 2624 .flags = CLOCK_IN_OMAP343X,
2625 .clkdm_name = "per_clkdm",
2505 .recalc = &followparent_recalc, 2626 .recalc = &followparent_recalc,
2506}; 2627};
2507 2628
@@ -2511,6 +2632,7 @@ static struct clk gpio3_ick = {
2511 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2632 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2512 .enable_bit = OMAP3430_EN_GPIO3_SHIFT, 2633 .enable_bit = OMAP3430_EN_GPIO3_SHIFT,
2513 .flags = CLOCK_IN_OMAP343X, 2634 .flags = CLOCK_IN_OMAP343X,
2635 .clkdm_name = "per_clkdm",
2514 .recalc = &followparent_recalc, 2636 .recalc = &followparent_recalc,
2515}; 2637};
2516 2638
@@ -2520,6 +2642,7 @@ static struct clk gpio2_ick = {
2520 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2642 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2521 .enable_bit = OMAP3430_EN_GPIO2_SHIFT, 2643 .enable_bit = OMAP3430_EN_GPIO2_SHIFT,
2522 .flags = CLOCK_IN_OMAP343X, 2644 .flags = CLOCK_IN_OMAP343X,
2645 .clkdm_name = "per_clkdm",
2523 .recalc = &followparent_recalc, 2646 .recalc = &followparent_recalc,
2524}; 2647};
2525 2648
@@ -2529,6 +2652,7 @@ static struct clk wdt3_ick = {
2529 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2652 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2530 .enable_bit = OMAP3430_EN_WDT3_SHIFT, 2653 .enable_bit = OMAP3430_EN_WDT3_SHIFT,
2531 .flags = CLOCK_IN_OMAP343X, 2654 .flags = CLOCK_IN_OMAP343X,
2655 .clkdm_name = "per_clkdm",
2532 .recalc = &followparent_recalc, 2656 .recalc = &followparent_recalc,
2533}; 2657};
2534 2658
@@ -2538,6 +2662,7 @@ static struct clk uart3_ick = {
2538 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2662 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2539 .enable_bit = OMAP3430_EN_UART3_SHIFT, 2663 .enable_bit = OMAP3430_EN_UART3_SHIFT,
2540 .flags = CLOCK_IN_OMAP343X, 2664 .flags = CLOCK_IN_OMAP343X,
2665 .clkdm_name = "per_clkdm",
2541 .recalc = &followparent_recalc, 2666 .recalc = &followparent_recalc,
2542}; 2667};
2543 2668
@@ -2547,6 +2672,7 @@ static struct clk gpt9_ick = {
2547 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2672 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2548 .enable_bit = OMAP3430_EN_GPT9_SHIFT, 2673 .enable_bit = OMAP3430_EN_GPT9_SHIFT,
2549 .flags = CLOCK_IN_OMAP343X, 2674 .flags = CLOCK_IN_OMAP343X,
2675 .clkdm_name = "per_clkdm",
2550 .recalc = &followparent_recalc, 2676 .recalc = &followparent_recalc,
2551}; 2677};
2552 2678
@@ -2556,6 +2682,7 @@ static struct clk gpt8_ick = {
2556 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2682 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2557 .enable_bit = OMAP3430_EN_GPT8_SHIFT, 2683 .enable_bit = OMAP3430_EN_GPT8_SHIFT,
2558 .flags = CLOCK_IN_OMAP343X, 2684 .flags = CLOCK_IN_OMAP343X,
2685 .clkdm_name = "per_clkdm",
2559 .recalc = &followparent_recalc, 2686 .recalc = &followparent_recalc,
2560}; 2687};
2561 2688
@@ -2565,6 +2692,7 @@ static struct clk gpt7_ick = {
2565 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2692 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2566 .enable_bit = OMAP3430_EN_GPT7_SHIFT, 2693 .enable_bit = OMAP3430_EN_GPT7_SHIFT,
2567 .flags = CLOCK_IN_OMAP343X, 2694 .flags = CLOCK_IN_OMAP343X,
2695 .clkdm_name = "per_clkdm",
2568 .recalc = &followparent_recalc, 2696 .recalc = &followparent_recalc,
2569}; 2697};
2570 2698
@@ -2574,6 +2702,7 @@ static struct clk gpt6_ick = {
2574 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2702 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2575 .enable_bit = OMAP3430_EN_GPT6_SHIFT, 2703 .enable_bit = OMAP3430_EN_GPT6_SHIFT,
2576 .flags = CLOCK_IN_OMAP343X, 2704 .flags = CLOCK_IN_OMAP343X,
2705 .clkdm_name = "per_clkdm",
2577 .recalc = &followparent_recalc, 2706 .recalc = &followparent_recalc,
2578}; 2707};
2579 2708
@@ -2583,6 +2712,7 @@ static struct clk gpt5_ick = {
2583 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2712 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2584 .enable_bit = OMAP3430_EN_GPT5_SHIFT, 2713 .enable_bit = OMAP3430_EN_GPT5_SHIFT,
2585 .flags = CLOCK_IN_OMAP343X, 2714 .flags = CLOCK_IN_OMAP343X,
2715 .clkdm_name = "per_clkdm",
2586 .recalc = &followparent_recalc, 2716 .recalc = &followparent_recalc,
2587}; 2717};
2588 2718
@@ -2592,6 +2722,7 @@ static struct clk gpt4_ick = {
2592 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2722 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2593 .enable_bit = OMAP3430_EN_GPT4_SHIFT, 2723 .enable_bit = OMAP3430_EN_GPT4_SHIFT,
2594 .flags = CLOCK_IN_OMAP343X, 2724 .flags = CLOCK_IN_OMAP343X,
2725 .clkdm_name = "per_clkdm",
2595 .recalc = &followparent_recalc, 2726 .recalc = &followparent_recalc,
2596}; 2727};
2597 2728
@@ -2601,6 +2732,7 @@ static struct clk gpt3_ick = {
2601 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2732 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2602 .enable_bit = OMAP3430_EN_GPT3_SHIFT, 2733 .enable_bit = OMAP3430_EN_GPT3_SHIFT,
2603 .flags = CLOCK_IN_OMAP343X, 2734 .flags = CLOCK_IN_OMAP343X,
2735 .clkdm_name = "per_clkdm",
2604 .recalc = &followparent_recalc, 2736 .recalc = &followparent_recalc,
2605}; 2737};
2606 2738
@@ -2610,6 +2742,7 @@ static struct clk gpt2_ick = {
2610 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2742 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2611 .enable_bit = OMAP3430_EN_GPT2_SHIFT, 2743 .enable_bit = OMAP3430_EN_GPT2_SHIFT,
2612 .flags = CLOCK_IN_OMAP343X, 2744 .flags = CLOCK_IN_OMAP343X,
2745 .clkdm_name = "per_clkdm",
2613 .recalc = &followparent_recalc, 2746 .recalc = &followparent_recalc,
2614}; 2747};
2615 2748
@@ -2620,6 +2753,7 @@ static struct clk mcbsp2_ick = {
2620 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2753 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2621 .enable_bit = OMAP3430_EN_MCBSP2_SHIFT, 2754 .enable_bit = OMAP3430_EN_MCBSP2_SHIFT,
2622 .flags = CLOCK_IN_OMAP343X, 2755 .flags = CLOCK_IN_OMAP343X,
2756 .clkdm_name = "per_clkdm",
2623 .recalc = &followparent_recalc, 2757 .recalc = &followparent_recalc,
2624}; 2758};
2625 2759
@@ -2630,6 +2764,7 @@ static struct clk mcbsp3_ick = {
2630 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2764 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2631 .enable_bit = OMAP3430_EN_MCBSP3_SHIFT, 2765 .enable_bit = OMAP3430_EN_MCBSP3_SHIFT,
2632 .flags = CLOCK_IN_OMAP343X, 2766 .flags = CLOCK_IN_OMAP343X,
2767 .clkdm_name = "per_clkdm",
2633 .recalc = &followparent_recalc, 2768 .recalc = &followparent_recalc,
2634}; 2769};
2635 2770
@@ -2640,12 +2775,13 @@ static struct clk mcbsp4_ick = {
2640 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN), 2775 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2641 .enable_bit = OMAP3430_EN_MCBSP4_SHIFT, 2776 .enable_bit = OMAP3430_EN_MCBSP4_SHIFT,
2642 .flags = CLOCK_IN_OMAP343X, 2777 .flags = CLOCK_IN_OMAP343X,
2778 .clkdm_name = "per_clkdm",
2643 .recalc = &followparent_recalc, 2779 .recalc = &followparent_recalc,
2644}; 2780};
2645 2781
2646static const struct clksel mcbsp_234_clksel[] = { 2782static const struct clksel mcbsp_234_clksel[] = {
2647 { .parent = &per_96m_fck, .rates = common_mcbsp_96m_rates }, 2783 { .parent = &per_96m_fck, .rates = common_mcbsp_96m_rates },
2648 { .parent = &mcbsp_clks, .rates = common_mcbsp_mcbsp_rates }, 2784 { .parent = &mcbsp_clks, .rates = common_mcbsp_mcbsp_rates },
2649 { .parent = NULL } 2785 { .parent = NULL }
2650}; 2786};
2651 2787
@@ -2659,6 +2795,7 @@ static struct clk mcbsp2_fck = {
2659 .clksel_mask = OMAP2_MCBSP2_CLKS_MASK, 2795 .clksel_mask = OMAP2_MCBSP2_CLKS_MASK,
2660 .clksel = mcbsp_234_clksel, 2796 .clksel = mcbsp_234_clksel,
2661 .flags = CLOCK_IN_OMAP343X, 2797 .flags = CLOCK_IN_OMAP343X,
2798 .clkdm_name = "per_clkdm",
2662 .recalc = &omap2_clksel_recalc, 2799 .recalc = &omap2_clksel_recalc,
2663}; 2800};
2664 2801
@@ -2672,6 +2809,7 @@ static struct clk mcbsp3_fck = {
2672 .clksel_mask = OMAP2_MCBSP3_CLKS_MASK, 2809 .clksel_mask = OMAP2_MCBSP3_CLKS_MASK,
2673 .clksel = mcbsp_234_clksel, 2810 .clksel = mcbsp_234_clksel,
2674 .flags = CLOCK_IN_OMAP343X, 2811 .flags = CLOCK_IN_OMAP343X,
2812 .clkdm_name = "per_clkdm",
2675 .recalc = &omap2_clksel_recalc, 2813 .recalc = &omap2_clksel_recalc,
2676}; 2814};
2677 2815
@@ -2685,6 +2823,7 @@ static struct clk mcbsp4_fck = {
2685 .clksel_mask = OMAP2_MCBSP4_CLKS_MASK, 2823 .clksel_mask = OMAP2_MCBSP4_CLKS_MASK,
2686 .clksel = mcbsp_234_clksel, 2824 .clksel = mcbsp_234_clksel,
2687 .flags = CLOCK_IN_OMAP343X, 2825 .flags = CLOCK_IN_OMAP343X,
2826 .clkdm_name = "per_clkdm",
2688 .recalc = &omap2_clksel_recalc, 2827 .recalc = &omap2_clksel_recalc,
2689}; 2828};
2690 2829
@@ -2732,6 +2871,7 @@ static struct clk emu_src_ck = {
2732 .clksel_mask = OMAP3430_MUX_CTRL_MASK, 2871 .clksel_mask = OMAP3430_MUX_CTRL_MASK,
2733 .clksel = emu_src_clksel, 2872 .clksel = emu_src_clksel,
2734 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2873 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2874 .clkdm_name = "emu_clkdm",
2735 .recalc = &omap2_clksel_recalc, 2875 .recalc = &omap2_clksel_recalc,
2736}; 2876};
2737 2877
@@ -2755,6 +2895,7 @@ static struct clk pclk_fck = {
2755 .clksel_mask = OMAP3430_CLKSEL_PCLK_MASK, 2895 .clksel_mask = OMAP3430_CLKSEL_PCLK_MASK,
2756 .clksel = pclk_emu_clksel, 2896 .clksel = pclk_emu_clksel,
2757 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2897 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2898 .clkdm_name = "emu_clkdm",
2758 .recalc = &omap2_clksel_recalc, 2899 .recalc = &omap2_clksel_recalc,
2759}; 2900};
2760 2901
@@ -2777,6 +2918,7 @@ static struct clk pclkx2_fck = {
2777 .clksel_mask = OMAP3430_CLKSEL_PCLKX2_MASK, 2918 .clksel_mask = OMAP3430_CLKSEL_PCLKX2_MASK,
2778 .clksel = pclkx2_emu_clksel, 2919 .clksel = pclkx2_emu_clksel,
2779 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2920 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2921 .clkdm_name = "emu_clkdm",
2780 .recalc = &omap2_clksel_recalc, 2922 .recalc = &omap2_clksel_recalc,
2781}; 2923};
2782 2924
@@ -2792,6 +2934,7 @@ static struct clk atclk_fck = {
2792 .clksel_mask = OMAP3430_CLKSEL_ATCLK_MASK, 2934 .clksel_mask = OMAP3430_CLKSEL_ATCLK_MASK,
2793 .clksel = atclk_emu_clksel, 2935 .clksel = atclk_emu_clksel,
2794 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2936 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2937 .clkdm_name = "emu_clkdm",
2795 .recalc = &omap2_clksel_recalc, 2938 .recalc = &omap2_clksel_recalc,
2796}; 2939};
2797 2940
@@ -2802,6 +2945,7 @@ static struct clk traceclk_src_fck = {
2802 .clksel_mask = OMAP3430_TRACE_MUX_CTRL_MASK, 2945 .clksel_mask = OMAP3430_TRACE_MUX_CTRL_MASK,
2803 .clksel = emu_src_clksel, 2946 .clksel = emu_src_clksel,
2804 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED, 2947 .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES | ALWAYS_ENABLED,
2948 .clkdm_name = "emu_clkdm",
2805 .recalc = &omap2_clksel_recalc, 2949 .recalc = &omap2_clksel_recalc,
2806}; 2950};
2807 2951
@@ -2824,6 +2968,7 @@ static struct clk traceclk_fck = {
2824 .clksel_mask = OMAP3430_CLKSEL_TRACECLK_MASK, 2968 .clksel_mask = OMAP3430_CLKSEL_TRACECLK_MASK,
2825 .clksel = traceclk_clksel, 2969 .clksel = traceclk_clksel,
2826 .flags = CLOCK_IN_OMAP343X | ALWAYS_ENABLED, 2970 .flags = CLOCK_IN_OMAP343X | ALWAYS_ENABLED,
2971 .clkdm_name = "emu_clkdm",
2827 .recalc = &omap2_clksel_recalc, 2972 .recalc = &omap2_clksel_recalc,
2828}; 2973};
2829 2974
@@ -2853,11 +2998,13 @@ static struct clk sr_l4_ick = {
2853 .name = "sr_l4_ick", 2998 .name = "sr_l4_ick",
2854 .parent = &l4_ick, 2999 .parent = &l4_ick,
2855 .flags = CLOCK_IN_OMAP343X, 3000 .flags = CLOCK_IN_OMAP343X,
3001 .clkdm_name = "core_l4_clkdm",
2856 .recalc = &followparent_recalc, 3002 .recalc = &followparent_recalc,
2857}; 3003};
2858 3004
2859/* SECURE_32K_FCK clocks */ 3005/* SECURE_32K_FCK clocks */
2860 3006
3007/* XXX This clock no longer exists in 3430 TRM rev F */
2861static struct clk gpt12_fck = { 3008static struct clk gpt12_fck = {
2862 .name = "gpt12_fck", 3009 .name = "gpt12_fck",
2863 .parent = &secure_32k_fck, 3010 .parent = &secure_32k_fck,
@@ -2933,6 +3080,7 @@ static struct clk *onchip_34xx_clks[] __initdata = {
2933 &l3_ick, 3080 &l3_ick,
2934 &l4_ick, 3081 &l4_ick,
2935 &rm_ick, 3082 &rm_ick,
3083 &gfx_l3_ck,
2936 &gfx_l3_fck, 3084 &gfx_l3_fck,
2937 &gfx_l3_ick, 3085 &gfx_l3_ick,
2938 &gfx_cg1_ck, 3086 &gfx_cg1_ck,
@@ -3014,12 +3162,10 @@ static struct clk *onchip_34xx_clks[] __initdata = {
3014 &dss2_alwon_fck, 3162 &dss2_alwon_fck,
3015 &dss_ick, 3163 &dss_ick,
3016 &cam_mclk, 3164 &cam_mclk,
3017 &cam_l3_ick, 3165 &cam_ick,
3018 &cam_l4_ick,
3019 &usbhost_120m_fck, 3166 &usbhost_120m_fck,
3020 &usbhost_48m_fck, 3167 &usbhost_48m_fck,
3021 &usbhost_l3_ick, 3168 &usbhost_ick,
3022 &usbhost_l4_ick,
3023 &usbhost_sar_fck, 3169 &usbhost_sar_fck,
3024 &usim_fck, 3170 &usim_fck,
3025 &gpt1_fck, 3171 &gpt1_fck,
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
new file mode 100644
index 000000000000..4c3ce9cfd948
--- /dev/null
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -0,0 +1,623 @@
1/*
2 * OMAP2/3 clockdomain framework functions
3 *
4 * Copyright (C) 2008 Texas Instruments, Inc.
5 * Copyright (C) 2008 Nokia Corporation
6 *
7 * Written by Paul Walmsley and Jouni Högander
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#ifdef CONFIG_OMAP_DEBUG_CLOCKDOMAIN
14# define DEBUG
15#endif
16
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/device.h>
20#include <linux/list.h>
21#include <linux/errno.h>
22#include <linux/delay.h>
23#include <linux/clk.h>
24#include <linux/limits.h>
25
26#include <linux/io.h>
27
28#include <linux/bitops.h>
29
30#include <mach/clock.h>
31
32#include "prm.h"
33#include "prm-regbits-24xx.h"
34#include "cm.h"
35
36#include <mach/powerdomain.h>
37#include <mach/clockdomain.h>
38
39/* clkdm_list contains all registered struct clockdomains */
40static LIST_HEAD(clkdm_list);
41
42/* clkdm_mutex protects clkdm_list add and del ops */
43static DEFINE_MUTEX(clkdm_mutex);
44
45/* array of powerdomain deps to be added/removed when clkdm in hwsup mode */
46static struct clkdm_pwrdm_autodep *autodeps;
47
48
49/* Private functions */
50
51/*
52 * _autodep_lookup - resolve autodep pwrdm names to pwrdm pointers; store
53 * @autodep: struct clkdm_pwrdm_autodep * to resolve
54 *
55 * Resolve autodep powerdomain names to powerdomain pointers via
56 * pwrdm_lookup() and store the pointers in the autodep structure. An
57 * "autodep" is a powerdomain sleep/wakeup dependency that is
58 * automatically added and removed whenever clocks in the associated
59 * clockdomain are enabled or disabled (respectively) when the
60 * clockdomain is in hardware-supervised mode. Meant to be called
61 * once at clockdomain layer initialization, since these should remain
62 * fixed for a particular architecture. No return value.
63 */
64static void _autodep_lookup(struct clkdm_pwrdm_autodep *autodep)
65{
66 struct powerdomain *pwrdm;
67
68 if (!autodep)
69 return;
70
71 if (!omap_chip_is(autodep->omap_chip))
72 return;
73
74 pwrdm = pwrdm_lookup(autodep->pwrdm_name);
75 if (!pwrdm) {
76 pr_debug("clockdomain: _autodep_lookup: powerdomain %s "
77 "does not exist\n", autodep->pwrdm_name);
78 WARN_ON(1);
79 return;
80 }
81 autodep->pwrdm = pwrdm;
82
83 return;
84}
85
86/*
87 * _clkdm_add_autodeps - add auto sleepdeps/wkdeps to clkdm upon clock enable
88 * @clkdm: struct clockdomain *
89 *
90 * Add the "autodep" sleep & wakeup dependencies to clockdomain 'clkdm'
91 * in hardware-supervised mode. Meant to be called from clock framework
92 * when a clock inside clockdomain 'clkdm' is enabled. No return value.
93 */
94static void _clkdm_add_autodeps(struct clockdomain *clkdm)
95{
96 struct clkdm_pwrdm_autodep *autodep;
97
98 for (autodep = autodeps; autodep->pwrdm_name; autodep++) {
99 if (!autodep->pwrdm)
100 continue;
101
102 pr_debug("clockdomain: adding %s sleepdep/wkdep for "
103 "pwrdm %s\n", autodep->pwrdm_name,
104 clkdm->pwrdm->name);
105
106 pwrdm_add_sleepdep(clkdm->pwrdm, autodep->pwrdm);
107 pwrdm_add_wkdep(clkdm->pwrdm, autodep->pwrdm);
108 }
109}
110
111/*
112 * _clkdm_add_autodeps - remove auto sleepdeps/wkdeps from clkdm
113 * @clkdm: struct clockdomain *
114 *
115 * Remove the "autodep" sleep & wakeup dependencies from clockdomain 'clkdm'
116 * in hardware-supervised mode. Meant to be called from clock framework
117 * when a clock inside clockdomain 'clkdm' is disabled. No return value.
118 */
119static void _clkdm_del_autodeps(struct clockdomain *clkdm)
120{
121 struct clkdm_pwrdm_autodep *autodep;
122
123 for (autodep = autodeps; autodep->pwrdm_name; autodep++) {
124 if (!autodep->pwrdm)
125 continue;
126
127 pr_debug("clockdomain: removing %s sleepdep/wkdep for "
128 "pwrdm %s\n", autodep->pwrdm_name,
129 clkdm->pwrdm->name);
130
131 pwrdm_del_sleepdep(clkdm->pwrdm, autodep->pwrdm);
132 pwrdm_del_wkdep(clkdm->pwrdm, autodep->pwrdm);
133 }
134}
135
136
137static struct clockdomain *_clkdm_lookup(const char *name)
138{
139 struct clockdomain *clkdm, *temp_clkdm;
140
141 if (!name)
142 return NULL;
143
144 clkdm = NULL;
145
146 list_for_each_entry(temp_clkdm, &clkdm_list, node) {
147 if (!strcmp(name, temp_clkdm->name)) {
148 clkdm = temp_clkdm;
149 break;
150 }
151 }
152
153 return clkdm;
154}
155
156
157/* Public functions */
158
159/**
160 * clkdm_init - set up the clockdomain layer
161 * @clkdms: optional pointer to an array of clockdomains to register
162 * @init_autodeps: optional pointer to an array of autodeps to register
163 *
164 * Set up internal state. If a pointer to an array of clockdomains
165 * was supplied, loop through the list of clockdomains, register all
166 * that are available on the current platform. Similarly, if a
167 * pointer to an array of clockdomain-powerdomain autodependencies was
168 * provided, register those. No return value.
169 */
170void clkdm_init(struct clockdomain **clkdms,
171 struct clkdm_pwrdm_autodep *init_autodeps)
172{
173 struct clockdomain **c = NULL;
174 struct clkdm_pwrdm_autodep *autodep = NULL;
175
176 if (clkdms)
177 for (c = clkdms; *c; c++)
178 clkdm_register(*c);
179
180 autodeps = init_autodeps;
181 if (autodeps)
182 for (autodep = autodeps; autodep->pwrdm_name; autodep++)
183 _autodep_lookup(autodep);
184}
185
186/**
187 * clkdm_register - register a clockdomain
188 * @clkdm: struct clockdomain * to register
189 *
190 * Adds a clockdomain to the internal clockdomain list.
191 * Returns -EINVAL if given a null pointer, -EEXIST if a clockdomain is
192 * already registered by the provided name, or 0 upon success.
193 */
194int clkdm_register(struct clockdomain *clkdm)
195{
196 int ret = -EINVAL;
197 struct powerdomain *pwrdm;
198
199 if (!clkdm || !clkdm->name)
200 return -EINVAL;
201
202 if (!omap_chip_is(clkdm->omap_chip))
203 return -EINVAL;
204
205 pwrdm = pwrdm_lookup(clkdm->pwrdm_name);
206 if (!pwrdm) {
207 pr_debug("clockdomain: clkdm_register %s: powerdomain %s "
208 "does not exist\n", clkdm->name, clkdm->pwrdm_name);
209 return -EINVAL;
210 }
211 clkdm->pwrdm = pwrdm;
212
213 mutex_lock(&clkdm_mutex);
214 /* Verify that the clockdomain is not already registered */
215 if (_clkdm_lookup(clkdm->name)) {
216 ret = -EEXIST;
217 goto cr_unlock;
218 };
219
220 list_add(&clkdm->node, &clkdm_list);
221
222 pwrdm_add_clkdm(pwrdm, clkdm);
223
224 pr_debug("clockdomain: registered %s\n", clkdm->name);
225 ret = 0;
226
227cr_unlock:
228 mutex_unlock(&clkdm_mutex);
229
230 return ret;
231}
232
233/**
234 * clkdm_unregister - unregister a clockdomain
235 * @clkdm: struct clockdomain * to unregister
236 *
237 * Removes a clockdomain from the internal clockdomain list. Returns
238 * -EINVAL if clkdm argument is NULL.
239 */
240int clkdm_unregister(struct clockdomain *clkdm)
241{
242 if (!clkdm)
243 return -EINVAL;
244
245 pwrdm_del_clkdm(clkdm->pwrdm, clkdm);
246
247 mutex_lock(&clkdm_mutex);
248 list_del(&clkdm->node);
249 mutex_unlock(&clkdm_mutex);
250
251 pr_debug("clockdomain: unregistered %s\n", clkdm->name);
252
253 return 0;
254}
255
256/**
257 * clkdm_lookup - look up a clockdomain by name, return a pointer
258 * @name: name of clockdomain
259 *
260 * Find a registered clockdomain by its name. Returns a pointer to the
261 * struct clockdomain if found, or NULL otherwise.
262 */
263struct clockdomain *clkdm_lookup(const char *name)
264{
265 struct clockdomain *clkdm, *temp_clkdm;
266
267 if (!name)
268 return NULL;
269
270 clkdm = NULL;
271
272 mutex_lock(&clkdm_mutex);
273 list_for_each_entry(temp_clkdm, &clkdm_list, node) {
274 if (!strcmp(name, temp_clkdm->name)) {
275 clkdm = temp_clkdm;
276 break;
277 }
278 }
279 mutex_unlock(&clkdm_mutex);
280
281 return clkdm;
282}
283
284/**
285 * clkdm_for_each - call function on each registered clockdomain
286 * @fn: callback function *
287 *
288 * Call the supplied function for each registered clockdomain.
289 * The callback function can return anything but 0 to bail
290 * out early from the iterator. The callback function is called with
291 * the clkdm_mutex held, so no clockdomain structure manipulation
292 * functions should be called from the callback, although hardware
293 * clockdomain control functions are fine. Returns the last return
294 * value of the callback function, which should be 0 for success or
295 * anything else to indicate failure; or -EINVAL if the function pointer
296 * is null.
297 */
298int clkdm_for_each(int (*fn)(struct clockdomain *clkdm))
299{
300 struct clockdomain *clkdm;
301 int ret = 0;
302
303 if (!fn)
304 return -EINVAL;
305
306 mutex_lock(&clkdm_mutex);
307 list_for_each_entry(clkdm, &clkdm_list, node) {
308 ret = (*fn)(clkdm);
309 if (ret)
310 break;
311 }
312 mutex_unlock(&clkdm_mutex);
313
314 return ret;
315}
316
317
318/**
319 * clkdm_get_pwrdm - return a ptr to the pwrdm that this clkdm resides in
320 * @clkdm: struct clockdomain *
321 *
322 * Return a pointer to the struct powerdomain that the specified clockdomain
323 * 'clkdm' exists in, or returns NULL if clkdm argument is NULL.
324 */
325struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
326{
327 if (!clkdm)
328 return NULL;
329
330 return clkdm->pwrdm;
331}
332
333
334/* Hardware clockdomain control */
335
336/**
337 * omap2_clkdm_clktrctrl_read - read the clkdm's current state transition mode
338 * @clk: struct clk * of a clockdomain
339 *
340 * Return the clockdomain's current state transition mode from the
341 * corresponding domain CM_CLKSTCTRL register. Returns -EINVAL if clk
342 * is NULL or the current mode upon success.
343 */
344static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
345{
346 u32 v;
347
348 if (!clkdm)
349 return -EINVAL;
350
351 v = cm_read_mod_reg(clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
352 v &= clkdm->clktrctrl_mask;
353 v >>= __ffs(clkdm->clktrctrl_mask);
354
355 return v;
356}
357
358/**
359 * omap2_clkdm_sleep - force clockdomain sleep transition
360 * @clkdm: struct clockdomain *
361 *
362 * Instruct the CM to force a sleep transition on the specified
363 * clockdomain 'clkdm'. Returns -EINVAL if clk is NULL or if
364 * clockdomain does not support software-initiated sleep; 0 upon
365 * success.
366 */
367int omap2_clkdm_sleep(struct clockdomain *clkdm)
368{
369 if (!clkdm)
370 return -EINVAL;
371
372 if (!(clkdm->flags & CLKDM_CAN_FORCE_SLEEP)) {
373 pr_debug("clockdomain: %s does not support forcing "
374 "sleep via software\n", clkdm->name);
375 return -EINVAL;
376 }
377
378 pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name);
379
380 if (cpu_is_omap24xx()) {
381
382 cm_set_mod_reg_bits(OMAP24XX_FORCESTATE,
383 clkdm->pwrdm->prcm_offs, PM_PWSTCTRL);
384
385 } else if (cpu_is_omap34xx()) {
386
387 u32 v = (OMAP34XX_CLKSTCTRL_FORCE_SLEEP <<
388 __ffs(clkdm->clktrctrl_mask));
389
390 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
391 clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
392
393 } else {
394 BUG();
395 };
396
397 return 0;
398}
399
400/**
401 * omap2_clkdm_wakeup - force clockdomain wakeup transition
402 * @clkdm: struct clockdomain *
403 *
404 * Instruct the CM to force a wakeup transition on the specified
405 * clockdomain 'clkdm'. Returns -EINVAL if clkdm is NULL or if the
406 * clockdomain does not support software-controlled wakeup; 0 upon
407 * success.
408 */
409int omap2_clkdm_wakeup(struct clockdomain *clkdm)
410{
411 if (!clkdm)
412 return -EINVAL;
413
414 if (!(clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)) {
415 pr_debug("clockdomain: %s does not support forcing "
416 "wakeup via software\n", clkdm->name);
417 return -EINVAL;
418 }
419
420 pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name);
421
422 if (cpu_is_omap24xx()) {
423
424 cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE,
425 clkdm->pwrdm->prcm_offs, PM_PWSTCTRL);
426
427 } else if (cpu_is_omap34xx()) {
428
429 u32 v = (OMAP34XX_CLKSTCTRL_FORCE_WAKEUP <<
430 __ffs(clkdm->clktrctrl_mask));
431
432 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
433 clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
434
435 } else {
436 BUG();
437 };
438
439 return 0;
440}
441
442/**
443 * omap2_clkdm_allow_idle - enable hwsup idle transitions for clkdm
444 * @clkdm: struct clockdomain *
445 *
446 * Allow the hardware to automatically switch the clockdomain into
447 * active or idle states, as needed by downstream clocks. If the
448 * clockdomain has any downstream clocks enabled in the clock
449 * framework, wkdep/sleepdep autodependencies are added; this is so
450 * device drivers can read and write to the device. No return value.
451 */
452void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
453{
454 u32 v;
455
456 if (!clkdm)
457 return;
458
459 if (!(clkdm->flags & CLKDM_CAN_ENABLE_AUTO)) {
460 pr_debug("clock: automatic idle transitions cannot be enabled "
461 "on clockdomain %s\n", clkdm->name);
462 return;
463 }
464
465 pr_debug("clockdomain: enabling automatic idle transitions for %s\n",
466 clkdm->name);
467
468 if (atomic_read(&clkdm->usecount) > 0)
469 _clkdm_add_autodeps(clkdm);
470
471 if (cpu_is_omap24xx())
472 v = OMAP24XX_CLKSTCTRL_ENABLE_AUTO;
473 else if (cpu_is_omap34xx())
474 v = OMAP34XX_CLKSTCTRL_ENABLE_AUTO;
475 else
476 BUG();
477
478
479 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
480 v << __ffs(clkdm->clktrctrl_mask),
481 clkdm->pwrdm->prcm_offs,
482 CM_CLKSTCTRL);
483}
484
485/**
486 * omap2_clkdm_deny_idle - disable hwsup idle transitions for clkdm
487 * @clkdm: struct clockdomain *
488 *
489 * Prevent the hardware from automatically switching the clockdomain
490 * into inactive or idle states. If the clockdomain has downstream
491 * clocks enabled in the clock framework, wkdep/sleepdep
492 * autodependencies are removed. No return value.
493 */
494void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
495{
496 u32 v;
497
498 if (!clkdm)
499 return;
500
501 if (!(clkdm->flags & CLKDM_CAN_DISABLE_AUTO)) {
502 pr_debug("clockdomain: automatic idle transitions cannot be "
503 "disabled on %s\n", clkdm->name);
504 return;
505 }
506
507 pr_debug("clockdomain: disabling automatic idle transitions for %s\n",
508 clkdm->name);
509
510 if (cpu_is_omap24xx())
511 v = OMAP24XX_CLKSTCTRL_DISABLE_AUTO;
512 else if (cpu_is_omap34xx())
513 v = OMAP34XX_CLKSTCTRL_DISABLE_AUTO;
514 else
515 BUG();
516
517 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
518 v << __ffs(clkdm->clktrctrl_mask),
519 clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
520
521 if (atomic_read(&clkdm->usecount) > 0)
522 _clkdm_del_autodeps(clkdm);
523}
524
525
526/* Clockdomain-to-clock framework interface code */
527
528/**
529 * omap2_clkdm_clk_enable - add an enabled downstream clock to this clkdm
530 * @clkdm: struct clockdomain *
531 * @clk: struct clk * of the enabled downstream clock
532 *
533 * Increment the usecount of this clockdomain 'clkdm' and ensure that
534 * it is awake. Intended to be called by clk_enable() code. If the
535 * clockdomain is in software-supervised idle mode, force the
536 * clockdomain to wake. If the clockdomain is in hardware-supervised
537 * idle mode, add clkdm-pwrdm autodependencies, to ensure that devices
538 * in the clockdomain can be read from/written to by on-chip processors.
539 * Returns -EINVAL if passed null pointers; returns 0 upon success or
540 * if the clockdomain is in hwsup idle mode.
541 */
542int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
543{
544 int v;
545
546 /*
547 * XXX Rewrite this code to maintain a list of enabled
548 * downstream clocks for debugging purposes?
549 */
550
551 if (!clkdm || !clk)
552 return -EINVAL;
553
554 if (atomic_inc_return(&clkdm->usecount) > 1)
555 return 0;
556
557 /* Clockdomain now has one enabled downstream clock */
558
559 pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name,
560 clk->name);
561
562 v = omap2_clkdm_clktrctrl_read(clkdm);
563
564 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ||
565 (cpu_is_omap24xx() && v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO))
566 _clkdm_add_autodeps(clkdm);
567 else
568 omap2_clkdm_wakeup(clkdm);
569
570 return 0;
571}
572
573/**
574 * omap2_clkdm_clk_disable - remove an enabled downstream clock from this clkdm
575 * @clkdm: struct clockdomain *
576 * @clk: struct clk * of the disabled downstream clock
577 *
578 * Decrement the usecount of this clockdomain 'clkdm'. Intended to be
579 * called by clk_disable() code. If the usecount goes to 0, put the
580 * clockdomain to sleep (software-supervised mode) or remove the
581 * clkdm-pwrdm autodependencies (hardware-supervised mode). Returns
582 * -EINVAL if passed null pointers; -ERANGE if the clkdm usecount
583 * underflows and debugging is enabled; or returns 0 upon success or
584 * if the clockdomain is in hwsup idle mode.
585 */
586int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
587{
588 int v;
589
590 /*
591 * XXX Rewrite this code to maintain a list of enabled
592 * downstream clocks for debugging purposes?
593 */
594
595 if (!clkdm || !clk)
596 return -EINVAL;
597
598#ifdef DEBUG
599 if (atomic_read(&clkdm->usecount) == 0) {
600 WARN_ON(1); /* underflow */
601 return -ERANGE;
602 }
603#endif
604
605 if (atomic_dec_return(&clkdm->usecount) > 0)
606 return 0;
607
608 /* All downstream clocks of this clockdomain are now disabled */
609
610 pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name,
611 clk->name);
612
613 v = omap2_clkdm_clktrctrl_read(clkdm);
614
615 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ||
616 (cpu_is_omap24xx() && v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO))
617 _clkdm_del_autodeps(clkdm);
618 else
619 omap2_clkdm_sleep(clkdm);
620
621 return 0;
622}
623
diff --git a/arch/arm/mach-omap2/clockdomains.h b/arch/arm/mach-omap2/clockdomains.h
new file mode 100644
index 000000000000..cd86dcc7b424
--- /dev/null
+++ b/arch/arm/mach-omap2/clockdomains.h
@@ -0,0 +1,305 @@
1/*
2 * OMAP2/3 clockdomains
3 *
4 * Copyright (C) 2008 Texas Instruments, Inc.
5 * Copyright (C) 2008 Nokia Corporation
6 *
7 * Written by Paul Walmsley
8 */
9
10#ifndef __ARCH_ARM_MACH_OMAP2_CLOCKDOMAINS_H
11#define __ARCH_ARM_MACH_OMAP2_CLOCKDOMAINS_H
12
13#include <mach/clockdomain.h>
14
15/*
16 * OMAP2/3-common clockdomains
17 */
18
19/* This is an implicit clockdomain - it is never defined as such in TRM */
20static struct clockdomain wkup_clkdm = {
21 .name = "wkup_clkdm",
22 .pwrdm_name = "wkup_pwrdm",
23 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX | CHIP_IS_OMAP3430),
24};
25
26/*
27 * 2420-only clockdomains
28 */
29
30#if defined(CONFIG_ARCH_OMAP2420)
31
32static struct clockdomain mpu_2420_clkdm = {
33 .name = "mpu_clkdm",
34 .pwrdm_name = "mpu_pwrdm",
35 .flags = CLKDM_CAN_HWSUP,
36 .clktrctrl_mask = OMAP24XX_AUTOSTATE_MPU_MASK,
37 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
38};
39
40static struct clockdomain iva1_2420_clkdm = {
41 .name = "iva1_clkdm",
42 .pwrdm_name = "dsp_pwrdm",
43 .flags = CLKDM_CAN_HWSUP_SWSUP,
44 .clktrctrl_mask = OMAP2420_AUTOSTATE_IVA_MASK,
45 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
46};
47
48#endif /* CONFIG_ARCH_OMAP2420 */
49
50
51/*
52 * 2430-only clockdomains
53 */
54
55#if defined(CONFIG_ARCH_OMAP2430)
56
57static struct clockdomain mpu_2430_clkdm = {
58 .name = "mpu_clkdm",
59 .pwrdm_name = "mpu_pwrdm",
60 .flags = CLKDM_CAN_HWSUP_SWSUP,
61 .clktrctrl_mask = OMAP24XX_AUTOSTATE_MPU_MASK,
62 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
63};
64
65static struct clockdomain mdm_clkdm = {
66 .name = "mdm_clkdm",
67 .pwrdm_name = "mdm_pwrdm",
68 .flags = CLKDM_CAN_HWSUP_SWSUP,
69 .clktrctrl_mask = OMAP2430_AUTOSTATE_MDM_MASK,
70 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
71};
72
73#endif /* CONFIG_ARCH_OMAP2430 */
74
75
76/*
77 * 24XX-only clockdomains
78 */
79
80#if defined(CONFIG_ARCH_OMAP24XX)
81
82static struct clockdomain dsp_clkdm = {
83 .name = "dsp_clkdm",
84 .pwrdm_name = "dsp_pwrdm",
85 .flags = CLKDM_CAN_HWSUP_SWSUP,
86 .clktrctrl_mask = OMAP24XX_AUTOSTATE_DSP_MASK,
87 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
88};
89
90static struct clockdomain gfx_24xx_clkdm = {
91 .name = "gfx_clkdm",
92 .pwrdm_name = "gfx_pwrdm",
93 .flags = CLKDM_CAN_HWSUP_SWSUP,
94 .clktrctrl_mask = OMAP24XX_AUTOSTATE_GFX_MASK,
95 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
96};
97
98static struct clockdomain core_l3_24xx_clkdm = {
99 .name = "core_l3_clkdm",
100 .pwrdm_name = "core_pwrdm",
101 .flags = CLKDM_CAN_HWSUP,
102 .clktrctrl_mask = OMAP24XX_AUTOSTATE_L3_MASK,
103 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
104};
105
106static struct clockdomain core_l4_24xx_clkdm = {
107 .name = "core_l4_clkdm",
108 .pwrdm_name = "core_pwrdm",
109 .flags = CLKDM_CAN_HWSUP,
110 .clktrctrl_mask = OMAP24XX_AUTOSTATE_L4_MASK,
111 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
112};
113
114static struct clockdomain dss_24xx_clkdm = {
115 .name = "dss_clkdm",
116 .pwrdm_name = "core_pwrdm",
117 .flags = CLKDM_CAN_HWSUP,
118 .clktrctrl_mask = OMAP24XX_AUTOSTATE_DSS_MASK,
119 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
120};
121
122#endif /* CONFIG_ARCH_OMAP24XX */
123
124
125/*
126 * 34xx clockdomains
127 */
128
129#if defined(CONFIG_ARCH_OMAP34XX)
130
131static struct clockdomain mpu_34xx_clkdm = {
132 .name = "mpu_clkdm",
133 .pwrdm_name = "mpu_pwrdm",
134 .flags = CLKDM_CAN_HWSUP | CLKDM_CAN_FORCE_WAKEUP,
135 .clktrctrl_mask = OMAP3430_CLKTRCTRL_MPU_MASK,
136 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
137};
138
139static struct clockdomain neon_clkdm = {
140 .name = "neon_clkdm",
141 .pwrdm_name = "neon_pwrdm",
142 .flags = CLKDM_CAN_HWSUP_SWSUP,
143 .clktrctrl_mask = OMAP3430_CLKTRCTRL_NEON_MASK,
144 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
145};
146
147static struct clockdomain iva2_clkdm = {
148 .name = "iva2_clkdm",
149 .pwrdm_name = "iva2_pwrdm",
150 .flags = CLKDM_CAN_HWSUP_SWSUP,
151 .clktrctrl_mask = OMAP3430_CLKTRCTRL_IVA2_MASK,
152 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
153};
154
155static struct clockdomain gfx_3430es1_clkdm = {
156 .name = "gfx_clkdm",
157 .pwrdm_name = "gfx_pwrdm",
158 .flags = CLKDM_CAN_HWSUP_SWSUP,
159 .clktrctrl_mask = OMAP3430ES1_CLKTRCTRL_GFX_MASK,
160 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430ES1),
161};
162
163static struct clockdomain sgx_clkdm = {
164 .name = "sgx_clkdm",
165 .pwrdm_name = "sgx_pwrdm",
166 .flags = CLKDM_CAN_HWSUP_SWSUP,
167 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_SGX_MASK,
168 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430ES2),
169};
170
171/*
172 * The die-to-die clockdomain was documented in the 34xx ES1 TRM, but
173 * then that information was removed from the 34xx ES2+ TRM. It is
174 * unclear whether the core is still there, but the clockdomain logic
175 * is there, and must be programmed to an appropriate state if the
176 * CORE clockdomain is to become inactive.
177 */
178static struct clockdomain d2d_clkdm = {
179 .name = "d2d_clkdm",
180 .pwrdm_name = "core_pwrdm",
181 .flags = CLKDM_CAN_HWSUP,
182 .clktrctrl_mask = OMAP3430ES1_CLKTRCTRL_D2D_MASK,
183 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
184};
185
186static struct clockdomain core_l3_34xx_clkdm = {
187 .name = "core_l3_clkdm",
188 .pwrdm_name = "core_pwrdm",
189 .flags = CLKDM_CAN_HWSUP,
190 .clktrctrl_mask = OMAP3430_CLKTRCTRL_L3_MASK,
191 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
192};
193
194static struct clockdomain core_l4_34xx_clkdm = {
195 .name = "core_l4_clkdm",
196 .pwrdm_name = "core_pwrdm",
197 .flags = CLKDM_CAN_HWSUP,
198 .clktrctrl_mask = OMAP3430_CLKTRCTRL_L4_MASK,
199 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
200};
201
202static struct clockdomain dss_34xx_clkdm = {
203 .name = "dss_clkdm",
204 .pwrdm_name = "dss_pwrdm",
205 .flags = CLKDM_CAN_HWSUP_SWSUP,
206 .clktrctrl_mask = OMAP3430_CLKTRCTRL_DSS_MASK,
207 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
208};
209
210static struct clockdomain cam_clkdm = {
211 .name = "cam_clkdm",
212 .pwrdm_name = "cam_pwrdm",
213 .flags = CLKDM_CAN_HWSUP_SWSUP,
214 .clktrctrl_mask = OMAP3430_CLKTRCTRL_CAM_MASK,
215 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
216};
217
218static struct clockdomain usbhost_clkdm = {
219 .name = "usbhost_clkdm",
220 .pwrdm_name = "usbhost_pwrdm",
221 .flags = CLKDM_CAN_HWSUP_SWSUP,
222 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_USBHOST_MASK,
223 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430ES2),
224};
225
226static struct clockdomain per_clkdm = {
227 .name = "per_clkdm",
228 .pwrdm_name = "per_pwrdm",
229 .flags = CLKDM_CAN_HWSUP_SWSUP,
230 .clktrctrl_mask = OMAP3430_CLKTRCTRL_PER_MASK,
231 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
232};
233
234static struct clockdomain emu_clkdm = {
235 .name = "emu_clkdm",
236 .pwrdm_name = "emu_pwrdm",
237 .flags = CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_SWSUP,
238 .clktrctrl_mask = OMAP3430_CLKTRCTRL_EMU_MASK,
239 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
240};
241
242#endif /* CONFIG_ARCH_OMAP34XX */
243
244/*
245 * Clockdomain-powerdomain hwsup dependencies (34XX only)
246 */
247
248static struct clkdm_pwrdm_autodep clkdm_pwrdm_autodeps[] = {
249 {
250 .pwrdm_name = "mpu_pwrdm",
251 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
252 },
253 {
254 .pwrdm_name = "iva2_pwrdm",
255 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
256 },
257 { NULL }
258};
259
260/*
261 *
262 */
263
264static struct clockdomain *clockdomains_omap[] = {
265
266 &wkup_clkdm,
267
268#ifdef CONFIG_ARCH_OMAP2420
269 &mpu_2420_clkdm,
270 &iva1_2420_clkdm,
271#endif
272
273#ifdef CONFIG_ARCH_OMAP2430
274 &mpu_2430_clkdm,
275 &mdm_clkdm,
276#endif
277
278#ifdef CONFIG_ARCH_OMAP24XX
279 &dsp_clkdm,
280 &gfx_24xx_clkdm,
281 &core_l3_24xx_clkdm,
282 &core_l4_24xx_clkdm,
283 &dss_24xx_clkdm,
284#endif
285
286#ifdef CONFIG_ARCH_OMAP34XX
287 &mpu_34xx_clkdm,
288 &neon_clkdm,
289 &iva2_clkdm,
290 &gfx_3430es1_clkdm,
291 &sgx_clkdm,
292 &d2d_clkdm,
293 &core_l3_34xx_clkdm,
294 &core_l4_34xx_clkdm,
295 &dss_34xx_clkdm,
296 &cam_clkdm,
297 &usbhost_clkdm,
298 &per_clkdm,
299 &emu_clkdm,
300#endif
301
302 NULL,
303};
304
305#endif
diff --git a/arch/arm/mach-omap2/cm-regbits-24xx.h b/arch/arm/mach-omap2/cm-regbits-24xx.h
index 20ac38100678..1098ecfab861 100644
--- a/arch/arm/mach-omap2/cm-regbits-24xx.h
+++ b/arch/arm/mach-omap2/cm-regbits-24xx.h
@@ -63,7 +63,8 @@
63#define OMAP24XX_CLKSEL_MPU_MASK (0x1f << 0) 63#define OMAP24XX_CLKSEL_MPU_MASK (0x1f << 0)
64 64
65/* CM_CLKSTCTRL_MPU */ 65/* CM_CLKSTCTRL_MPU */
66#define OMAP24XX_AUTOSTATE_MPU (1 << 0) 66#define OMAP24XX_AUTOSTATE_MPU_SHIFT 0
67#define OMAP24XX_AUTOSTATE_MPU_MASK (1 << 0)
67 68
68/* CM_FCLKEN1_CORE specific bits*/ 69/* CM_FCLKEN1_CORE specific bits*/
69#define OMAP24XX_EN_TV_SHIFT 2 70#define OMAP24XX_EN_TV_SHIFT 2
@@ -238,9 +239,12 @@
238#define OMAP24XX_CLKSEL_GPT2_MASK (0x3 << 2) 239#define OMAP24XX_CLKSEL_GPT2_MASK (0x3 << 2)
239 240
240/* CM_CLKSTCTRL_CORE */ 241/* CM_CLKSTCTRL_CORE */
241#define OMAP24XX_AUTOSTATE_DSS (1 << 2) 242#define OMAP24XX_AUTOSTATE_DSS_SHIFT 2
242#define OMAP24XX_AUTOSTATE_L4 (1 << 1) 243#define OMAP24XX_AUTOSTATE_DSS_MASK (1 << 2)
243#define OMAP24XX_AUTOSTATE_L3 (1 << 0) 244#define OMAP24XX_AUTOSTATE_L4_SHIFT 1
245#define OMAP24XX_AUTOSTATE_L4_MASK (1 << 1)
246#define OMAP24XX_AUTOSTATE_L3_SHIFT 0
247#define OMAP24XX_AUTOSTATE_L3_MASK (1 << 0)
244 248
245/* CM_FCLKEN_GFX */ 249/* CM_FCLKEN_GFX */
246#define OMAP24XX_EN_3D_SHIFT 2 250#define OMAP24XX_EN_3D_SHIFT 2
@@ -255,7 +259,8 @@
255/* CM_CLKSEL_GFX specific bits */ 259/* CM_CLKSEL_GFX specific bits */
256 260
257/* CM_CLKSTCTRL_GFX */ 261/* CM_CLKSTCTRL_GFX */
258#define OMAP24XX_AUTOSTATE_GFX (1 << 0) 262#define OMAP24XX_AUTOSTATE_GFX_SHIFT 0
263#define OMAP24XX_AUTOSTATE_GFX_MASK (1 << 0)
259 264
260/* CM_FCLKEN_WKUP specific bits */ 265/* CM_FCLKEN_WKUP specific bits */
261 266
@@ -367,8 +372,10 @@
367#define OMAP24XX_CLKSEL_DSP_MASK (0x1f << 0) 372#define OMAP24XX_CLKSEL_DSP_MASK (0x1f << 0)
368 373
369/* CM_CLKSTCTRL_DSP */ 374/* CM_CLKSTCTRL_DSP */
370#define OMAP2420_AUTOSTATE_IVA (1 << 8) 375#define OMAP2420_AUTOSTATE_IVA_SHIFT 8
371#define OMAP24XX_AUTOSTATE_DSP (1 << 0) 376#define OMAP2420_AUTOSTATE_IVA_MASK (1 << 8)
377#define OMAP24XX_AUTOSTATE_DSP_SHIFT 0
378#define OMAP24XX_AUTOSTATE_DSP_MASK (1 << 0)
372 379
373/* CM_FCLKEN_MDM */ 380/* CM_FCLKEN_MDM */
374/* 2430 only */ 381/* 2430 only */
@@ -396,6 +403,7 @@
396 403
397/* CM_CLKSTCTRL_MDM */ 404/* CM_CLKSTCTRL_MDM */
398/* 2430 only */ 405/* 2430 only */
399#define OMAP2430_AUTOSTATE_MDM (1 << 0) 406#define OMAP2430_AUTOSTATE_MDM_SHIFT 0
407#define OMAP2430_AUTOSTATE_MDM_MASK (1 << 0)
400 408
401#endif 409#endif
diff --git a/arch/arm/mach-omap2/cm-regbits-34xx.h b/arch/arm/mach-omap2/cm-regbits-34xx.h
index ee4c0ca1a708..219f5c8d9659 100644
--- a/arch/arm/mach-omap2/cm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/cm-regbits-34xx.h
@@ -96,7 +96,8 @@
96#define OMAP3430_CLKTRCTRL_IVA2_MASK (0x3 << 0) 96#define OMAP3430_CLKTRCTRL_IVA2_MASK (0x3 << 0)
97 97
98/* CM_CLKSTST_IVA2 */ 98/* CM_CLKSTST_IVA2 */
99#define OMAP3430_CLKACTIVITY_IVA2 (1 << 0) 99#define OMAP3430_CLKACTIVITY_IVA2_SHIFT 0
100#define OMAP3430_CLKACTIVITY_IVA2_MASK (1 << 0)
100 101
101/* CM_REVISION specific bits */ 102/* CM_REVISION specific bits */
102 103
@@ -140,7 +141,8 @@
140#define OMAP3430_CLKTRCTRL_MPU_MASK (0x3 << 0) 141#define OMAP3430_CLKTRCTRL_MPU_MASK (0x3 << 0)
141 142
142/* CM_CLKSTST_MPU */ 143/* CM_CLKSTST_MPU */
143#define OMAP3430_CLKACTIVITY_MPU (1 << 0) 144#define OMAP3430_CLKACTIVITY_MPU_SHIFT 0
145#define OMAP3430_CLKACTIVITY_MPU_MASK (1 << 0)
144 146
145/* CM_FCLKEN1_CORE specific bits */ 147/* CM_FCLKEN1_CORE specific bits */
146 148
@@ -300,9 +302,12 @@
300#define OMAP3430_CLKTRCTRL_L3_MASK (0x3 << 0) 302#define OMAP3430_CLKTRCTRL_L3_MASK (0x3 << 0)
301 303
302/* CM_CLKSTST_CORE */ 304/* CM_CLKSTST_CORE */
303#define OMAP3430ES1_CLKACTIVITY_D2D (1 << 2) 305#define OMAP3430ES1_CLKACTIVITY_D2D_SHIFT 2
304#define OMAP3430_CLKACTIVITY_L4 (1 << 1) 306#define OMAP3430ES1_CLKACTIVITY_D2D_MASK (1 << 2)
305#define OMAP3430_CLKACTIVITY_L3 (1 << 0) 307#define OMAP3430_CLKACTIVITY_L4_SHIFT 1
308#define OMAP3430_CLKACTIVITY_L4_MASK (1 << 1)
309#define OMAP3430_CLKACTIVITY_L3_SHIFT 0
310#define OMAP3430_CLKACTIVITY_L3_MASK (1 << 0)
306 311
307/* CM_FCLKEN_GFX */ 312/* CM_FCLKEN_GFX */
308#define OMAP3430ES1_EN_3D (1 << 2) 313#define OMAP3430ES1_EN_3D (1 << 2)
@@ -323,7 +328,8 @@
323#define OMAP3430ES1_CLKTRCTRL_GFX_MASK (0x3 << 0) 328#define OMAP3430ES1_CLKTRCTRL_GFX_MASK (0x3 << 0)
324 329
325/* CM_CLKSTST_GFX */ 330/* CM_CLKSTST_GFX */
326#define OMAP3430ES1_CLKACTIVITY_GFX (1 << 0) 331#define OMAP3430ES1_CLKACTIVITY_GFX_SHIFT 0
332#define OMAP3430ES1_CLKACTIVITY_GFX_MASK (1 << 0)
327 333
328/* CM_FCLKEN_SGX */ 334/* CM_FCLKEN_SGX */
329#define OMAP3430ES2_EN_SGX_SHIFT 1 335#define OMAP3430ES2_EN_SGX_SHIFT 1
@@ -333,6 +339,14 @@
333#define OMAP3430ES2_CLKSEL_SGX_SHIFT 0 339#define OMAP3430ES2_CLKSEL_SGX_SHIFT 0
334#define OMAP3430ES2_CLKSEL_SGX_MASK (0x7 << 0) 340#define OMAP3430ES2_CLKSEL_SGX_MASK (0x7 << 0)
335 341
342/* CM_CLKSTCTRL_SGX */
343#define OMAP3430ES2_CLKTRCTRL_SGX_SHIFT 0
344#define OMAP3430ES2_CLKTRCTRL_SGX_MASK (0x3 << 0)
345
346/* CM_CLKSTST_SGX */
347#define OMAP3430ES2_CLKACTIVITY_SGX_SHIFT 0
348#define OMAP3430ES2_CLKACTIVITY_SGX_MASK (1 << 0)
349
336/* CM_FCLKEN_WKUP specific bits */ 350/* CM_FCLKEN_WKUP specific bits */
337#define OMAP3430ES2_EN_USIMOCP_SHIFT 9 351#define OMAP3430ES2_EN_USIMOCP_SHIFT 9
338 352
@@ -498,7 +512,8 @@
498#define OMAP3430_CLKTRCTRL_DSS_MASK (0x3 << 0) 512#define OMAP3430_CLKTRCTRL_DSS_MASK (0x3 << 0)
499 513
500/* CM_CLKSTST_DSS */ 514/* CM_CLKSTST_DSS */
501#define OMAP3430_CLKACTIVITY_DSS (1 << 0) 515#define OMAP3430_CLKACTIVITY_DSS_SHIFT 0
516#define OMAP3430_CLKACTIVITY_DSS_MASK (1 << 0)
502 517
503/* CM_FCLKEN_CAM specific bits */ 518/* CM_FCLKEN_CAM specific bits */
504 519
@@ -522,7 +537,8 @@
522#define OMAP3430_CLKTRCTRL_CAM_MASK (0x3 << 0) 537#define OMAP3430_CLKTRCTRL_CAM_MASK (0x3 << 0)
523 538
524/* CM_CLKSTST_CAM */ 539/* CM_CLKSTST_CAM */
525#define OMAP3430_CLKACTIVITY_CAM (1 << 0) 540#define OMAP3430_CLKACTIVITY_CAM_SHIFT 0
541#define OMAP3430_CLKACTIVITY_CAM_MASK (1 << 0)
526 542
527/* CM_FCLKEN_PER specific bits */ 543/* CM_FCLKEN_PER specific bits */
528 544
@@ -598,7 +614,8 @@
598#define OMAP3430_CLKTRCTRL_PER_MASK (0x3 << 0) 614#define OMAP3430_CLKTRCTRL_PER_MASK (0x3 << 0)
599 615
600/* CM_CLKSTST_PER */ 616/* CM_CLKSTST_PER */
601#define OMAP3430_CLKACTIVITY_PER (1 << 0) 617#define OMAP3430_CLKACTIVITY_PER_SHIFT 0
618#define OMAP3430_CLKACTIVITY_PER_MASK (1 << 0)
602 619
603/* CM_CLKSEL1_EMU */ 620/* CM_CLKSEL1_EMU */
604#define OMAP3430_DIV_DPLL4_SHIFT 24 621#define OMAP3430_DIV_DPLL4_SHIFT 24
@@ -623,7 +640,8 @@
623#define OMAP3430_CLKTRCTRL_EMU_MASK (0x3 << 0) 640#define OMAP3430_CLKTRCTRL_EMU_MASK (0x3 << 0)
624 641
625/* CM_CLKSTST_EMU */ 642/* CM_CLKSTST_EMU */
626#define OMAP3430_CLKACTIVITY_EMU (1 << 0) 643#define OMAP3430_CLKACTIVITY_EMU_SHIFT 0
644#define OMAP3430_CLKACTIVITY_EMU_MASK (1 << 0)
627 645
628/* CM_CLKSEL2_EMU specific bits */ 646/* CM_CLKSEL2_EMU specific bits */
629#define OMAP3430_CORE_DPLL_EMU_MULT_SHIFT 8 647#define OMAP3430_CORE_DPLL_EMU_MULT_SHIFT 8
@@ -673,6 +691,8 @@
673#define OMAP3430ES2_CLKTRCTRL_USBHOST_SHIFT 0 691#define OMAP3430ES2_CLKTRCTRL_USBHOST_SHIFT 0
674#define OMAP3430ES2_CLKTRCTRL_USBHOST_MASK (3 << 0) 692#define OMAP3430ES2_CLKTRCTRL_USBHOST_MASK (3 << 0)
675 693
676 694/* CM_CLKSTST_USBHOST */
695#define OMAP3430ES2_CLKACTIVITY_USBHOST_SHIFT 0
696#define OMAP3430ES2_CLKACTIVITY_USBHOST_MASK (1 << 0)
677 697
678#endif 698#endif
diff --git a/arch/arm/mach-omap2/cm.h b/arch/arm/mach-omap2/cm.h
index 87a44c715aa4..65fdf78c91e1 100644
--- a/arch/arm/mach-omap2/cm.h
+++ b/arch/arm/mach-omap2/cm.h
@@ -18,7 +18,7 @@
18 18
19#ifndef __ASSEMBLER__ 19#ifndef __ASSEMBLER__
20#define OMAP_CM_REGADDR(module, reg) \ 20#define OMAP_CM_REGADDR(module, reg) \
21 (void __iomem *)IO_ADDRESS(OMAP2_CM_BASE + (module) + (reg)) 21 IO_ADDRESS(OMAP2_CM_BASE + (module) + (reg))
22#else 22#else
23#define OMAP2420_CM_REGADDR(module, reg) \ 23#define OMAP2420_CM_REGADDR(module, reg) \
24 IO_ADDRESS(OMAP2420_CM_BASE + (module) + (reg)) 24 IO_ADDRESS(OMAP2420_CM_BASE + (module) + (reg))
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 2ee954a0bc7c..90af2ac469aa 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -23,50 +23,7 @@
23#include <mach/board.h> 23#include <mach/board.h>
24#include <mach/mux.h> 24#include <mach/mux.h>
25#include <mach/gpio.h> 25#include <mach/gpio.h>
26 26#include <mach/eac.h>
27#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
28
29#define OMAP2_I2C_BASE2 0x48072000
30#define OMAP2_I2C_INT2 57
31
32static struct resource i2c_resources2[] = {
33 {
34 .start = OMAP2_I2C_BASE2,
35 .end = OMAP2_I2C_BASE2 + 0x3f,
36 .flags = IORESOURCE_MEM,
37 },
38 {
39 .start = OMAP2_I2C_INT2,
40 .flags = IORESOURCE_IRQ,
41 },
42};
43
44static struct platform_device omap_i2c_device2 = {
45 .name = "i2c_omap",
46 .id = 2,
47 .num_resources = ARRAY_SIZE(i2c_resources2),
48 .resource = i2c_resources2,
49};
50
51/* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
52static void omap_init_i2c(void)
53{
54 /* REVISIT: Second I2C not in use on H4? */
55 if (machine_is_omap_h4())
56 return;
57
58 if (!cpu_is_omap2430()) {
59 omap_cfg_reg(J15_24XX_I2C2_SCL);
60 omap_cfg_reg(H19_24XX_I2C2_SDA);
61 }
62 (void) platform_device_register(&omap_i2c_device2);
63}
64
65#else
66
67static void omap_init_i2c(void) {}
68
69#endif
70 27
71#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE) 28#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
72#define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE) 29#define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
@@ -104,7 +61,9 @@ static inline void omap_init_mbox(void) { }
104 61
105#if defined(CONFIG_OMAP_STI) 62#if defined(CONFIG_OMAP_STI)
106 63
107#define OMAP2_STI_BASE IO_ADDRESS(0x48068000) 64#if defined(CONFIG_ARCH_OMAP2)
65
66#define OMAP2_STI_BASE 0x48068000
108#define OMAP2_STI_CHANNEL_BASE 0x54000000 67#define OMAP2_STI_CHANNEL_BASE 0x54000000
109#define OMAP2_STI_IRQ 4 68#define OMAP2_STI_IRQ 4
110 69
@@ -124,6 +83,25 @@ static struct resource sti_resources[] = {
124 .flags = IORESOURCE_IRQ, 83 .flags = IORESOURCE_IRQ,
125 } 84 }
126}; 85};
86#elif defined(CONFIG_ARCH_OMAP3)
87
88#define OMAP3_SDTI_BASE 0x54500000
89#define OMAP3_SDTI_CHANNEL_BASE 0x54600000
90
91static struct resource sti_resources[] = {
92 {
93 .start = OMAP3_SDTI_BASE,
94 .end = OMAP3_SDTI_BASE + 0xFFF,
95 .flags = IORESOURCE_MEM,
96 },
97 {
98 .start = OMAP3_SDTI_CHANNEL_BASE,
99 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
100 .flags = IORESOURCE_MEM,
101 }
102};
103
104#endif
127 105
128static struct platform_device sti_device = { 106static struct platform_device sti_device = {
129 .name = "sti", 107 .name = "sti",
@@ -140,12 +118,14 @@ static inline void omap_init_sti(void)
140static inline void omap_init_sti(void) {} 118static inline void omap_init_sti(void) {}
141#endif 119#endif
142 120
143#if defined(CONFIG_SPI_OMAP24XX) 121#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
144 122
145#include <mach/mcspi.h> 123#include <mach/mcspi.h>
146 124
147#define OMAP2_MCSPI1_BASE 0x48098000 125#define OMAP2_MCSPI1_BASE 0x48098000
148#define OMAP2_MCSPI2_BASE 0x4809a000 126#define OMAP2_MCSPI2_BASE 0x4809a000
127#define OMAP2_MCSPI3_BASE 0x480b8000
128#define OMAP2_MCSPI4_BASE 0x480ba000
149 129
150static struct omap2_mcspi_platform_config omap2_mcspi1_config = { 130static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
151 .num_cs = 4, 131 .num_cs = 4,
@@ -159,7 +139,7 @@ static struct resource omap2_mcspi1_resources[] = {
159 }, 139 },
160}; 140};
161 141
162struct platform_device omap2_mcspi1 = { 142static struct platform_device omap2_mcspi1 = {
163 .name = "omap2_mcspi", 143 .name = "omap2_mcspi",
164 .id = 1, 144 .id = 1,
165 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources), 145 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
@@ -181,7 +161,7 @@ static struct resource omap2_mcspi2_resources[] = {
181 }, 161 },
182}; 162};
183 163
184struct platform_device omap2_mcspi2 = { 164static struct platform_device omap2_mcspi2 = {
185 .name = "omap2_mcspi", 165 .name = "omap2_mcspi",
186 .id = 2, 166 .id = 2,
187 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources), 167 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
@@ -191,16 +171,162 @@ struct platform_device omap2_mcspi2 = {
191 }, 171 },
192}; 172};
193 173
174#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
175static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
176 .num_cs = 2,
177};
178
179static struct resource omap2_mcspi3_resources[] = {
180 {
181 .start = OMAP2_MCSPI3_BASE,
182 .end = OMAP2_MCSPI3_BASE + 0xff,
183 .flags = IORESOURCE_MEM,
184 },
185};
186
187static struct platform_device omap2_mcspi3 = {
188 .name = "omap2_mcspi",
189 .id = 3,
190 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
191 .resource = omap2_mcspi3_resources,
192 .dev = {
193 .platform_data = &omap2_mcspi3_config,
194 },
195};
196#endif
197
198#ifdef CONFIG_ARCH_OMAP3
199static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
200 .num_cs = 1,
201};
202
203static struct resource omap2_mcspi4_resources[] = {
204 {
205 .start = OMAP2_MCSPI4_BASE,
206 .end = OMAP2_MCSPI4_BASE + 0xff,
207 .flags = IORESOURCE_MEM,
208 },
209};
210
211static struct platform_device omap2_mcspi4 = {
212 .name = "omap2_mcspi",
213 .id = 4,
214 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
215 .resource = omap2_mcspi4_resources,
216 .dev = {
217 .platform_data = &omap2_mcspi4_config,
218 },
219};
220#endif
221
194static void omap_init_mcspi(void) 222static void omap_init_mcspi(void)
195{ 223{
196 platform_device_register(&omap2_mcspi1); 224 platform_device_register(&omap2_mcspi1);
197 platform_device_register(&omap2_mcspi2); 225 platform_device_register(&omap2_mcspi2);
226#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
227 platform_device_register(&omap2_mcspi3);
228#endif
229#ifdef CONFIG_ARCH_OMAP3
230 platform_device_register(&omap2_mcspi4);
231#endif
198} 232}
199 233
200#else 234#else
201static inline void omap_init_mcspi(void) {} 235static inline void omap_init_mcspi(void) {}
202#endif 236#endif
203 237
238#ifdef CONFIG_SND_OMAP24XX_EAC
239
240#define OMAP2_EAC_BASE 0x48090000
241
242static struct resource omap2_eac_resources[] = {
243 {
244 .start = OMAP2_EAC_BASE,
245 .end = OMAP2_EAC_BASE + 0x109,
246 .flags = IORESOURCE_MEM,
247 },
248};
249
250static struct platform_device omap2_eac_device = {
251 .name = "omap24xx-eac",
252 .id = -1,
253 .num_resources = ARRAY_SIZE(omap2_eac_resources),
254 .resource = omap2_eac_resources,
255 .dev = {
256 .platform_data = NULL,
257 },
258};
259
260void omap_init_eac(struct eac_platform_data *pdata)
261{
262 omap2_eac_device.dev.platform_data = pdata;
263 platform_device_register(&omap2_eac_device);
264}
265
266#else
267void omap_init_eac(struct eac_platform_data *pdata) {}
268#endif
269
270#ifdef CONFIG_OMAP_SHA1_MD5
271static struct resource sha1_md5_resources[] = {
272 {
273 .start = OMAP24XX_SEC_SHA1MD5_BASE,
274 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
275 .flags = IORESOURCE_MEM,
276 },
277 {
278 .start = INT_24XX_SHA1MD5,
279 .flags = IORESOURCE_IRQ,
280 }
281};
282
283static struct platform_device sha1_md5_device = {
284 .name = "OMAP SHA1/MD5",
285 .id = -1,
286 .num_resources = ARRAY_SIZE(sha1_md5_resources),
287 .resource = sha1_md5_resources,
288};
289
290static void omap_init_sha1_md5(void)
291{
292 platform_device_register(&sha1_md5_device);
293}
294#else
295static inline void omap_init_sha1_md5(void) { }
296#endif
297
298#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
299#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
300#define OMAP_HDQ_BASE 0x480B2000
301#endif
302static struct resource omap_hdq_resources[] = {
303 {
304 .start = OMAP_HDQ_BASE,
305 .end = OMAP_HDQ_BASE + 0x1C,
306 .flags = IORESOURCE_MEM,
307 },
308 {
309 .start = INT_24XX_HDQ_IRQ,
310 .flags = IORESOURCE_IRQ,
311 },
312};
313static struct platform_device omap_hdq_dev = {
314 .name = "omap_hdq",
315 .id = 0,
316 .dev = {
317 .platform_data = NULL,
318 },
319 .num_resources = ARRAY_SIZE(omap_hdq_resources),
320 .resource = omap_hdq_resources,
321};
322static inline void omap_hdq_init(void)
323{
324 (void) platform_device_register(&omap_hdq_dev);
325}
326#else
327static inline void omap_hdq_init(void) {}
328#endif
329
204/*-------------------------------------------------------------------------*/ 330/*-------------------------------------------------------------------------*/
205 331
206static int __init omap2_init_devices(void) 332static int __init omap2_init_devices(void)
@@ -208,10 +334,11 @@ static int __init omap2_init_devices(void)
208 /* please keep these calls, and their implementations above, 334 /* please keep these calls, and their implementations above,
209 * in alphabetical order so they're easier to sort through. 335 * in alphabetical order so they're easier to sort through.
210 */ 336 */
211 omap_init_i2c();
212 omap_init_mbox(); 337 omap_init_mbox();
213 omap_init_mcspi(); 338 omap_init_mcspi();
339 omap_hdq_init();
214 omap_init_sti(); 340 omap_init_sti();
341 omap_init_sha1_md5();
215 342
216 return 0; 343 return 0;
217} 344}
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index af1081a0b27c..763bdbeaf681 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -9,6 +9,8 @@
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12#undef DEBUG
13
12#include <linux/kernel.h> 14#include <linux/kernel.h>
13#include <linux/init.h> 15#include <linux/init.h>
14#include <linux/err.h> 16#include <linux/err.h>
@@ -16,20 +18,14 @@
16#include <linux/ioport.h> 18#include <linux/ioport.h>
17#include <linux/spinlock.h> 19#include <linux/spinlock.h>
18#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/module.h>
19 22
20#include <asm/mach-types.h> 23#include <asm/mach-types.h>
21#include <mach/gpmc.h> 24#include <mach/gpmc.h>
22 25
23#undef DEBUG 26#include <mach/sdrc.h>
24
25#ifdef CONFIG_ARCH_OMAP2420
26#define GPMC_BASE 0x6800a000
27#endif
28
29#ifdef CONFIG_ARCH_OMAP2430
30#define GPMC_BASE 0x6E000000
31#endif
32 27
28/* GPMC register offsets */
33#define GPMC_REVISION 0x00 29#define GPMC_REVISION 0x00
34#define GPMC_SYSCONFIG 0x10 30#define GPMC_SYSCONFIG 0x10
35#define GPMC_SYSSTATUS 0x14 31#define GPMC_SYSSTATUS 0x14
@@ -51,7 +47,6 @@
51#define GPMC_CS0 0x60 47#define GPMC_CS0 0x60
52#define GPMC_CS_SIZE 0x30 48#define GPMC_CS_SIZE 0x30
53 49
54#define GPMC_CS_NUM 8
55#define GPMC_MEM_START 0x00000000 50#define GPMC_MEM_START 0x00000000
56#define GPMC_MEM_END 0x3FFFFFFF 51#define GPMC_MEM_END 0x3FFFFFFF
57#define BOOT_ROM_SPACE 0x100000 /* 1MB */ 52#define BOOT_ROM_SPACE 0x100000 /* 1MB */
@@ -64,12 +59,9 @@ static struct resource gpmc_cs_mem[GPMC_CS_NUM];
64static DEFINE_SPINLOCK(gpmc_mem_lock); 59static DEFINE_SPINLOCK(gpmc_mem_lock);
65static unsigned gpmc_cs_map; 60static unsigned gpmc_cs_map;
66 61
67static void __iomem *gpmc_base = 62static void __iomem *gpmc_base;
68 (void __iomem *) IO_ADDRESS(GPMC_BASE);
69static void __iomem *gpmc_cs_base =
70 (void __iomem *) IO_ADDRESS(GPMC_BASE) + GPMC_CS0;
71 63
72static struct clk *gpmc_fck; 64static struct clk *gpmc_l3_clk;
73 65
74static void gpmc_write_reg(int idx, u32 val) 66static void gpmc_write_reg(int idx, u32 val)
75{ 67{
@@ -85,19 +77,32 @@ void gpmc_cs_write_reg(int cs, int idx, u32 val)
85{ 77{
86 void __iomem *reg_addr; 78 void __iomem *reg_addr;
87 79
88 reg_addr = gpmc_cs_base + (cs * GPMC_CS_SIZE) + idx; 80 reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
89 __raw_writel(val, reg_addr); 81 __raw_writel(val, reg_addr);
90} 82}
91 83
92u32 gpmc_cs_read_reg(int cs, int idx) 84u32 gpmc_cs_read_reg(int cs, int idx)
93{ 85{
94 return __raw_readl(gpmc_cs_base + (cs * GPMC_CS_SIZE) + idx); 86 void __iomem *reg_addr;
87
88 reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
89 return __raw_readl(reg_addr);
95} 90}
96 91
92/* TODO: Add support for gpmc_fck to clock framework and use it */
97unsigned long gpmc_get_fclk_period(void) 93unsigned long gpmc_get_fclk_period(void)
98{ 94{
99 /* In picoseconds */ 95 unsigned long rate = clk_get_rate(gpmc_l3_clk);
100 return 1000000000 / ((clk_get_rate(gpmc_fck)) / 1000); 96
97 if (rate == 0) {
98 printk(KERN_WARNING "gpmc_l3_clk not enabled\n");
99 return 0;
100 }
101
102 rate /= 1000;
103 rate = 1000000000 / rate; /* In picoseconds */
104
105 return rate;
101} 106}
102 107
103unsigned int gpmc_ns_to_ticks(unsigned int time_ns) 108unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
@@ -110,6 +115,11 @@ unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
110 return (time_ns * 1000 + tick_ps - 1) / tick_ps; 115 return (time_ns * 1000 + tick_ps - 1) / tick_ps;
111} 116}
112 117
118unsigned int gpmc_ticks_to_ns(unsigned int ticks)
119{
120 return ticks * gpmc_get_fclk_period() / 1000;
121}
122
113unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns) 123unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns)
114{ 124{
115 unsigned long ticks = gpmc_ns_to_ticks(time_ns); 125 unsigned long ticks = gpmc_ns_to_ticks(time_ns);
@@ -210,6 +220,11 @@ int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t)
210 220
211 GPMC_SET_ONE(GPMC_CS_CONFIG5, 24, 27, page_burst_access); 221 GPMC_SET_ONE(GPMC_CS_CONFIG5, 24, 27, page_burst_access);
212 222
223 if (cpu_is_omap34xx()) {
224 GPMC_SET_ONE(GPMC_CS_CONFIG6, 16, 19, wr_data_mux_bus);
225 GPMC_SET_ONE(GPMC_CS_CONFIG6, 24, 28, wr_access);
226 }
227
213 /* caller is expected to have initialized CONFIG1 to cover 228 /* caller is expected to have initialized CONFIG1 to cover
214 * at least sync vs async 229 * at least sync vs async
215 */ 230 */
@@ -350,6 +365,7 @@ out:
350 spin_unlock(&gpmc_mem_lock); 365 spin_unlock(&gpmc_mem_lock);
351 return r; 366 return r;
352} 367}
368EXPORT_SYMBOL(gpmc_cs_request);
353 369
354void gpmc_cs_free(int cs) 370void gpmc_cs_free(int cs)
355{ 371{
@@ -365,8 +381,9 @@ void gpmc_cs_free(int cs)
365 gpmc_cs_set_reserved(cs, 0); 381 gpmc_cs_set_reserved(cs, 0);
366 spin_unlock(&gpmc_mem_lock); 382 spin_unlock(&gpmc_mem_lock);
367} 383}
384EXPORT_SYMBOL(gpmc_cs_free);
368 385
369void __init gpmc_mem_init(void) 386static void __init gpmc_mem_init(void)
370{ 387{
371 int cs; 388 int cs;
372 unsigned long boot_rom_space = 0; 389 unsigned long boot_rom_space = 0;
@@ -396,12 +413,33 @@ void __init gpmc_mem_init(void)
396void __init gpmc_init(void) 413void __init gpmc_init(void)
397{ 414{
398 u32 l; 415 u32 l;
416 char *ck;
417
418 if (cpu_is_omap24xx()) {
419 ck = "core_l3_ck";
420 if (cpu_is_omap2420())
421 l = OMAP2420_GPMC_BASE;
422 else
423 l = OMAP34XX_GPMC_BASE;
424 } else if (cpu_is_omap34xx()) {
425 ck = "gpmc_fck";
426 l = OMAP34XX_GPMC_BASE;
427 }
399 428
400 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ 429 gpmc_l3_clk = clk_get(NULL, ck);
401 if (IS_ERR(gpmc_fck)) 430 if (IS_ERR(gpmc_l3_clk)) {
402 WARN_ON(1); 431 printk(KERN_ERR "Could not get GPMC clock %s\n", ck);
403 else 432 return -ENODEV;
404 clk_enable(gpmc_fck); 433 }
434
435 gpmc_base = ioremap(l, SZ_4K);
436 if (!gpmc_base) {
437 clk_put(gpmc_l3_clk);
438 printk(KERN_ERR "Could not get GPMC register memory\n");
439 return -ENOMEM;
440 }
441
442 BUG_ON(IS_ERR(gpmc_l3_clk));
405 443
406 l = gpmc_read_reg(GPMC_REVISION); 444 l = gpmc_read_reg(GPMC_REVISION);
407 printk(KERN_INFO "GPMC revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f); 445 printk(KERN_INFO "GPMC revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f);
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 209177c7f22f..bf45ff39a7b5 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -18,24 +18,15 @@
18 18
19#include <asm/cputype.h> 19#include <asm/cputype.h>
20 20
21#include <mach/common.h>
21#include <mach/control.h> 22#include <mach/control.h>
22#include <mach/cpu.h> 23#include <mach/cpu.h>
23 24
24#if defined(CONFIG_ARCH_OMAP2420) 25static u32 class;
25#define TAP_BASE io_p2v(0x48014000) 26static void __iomem *tap_base;
26#elif defined(CONFIG_ARCH_OMAP2430) 27static u16 tap_prod_id;
27#define TAP_BASE io_p2v(0x4900A000)
28#elif defined(CONFIG_ARCH_OMAP34XX)
29#define TAP_BASE io_p2v(0x4830A000)
30#endif
31 28
32#define OMAP_TAP_IDCODE 0x0204 29#define OMAP_TAP_IDCODE 0x0204
33#if defined(CONFIG_ARCH_OMAP34XX)
34#define OMAP_TAP_PROD_ID 0x0210
35#else
36#define OMAP_TAP_PROD_ID 0x0208
37#endif
38
39#define OMAP_TAP_DIE_ID_0 0x0218 30#define OMAP_TAP_DIE_ID_0 0x0218
40#define OMAP_TAP_DIE_ID_1 0x021C 31#define OMAP_TAP_DIE_ID_1 0x021C
41#define OMAP_TAP_DIE_ID_2 0x0220 32#define OMAP_TAP_DIE_ID_2 0x0220
@@ -94,18 +85,24 @@ static u32 __init read_tap_reg(int reg)
94 * it means its Cortex r0p0 which is 3430 ES1 85 * it means its Cortex r0p0 which is 3430 ES1
95 */ 86 */
96 if ((((cpuid >> 4) & 0xFFF) == 0xC08) && ((cpuid & 0xF) == 0x0)) { 87 if ((((cpuid >> 4) & 0xFFF) == 0xC08) && ((cpuid & 0xF) == 0x0)) {
88
89 if (reg == tap_prod_id) {
90 regval = 0x000F00F0;
91 goto out;
92 }
93
97 switch (reg) { 94 switch (reg) {
98 case OMAP_TAP_IDCODE : regval = 0x0B7AE02F; break; 95 case OMAP_TAP_IDCODE : regval = 0x0B7AE02F; break;
99 /* Making DevType as 0xF in ES1 to differ from ES2 */ 96 /* Making DevType as 0xF in ES1 to differ from ES2 */
100 case OMAP_TAP_PROD_ID : regval = 0x000F00F0; break;
101 case OMAP_TAP_DIE_ID_0: regval = 0x01000000; break; 97 case OMAP_TAP_DIE_ID_0: regval = 0x01000000; break;
102 case OMAP_TAP_DIE_ID_1: regval = 0x1012d687; break; 98 case OMAP_TAP_DIE_ID_1: regval = 0x1012d687; break;
103 case OMAP_TAP_DIE_ID_2: regval = 0x00000000; break; 99 case OMAP_TAP_DIE_ID_2: regval = 0x00000000; break;
104 case OMAP_TAP_DIE_ID_3: regval = 0x2d2c0000; break; 100 case OMAP_TAP_DIE_ID_3: regval = 0x2d2c0000; break;
105 } 101 }
106 } else 102 } else
107 regval = __raw_readl(TAP_BASE + reg); 103 regval = __raw_readl(tap_base + reg);
108 104
105out:
109 return regval; 106 return regval;
110 107
111} 108}
@@ -204,7 +201,7 @@ void __init omap2_check_revision(void)
204 u8 rev; 201 u8 rev;
205 202
206 idcode = read_tap_reg(OMAP_TAP_IDCODE); 203 idcode = read_tap_reg(OMAP_TAP_IDCODE);
207 prod_id = read_tap_reg(OMAP_TAP_PROD_ID); 204 prod_id = read_tap_reg(tap_prod_id);
208 hawkeye = (idcode >> 12) & 0xffff; 205 hawkeye = (idcode >> 12) & 0xffff;
209 rev = (idcode >> 28) & 0x0f; 206 rev = (idcode >> 28) & 0x0f;
210 dev_type = (prod_id >> 16) & 0x0f; 207 dev_type = (prod_id >> 16) & 0x0f;
@@ -269,3 +266,13 @@ void __init omap2_check_revision(void)
269 266
270} 267}
271 268
269void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
270{
271 class = omap2_globals->class;
272 tap_base = omap2_globals->tap;
273
274 if (class == 0x3430)
275 tap_prod_id = 0x0210;
276 else
277 tap_prod_id = 0x0208;
278}
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 7c3d6289c05f..5ea64f926ed5 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -4,8 +4,11 @@
4 * OMAP2 I/O mapping code 4 * OMAP2 I/O mapping code
5 * 5 *
6 * Copyright (C) 2005 Nokia Corporation 6 * Copyright (C) 2005 Nokia Corporation
7 * Author: Juha Yrjölä <juha.yrjola@nokia.com> 7 * Copyright (C) 2007 Texas Instruments
8 * Updated map desc to add 2430 support : <x0khasim@ti.com> 8 *
9 * Author:
10 * Juha Yrjola <juha.yrjola@nokia.com>
11 * Syed Khasim <x0khasim@ti.com>
9 * 12 *
10 * This program is free software; you can redistribute it and/or modify 13 * 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 14 * it under the terms of the GNU General Public License version 2 as
@@ -23,19 +26,26 @@
23 26
24#include <mach/mux.h> 27#include <mach/mux.h>
25#include <mach/omapfb.h> 28#include <mach/omapfb.h>
29#include <mach/sram.h>
30
31#include "memory.h"
32
33#include "clock.h"
34
35#include <mach/powerdomain.h>
36
37#include "powerdomains.h"
26 38
27extern void omap_sram_init(void); 39#include <mach/clockdomain.h>
28extern int omap2_clk_init(void); 40#include "clockdomains.h"
29extern void omap2_check_revision(void);
30extern void omap2_init_memory(void);
31extern void gpmc_init(void);
32extern void omapfb_reserve_sdram(void);
33 41
34/* 42/*
35 * The machine specific code may provide the extra mapping besides the 43 * The machine specific code may provide the extra mapping besides the
36 * default mapping provided here. 44 * default mapping provided here.
37 */ 45 */
38static struct map_desc omap2_io_desc[] __initdata = { 46
47#ifdef CONFIG_ARCH_OMAP24XX
48static struct map_desc omap24xx_io_desc[] __initdata = {
39 { 49 {
40 .virtual = L3_24XX_VIRT, 50 .virtual = L3_24XX_VIRT,
41 .pfn = __phys_to_pfn(L3_24XX_PHYS), 51 .pfn = __phys_to_pfn(L3_24XX_PHYS),
@@ -43,12 +53,39 @@ static struct map_desc omap2_io_desc[] __initdata = {
43 .type = MT_DEVICE 53 .type = MT_DEVICE
44 }, 54 },
45 { 55 {
46 .virtual = L4_24XX_VIRT, 56 .virtual = L4_24XX_VIRT,
47 .pfn = __phys_to_pfn(L4_24XX_PHYS), 57 .pfn = __phys_to_pfn(L4_24XX_PHYS),
48 .length = L4_24XX_SIZE, 58 .length = L4_24XX_SIZE,
49 .type = MT_DEVICE 59 .type = MT_DEVICE
50 }, 60 },
61};
62
63#ifdef CONFIG_ARCH_OMAP2420
64static struct map_desc omap242x_io_desc[] __initdata = {
65 {
66 .virtual = DSP_MEM_24XX_VIRT,
67 .pfn = __phys_to_pfn(DSP_MEM_24XX_PHYS),
68 .length = DSP_MEM_24XX_SIZE,
69 .type = MT_DEVICE
70 },
71 {
72 .virtual = DSP_IPI_24XX_VIRT,
73 .pfn = __phys_to_pfn(DSP_IPI_24XX_PHYS),
74 .length = DSP_IPI_24XX_SIZE,
75 .type = MT_DEVICE
76 },
77 {
78 .virtual = DSP_MMU_24XX_VIRT,
79 .pfn = __phys_to_pfn(DSP_MMU_24XX_PHYS),
80 .length = DSP_MMU_24XX_SIZE,
81 .type = MT_DEVICE
82 },
83};
84
85#endif
86
51#ifdef CONFIG_ARCH_OMAP2430 87#ifdef CONFIG_ARCH_OMAP2430
88static struct map_desc omap243x_io_desc[] __initdata = {
52 { 89 {
53 .virtual = L4_WK_243X_VIRT, 90 .virtual = L4_WK_243X_VIRT,
54 .pfn = __phys_to_pfn(L4_WK_243X_PHYS), 91 .pfn = __phys_to_pfn(L4_WK_243X_PHYS),
@@ -61,30 +98,90 @@ static struct map_desc omap2_io_desc[] __initdata = {
61 .length = OMAP243X_GPMC_SIZE, 98 .length = OMAP243X_GPMC_SIZE,
62 .type = MT_DEVICE 99 .type = MT_DEVICE
63 }, 100 },
101 {
102 .virtual = OMAP243X_SDRC_VIRT,
103 .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS),
104 .length = OMAP243X_SDRC_SIZE,
105 .type = MT_DEVICE
106 },
107 {
108 .virtual = OMAP243X_SMS_VIRT,
109 .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS),
110 .length = OMAP243X_SMS_SIZE,
111 .type = MT_DEVICE
112 },
113};
114#endif
64#endif 115#endif
116
117#ifdef CONFIG_ARCH_OMAP34XX
118static struct map_desc omap34xx_io_desc[] __initdata = {
65 { 119 {
66 .virtual = DSP_MEM_24XX_VIRT, 120 .virtual = L3_34XX_VIRT,
67 .pfn = __phys_to_pfn(DSP_MEM_24XX_PHYS), 121 .pfn = __phys_to_pfn(L3_34XX_PHYS),
68 .length = DSP_MEM_24XX_SIZE, 122 .length = L3_34XX_SIZE,
69 .type = MT_DEVICE 123 .type = MT_DEVICE
70 }, 124 },
71 { 125 {
72 .virtual = DSP_IPI_24XX_VIRT, 126 .virtual = L4_34XX_VIRT,
73 .pfn = __phys_to_pfn(DSP_IPI_24XX_PHYS), 127 .pfn = __phys_to_pfn(L4_34XX_PHYS),
74 .length = DSP_IPI_24XX_SIZE, 128 .length = L4_34XX_SIZE,
75 .type = MT_DEVICE 129 .type = MT_DEVICE
76 }, 130 },
77 { 131 {
78 .virtual = DSP_MMU_24XX_VIRT, 132 .virtual = L4_WK_34XX_VIRT,
79 .pfn = __phys_to_pfn(DSP_MMU_24XX_PHYS), 133 .pfn = __phys_to_pfn(L4_WK_34XX_PHYS),
80 .length = DSP_MMU_24XX_SIZE, 134 .length = L4_WK_34XX_SIZE,
135 .type = MT_DEVICE
136 },
137 {
138 .virtual = OMAP34XX_GPMC_VIRT,
139 .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS),
140 .length = OMAP34XX_GPMC_SIZE,
81 .type = MT_DEVICE 141 .type = MT_DEVICE
82 } 142 },
143 {
144 .virtual = OMAP343X_SMS_VIRT,
145 .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS),
146 .length = OMAP343X_SMS_SIZE,
147 .type = MT_DEVICE
148 },
149 {
150 .virtual = OMAP343X_SDRC_VIRT,
151 .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS),
152 .length = OMAP343X_SDRC_SIZE,
153 .type = MT_DEVICE
154 },
155 {
156 .virtual = L4_PER_34XX_VIRT,
157 .pfn = __phys_to_pfn(L4_PER_34XX_PHYS),
158 .length = L4_PER_34XX_SIZE,
159 .type = MT_DEVICE
160 },
161 {
162 .virtual = L4_EMU_34XX_VIRT,
163 .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS),
164 .length = L4_EMU_34XX_SIZE,
165 .type = MT_DEVICE
166 },
83}; 167};
168#endif
84 169
85void __init omap2_map_common_io(void) 170void __init omap2_map_common_io(void)
86{ 171{
87 iotable_init(omap2_io_desc, ARRAY_SIZE(omap2_io_desc)); 172#if defined(CONFIG_ARCH_OMAP2420)
173 iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
174 iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
175#endif
176
177#if defined(CONFIG_ARCH_OMAP2430)
178 iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
179 iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
180#endif
181
182#if defined(CONFIG_ARCH_OMAP34XX)
183 iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
184#endif
88 185
89 /* Normally devicemaps_init() would flush caches and tlb after 186 /* Normally devicemaps_init() would flush caches and tlb after
90 * mdesc->map_io(), but we must also do it here because of the CPU 187 * mdesc->map_io(), but we must also do it here because of the CPU
@@ -101,12 +198,9 @@ void __init omap2_map_common_io(void)
101void __init omap2_init_common_hw(void) 198void __init omap2_init_common_hw(void)
102{ 199{
103 omap2_mux_init(); 200 omap2_mux_init();
201 pwrdm_init(powerdomains_omap);
202 clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps);
104 omap2_clk_init(); 203 omap2_clk_init();
105/*
106 * Need to Fix this for 2430
107 */
108#ifndef CONFIG_ARCH_OMAP2430
109 omap2_init_memory(); 204 omap2_init_memory();
110#endif
111 gpmc_init(); 205 gpmc_init();
112} 206}
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 196a9565a8dc..d354e0fe4477 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -16,14 +16,20 @@
16#include <linux/io.h> 16#include <linux/io.h>
17#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <asm/mach/irq.h> 18#include <asm/mach/irq.h>
19#include <asm/irq.h>
20 19
21#define INTC_REVISION 0x0000 20
22#define INTC_SYSCONFIG 0x0010 21/* selected INTC register offsets */
23#define INTC_SYSSTATUS 0x0014 22
24#define INTC_CONTROL 0x0048 23#define INTC_REVISION 0x0000
25#define INTC_MIR_CLEAR0 0x0088 24#define INTC_SYSCONFIG 0x0010
26#define INTC_MIR_SET0 0x008c 25#define INTC_SYSSTATUS 0x0014
26#define INTC_CONTROL 0x0048
27#define INTC_MIR_CLEAR0 0x0088
28#define INTC_MIR_SET0 0x008c
29#define INTC_PENDING_IRQ0 0x0098
30
31/* Number of IRQ state bits in each MIR register */
32#define IRQ_BITS_PER_REG 32
27 33
28/* 34/*
29 * OMAP2 has a number of different interrupt controllers, each interrupt 35 * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -32,48 +38,50 @@
32 * for each bank.. when in doubt, consult the TRM. 38 * for each bank.. when in doubt, consult the TRM.
33 */ 39 */
34static struct omap_irq_bank { 40static struct omap_irq_bank {
35 unsigned long base_reg; 41 void __iomem *base_reg;
36 unsigned int nr_irqs; 42 unsigned int nr_irqs;
37} __attribute__ ((aligned(4))) irq_banks[] = { 43} __attribute__ ((aligned(4))) irq_banks[] = {
38 { 44 {
39 /* MPU INTC */ 45 /* MPU INTC */
40 .base_reg = IO_ADDRESS(OMAP24XX_IC_BASE), 46 .base_reg = 0,
41 .nr_irqs = 96, 47 .nr_irqs = 96,
42 }, { 48 },
43 /* XXX: DSP INTC */
44 }
45}; 49};
46 50
51/* INTC bank register get/set */
52
53static void intc_bank_write_reg(u32 val, struct omap_irq_bank *bank, u16 reg)
54{
55 __raw_writel(val, bank->base_reg + reg);
56}
57
58static u32 intc_bank_read_reg(struct omap_irq_bank *bank, u16 reg)
59{
60 return __raw_readl(bank->base_reg + reg);
61}
62
47/* XXX: FIQ and additional INTC support (only MPU at the moment) */ 63/* XXX: FIQ and additional INTC support (only MPU at the moment) */
48static void omap_ack_irq(unsigned int irq) 64static void omap_ack_irq(unsigned int irq)
49{ 65{
50 __raw_writel(0x1, irq_banks[0].base_reg + INTC_CONTROL); 66 intc_bank_write_reg(0x1, &irq_banks[0], INTC_CONTROL);
51} 67}
52 68
53static void omap_mask_irq(unsigned int irq) 69static void omap_mask_irq(unsigned int irq)
54{ 70{
55 int offset = (irq >> 5) << 5; 71 int offset = irq & (~(IRQ_BITS_PER_REG - 1));
56 72
57 if (irq >= 64) { 73 irq &= (IRQ_BITS_PER_REG - 1);
58 irq %= 64;
59 } else if (irq >= 32) {
60 irq %= 32;
61 }
62 74
63 __raw_writel(1 << irq, irq_banks[0].base_reg + INTC_MIR_SET0 + offset); 75 intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_SET0 + offset);
64} 76}
65 77
66static void omap_unmask_irq(unsigned int irq) 78static void omap_unmask_irq(unsigned int irq)
67{ 79{
68 int offset = (irq >> 5) << 5; 80 int offset = irq & (~(IRQ_BITS_PER_REG - 1));
69 81
70 if (irq >= 64) { 82 irq &= (IRQ_BITS_PER_REG - 1);
71 irq %= 64;
72 } else if (irq >= 32) {
73 irq %= 32;
74 }
75 83
76 __raw_writel(1 << irq, irq_banks[0].base_reg + INTC_MIR_CLEAR0 + offset); 84 intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_CLEAR0 + offset);
77} 85}
78 86
79static void omap_mask_ack_irq(unsigned int irq) 87static void omap_mask_ack_irq(unsigned int irq)
@@ -93,20 +101,20 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
93{ 101{
94 unsigned long tmp; 102 unsigned long tmp;
95 103
96 tmp = __raw_readl(bank->base_reg + INTC_REVISION) & 0xff; 104 tmp = intc_bank_read_reg(bank, INTC_REVISION) & 0xff;
97 printk(KERN_INFO "IRQ: Found an INTC at 0x%08lx " 105 printk(KERN_INFO "IRQ: Found an INTC at 0x%p "
98 "(revision %ld.%ld) with %d interrupts\n", 106 "(revision %ld.%ld) with %d interrupts\n",
99 bank->base_reg, tmp >> 4, tmp & 0xf, bank->nr_irqs); 107 bank->base_reg, tmp >> 4, tmp & 0xf, bank->nr_irqs);
100 108
101 tmp = __raw_readl(bank->base_reg + INTC_SYSCONFIG); 109 tmp = intc_bank_read_reg(bank, INTC_SYSCONFIG);
102 tmp |= 1 << 1; /* soft reset */ 110 tmp |= 1 << 1; /* soft reset */
103 __raw_writel(tmp, bank->base_reg + INTC_SYSCONFIG); 111 intc_bank_write_reg(tmp, bank, INTC_SYSCONFIG);
104 112
105 while (!(__raw_readl(bank->base_reg + INTC_SYSSTATUS) & 0x1)) 113 while (!(intc_bank_read_reg(bank, INTC_SYSSTATUS) & 0x1))
106 /* Wait for reset to complete */; 114 /* Wait for reset to complete */;
107 115
108 /* Enable autoidle */ 116 /* Enable autoidle */
109 __raw_writel(1 << 0, bank->base_reg + INTC_SYSCONFIG); 117 intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
110} 118}
111 119
112void __init omap_init_irq(void) 120void __init omap_init_irq(void)
@@ -118,9 +126,10 @@ void __init omap_init_irq(void)
118 for (i = 0; i < ARRAY_SIZE(irq_banks); i++) { 126 for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
119 struct omap_irq_bank *bank = irq_banks + i; 127 struct omap_irq_bank *bank = irq_banks + i;
120 128
121 /* XXX */ 129 if (cpu_is_omap24xx())
122 if (!bank->base_reg) 130 bank->base_reg = OMAP2_IO_ADDRESS(OMAP24XX_IC_BASE);
123 continue; 131 else if (cpu_is_omap34xx())
132 bank->base_reg = OMAP2_IO_ADDRESS(OMAP34XX_IC_BASE);
124 133
125 omap_irq_bank_init_one(bank); 134 omap_irq_bank_init_one(bank);
126 135
diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index b261f1f80b5e..cae3ebe249b3 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -89,6 +89,30 @@ static struct mcbsp_internal_clk omap_mcbsp_clks[] = {
89 .disable = omap_mcbsp_clk_disable, 89 .disable = omap_mcbsp_clk_disable,
90 }, 90 },
91 }, 91 },
92 {
93 .clk = {
94 .name = "mcbsp_clk",
95 .id = 3,
96 .enable = omap_mcbsp_clk_enable,
97 .disable = omap_mcbsp_clk_disable,
98 },
99 },
100 {
101 .clk = {
102 .name = "mcbsp_clk",
103 .id = 4,
104 .enable = omap_mcbsp_clk_enable,
105 .disable = omap_mcbsp_clk_disable,
106 },
107 },
108 {
109 .clk = {
110 .name = "mcbsp_clk",
111 .id = 5,
112 .enable = omap_mcbsp_clk_enable,
113 .disable = omap_mcbsp_clk_disable,
114 },
115 },
92}; 116};
93 117
94#define omap_mcbsp_clks_size ARRAY_SIZE(omap_mcbsp_clks) 118#define omap_mcbsp_clks_size ARRAY_SIZE(omap_mcbsp_clks)
@@ -117,25 +141,14 @@ static void omap2_mcbsp_request(unsigned int id)
117 omap2_mcbsp2_mux_setup(); 141 omap2_mcbsp2_mux_setup();
118} 142}
119 143
120static int omap2_mcbsp_check(unsigned int id)
121{
122 if (id > OMAP_MAX_MCBSP_COUNT - 1) {
123 printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
124 return -ENODEV;
125 }
126 return 0;
127}
128
129static struct omap_mcbsp_ops omap2_mcbsp_ops = { 144static struct omap_mcbsp_ops omap2_mcbsp_ops = {
130 .request = omap2_mcbsp_request, 145 .request = omap2_mcbsp_request,
131 .check = omap2_mcbsp_check,
132}; 146};
133 147
134#ifdef CONFIG_ARCH_OMAP24XX 148#ifdef CONFIG_ARCH_OMAP2420
135static struct omap_mcbsp_platform_data omap24xx_mcbsp_pdata[] = { 149static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
136 { 150 {
137 .phys_base = OMAP24XX_MCBSP1_BASE, 151 .phys_base = OMAP24XX_MCBSP1_BASE,
138 .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
139 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, 152 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
140 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 153 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
141 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 154 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
@@ -145,7 +158,6 @@ static struct omap_mcbsp_platform_data omap24xx_mcbsp_pdata[] = {
145 }, 158 },
146 { 159 {
147 .phys_base = OMAP24XX_MCBSP2_BASE, 160 .phys_base = OMAP24XX_MCBSP2_BASE,
148 .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
149 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, 161 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
150 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 162 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
151 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 163 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -154,17 +166,70 @@ static struct omap_mcbsp_platform_data omap24xx_mcbsp_pdata[] = {
154 .clk_name = "mcbsp_clk", 166 .clk_name = "mcbsp_clk",
155 }, 167 },
156}; 168};
157#define OMAP24XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap24xx_mcbsp_pdata) 169#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
158#else 170#else
159#define omap24xx_mcbsp_pdata NULL 171#define omap2420_mcbsp_pdata NULL
160#define OMAP24XX_MCBSP_PDATA_SZ 0 172#define OMAP2420_MCBSP_PDATA_SZ 0
173#endif
174
175#ifdef CONFIG_ARCH_OMAP2430
176static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
177 {
178 .phys_base = OMAP24XX_MCBSP1_BASE,
179 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
180 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
181 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
182 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
183 .ops = &omap2_mcbsp_ops,
184 .clk_name = "mcbsp_clk",
185 },
186 {
187 .phys_base = OMAP24XX_MCBSP2_BASE,
188 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
189 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
190 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
191 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
192 .ops = &omap2_mcbsp_ops,
193 .clk_name = "mcbsp_clk",
194 },
195 {
196 .phys_base = OMAP2430_MCBSP3_BASE,
197 .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
198 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
199 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
200 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
201 .ops = &omap2_mcbsp_ops,
202 .clk_name = "mcbsp_clk",
203 },
204 {
205 .phys_base = OMAP2430_MCBSP4_BASE,
206 .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
207 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
208 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
209 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
210 .ops = &omap2_mcbsp_ops,
211 .clk_name = "mcbsp_clk",
212 },
213 {
214 .phys_base = OMAP2430_MCBSP5_BASE,
215 .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
216 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
217 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
218 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
219 .ops = &omap2_mcbsp_ops,
220 .clk_name = "mcbsp_clk",
221 },
222};
223#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
224#else
225#define omap2430_mcbsp_pdata NULL
226#define OMAP2430_MCBSP_PDATA_SZ 0
161#endif 227#endif
162 228
163#ifdef CONFIG_ARCH_OMAP34XX 229#ifdef CONFIG_ARCH_OMAP34XX
164static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { 230static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
165 { 231 {
166 .phys_base = OMAP34XX_MCBSP1_BASE, 232 .phys_base = OMAP34XX_MCBSP1_BASE,
167 .virt_base = IO_ADDRESS(OMAP34XX_MCBSP1_BASE),
168 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, 233 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
169 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 234 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
170 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 235 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
@@ -174,7 +239,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
174 }, 239 },
175 { 240 {
176 .phys_base = OMAP34XX_MCBSP2_BASE, 241 .phys_base = OMAP34XX_MCBSP2_BASE,
177 .virt_base = IO_ADDRESS(OMAP34XX_MCBSP2_BASE),
178 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, 242 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
179 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 243 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
180 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 244 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -182,6 +246,33 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
182 .ops = &omap2_mcbsp_ops, 246 .ops = &omap2_mcbsp_ops,
183 .clk_name = "mcbsp_clk", 247 .clk_name = "mcbsp_clk",
184 }, 248 },
249 {
250 .phys_base = OMAP34XX_MCBSP3_BASE,
251 .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
252 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
253 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
254 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
255 .ops = &omap2_mcbsp_ops,
256 .clk_name = "mcbsp_clk",
257 },
258 {
259 .phys_base = OMAP34XX_MCBSP4_BASE,
260 .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
261 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
262 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
263 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
264 .ops = &omap2_mcbsp_ops,
265 .clk_name = "mcbsp_clk",
266 },
267 {
268 .phys_base = OMAP34XX_MCBSP5_BASE,
269 .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
270 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
271 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
272 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
273 .ops = &omap2_mcbsp_ops,
274 .clk_name = "mcbsp_clk",
275 },
185}; 276};
186#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata) 277#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
187#else 278#else
@@ -189,7 +280,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
189#define OMAP34XX_MCBSP_PDATA_SZ 0 280#define OMAP34XX_MCBSP_PDATA_SZ 0
190#endif 281#endif
191 282
192int __init omap2_mcbsp_init(void) 283static int __init omap2_mcbsp_init(void)
193{ 284{
194 int i; 285 int i;
195 286
@@ -199,10 +290,24 @@ int __init omap2_mcbsp_init(void)
199 clk_register(&omap_mcbsp_clks[i].clk); 290 clk_register(&omap_mcbsp_clks[i].clk);
200 } 291 }
201 292
202 if (cpu_is_omap24xx()) 293 if (cpu_is_omap2420())
203 omap_mcbsp_register_board_cfg(omap24xx_mcbsp_pdata, 294 omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
204 OMAP24XX_MCBSP_PDATA_SZ); 295 if (cpu_is_omap2430())
296 omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ;
297 if (cpu_is_omap34xx())
298 omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
299
300 mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
301 GFP_KERNEL);
302 if (!mcbsp_ptr)
303 return -ENOMEM;
205 304
305 if (cpu_is_omap2420())
306 omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata,
307 OMAP2420_MCBSP_PDATA_SZ);
308 if (cpu_is_omap2430())
309 omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata,
310 OMAP2430_MCBSP_PDATA_SZ);
206 if (cpu_is_omap34xx()) 311 if (cpu_is_omap34xx())
207 omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata, 312 omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
208 OMAP34XX_MCBSP_PDATA_SZ); 313 OMAP34XX_MCBSP_PDATA_SZ);
diff --git a/arch/arm/mach-omap2/memory.c b/arch/arm/mach-omap2/memory.c
index ab1462b02e6e..882c70224292 100644
--- a/arch/arm/mach-omap2/memory.c
+++ b/arch/arm/mach-omap2/memory.c
@@ -101,6 +101,17 @@ u32 omap2_reprogram_sdrc(u32 level, u32 force)
101 return prev; 101 return prev;
102} 102}
103 103
104#if !defined(CONFIG_ARCH_OMAP2)
105void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,
106 u32 base_cs, u32 force_unlock)
107{
108}
109void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
110 u32 mem_type)
111{
112}
113#endif
114
104void omap2_init_memory_params(u32 force_lock_to_unlock_mode) 115void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
105{ 116{
106 unsigned long dll_cnt; 117 unsigned long dll_cnt;
@@ -165,6 +176,9 @@ void __init omap2_init_memory(void)
165{ 176{
166 u32 l; 177 u32 l;
167 178
179 if (!cpu_is_omap2420())
180 return;
181
168 l = sms_read_reg(SMS_SYSCONFIG); 182 l = sms_read_reg(SMS_SYSCONFIG);
169 l &= ~(0x3 << 3); 183 l &= ~(0x3 << 3);
170 l |= (0x2 << 3); 184 l |= (0x2 << 3);
diff --git a/arch/arm/mach-omap2/memory.h b/arch/arm/mach-omap2/memory.h
index 9a280b50a893..bb3db80a7c46 100644
--- a/arch/arm/mach-omap2/memory.h
+++ b/arch/arm/mach-omap2/memory.h
@@ -14,6 +14,9 @@
14 * published by the Free Software Foundation. 14 * published by the Free Software Foundation.
15 */ 15 */
16 16
17#ifndef ARCH_ARM_MACH_OMAP2_MEMORY_H
18#define ARCH_ARM_MACH_OMAP2_MEMORY_H
19
17/* Memory timings */ 20/* Memory timings */
18#define M_DDR 1 21#define M_DDR 1
19#define M_LOCK_CTRL (1 << 2) 22#define M_LOCK_CTRL (1 << 2)
@@ -34,3 +37,7 @@ extern u32 omap2_memory_get_fast_dll_ctrl(void);
34extern u32 omap2_memory_get_type(void); 37extern u32 omap2_memory_get_type(void);
35u32 omap2_dll_force_needed(void); 38u32 omap2_dll_force_needed(void);
36u32 omap2_reprogram_sdrc(u32 level, u32 force); 39u32 omap2_reprogram_sdrc(u32 level, u32 force);
40void __init omap2_init_memory(void);
41void __init gpmc_init(void);
42
43#endif
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 6b7d672058b9..b1393673d95d 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/mach-omap2/mux.c 2 * linux/arch/arm/mach-omap2/mux.c
3 * 3 *
4 * OMAP2 pin multiplexing configurations 4 * OMAP2 and OMAP3 pin multiplexing configurations
5 * 5 *
6 * Copyright (C) 2004 - 2008 Texas Instruments Inc. 6 * Copyright (C) 2004 - 2008 Texas Instruments Inc.
7 * Copyright (C) 2003 - 2008 Nokia Corporation 7 * Copyright (C) 2003 - 2008 Nokia Corporation
@@ -220,16 +220,222 @@ MUX_CFG_24XX("AD13_2430_MCBSP2_DR_OFF", 0x0131, 0, 0, 0, 1)
220#define OMAP24XX_PINS_SZ 0 220#define OMAP24XX_PINS_SZ 0
221#endif /* CONFIG_ARCH_OMAP24XX */ 221#endif /* CONFIG_ARCH_OMAP24XX */
222 222
223#define OMAP24XX_PULL_ENA (1 << 3) 223#ifdef CONFIG_ARCH_OMAP34XX
224#define OMAP24XX_PULL_UP (1 << 4) 224static struct pin_config __initdata_or_module omap34xx_pins[] = {
225/*
226 * Name, reg-offset,
227 * mux-mode | [active-mode | off-mode]
228 */
229
230/* 34xx I2C */
231MUX_CFG_34XX("K21_34XX_I2C1_SCL", 0x1ba,
232 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
233MUX_CFG_34XX("J21_34XX_I2C1_SDA", 0x1bc,
234 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
235MUX_CFG_34XX("AF15_34XX_I2C2_SCL", 0x1be,
236 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
237MUX_CFG_34XX("AE15_34XX_I2C2_SDA", 0x1c0,
238 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
239MUX_CFG_34XX("AF14_34XX_I2C3_SCL", 0x1c2,
240 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
241MUX_CFG_34XX("AG14_34XX_I2C3_SDA", 0x1c4,
242 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
243MUX_CFG_34XX("AD26_34XX_I2C4_SCL", 0xa00,
244 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
245MUX_CFG_34XX("AE26_34XX_I2C4_SDA", 0xa02,
246 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_INPUT_PULLUP)
247
248/* PHY - HSUSB: 12-pin ULPI PHY: Port 1*/
249MUX_CFG_34XX("Y8_3430_USB1HS_PHY_CLK", 0x5da,
250 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_OUTPUT)
251MUX_CFG_34XX("Y9_3430_USB1HS_PHY_STP", 0x5d8,
252 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_OUTPUT)
253MUX_CFG_34XX("AA14_3430_USB1HS_PHY_DIR", 0x5ec,
254 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
255MUX_CFG_34XX("AA11_3430_USB1HS_PHY_NXT", 0x5ee,
256 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
257MUX_CFG_34XX("W13_3430_USB1HS_PHY_D0", 0x5dc,
258 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
259MUX_CFG_34XX("W12_3430_USB1HS_PHY_D1", 0x5de,
260 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
261MUX_CFG_34XX("W11_3430_USB1HS_PHY_D2", 0x5e0,
262 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
263MUX_CFG_34XX("Y11_3430_USB1HS_PHY_D3", 0x5ea,
264 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
265MUX_CFG_34XX("W9_3430_USB1HS_PHY_D4", 0x5e4,
266 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
267MUX_CFG_34XX("Y12_3430_USB1HS_PHY_D5", 0x5e6,
268 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
269MUX_CFG_34XX("W8_3430_USB1HS_PHY_D6", 0x5e8,
270 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
271MUX_CFG_34XX("Y13_3430_USB1HS_PHY_D7", 0x5e2,
272 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
273
274/* PHY - HSUSB: 12-pin ULPI PHY: Port 2*/
275MUX_CFG_34XX("AA8_3430_USB2HS_PHY_CLK", 0x5f0,
276 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_OUTPUT)
277MUX_CFG_34XX("AA10_3430_USB2HS_PHY_STP", 0x5f2,
278 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_OUTPUT)
279MUX_CFG_34XX("AA9_3430_USB2HS_PHY_DIR", 0x5f4,
280 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
281MUX_CFG_34XX("AB11_3430_USB2HS_PHY_NXT", 0x5f6,
282 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
283MUX_CFG_34XX("AB10_3430_USB2HS_PHY_D0", 0x5f8,
284 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
285MUX_CFG_34XX("AB9_3430_USB2HS_PHY_D1", 0x5fa,
286 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
287MUX_CFG_34XX("W3_3430_USB2HS_PHY_D2", 0x1d4,
288 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
289MUX_CFG_34XX("T4_3430_USB2HS_PHY_D3", 0x1de,
290 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
291MUX_CFG_34XX("T3_3430_USB2HS_PHY_D4", 0x1d8,
292 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
293MUX_CFG_34XX("R3_3430_USB2HS_PHY_D5", 0x1da,
294 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
295MUX_CFG_34XX("R4_3430_USB2HS_PHY_D6", 0x1dc,
296 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
297MUX_CFG_34XX("T2_3430_USB2HS_PHY_D7", 0x1d6,
298 OMAP34XX_MUX_MODE3 | OMAP34XX_PIN_INPUT_PULLDOWN)
299
300/* TLL - HSUSB: 12-pin TLL Port 1*/
301MUX_CFG_34XX("Y8_3430_USB1HS_TLL_CLK", 0x5da,
302 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
303MUX_CFG_34XX("Y9_3430_USB1HS_TLL_STP", 0x5d8,
304 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLUP)
305MUX_CFG_34XX("AA14_3430_USB1HS_TLL_DIR", 0x5ec,
306 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
307MUX_CFG_34XX("AA11_3430_USB1HS_TLL_NXT", 0x5ee,
308 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
309MUX_CFG_34XX("W13_3430_USB1HS_TLL_D0", 0x5dc,
310 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
311MUX_CFG_34XX("W12_3430_USB1HS_TLL_D1", 0x5de,
312 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
313MUX_CFG_34XX("W11_3430_USB1HS_TLL_D2", 0x5e0,
314 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
315MUX_CFG_34XX("Y11_3430_USB1HS_TLL_D3", 0x5ea,
316 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
317MUX_CFG_34XX("W9_3430_USB1HS_TLL_D4", 0x5e4,
318 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
319MUX_CFG_34XX("Y12_3430_USB1HS_TLL_D5", 0x5e6,
320 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
321MUX_CFG_34XX("W8_3430_USB1HS_TLL_D6", 0x5e8,
322 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
323MUX_CFG_34XX("Y13_3430_USB1HS_TLL_D7", 0x5e2,
324 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
325
326/* TLL - HSUSB: 12-pin TLL Port 2*/
327MUX_CFG_34XX("AA8_3430_USB2HS_TLL_CLK", 0x5f0,
328 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
329MUX_CFG_34XX("AA10_3430_USB2HS_TLL_STP", 0x5f2,
330 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLUP)
331MUX_CFG_34XX("AA9_3430_USB2HS_TLL_DIR", 0x5f4,
332 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
333MUX_CFG_34XX("AB11_3430_USB2HS_TLL_NXT", 0x5f6,
334 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
335MUX_CFG_34XX("AB10_3430_USB2HS_TLL_D0", 0x5f8,
336 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
337MUX_CFG_34XX("AB9_3430_USB2HS_TLL_D1", 0x5fa,
338 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
339MUX_CFG_34XX("W3_3430_USB2HS_TLL_D2", 0x1d4,
340 OMAP34XX_MUX_MODE2 | OMAP34XX_PIN_INPUT_PULLDOWN)
341MUX_CFG_34XX("T4_3430_USB2HS_TLL_D3", 0x1de,
342 OMAP34XX_MUX_MODE2 | OMAP34XX_PIN_INPUT_PULLDOWN)
343MUX_CFG_34XX("T3_3430_USB2HS_TLL_D4", 0x1d8,
344 OMAP34XX_MUX_MODE2 | OMAP34XX_PIN_INPUT_PULLDOWN)
345MUX_CFG_34XX("R3_3430_USB2HS_TLL_D5", 0x1da,
346 OMAP34XX_MUX_MODE2 | OMAP34XX_PIN_INPUT_PULLDOWN)
347MUX_CFG_34XX("R4_3430_USB2HS_TLL_D6", 0x1dc,
348 OMAP34XX_MUX_MODE2 | OMAP34XX_PIN_INPUT_PULLDOWN)
349MUX_CFG_34XX("T2_3430_USB2HS_TLL_D7", 0x1d6,
350 OMAP34XX_MUX_MODE2 | OMAP34XX_PIN_INPUT_PULLDOWN)
351
352/* TLL - HSUSB: 12-pin TLL Port 3*/
353MUX_CFG_34XX("AA6_3430_USB3HS_TLL_CLK", 0x180,
354 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
355MUX_CFG_34XX("AB3_3430_USB3HS_TLL_STP", 0x166,
356 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLUP)
357MUX_CFG_34XX("AA3_3430_USB3HS_TLL_DIR", 0x168,
358 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
359MUX_CFG_34XX("Y3_3430_USB3HS_TLL_NXT", 0x16a,
360 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
361MUX_CFG_34XX("AA5_3430_USB3HS_TLL_D0", 0x186,
362 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
363MUX_CFG_34XX("Y4_3430_USB3HS_TLL_D1", 0x184,
364 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
365MUX_CFG_34XX("Y5_3430_USB3HS_TLL_D2", 0x188,
366 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
367MUX_CFG_34XX("W5_3430_USB3HS_TLL_D3", 0x18a,
368 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
369MUX_CFG_34XX("AB12_3430_USB3HS_TLL_D4", 0x16c,
370 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
371MUX_CFG_34XX("AB13_3430_USB3HS_TLL_D5", 0x16e,
372 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
373MUX_CFG_34XX("AA13_3430_USB3HS_TLL_D6", 0x170,
374 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
375MUX_CFG_34XX("AA12_3430_USB3HS_TLL_D7", 0x172,
376 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
377
378/* PHY FSUSB: FS Serial for Port 1 (multiple PHY modes supported) */
379MUX_CFG_34XX("AF10_3430_USB1FS_PHY_MM1_RXDP", 0x5d8,
380 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
381MUX_CFG_34XX("AG9_3430_USB1FS_PHY_MM1_RXDM", 0x5ee,
382 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
383MUX_CFG_34XX("W13_3430_USB1FS_PHY_MM1_RXRCV", 0x5dc,
384 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
385MUX_CFG_34XX("W12_3430_USB1FS_PHY_MM1_TXSE0", 0x5de,
386 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
387MUX_CFG_34XX("W11_3430_USB1FS_PHY_MM1_TXDAT", 0x5e0,
388 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
389MUX_CFG_34XX("Y11_3430_USB1FS_PHY_MM1_TXEN_N", 0x5ea,
390 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_OUTPUT)
391
392/* PHY FSUSB: FS Serial for Port 2 (multiple PHY modes supported) */
393MUX_CFG_34XX("AF7_3430_USB2FS_PHY_MM2_RXDP", 0x5f2,
394 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
395MUX_CFG_34XX("AH7_3430_USB2FS_PHY_MM2_RXDM", 0x5f6,
396 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
397MUX_CFG_34XX("AB10_3430_USB2FS_PHY_MM2_RXRCV", 0x5f8,
398 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
399MUX_CFG_34XX("AB9_3430_USB2FS_PHY_MM2_TXSE0", 0x5fa,
400 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
401MUX_CFG_34XX("W3_3430_USB2FS_PHY_MM2_TXDAT", 0x1d4,
402 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_INPUT_PULLDOWN)
403MUX_CFG_34XX("T4_3430_USB2FS_PHY_MM2_TXEN_N", 0x1de,
404 OMAP34XX_MUX_MODE5 | OMAP34XX_PIN_OUTPUT)
405
406/* PHY FSUSB: FS Serial for Port 3 (multiple PHY modes supported) */
407MUX_CFG_34XX("AH3_3430_USB3FS_PHY_MM3_RXDP", 0x166,
408 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
409MUX_CFG_34XX("AE3_3430_USB3FS_PHY_MM3_RXDM", 0x16a,
410 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
411MUX_CFG_34XX("AD1_3430_USB3FS_PHY_MM3_RXRCV", 0x186,
412 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
413MUX_CFG_34XX("AE1_3430_USB3FS_PHY_MM3_TXSE0", 0x184,
414 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
415MUX_CFG_34XX("AD2_3430_USB3FS_PHY_MM3_TXDAT", 0x188,
416 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_INPUT_PULLDOWN)
417MUX_CFG_34XX("AC1_3430_USB3FS_PHY_MM3_TXEN_N", 0x18a,
418 OMAP34XX_MUX_MODE6 | OMAP34XX_PIN_OUTPUT)
419
420};
421
422#define OMAP34XX_PINS_SZ ARRAY_SIZE(omap34xx_pins)
423
424#else
425#define omap34xx_pins NULL
426#define OMAP34XX_PINS_SZ 0
427#endif /* CONFIG_ARCH_OMAP34XX */
225 428
226#if defined(CONFIG_OMAP_MUX_DEBUG) || defined(CONFIG_OMAP_MUX_WARNINGS) 429#if defined(CONFIG_OMAP_MUX_DEBUG) || defined(CONFIG_OMAP_MUX_WARNINGS)
227void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u8 reg) 430static void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u16 reg)
228{ 431{
229 u16 orig; 432 u16 orig;
230 u8 warn = 0, debug = 0; 433 u8 warn = 0, debug = 0;
231 434
232 orig = omap_ctrl_readb(cfg->mux_reg); 435 if (cpu_is_omap24xx())
436 orig = omap_ctrl_readb(cfg->mux_reg);
437 else
438 orig = omap_ctrl_readw(cfg->mux_reg);
233 439
234#ifdef CONFIG_OMAP_MUX_DEBUG 440#ifdef CONFIG_OMAP_MUX_DEBUG
235 debug = cfg->debug; 441 debug = cfg->debug;
@@ -255,9 +461,9 @@ int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
255 spin_lock_irqsave(&mux_spin_lock, flags); 461 spin_lock_irqsave(&mux_spin_lock, flags);
256 reg |= cfg->mask & 0x7; 462 reg |= cfg->mask & 0x7;
257 if (cfg->pull_val) 463 if (cfg->pull_val)
258 reg |= OMAP24XX_PULL_ENA; 464 reg |= OMAP2_PULL_ENA;
259 if (cfg->pu_pd_val) 465 if (cfg->pu_pd_val)
260 reg |= OMAP24XX_PULL_UP; 466 reg |= OMAP2_PULL_UP;
261 omap2_cfg_debug(cfg, reg); 467 omap2_cfg_debug(cfg, reg);
262 omap_ctrl_writeb(reg, cfg->mux_reg); 468 omap_ctrl_writeb(reg, cfg->mux_reg);
263 spin_unlock_irqrestore(&mux_spin_lock, flags); 469 spin_unlock_irqrestore(&mux_spin_lock, flags);
@@ -265,7 +471,26 @@ int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
265 return 0; 471 return 0;
266} 472}
267#else 473#else
268#define omap24xx_cfg_reg 0 474#define omap24xx_cfg_reg NULL
475#endif
476
477#ifdef CONFIG_ARCH_OMAP34XX
478static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
479{
480 static DEFINE_SPINLOCK(mux_spin_lock);
481 unsigned long flags;
482 u16 reg = 0;
483
484 spin_lock_irqsave(&mux_spin_lock, flags);
485 reg |= cfg->mux_val;
486 omap2_cfg_debug(cfg, reg);
487 omap_ctrl_writew(reg, cfg->mux_reg);
488 spin_unlock_irqrestore(&mux_spin_lock, flags);
489
490 return 0;
491}
492#else
493#define omap34xx_cfg_reg NULL
269#endif 494#endif
270 495
271int __init omap2_mux_init(void) 496int __init omap2_mux_init(void)
@@ -274,6 +499,10 @@ int __init omap2_mux_init(void)
274 arch_mux_cfg.pins = omap24xx_pins; 499 arch_mux_cfg.pins = omap24xx_pins;
275 arch_mux_cfg.size = OMAP24XX_PINS_SZ; 500 arch_mux_cfg.size = OMAP24XX_PINS_SZ;
276 arch_mux_cfg.cfg_reg = omap24xx_cfg_reg; 501 arch_mux_cfg.cfg_reg = omap24xx_cfg_reg;
502 } else if (cpu_is_omap34xx()) {
503 arch_mux_cfg.pins = omap34xx_pins;
504 arch_mux_cfg.size = OMAP34XX_PINS_SZ;
505 arch_mux_cfg.cfg_reg = omap34xx_cfg_reg;
277 } 506 }
278 507
279 return omap_mux_register(&arch_mux_cfg); 508 return omap_mux_register(&arch_mux_cfg);
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
new file mode 100644
index 000000000000..73e2971b1757
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -0,0 +1,1113 @@
1/*
2 * OMAP powerdomain control
3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2008 Nokia Corporation
6 *
7 * Written by Paul Walmsley
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#ifdef CONFIG_OMAP_DEBUG_POWERDOMAIN
14# define DEBUG
15#endif
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/types.h>
20#include <linux/delay.h>
21#include <linux/spinlock.h>
22#include <linux/list.h>
23#include <linux/errno.h>
24#include <linux/err.h>
25#include <linux/io.h>
26
27#include <asm/atomic.h>
28
29#include "cm.h"
30#include "cm-regbits-34xx.h"
31#include "prm.h"
32#include "prm-regbits-34xx.h"
33
34#include <mach/cpu.h>
35#include <mach/powerdomain.h>
36#include <mach/clockdomain.h>
37
38/* pwrdm_list contains all registered struct powerdomains */
39static LIST_HEAD(pwrdm_list);
40
41/*
42 * pwrdm_rwlock protects pwrdm_list add and del ops - also reused to
43 * protect pwrdm_clkdms[] during clkdm add/del ops
44 */
45static DEFINE_RWLOCK(pwrdm_rwlock);
46
47
48/* Private functions */
49
50static u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
51{
52 u32 v;
53
54 v = prm_read_mod_reg(domain, idx);
55 v &= mask;
56 v >>= __ffs(mask);
57
58 return v;
59}
60
61static struct powerdomain *_pwrdm_lookup(const char *name)
62{
63 struct powerdomain *pwrdm, *temp_pwrdm;
64
65 pwrdm = NULL;
66
67 list_for_each_entry(temp_pwrdm, &pwrdm_list, node) {
68 if (!strcmp(name, temp_pwrdm->name)) {
69 pwrdm = temp_pwrdm;
70 break;
71 }
72 }
73
74 return pwrdm;
75}
76
77/* _pwrdm_deps_lookup - look up the specified powerdomain in a pwrdm list */
78static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
79 struct pwrdm_dep *deps)
80{
81 struct pwrdm_dep *pd;
82
83 if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
84 return ERR_PTR(-EINVAL);
85
86 for (pd = deps; pd; pd++) {
87
88 if (!omap_chip_is(pd->omap_chip))
89 continue;
90
91 if (!pd->pwrdm && pd->pwrdm_name)
92 pd->pwrdm = pwrdm_lookup(pd->pwrdm_name);
93
94 if (pd->pwrdm == pwrdm)
95 break;
96
97 }
98
99 if (!pd)
100 return ERR_PTR(-ENOENT);
101
102 return pd->pwrdm;
103}
104
105
106/* Public functions */
107
108/**
109 * pwrdm_init - set up the powerdomain layer
110 *
111 * Loop through the list of powerdomains, registering all that are
112 * available on the current CPU. If pwrdm_list is supplied and not
113 * null, all of the referenced powerdomains will be registered. No
114 * return value.
115 */
116void pwrdm_init(struct powerdomain **pwrdm_list)
117{
118 struct powerdomain **p = NULL;
119
120 if (pwrdm_list)
121 for (p = pwrdm_list; *p; p++)
122 pwrdm_register(*p);
123}
124
125/**
126 * pwrdm_register - register a powerdomain
127 * @pwrdm: struct powerdomain * to register
128 *
129 * Adds a powerdomain to the internal powerdomain list. Returns
130 * -EINVAL if given a null pointer, -EEXIST if a powerdomain is
131 * already registered by the provided name, or 0 upon success.
132 */
133int pwrdm_register(struct powerdomain *pwrdm)
134{
135 unsigned long flags;
136 int ret = -EINVAL;
137
138 if (!pwrdm)
139 return -EINVAL;
140
141 if (!omap_chip_is(pwrdm->omap_chip))
142 return -EINVAL;
143
144 write_lock_irqsave(&pwrdm_rwlock, flags);
145 if (_pwrdm_lookup(pwrdm->name)) {
146 ret = -EEXIST;
147 goto pr_unlock;
148 }
149
150 list_add(&pwrdm->node, &pwrdm_list);
151
152 pr_debug("powerdomain: registered %s\n", pwrdm->name);
153 ret = 0;
154
155pr_unlock:
156 write_unlock_irqrestore(&pwrdm_rwlock, flags);
157
158 return ret;
159}
160
161/**
162 * pwrdm_unregister - unregister a powerdomain
163 * @pwrdm: struct powerdomain * to unregister
164 *
165 * Removes a powerdomain from the internal powerdomain list. Returns
166 * -EINVAL if pwrdm argument is NULL.
167 */
168int pwrdm_unregister(struct powerdomain *pwrdm)
169{
170 unsigned long flags;
171
172 if (!pwrdm)
173 return -EINVAL;
174
175 write_lock_irqsave(&pwrdm_rwlock, flags);
176 list_del(&pwrdm->node);
177 write_unlock_irqrestore(&pwrdm_rwlock, flags);
178
179 pr_debug("powerdomain: unregistered %s\n", pwrdm->name);
180
181 return 0;
182}
183
184/**
185 * pwrdm_lookup - look up a powerdomain by name, return a pointer
186 * @name: name of powerdomain
187 *
188 * Find a registered powerdomain by its name. Returns a pointer to the
189 * struct powerdomain if found, or NULL otherwise.
190 */
191struct powerdomain *pwrdm_lookup(const char *name)
192{
193 struct powerdomain *pwrdm;
194 unsigned long flags;
195
196 if (!name)
197 return NULL;
198
199 read_lock_irqsave(&pwrdm_rwlock, flags);
200 pwrdm = _pwrdm_lookup(name);
201 read_unlock_irqrestore(&pwrdm_rwlock, flags);
202
203 return pwrdm;
204}
205
206/**
207 * pwrdm_for_each - call function on each registered clockdomain
208 * @fn: callback function *
209 *
210 * Call the supplied function for each registered powerdomain. The
211 * callback function can return anything but 0 to bail out early from
212 * the iterator. The callback function is called with the pwrdm_rwlock
213 * held for reading, so no powerdomain structure manipulation
214 * functions should be called from the callback, although hardware
215 * powerdomain control functions are fine. Returns the last return
216 * value of the callback function, which should be 0 for success or
217 * anything else to indicate failure; or -EINVAL if the function
218 * pointer is null.
219 */
220int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm))
221{
222 struct powerdomain *temp_pwrdm;
223 unsigned long flags;
224 int ret = 0;
225
226 if (!fn)
227 return -EINVAL;
228
229 read_lock_irqsave(&pwrdm_rwlock, flags);
230 list_for_each_entry(temp_pwrdm, &pwrdm_list, node) {
231 ret = (*fn)(temp_pwrdm);
232 if (ret)
233 break;
234 }
235 read_unlock_irqrestore(&pwrdm_rwlock, flags);
236
237 return ret;
238}
239
240/**
241 * pwrdm_add_clkdm - add a clockdomain to a powerdomain
242 * @pwrdm: struct powerdomain * to add the clockdomain to
243 * @clkdm: struct clockdomain * to associate with a powerdomain
244 *
245 * Associate the clockdomain 'clkdm' with a powerdomain 'pwrdm'. This
246 * enables the use of pwrdm_for_each_clkdm(). Returns -EINVAL if
247 * presented with invalid pointers; -ENOMEM if memory could not be allocated;
248 * or 0 upon success.
249 */
250int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
251{
252 unsigned long flags;
253 int i;
254 int ret = -EINVAL;
255
256 if (!pwrdm || !clkdm)
257 return -EINVAL;
258
259 pr_debug("powerdomain: associating clockdomain %s with powerdomain "
260 "%s\n", clkdm->name, pwrdm->name);
261
262 write_lock_irqsave(&pwrdm_rwlock, flags);
263
264 for (i = 0; i < PWRDM_MAX_CLKDMS; i++) {
265 if (!pwrdm->pwrdm_clkdms[i])
266 break;
267#ifdef DEBUG
268 if (pwrdm->pwrdm_clkdms[i] == clkdm) {
269 ret = -EINVAL;
270 goto pac_exit;
271 }
272#endif
273 }
274
275 if (i == PWRDM_MAX_CLKDMS) {
276 pr_debug("powerdomain: increase PWRDM_MAX_CLKDMS for "
277 "pwrdm %s clkdm %s\n", pwrdm->name, clkdm->name);
278 WARN_ON(1);
279 ret = -ENOMEM;
280 goto pac_exit;
281 }
282
283 pwrdm->pwrdm_clkdms[i] = clkdm;
284
285 ret = 0;
286
287pac_exit:
288 write_unlock_irqrestore(&pwrdm_rwlock, flags);
289
290 return ret;
291}
292
293/**
294 * pwrdm_del_clkdm - remove a clockdomain from a powerdomain
295 * @pwrdm: struct powerdomain * to add the clockdomain to
296 * @clkdm: struct clockdomain * to associate with a powerdomain
297 *
298 * Dissociate the clockdomain 'clkdm' from the powerdomain
299 * 'pwrdm'. Returns -EINVAL if presented with invalid pointers;
300 * -ENOENT if the clkdm was not associated with the powerdomain, or 0
301 * upon success.
302 */
303int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
304{
305 unsigned long flags;
306 int ret = -EINVAL;
307 int i;
308
309 if (!pwrdm || !clkdm)
310 return -EINVAL;
311
312 pr_debug("powerdomain: dissociating clockdomain %s from powerdomain "
313 "%s\n", clkdm->name, pwrdm->name);
314
315 write_lock_irqsave(&pwrdm_rwlock, flags);
316
317 for (i = 0; i < PWRDM_MAX_CLKDMS; i++)
318 if (pwrdm->pwrdm_clkdms[i] == clkdm)
319 break;
320
321 if (i == PWRDM_MAX_CLKDMS) {
322 pr_debug("powerdomain: clkdm %s not associated with pwrdm "
323 "%s ?!\n", clkdm->name, pwrdm->name);
324 ret = -ENOENT;
325 goto pdc_exit;
326 }
327
328 pwrdm->pwrdm_clkdms[i] = NULL;
329
330 ret = 0;
331
332pdc_exit:
333 write_unlock_irqrestore(&pwrdm_rwlock, flags);
334
335 return ret;
336}
337
338/**
339 * pwrdm_for_each_clkdm - call function on each clkdm in a pwrdm
340 * @pwrdm: struct powerdomain * to iterate over
341 * @fn: callback function *
342 *
343 * Call the supplied function for each clockdomain in the powerdomain
344 * 'pwrdm'. The callback function can return anything but 0 to bail
345 * out early from the iterator. The callback function is called with
346 * the pwrdm_rwlock held for reading, so no powerdomain structure
347 * manipulation functions should be called from the callback, although
348 * hardware powerdomain control functions are fine. Returns -EINVAL
349 * if presented with invalid pointers; or passes along the last return
350 * value of the callback function, which should be 0 for success or
351 * anything else to indicate failure.
352 */
353int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
354 int (*fn)(struct powerdomain *pwrdm,
355 struct clockdomain *clkdm))
356{
357 unsigned long flags;
358 int ret = 0;
359 int i;
360
361 if (!fn)
362 return -EINVAL;
363
364 read_lock_irqsave(&pwrdm_rwlock, flags);
365
366 for (i = 0; i < PWRDM_MAX_CLKDMS && !ret; i++)
367 ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
368
369 read_unlock_irqrestore(&pwrdm_rwlock, flags);
370
371 return ret;
372}
373
374
375/**
376 * pwrdm_add_wkdep - add a wakeup dependency from pwrdm2 to pwrdm1
377 * @pwrdm1: wake this struct powerdomain * up (dependent)
378 * @pwrdm2: when this struct powerdomain * wakes up (source)
379 *
380 * When the powerdomain represented by pwrdm2 wakes up (due to an
381 * interrupt), wake up pwrdm1. Implemented in hardware on the OMAP,
382 * this feature is designed to reduce wakeup latency of the dependent
383 * powerdomain. Returns -EINVAL if presented with invalid powerdomain
384 * pointers, -ENOENT if pwrdm2 cannot wake up pwrdm1 in hardware, or
385 * 0 upon success.
386 */
387int pwrdm_add_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
388{
389 struct powerdomain *p;
390
391 if (!pwrdm1)
392 return -EINVAL;
393
394 p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->wkdep_srcs);
395 if (IS_ERR(p)) {
396 pr_debug("powerdomain: hardware cannot set/clear wake up of "
397 "%s when %s wakes up\n", pwrdm1->name, pwrdm2->name);
398 return IS_ERR(p);
399 }
400
401 pr_debug("powerdomain: hardware will wake up %s when %s wakes up\n",
402 pwrdm1->name, pwrdm2->name);
403
404 prm_set_mod_reg_bits((1 << pwrdm2->dep_bit),
405 pwrdm1->prcm_offs, PM_WKDEP);
406
407 return 0;
408}
409
410/**
411 * pwrdm_del_wkdep - remove a wakeup dependency from pwrdm2 to pwrdm1
412 * @pwrdm1: wake this struct powerdomain * up (dependent)
413 * @pwrdm2: when this struct powerdomain * wakes up (source)
414 *
415 * Remove a wakeup dependency that causes pwrdm1 to wake up when pwrdm2
416 * wakes up. Returns -EINVAL if presented with invalid powerdomain
417 * pointers, -ENOENT if pwrdm2 cannot wake up pwrdm1 in hardware, or
418 * 0 upon success.
419 */
420int pwrdm_del_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
421{
422 struct powerdomain *p;
423
424 if (!pwrdm1)
425 return -EINVAL;
426
427 p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->wkdep_srcs);
428 if (IS_ERR(p)) {
429 pr_debug("powerdomain: hardware cannot set/clear wake up of "
430 "%s when %s wakes up\n", pwrdm1->name, pwrdm2->name);
431 return IS_ERR(p);
432 }
433
434 pr_debug("powerdomain: hardware will no longer wake up %s after %s "
435 "wakes up\n", pwrdm1->name, pwrdm2->name);
436
437 prm_clear_mod_reg_bits((1 << pwrdm2->dep_bit),
438 pwrdm1->prcm_offs, PM_WKDEP);
439
440 return 0;
441}
442
443/**
444 * pwrdm_read_wkdep - read wakeup dependency state from pwrdm2 to pwrdm1
445 * @pwrdm1: wake this struct powerdomain * up (dependent)
446 * @pwrdm2: when this struct powerdomain * wakes up (source)
447 *
448 * Return 1 if a hardware wakeup dependency exists wherein pwrdm1 will be
449 * awoken when pwrdm2 wakes up; 0 if dependency is not set; -EINVAL
450 * if either powerdomain pointer is invalid; or -ENOENT if the hardware
451 * is incapable.
452 *
453 * REVISIT: Currently this function only represents software-controllable
454 * wakeup dependencies. Wakeup dependencies fixed in hardware are not
455 * yet handled here.
456 */
457int pwrdm_read_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
458{
459 struct powerdomain *p;
460
461 if (!pwrdm1)
462 return -EINVAL;
463
464 p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->wkdep_srcs);
465 if (IS_ERR(p)) {
466 pr_debug("powerdomain: hardware cannot set/clear wake up of "
467 "%s when %s wakes up\n", pwrdm1->name, pwrdm2->name);
468 return IS_ERR(p);
469 }
470
471 return prm_read_mod_bits_shift(pwrdm1->prcm_offs, PM_WKDEP,
472 (1 << pwrdm2->dep_bit));
473}
474
475/**
476 * pwrdm_add_sleepdep - add a sleep dependency from pwrdm2 to pwrdm1
477 * @pwrdm1: prevent this struct powerdomain * from sleeping (dependent)
478 * @pwrdm2: when this struct powerdomain * is active (source)
479 *
480 * Prevent pwrdm1 from automatically going inactive (and then to
481 * retention or off) if pwrdm2 is still active. Returns -EINVAL if
482 * presented with invalid powerdomain pointers or called on a machine
483 * that does not support software-configurable hardware sleep dependencies,
484 * -ENOENT if the specified dependency cannot be set in hardware, or
485 * 0 upon success.
486 */
487int pwrdm_add_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
488{
489 struct powerdomain *p;
490
491 if (!pwrdm1)
492 return -EINVAL;
493
494 if (!cpu_is_omap34xx())
495 return -EINVAL;
496
497 p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->sleepdep_srcs);
498 if (IS_ERR(p)) {
499 pr_debug("powerdomain: hardware cannot set/clear sleep "
500 "dependency affecting %s from %s\n", pwrdm1->name,
501 pwrdm2->name);
502 return IS_ERR(p);
503 }
504
505 pr_debug("powerdomain: will prevent %s from sleeping if %s is active\n",
506 pwrdm1->name, pwrdm2->name);
507
508 cm_set_mod_reg_bits((1 << pwrdm2->dep_bit),
509 pwrdm1->prcm_offs, OMAP3430_CM_SLEEPDEP);
510
511 return 0;
512}
513
514/**
515 * pwrdm_del_sleepdep - remove a sleep dependency from pwrdm2 to pwrdm1
516 * @pwrdm1: prevent this struct powerdomain * from sleeping (dependent)
517 * @pwrdm2: when this struct powerdomain * is active (source)
518 *
519 * Allow pwrdm1 to automatically go inactive (and then to retention or
520 * off), independent of the activity state of pwrdm2. Returns -EINVAL
521 * if presented with invalid powerdomain pointers or called on a machine
522 * that does not support software-configurable hardware sleep dependencies,
523 * -ENOENT if the specified dependency cannot be cleared in hardware, or
524 * 0 upon success.
525 */
526int pwrdm_del_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
527{
528 struct powerdomain *p;
529
530 if (!pwrdm1)
531 return -EINVAL;
532
533 if (!cpu_is_omap34xx())
534 return -EINVAL;
535
536 p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->sleepdep_srcs);
537 if (IS_ERR(p)) {
538 pr_debug("powerdomain: hardware cannot set/clear sleep "
539 "dependency affecting %s from %s\n", pwrdm1->name,
540 pwrdm2->name);
541 return IS_ERR(p);
542 }
543
544 pr_debug("powerdomain: will no longer prevent %s from sleeping if "
545 "%s is active\n", pwrdm1->name, pwrdm2->name);
546
547 cm_clear_mod_reg_bits((1 << pwrdm2->dep_bit),
548 pwrdm1->prcm_offs, OMAP3430_CM_SLEEPDEP);
549
550 return 0;
551}
552
553/**
554 * pwrdm_read_sleepdep - read sleep dependency state from pwrdm2 to pwrdm1
555 * @pwrdm1: prevent this struct powerdomain * from sleeping (dependent)
556 * @pwrdm2: when this struct powerdomain * is active (source)
557 *
558 * Return 1 if a hardware sleep dependency exists wherein pwrdm1 will
559 * not be allowed to automatically go inactive if pwrdm2 is active;
560 * 0 if pwrdm1's automatic power state inactivity transition is independent
561 * of pwrdm2's; -EINVAL if either powerdomain pointer is invalid or called
562 * on a machine that does not support software-configurable hardware sleep
563 * dependencies; or -ENOENT if the hardware is incapable.
564 *
565 * REVISIT: Currently this function only represents software-controllable
566 * sleep dependencies. Sleep dependencies fixed in hardware are not
567 * yet handled here.
568 */
569int pwrdm_read_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
570{
571 struct powerdomain *p;
572
573 if (!pwrdm1)
574 return -EINVAL;
575
576 if (!cpu_is_omap34xx())
577 return -EINVAL;
578
579 p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->sleepdep_srcs);
580 if (IS_ERR(p)) {
581 pr_debug("powerdomain: hardware cannot set/clear sleep "
582 "dependency affecting %s from %s\n", pwrdm1->name,
583 pwrdm2->name);
584 return IS_ERR(p);
585 }
586
587 return prm_read_mod_bits_shift(pwrdm1->prcm_offs, OMAP3430_CM_SLEEPDEP,
588 (1 << pwrdm2->dep_bit));
589}
590
591/**
592 * pwrdm_get_mem_bank_count - get number of memory banks in this powerdomain
593 * @pwrdm: struct powerdomain *
594 *
595 * Return the number of controllable memory banks in powerdomain pwrdm,
596 * starting with 1. Returns -EINVAL if the powerdomain pointer is null.
597 */
598int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm)
599{
600 if (!pwrdm)
601 return -EINVAL;
602
603 return pwrdm->banks;
604}
605
606/**
607 * pwrdm_set_next_pwrst - set next powerdomain power state
608 * @pwrdm: struct powerdomain * to set
609 * @pwrst: one of the PWRDM_POWER_* macros
610 *
611 * Set the powerdomain pwrdm's next power state to pwrst. The powerdomain
612 * may not enter this state immediately if the preconditions for this state
613 * have not been satisfied. Returns -EINVAL if the powerdomain pointer is
614 * null or if the power state is invalid for the powerdomin, or returns 0
615 * upon success.
616 */
617int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst)
618{
619 if (!pwrdm)
620 return -EINVAL;
621
622 if (!(pwrdm->pwrsts & (1 << pwrst)))
623 return -EINVAL;
624
625 pr_debug("powerdomain: setting next powerstate for %s to %0x\n",
626 pwrdm->name, pwrst);
627
628 prm_rmw_mod_reg_bits(OMAP_POWERSTATE_MASK,
629 (pwrst << OMAP_POWERSTATE_SHIFT),
630 pwrdm->prcm_offs, PM_PWSTCTRL);
631
632 return 0;
633}
634
635/**
636 * pwrdm_read_next_pwrst - get next powerdomain power state
637 * @pwrdm: struct powerdomain * to get power state
638 *
639 * Return the powerdomain pwrdm's next power state. Returns -EINVAL
640 * if the powerdomain pointer is null or returns the next power state
641 * upon success.
642 */
643int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
644{
645 if (!pwrdm)
646 return -EINVAL;
647
648 return prm_read_mod_bits_shift(pwrdm->prcm_offs, PM_PWSTCTRL,
649 OMAP_POWERSTATE_MASK);
650}
651
652/**
653 * pwrdm_read_pwrst - get current powerdomain power state
654 * @pwrdm: struct powerdomain * to get power state
655 *
656 * Return the powerdomain pwrdm's current power state. Returns -EINVAL
657 * if the powerdomain pointer is null or returns the current power state
658 * upon success.
659 */
660int pwrdm_read_pwrst(struct powerdomain *pwrdm)
661{
662 if (!pwrdm)
663 return -EINVAL;
664
665 return prm_read_mod_bits_shift(pwrdm->prcm_offs, PM_PWSTST,
666 OMAP_POWERSTATEST_MASK);
667}
668
669/**
670 * pwrdm_read_prev_pwrst - get previous powerdomain power state
671 * @pwrdm: struct powerdomain * to get previous power state
672 *
673 * Return the powerdomain pwrdm's previous power state. Returns -EINVAL
674 * if the powerdomain pointer is null or returns the previous power state
675 * upon success.
676 */
677int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm)
678{
679 if (!pwrdm)
680 return -EINVAL;
681
682 return prm_read_mod_bits_shift(pwrdm->prcm_offs, OMAP3430_PM_PREPWSTST,
683 OMAP3430_LASTPOWERSTATEENTERED_MASK);
684}
685
686/**
687 * pwrdm_set_logic_retst - set powerdomain logic power state upon retention
688 * @pwrdm: struct powerdomain * to set
689 * @pwrst: one of the PWRDM_POWER_* macros
690 *
691 * Set the next power state that the logic portion of the powerdomain
692 * pwrdm will enter when the powerdomain enters retention. This will
693 * be either RETENTION or OFF, if supported. Returns -EINVAL if the
694 * powerdomain pointer is null or the target power state is not not
695 * supported, or returns 0 upon success.
696 */
697int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
698{
699 if (!pwrdm)
700 return -EINVAL;
701
702 if (!(pwrdm->pwrsts_logic_ret & (1 << pwrst)))
703 return -EINVAL;
704
705 pr_debug("powerdomain: setting next logic powerstate for %s to %0x\n",
706 pwrdm->name, pwrst);
707
708 /*
709 * The register bit names below may not correspond to the
710 * actual names of the bits in each powerdomain's register,
711 * but the type of value returned is the same for each
712 * powerdomain.
713 */
714 prm_rmw_mod_reg_bits(OMAP3430_LOGICL1CACHERETSTATE,
715 (pwrst << __ffs(OMAP3430_LOGICL1CACHERETSTATE)),
716 pwrdm->prcm_offs, PM_PWSTCTRL);
717
718 return 0;
719}
720
721/**
722 * pwrdm_set_mem_onst - set memory power state while powerdomain ON
723 * @pwrdm: struct powerdomain * to set
724 * @bank: memory bank number to set (0-3)
725 * @pwrst: one of the PWRDM_POWER_* macros
726 *
727 * Set the next power state that memory bank x of the powerdomain
728 * pwrdm will enter when the powerdomain enters the ON state. Bank
729 * will be a number from 0 to 3, and represents different types of
730 * memory, depending on the powerdomain. Returns -EINVAL if the
731 * powerdomain pointer is null or the target power state is not not
732 * supported for this memory bank, -EEXIST if the target memory bank
733 * does not exist or is not controllable, or returns 0 upon success.
734 */
735int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
736{
737 u32 m;
738
739 if (!pwrdm)
740 return -EINVAL;
741
742 if (pwrdm->banks < (bank + 1))
743 return -EEXIST;
744
745 if (!(pwrdm->pwrsts_mem_on[bank] & (1 << pwrst)))
746 return -EINVAL;
747
748 pr_debug("powerdomain: setting next memory powerstate for domain %s "
749 "bank %0x while pwrdm-ON to %0x\n", pwrdm->name, bank, pwrst);
750
751 /*
752 * The register bit names below may not correspond to the
753 * actual names of the bits in each powerdomain's register,
754 * but the type of value returned is the same for each
755 * powerdomain.
756 */
757 switch (bank) {
758 case 0:
759 m = OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK;
760 break;
761 case 1:
762 m = OMAP3430_L1FLATMEMONSTATE_MASK;
763 break;
764 case 2:
765 m = OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK;
766 break;
767 case 3:
768 m = OMAP3430_L2FLATMEMONSTATE_MASK;
769 break;
770 default:
771 WARN_ON(1); /* should never happen */
772 return -EEXIST;
773 }
774
775 prm_rmw_mod_reg_bits(m, (pwrst << __ffs(m)),
776 pwrdm->prcm_offs, PM_PWSTCTRL);
777
778 return 0;
779}
780
781/**
782 * pwrdm_set_mem_retst - set memory power state while powerdomain in RET
783 * @pwrdm: struct powerdomain * to set
784 * @bank: memory bank number to set (0-3)
785 * @pwrst: one of the PWRDM_POWER_* macros
786 *
787 * Set the next power state that memory bank x of the powerdomain
788 * pwrdm will enter when the powerdomain enters the RETENTION state.
789 * Bank will be a number from 0 to 3, and represents different types
790 * of memory, depending on the powerdomain. pwrst will be either
791 * RETENTION or OFF, if supported. Returns -EINVAL if the powerdomain
792 * pointer is null or the target power state is not not supported for
793 * this memory bank, -EEXIST if the target memory bank does not exist
794 * or is not controllable, or returns 0 upon success.
795 */
796int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
797{
798 u32 m;
799
800 if (!pwrdm)
801 return -EINVAL;
802
803 if (pwrdm->banks < (bank + 1))
804 return -EEXIST;
805
806 if (!(pwrdm->pwrsts_mem_ret[bank] & (1 << pwrst)))
807 return -EINVAL;
808
809 pr_debug("powerdomain: setting next memory powerstate for domain %s "
810 "bank %0x while pwrdm-RET to %0x\n", pwrdm->name, bank, pwrst);
811
812 /*
813 * The register bit names below may not correspond to the
814 * actual names of the bits in each powerdomain's register,
815 * but the type of value returned is the same for each
816 * powerdomain.
817 */
818 switch (bank) {
819 case 0:
820 m = OMAP3430_SHAREDL1CACHEFLATRETSTATE;
821 break;
822 case 1:
823 m = OMAP3430_L1FLATMEMRETSTATE;
824 break;
825 case 2:
826 m = OMAP3430_SHAREDL2CACHEFLATRETSTATE;
827 break;
828 case 3:
829 m = OMAP3430_L2FLATMEMRETSTATE;
830 break;
831 default:
832 WARN_ON(1); /* should never happen */
833 return -EEXIST;
834 }
835
836 prm_rmw_mod_reg_bits(m, (pwrst << __ffs(m)), pwrdm->prcm_offs,
837 PM_PWSTCTRL);
838
839 return 0;
840}
841
842/**
843 * pwrdm_read_logic_pwrst - get current powerdomain logic retention power state
844 * @pwrdm: struct powerdomain * to get current logic retention power state
845 *
846 * Return the current power state that the logic portion of
847 * powerdomain pwrdm will enter
848 * Returns -EINVAL if the powerdomain pointer is null or returns the
849 * current logic retention power state upon success.
850 */
851int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm)
852{
853 if (!pwrdm)
854 return -EINVAL;
855
856 return prm_read_mod_bits_shift(pwrdm->prcm_offs, PM_PWSTST,
857 OMAP3430_LOGICSTATEST);
858}
859
860/**
861 * pwrdm_read_prev_logic_pwrst - get previous powerdomain logic power state
862 * @pwrdm: struct powerdomain * to get previous logic power state
863 *
864 * Return the powerdomain pwrdm's logic power state. Returns -EINVAL
865 * if the powerdomain pointer is null or returns the previous logic
866 * power state upon success.
867 */
868int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm)
869{
870 if (!pwrdm)
871 return -EINVAL;
872
873 /*
874 * The register bit names below may not correspond to the
875 * actual names of the bits in each powerdomain's register,
876 * but the type of value returned is the same for each
877 * powerdomain.
878 */
879 return prm_read_mod_bits_shift(pwrdm->prcm_offs, OMAP3430_PM_PREPWSTST,
880 OMAP3430_LASTLOGICSTATEENTERED);
881}
882
883/**
884 * pwrdm_read_mem_pwrst - get current memory bank power state
885 * @pwrdm: struct powerdomain * to get current memory bank power state
886 * @bank: memory bank number (0-3)
887 *
888 * Return the powerdomain pwrdm's current memory power state for bank
889 * x. Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
890 * the target memory bank does not exist or is not controllable, or
891 * returns the current memory power state upon success.
892 */
893int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
894{
895 u32 m;
896
897 if (!pwrdm)
898 return -EINVAL;
899
900 if (pwrdm->banks < (bank + 1))
901 return -EEXIST;
902
903 /*
904 * The register bit names below may not correspond to the
905 * actual names of the bits in each powerdomain's register,
906 * but the type of value returned is the same for each
907 * powerdomain.
908 */
909 switch (bank) {
910 case 0:
911 m = OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK;
912 break;
913 case 1:
914 m = OMAP3430_L1FLATMEMSTATEST_MASK;
915 break;
916 case 2:
917 m = OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK;
918 break;
919 case 3:
920 m = OMAP3430_L2FLATMEMSTATEST_MASK;
921 break;
922 default:
923 WARN_ON(1); /* should never happen */
924 return -EEXIST;
925 }
926
927 return prm_read_mod_bits_shift(pwrdm->prcm_offs, PM_PWSTST, m);
928}
929
930/**
931 * pwrdm_read_prev_mem_pwrst - get previous memory bank power state
932 * @pwrdm: struct powerdomain * to get previous memory bank power state
933 * @bank: memory bank number (0-3)
934 *
935 * Return the powerdomain pwrdm's previous memory power state for bank
936 * x. Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
937 * the target memory bank does not exist or is not controllable, or
938 * returns the previous memory power state upon success.
939 */
940int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
941{
942 u32 m;
943
944 if (!pwrdm)
945 return -EINVAL;
946
947 if (pwrdm->banks < (bank + 1))
948 return -EEXIST;
949
950 /*
951 * The register bit names below may not correspond to the
952 * actual names of the bits in each powerdomain's register,
953 * but the type of value returned is the same for each
954 * powerdomain.
955 */
956 switch (bank) {
957 case 0:
958 m = OMAP3430_LASTMEM1STATEENTERED_MASK;
959 break;
960 case 1:
961 m = OMAP3430_LASTMEM2STATEENTERED_MASK;
962 break;
963 case 2:
964 m = OMAP3430_LASTSHAREDL2CACHEFLATSTATEENTERED_MASK;
965 break;
966 case 3:
967 m = OMAP3430_LASTL2FLATMEMSTATEENTERED_MASK;
968 break;
969 default:
970 WARN_ON(1); /* should never happen */
971 return -EEXIST;
972 }
973
974 return prm_read_mod_bits_shift(pwrdm->prcm_offs,
975 OMAP3430_PM_PREPWSTST, m);
976}
977
978/**
979 * pwrdm_clear_all_prev_pwrst - clear previous powerstate register for a pwrdm
980 * @pwrdm: struct powerdomain * to clear
981 *
982 * Clear the powerdomain's previous power state register. Clears the
983 * entire register, including logic and memory bank previous power states.
984 * Returns -EINVAL if the powerdomain pointer is null, or returns 0 upon
985 * success.
986 */
987int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
988{
989 if (!pwrdm)
990 return -EINVAL;
991
992 /*
993 * XXX should get the powerdomain's current state here;
994 * warn & fail if it is not ON.
995 */
996
997 pr_debug("powerdomain: clearing previous power state reg for %s\n",
998 pwrdm->name);
999
1000 prm_write_mod_reg(0, pwrdm->prcm_offs, OMAP3430_PM_PREPWSTST);
1001
1002 return 0;
1003}
1004
1005/**
1006 * pwrdm_enable_hdwr_sar - enable automatic hardware SAR for a pwrdm
1007 * @pwrdm: struct powerdomain *
1008 *
1009 * Enable automatic context save-and-restore upon power state change
1010 * for some devices in a powerdomain. Warning: this only affects a
1011 * subset of devices in a powerdomain; check the TRM closely. Returns
1012 * -EINVAL if the powerdomain pointer is null or if the powerdomain
1013 * does not support automatic save-and-restore, or returns 0 upon
1014 * success.
1015 */
1016int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm)
1017{
1018 if (!pwrdm)
1019 return -EINVAL;
1020
1021 if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR))
1022 return -EINVAL;
1023
1024 pr_debug("powerdomain: %s: setting SAVEANDRESTORE bit\n",
1025 pwrdm->name);
1026
1027 prm_rmw_mod_reg_bits(0, 1 << OMAP3430ES2_SAVEANDRESTORE_SHIFT,
1028 pwrdm->prcm_offs, PM_PWSTCTRL);
1029
1030 return 0;
1031}
1032
1033/**
1034 * pwrdm_disable_hdwr_sar - disable automatic hardware SAR for a pwrdm
1035 * @pwrdm: struct powerdomain *
1036 *
1037 * Disable automatic context save-and-restore upon power state change
1038 * for some devices in a powerdomain. Warning: this only affects a
1039 * subset of devices in a powerdomain; check the TRM closely. Returns
1040 * -EINVAL if the powerdomain pointer is null or if the powerdomain
1041 * does not support automatic save-and-restore, or returns 0 upon
1042 * success.
1043 */
1044int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm)
1045{
1046 if (!pwrdm)
1047 return -EINVAL;
1048
1049 if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR))
1050 return -EINVAL;
1051
1052 pr_debug("powerdomain: %s: clearing SAVEANDRESTORE bit\n",
1053 pwrdm->name);
1054
1055 prm_rmw_mod_reg_bits(1 << OMAP3430ES2_SAVEANDRESTORE_SHIFT, 0,
1056 pwrdm->prcm_offs, PM_PWSTCTRL);
1057
1058 return 0;
1059}
1060
1061/**
1062 * pwrdm_has_hdwr_sar - test whether powerdomain supports hardware SAR
1063 * @pwrdm: struct powerdomain *
1064 *
1065 * Returns 1 if powerdomain 'pwrdm' supports hardware save-and-restore
1066 * for some devices, or 0 if it does not.
1067 */
1068bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm)
1069{
1070 return (pwrdm && pwrdm->flags & PWRDM_HAS_HDWR_SAR) ? 1 : 0;
1071}
1072
1073/**
1074 * pwrdm_wait_transition - wait for powerdomain power transition to finish
1075 * @pwrdm: struct powerdomain * to wait for
1076 *
1077 * If the powerdomain pwrdm is in the process of a state transition,
1078 * spin until it completes the power transition, or until an iteration
1079 * bailout value is reached. Returns -EINVAL if the powerdomain
1080 * pointer is null, -EAGAIN if the bailout value was reached, or
1081 * returns 0 upon success.
1082 */
1083int pwrdm_wait_transition(struct powerdomain *pwrdm)
1084{
1085 u32 c = 0;
1086
1087 if (!pwrdm)
1088 return -EINVAL;
1089
1090 /*
1091 * REVISIT: pwrdm_wait_transition() may be better implemented
1092 * via a callback and a periodic timer check -- how long do we expect
1093 * powerdomain transitions to take?
1094 */
1095
1096 /* XXX Is this udelay() value meaningful? */
1097 while ((prm_read_mod_reg(pwrdm->prcm_offs, PM_PWSTST) &
1098 OMAP_INTRANSITION) &&
1099 (c++ < PWRDM_TRANSITION_BAILOUT))
1100 udelay(1);
1101
1102 if (c >= PWRDM_TRANSITION_BAILOUT) {
1103 printk(KERN_ERR "powerdomain: waited too long for "
1104 "powerdomain %s to complete transition\n", pwrdm->name);
1105 return -EAGAIN;
1106 }
1107
1108 pr_debug("powerdomain: completed transition in %d loops\n", c);
1109
1110 return 0;
1111}
1112
1113
diff --git a/arch/arm/mach-omap2/powerdomains.h b/arch/arm/mach-omap2/powerdomains.h
new file mode 100644
index 000000000000..1e151faebbd3
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomains.h
@@ -0,0 +1,187 @@
1/*
2 * OMAP2/3 common powerdomain definitions
3 *
4 * Copyright (C) 2007-8 Texas Instruments, Inc.
5 * Copyright (C) 2007-8 Nokia Corporation
6 *
7 * Written by Paul Walmsley
8 * Debugging and integration fixes by Jouni Högander
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#ifndef ARCH_ARM_MACH_OMAP2_POWERDOMAINS
16#define ARCH_ARM_MACH_OMAP2_POWERDOMAINS
17
18/*
19 * This file contains all of the powerdomains that have some element
20 * of software control for the OMAP24xx and OMAP34XX chips.
21 *
22 * A few notes:
23 *
24 * This is not an exhaustive listing of powerdomains on the chips; only
25 * powerdomains that can be controlled in software.
26 *
27 * A useful validation rule for struct powerdomain:
28 * Any powerdomain referenced by a wkdep_srcs or sleepdep_srcs array
29 * must have a dep_bit assigned. So wkdep_srcs/sleepdep_srcs are really
30 * just software-controllable dependencies. Non-software-controllable
31 * dependencies do exist, but they are not encoded below (yet).
32 *
33 * 24xx does not support programmable sleep dependencies (SLEEPDEP)
34 *
35 */
36
37/*
38 * The names for the DSP/IVA2 powerdomains are confusing.
39 *
40 * Most OMAP chips have an on-board DSP.
41 *
42 * On the 2420, this is a 'C55 DSP called, simply, the DSP. Its
43 * powerdomain is called the "DSP power domain." On the 2430, the
44 * on-board DSP is a 'C64 DSP, now called the IVA2 or IVA2.1. Its
45 * powerdomain is still called the "DSP power domain." On the 3430,
46 * the DSP is a 'C64 DSP like the 2430, also known as the IVA2; but
47 * its powerdomain is now called the "IVA2 power domain."
48 *
49 * The 2420 also has something called the IVA, which is a separate ARM
50 * core, and has nothing to do with the DSP/IVA2.
51 *
52 * Ideally the DSP/IVA2 could just be the same powerdomain, but the PRCM
53 * address offset is different between the C55 and C64 DSPs.
54 *
55 * The overly-specific dep_bit names are due to a bit name collision
56 * with CM_FCLKEN_{DSP,IVA2}. The DSP/IVA2 PM_WKDEP and CM_SLEEPDEP shift
57 * value are the same for all powerdomains: 2
58 */
59
60/*
61 * XXX should dep_bit be a mask, so we can test to see if it is 0 as a
62 * sanity check?
63 * XXX encode hardware fixed wakeup dependencies -- esp. for 3430 CORE
64 */
65
66#include <mach/powerdomain.h>
67
68#include "prcm-common.h"
69#include "prm.h"
70#include "cm.h"
71
72/* OMAP2/3-common powerdomains and wakeup dependencies */
73
74/*
75 * 2420/2430 PM_WKDEP_GFX: CORE, MPU, WKUP
76 * 3430ES1 PM_WKDEP_GFX: adds IVA2, removes CORE
77 * 3430ES2 PM_WKDEP_SGX: adds IVA2, removes CORE
78 */
79static struct pwrdm_dep gfx_sgx_wkdeps[] = {
80 {
81 .pwrdm_name = "core_pwrdm",
82 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
83 },
84 {
85 .pwrdm_name = "iva2_pwrdm",
86 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
87 },
88 {
89 .pwrdm_name = "mpu_pwrdm",
90 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX |
91 CHIP_IS_OMAP3430)
92 },
93 {
94 .pwrdm_name = "wkup_pwrdm",
95 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX |
96 CHIP_IS_OMAP3430)
97 },
98 { NULL },
99};
100
101/*
102 * 3430: CM_SLEEPDEP_CAM: MPU
103 * 3430ES1: CM_SLEEPDEP_GFX: MPU
104 * 3430ES2: CM_SLEEPDEP_SGX: MPU
105 */
106static struct pwrdm_dep cam_gfx_sleepdeps[] = {
107 {
108 .pwrdm_name = "mpu_pwrdm",
109 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
110 },
111 { NULL },
112};
113
114
115#include "powerdomains24xx.h"
116#include "powerdomains34xx.h"
117
118
119/*
120 * OMAP2/3 common powerdomains
121 */
122
123/*
124 * The GFX powerdomain is not present on 3430ES2, but currently we do not
125 * have a macro to filter it out at compile-time.
126 */
127static struct powerdomain gfx_pwrdm = {
128 .name = "gfx_pwrdm",
129 .prcm_offs = GFX_MOD,
130 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX |
131 CHIP_IS_OMAP3430ES1),
132 .wkdep_srcs = gfx_sgx_wkdeps,
133 .sleepdep_srcs = cam_gfx_sleepdeps,
134 .pwrsts = PWRSTS_OFF_RET_ON,
135 .pwrsts_logic_ret = PWRDM_POWER_RET,
136 .banks = 1,
137 .pwrsts_mem_ret = {
138 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
139 },
140 .pwrsts_mem_on = {
141 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
142 },
143};
144
145static struct powerdomain wkup_pwrdm = {
146 .name = "wkup_pwrdm",
147 .prcm_offs = WKUP_MOD,
148 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX | CHIP_IS_OMAP3430),
149 .dep_bit = OMAP_EN_WKUP_SHIFT,
150};
151
152
153
154/* As powerdomains are added or removed above, this list must also be changed */
155static struct powerdomain *powerdomains_omap[] __initdata = {
156
157 &gfx_pwrdm,
158 &wkup_pwrdm,
159
160#ifdef CONFIG_ARCH_OMAP24XX
161 &dsp_pwrdm,
162 &mpu_24xx_pwrdm,
163 &core_24xx_pwrdm,
164#endif
165
166#ifdef CONFIG_ARCH_OMAP2430
167 &mdm_pwrdm,
168#endif
169
170#ifdef CONFIG_ARCH_OMAP34XX
171 &iva2_pwrdm,
172 &mpu_34xx_pwrdm,
173 &neon_pwrdm,
174 &core_34xx_pwrdm,
175 &cam_pwrdm,
176 &dss_pwrdm,
177 &per_pwrdm,
178 &emu_pwrdm,
179 &sgx_pwrdm,
180 &usbhost_pwrdm,
181#endif
182
183 NULL
184};
185
186
187#endif
diff --git a/arch/arm/mach-omap2/powerdomains24xx.h b/arch/arm/mach-omap2/powerdomains24xx.h
new file mode 100644
index 000000000000..9f08dc3f7fd2
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomains24xx.h
@@ -0,0 +1,200 @@
1/*
2 * OMAP24XX powerdomain definitions
3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2008 Nokia Corporation
6 *
7 * Written by Paul Walmsley
8 * Debugging and integration fixes by Jouni Högander
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#ifndef ARCH_ARM_MACH_OMAP2_POWERDOMAINS24XX
16#define ARCH_ARM_MACH_OMAP2_POWERDOMAINS24XX
17
18/*
19 * N.B. If powerdomains are added or removed from this file, update
20 * the array in mach-omap2/powerdomains.h.
21 */
22
23#include <mach/powerdomain.h>
24
25#include "prcm-common.h"
26#include "prm.h"
27#include "prm-regbits-24xx.h"
28#include "cm.h"
29#include "cm-regbits-24xx.h"
30
31/* 24XX powerdomains and dependencies */
32
33#ifdef CONFIG_ARCH_OMAP24XX
34
35
36/* Wakeup dependency source arrays */
37
38/*
39 * 2420/2430 PM_WKDEP_DSP: CORE, MPU, WKUP
40 * 2430 PM_WKDEP_MDM: same as above
41 */
42static struct pwrdm_dep dsp_mdm_24xx_wkdeps[] = {
43 {
44 .pwrdm_name = "core_pwrdm",
45 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
46 },
47 {
48 .pwrdm_name = "mpu_pwrdm",
49 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
50 },
51 {
52 .pwrdm_name = "wkup_pwrdm",
53 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
54 },
55 { NULL },
56};
57
58/*
59 * 2420 PM_WKDEP_MPU: CORE, DSP, WKUP
60 * 2430 adds MDM
61 */
62static struct pwrdm_dep mpu_24xx_wkdeps[] = {
63 {
64 .pwrdm_name = "core_pwrdm",
65 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
66 },
67 {
68 .pwrdm_name = "dsp_pwrdm",
69 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
70 },
71 {
72 .pwrdm_name = "wkup_pwrdm",
73 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
74 },
75 {
76 .pwrdm_name = "mdm_pwrdm",
77 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430)
78 },
79 { NULL },
80};
81
82/*
83 * 2420 PM_WKDEP_CORE: DSP, GFX, MPU, WKUP
84 * 2430 adds MDM
85 */
86static struct pwrdm_dep core_24xx_wkdeps[] = {
87 {
88 .pwrdm_name = "dsp_pwrdm",
89 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
90 },
91 {
92 .pwrdm_name = "gfx_pwrdm",
93 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
94 },
95 {
96 .pwrdm_name = "mpu_pwrdm",
97 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
98 },
99 {
100 .pwrdm_name = "wkup_pwrdm",
101 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX)
102 },
103 {
104 .pwrdm_name = "mdm_pwrdm",
105 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430)
106 },
107 { NULL },
108};
109
110
111/* Powerdomains */
112
113static struct powerdomain dsp_pwrdm = {
114 .name = "dsp_pwrdm",
115 .prcm_offs = OMAP24XX_DSP_MOD,
116 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
117 .dep_bit = OMAP24XX_PM_WKDEP_MPU_EN_DSP_SHIFT,
118 .wkdep_srcs = dsp_mdm_24xx_wkdeps,
119 .pwrsts = PWRSTS_OFF_RET_ON,
120 .pwrsts_logic_ret = PWRDM_POWER_RET,
121 .banks = 1,
122 .pwrsts_mem_ret = {
123 [0] = PWRDM_POWER_RET,
124 },
125 .pwrsts_mem_on = {
126 [0] = PWRDM_POWER_ON,
127 },
128};
129
130static struct powerdomain mpu_24xx_pwrdm = {
131 .name = "mpu_pwrdm",
132 .prcm_offs = MPU_MOD,
133 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
134 .dep_bit = OMAP24XX_EN_MPU_SHIFT,
135 .wkdep_srcs = mpu_24xx_wkdeps,
136 .pwrsts = PWRSTS_OFF_RET_ON,
137 .pwrsts_logic_ret = PWRSTS_OFF_RET,
138 .banks = 1,
139 .pwrsts_mem_ret = {
140 [0] = PWRDM_POWER_RET,
141 },
142 .pwrsts_mem_on = {
143 [0] = PWRDM_POWER_ON,
144 },
145};
146
147static struct powerdomain core_24xx_pwrdm = {
148 .name = "core_pwrdm",
149 .prcm_offs = CORE_MOD,
150 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP24XX),
151 .wkdep_srcs = core_24xx_wkdeps,
152 .pwrsts = PWRSTS_OFF_RET_ON,
153 .dep_bit = OMAP24XX_EN_CORE_SHIFT,
154 .banks = 3,
155 .pwrsts_mem_ret = {
156 [0] = PWRSTS_OFF_RET, /* MEM1RETSTATE */
157 [1] = PWRSTS_OFF_RET, /* MEM2RETSTATE */
158 [2] = PWRSTS_OFF_RET, /* MEM3RETSTATE */
159 },
160 .pwrsts_mem_on = {
161 [0] = PWRSTS_OFF_RET_ON, /* MEM1ONSTATE */
162 [1] = PWRSTS_OFF_RET_ON, /* MEM2ONSTATE */
163 [2] = PWRSTS_OFF_RET_ON, /* MEM3ONSTATE */
164 },
165};
166
167#endif /* CONFIG_ARCH_OMAP24XX */
168
169
170
171/*
172 * 2430-specific powerdomains
173 */
174
175#ifdef CONFIG_ARCH_OMAP2430
176
177/* XXX 2430 KILLDOMAINWKUP bit? No current users apparently */
178
179/* Another case of bit name collisions between several registers: EN_MDM */
180static struct powerdomain mdm_pwrdm = {
181 .name = "mdm_pwrdm",
182 .prcm_offs = OMAP2430_MDM_MOD,
183 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
184 .dep_bit = OMAP2430_PM_WKDEP_MPU_EN_MDM_SHIFT,
185 .wkdep_srcs = dsp_mdm_24xx_wkdeps,
186 .pwrsts = PWRSTS_OFF_RET_ON,
187 .pwrsts_logic_ret = PWRDM_POWER_RET,
188 .banks = 1,
189 .pwrsts_mem_ret = {
190 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
191 },
192 .pwrsts_mem_on = {
193 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
194 },
195};
196
197#endif /* CONFIG_ARCH_OMAP2430 */
198
199
200#endif
diff --git a/arch/arm/mach-omap2/powerdomains34xx.h b/arch/arm/mach-omap2/powerdomains34xx.h
new file mode 100644
index 000000000000..f573f7108398
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomains34xx.h
@@ -0,0 +1,327 @@
1/*
2 * OMAP34XX powerdomain definitions
3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2008 Nokia Corporation
6 *
7 * Written by Paul Walmsley
8 * Debugging and integration fixes by Jouni Högander
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#ifndef ARCH_ARM_MACH_OMAP2_POWERDOMAINS34XX
16#define ARCH_ARM_MACH_OMAP2_POWERDOMAINS34XX
17
18/*
19 * N.B. If powerdomains are added or removed from this file, update
20 * the array in mach-omap2/powerdomains.h.
21 */
22
23#include <mach/powerdomain.h>
24
25#include "prcm-common.h"
26#include "prm.h"
27#include "prm-regbits-34xx.h"
28#include "cm.h"
29#include "cm-regbits-34xx.h"
30
31/*
32 * 34XX-specific powerdomains, dependencies
33 */
34
35#ifdef CONFIG_ARCH_OMAP34XX
36
37/*
38 * 3430: PM_WKDEP_{PER,USBHOST}: CORE, IVA2, MPU, WKUP
39 * (USBHOST is ES2 only)
40 */
41static struct pwrdm_dep per_usbhost_wkdeps[] = {
42 {
43 .pwrdm_name = "core_pwrdm",
44 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
45 },
46 {
47 .pwrdm_name = "iva2_pwrdm",
48 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
49 },
50 {
51 .pwrdm_name = "mpu_pwrdm",
52 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
53 },
54 {
55 .pwrdm_name = "wkup_pwrdm",
56 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
57 },
58 { NULL },
59};
60
61/*
62 * 3430 PM_WKDEP_MPU: CORE, IVA2, DSS, PER
63 */
64static struct pwrdm_dep mpu_34xx_wkdeps[] = {
65 {
66 .pwrdm_name = "core_pwrdm",
67 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
68 },
69 {
70 .pwrdm_name = "iva2_pwrdm",
71 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
72 },
73 {
74 .pwrdm_name = "dss_pwrdm",
75 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
76 },
77 {
78 .pwrdm_name = "per_pwrdm",
79 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
80 },
81 { NULL },
82};
83
84/*
85 * 3430 PM_WKDEP_IVA2: CORE, MPU, WKUP, DSS, PER
86 */
87static struct pwrdm_dep iva2_wkdeps[] = {
88 {
89 .pwrdm_name = "core_pwrdm",
90 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
91 },
92 {
93 .pwrdm_name = "mpu_pwrdm",
94 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
95 },
96 {
97 .pwrdm_name = "wkup_pwrdm",
98 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
99 },
100 {
101 .pwrdm_name = "dss_pwrdm",
102 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
103 },
104 {
105 .pwrdm_name = "per_pwrdm",
106 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
107 },
108 { NULL },
109};
110
111
112/* 3430 PM_WKDEP_{CAM,DSS}: IVA2, MPU, WKUP */
113static struct pwrdm_dep cam_dss_wkdeps[] = {
114 {
115 .pwrdm_name = "iva2_pwrdm",
116 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
117 },
118 {
119 .pwrdm_name = "mpu_pwrdm",
120 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
121 },
122 {
123 .pwrdm_name = "wkup_pwrdm",
124 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
125 },
126 { NULL },
127};
128
129/* 3430: PM_WKDEP_NEON: MPU */
130static struct pwrdm_dep neon_wkdeps[] = {
131 {
132 .pwrdm_name = "mpu_pwrdm",
133 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
134 },
135 { NULL },
136};
137
138
139/* Sleep dependency source arrays for 34xx-specific pwrdms - 34XX only */
140
141/*
142 * 3430: CM_SLEEPDEP_{DSS,PER}: MPU, IVA
143 * 3430ES2: CM_SLEEPDEP_USBHOST: MPU, IVA
144 */
145static struct pwrdm_dep dss_per_usbhost_sleepdeps[] = {
146 {
147 .pwrdm_name = "mpu_pwrdm",
148 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
149 },
150 {
151 .pwrdm_name = "iva2_pwrdm",
152 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
153 },
154 { NULL },
155};
156
157
158/*
159 * Powerdomains
160 */
161
162static struct powerdomain iva2_pwrdm = {
163 .name = "iva2_pwrdm",
164 .prcm_offs = OMAP3430_IVA2_MOD,
165 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
166 .dep_bit = OMAP3430_PM_WKDEP_MPU_EN_IVA2_SHIFT,
167 .wkdep_srcs = iva2_wkdeps,
168 .pwrsts = PWRSTS_OFF_RET_ON,
169 .pwrsts_logic_ret = PWRSTS_OFF_RET,
170 .banks = 4,
171 .pwrsts_mem_ret = {
172 [0] = PWRSTS_OFF_RET,
173 [1] = PWRSTS_OFF_RET,
174 [2] = PWRSTS_OFF_RET,
175 [3] = PWRSTS_OFF_RET,
176 },
177 .pwrsts_mem_on = {
178 [0] = PWRDM_POWER_ON,
179 [1] = PWRDM_POWER_ON,
180 [2] = PWRSTS_OFF_ON,
181 [3] = PWRDM_POWER_ON,
182 },
183};
184
185static struct powerdomain mpu_34xx_pwrdm = {
186 .name = "mpu_pwrdm",
187 .prcm_offs = MPU_MOD,
188 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
189 .dep_bit = OMAP3430_EN_MPU_SHIFT,
190 .wkdep_srcs = mpu_34xx_wkdeps,
191 .pwrsts = PWRSTS_OFF_RET_ON,
192 .pwrsts_logic_ret = PWRSTS_OFF_RET,
193 .banks = 1,
194 .pwrsts_mem_ret = {
195 [0] = PWRSTS_OFF_RET,
196 },
197 .pwrsts_mem_on = {
198 [0] = PWRSTS_OFF_ON,
199 },
200};
201
202/* No wkdeps or sleepdeps for 34xx core apparently */
203static struct powerdomain core_34xx_pwrdm = {
204 .name = "core_pwrdm",
205 .prcm_offs = CORE_MOD,
206 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
207 .pwrsts = PWRSTS_OFF_RET_ON,
208 .dep_bit = OMAP3430_EN_CORE_SHIFT,
209 .banks = 2,
210 .pwrsts_mem_ret = {
211 [0] = PWRSTS_OFF_RET, /* MEM1RETSTATE */
212 [1] = PWRSTS_OFF_RET, /* MEM2RETSTATE */
213 },
214 .pwrsts_mem_on = {
215 [0] = PWRSTS_OFF_RET_ON, /* MEM1ONSTATE */
216 [1] = PWRSTS_OFF_RET_ON, /* MEM2ONSTATE */
217 },
218};
219
220/* Another case of bit name collisions between several registers: EN_DSS */
221static struct powerdomain dss_pwrdm = {
222 .name = "dss_pwrdm",
223 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
224 .prcm_offs = OMAP3430_DSS_MOD,
225 .dep_bit = OMAP3430_PM_WKDEP_MPU_EN_DSS_SHIFT,
226 .wkdep_srcs = cam_dss_wkdeps,
227 .sleepdep_srcs = dss_per_usbhost_sleepdeps,
228 .pwrsts = PWRSTS_OFF_RET_ON,
229 .pwrsts_logic_ret = PWRDM_POWER_RET,
230 .banks = 1,
231 .pwrsts_mem_ret = {
232 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
233 },
234 .pwrsts_mem_on = {
235 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
236 },
237};
238
239static struct powerdomain sgx_pwrdm = {
240 .name = "sgx_pwrdm",
241 .prcm_offs = OMAP3430ES2_SGX_MOD,
242 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430ES2),
243 .wkdep_srcs = gfx_sgx_wkdeps,
244 .sleepdep_srcs = cam_gfx_sleepdeps,
245 /* XXX This is accurate for 3430 SGX, but what about GFX? */
246 .pwrsts = PWRSTS_OFF_RET_ON,
247 .pwrsts_logic_ret = PWRDM_POWER_RET,
248 .banks = 1,
249 .pwrsts_mem_ret = {
250 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
251 },
252 .pwrsts_mem_on = {
253 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
254 },
255};
256
257static struct powerdomain cam_pwrdm = {
258 .name = "cam_pwrdm",
259 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
260 .prcm_offs = OMAP3430_CAM_MOD,
261 .wkdep_srcs = cam_dss_wkdeps,
262 .sleepdep_srcs = cam_gfx_sleepdeps,
263 .pwrsts = PWRSTS_OFF_RET_ON,
264 .pwrsts_logic_ret = PWRDM_POWER_RET,
265 .banks = 1,
266 .pwrsts_mem_ret = {
267 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
268 },
269 .pwrsts_mem_on = {
270 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
271 },
272};
273
274static struct powerdomain per_pwrdm = {
275 .name = "per_pwrdm",
276 .prcm_offs = OMAP3430_PER_MOD,
277 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
278 .dep_bit = OMAP3430_EN_PER_SHIFT,
279 .wkdep_srcs = per_usbhost_wkdeps,
280 .sleepdep_srcs = dss_per_usbhost_sleepdeps,
281 .pwrsts = PWRSTS_OFF_RET_ON,
282 .pwrsts_logic_ret = PWRSTS_OFF_RET,
283 .banks = 1,
284 .pwrsts_mem_ret = {
285 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
286 },
287 .pwrsts_mem_on = {
288 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
289 },
290};
291
292static struct powerdomain emu_pwrdm = {
293 .name = "emu_pwrdm",
294 .prcm_offs = OMAP3430_EMU_MOD,
295 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
296};
297
298static struct powerdomain neon_pwrdm = {
299 .name = "neon_pwrdm",
300 .prcm_offs = OMAP3430_NEON_MOD,
301 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
302 .wkdep_srcs = neon_wkdeps,
303 .pwrsts = PWRSTS_OFF_RET_ON,
304 .pwrsts_logic_ret = PWRDM_POWER_RET,
305};
306
307static struct powerdomain usbhost_pwrdm = {
308 .name = "usbhost_pwrdm",
309 .prcm_offs = OMAP3430ES2_USBHOST_MOD,
310 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430ES2),
311 .wkdep_srcs = per_usbhost_wkdeps,
312 .sleepdep_srcs = dss_per_usbhost_sleepdeps,
313 .pwrsts = PWRSTS_OFF_RET_ON,
314 .pwrsts_logic_ret = PWRDM_POWER_RET,
315 .banks = 1,
316 .pwrsts_mem_ret = {
317 [0] = PWRDM_POWER_RET, /* MEMRETSTATE */
318 },
319 .pwrsts_mem_on = {
320 [0] = PWRDM_POWER_ON, /* MEMONSTATE */
321 },
322};
323
324#endif /* CONFIG_ARCH_OMAP34XX */
325
326
327#endif
diff --git a/arch/arm/mach-omap2/prcm-common.h b/arch/arm/mach-omap2/prcm-common.h
index 54c32f482131..4a32822ff3fc 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -312,7 +312,8 @@
312#define OMAP3430_ST_GPT2 (1 << 3) 312#define OMAP3430_ST_GPT2 (1 << 3)
313 313
314/* CM_SLEEPDEP_PER, PM_WKDEP_IVA2, PM_WKDEP_MPU, PM_WKDEP_PER shared bits */ 314/* CM_SLEEPDEP_PER, PM_WKDEP_IVA2, PM_WKDEP_MPU, PM_WKDEP_PER shared bits */
315#define OMAP3430_EN_CORE (1 << 0) 315#define OMAP3430_EN_CORE_SHIFT 0
316#define OMAP3430_EN_CORE_MASK (1 << 0)
316 317
317#endif 318#endif
318 319
diff --git a/arch/arm/mach-omap2/prm-regbits-24xx.h b/arch/arm/mach-omap2/prm-regbits-24xx.h
index c6d17a3378ec..4002051c20b9 100644
--- a/arch/arm/mach-omap2/prm-regbits-24xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-24xx.h
@@ -29,8 +29,10 @@
29#define OMAP24XX_WKUP1_EN (1 << 0) 29#define OMAP24XX_WKUP1_EN (1 << 0)
30 30
31/* PM_WKDEP_GFX, PM_WKDEP_MPU, PM_WKDEP_DSP, PM_WKDEP_MDM shared bits */ 31/* PM_WKDEP_GFX, PM_WKDEP_MPU, PM_WKDEP_DSP, PM_WKDEP_MDM shared bits */
32#define OMAP24XX_EN_MPU (1 << 1) 32#define OMAP24XX_EN_MPU_SHIFT 1
33#define OMAP24XX_EN_CORE (1 << 0) 33#define OMAP24XX_EN_MPU_MASK (1 << 1)
34#define OMAP24XX_EN_CORE_SHIFT 0
35#define OMAP24XX_EN_CORE_MASK (1 << 0)
34 36
35/* 37/*
36 * PM_PWSTCTRL_MPU, PM_PWSTCTRL_GFX, PM_PWSTCTRL_DSP, PM_PWSTCTRL_MDM 38 * PM_PWSTCTRL_MPU, PM_PWSTCTRL_GFX, PM_PWSTCTRL_DSP, PM_PWSTCTRL_MDM
@@ -140,8 +142,10 @@
140/* 2430 calls GLOBALWMPU_RST "GLOBALWARM_RST" instead */ 142/* 2430 calls GLOBALWMPU_RST "GLOBALWARM_RST" instead */
141 143
142/* PM_WKDEP_MPU specific bits */ 144/* PM_WKDEP_MPU specific bits */
143#define OMAP2430_PM_WKDEP_MPU_EN_MDM (1 << 5) 145#define OMAP2430_PM_WKDEP_MPU_EN_MDM_SHIFT 5
144#define OMAP24XX_PM_WKDEP_MPU_EN_DSP (1 << 2) 146#define OMAP2430_PM_WKDEP_MPU_EN_MDM_MASK (1 << 5)
147#define OMAP24XX_PM_WKDEP_MPU_EN_DSP_SHIFT 2
148#define OMAP24XX_PM_WKDEP_MPU_EN_DSP_MASK (1 << 2)
145 149
146/* PM_EVGENCTRL_MPU specific bits */ 150/* PM_EVGENCTRL_MPU specific bits */
147 151
diff --git a/arch/arm/mach-omap2/prm-regbits-34xx.h b/arch/arm/mach-omap2/prm-regbits-34xx.h
index b4686bc345ca..5b5ecfe6c999 100644
--- a/arch/arm/mach-omap2/prm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-34xx.h
@@ -68,7 +68,8 @@
68#define OMAP3430_VPINIDLE (1 << 0) 68#define OMAP3430_VPINIDLE (1 << 0)
69 69
70/* PM_WKDEP_IVA2, PM_WKDEP_MPU shared bits */ 70/* PM_WKDEP_IVA2, PM_WKDEP_MPU shared bits */
71#define OMAP3430_EN_PER (1 << 7) 71#define OMAP3430_EN_PER_SHIFT 7
72#define OMAP3430_EN_PER_MASK (1 << 7)
72 73
73/* PM_PWSTCTRL_IVA2, PM_PWSTCTRL_MPU, PM_PWSTCTRL_CORE shared bits */ 74/* PM_PWSTCTRL_IVA2, PM_PWSTCTRL_MPU, PM_PWSTCTRL_CORE shared bits */
74#define OMAP3430_MEMORYCHANGE (1 << 3) 75#define OMAP3430_MEMORYCHANGE (1 << 3)
@@ -77,7 +78,7 @@
77#define OMAP3430_LOGICSTATEST (1 << 2) 78#define OMAP3430_LOGICSTATEST (1 << 2)
78 79
79/* PM_PREPWSTST_IVA2, PM_PREPWSTST_CORE shared bits */ 80/* PM_PREPWSTST_IVA2, PM_PREPWSTST_CORE shared bits */
80#define OMAP3430_LASTLOGICSTATEENTERED (1 << 2) 81#define OMAP3430_LASTLOGICSTATEENTERED (1 << 2)
81 82
82/* 83/*
83 * PM_PREPWSTST_IVA2, PM_PREPWSTST_MPU, PM_PREPWSTST_CORE, 84 * PM_PREPWSTST_IVA2, PM_PREPWSTST_MPU, PM_PREPWSTST_CORE,
@@ -278,8 +279,10 @@
278#define OMAP3430_EMULATION_MPU_RST (1 << 11) 279#define OMAP3430_EMULATION_MPU_RST (1 << 11)
279 280
280/* PM_WKDEP_MPU specific bits */ 281/* PM_WKDEP_MPU specific bits */
281#define OMAP3430_PM_WKDEP_MPU_EN_DSS (1 << 5) 282#define OMAP3430_PM_WKDEP_MPU_EN_DSS_SHIFT 5
282#define OMAP3430_PM_WKDEP_MPU_EN_IVA2 (1 << 2) 283#define OMAP3430_PM_WKDEP_MPU_EN_DSS_MASK (1 << 5)
284#define OMAP3430_PM_WKDEP_MPU_EN_IVA2_SHIFT 2
285#define OMAP3430_PM_WKDEP_MPU_EN_IVA2_MASK (1 << 2)
283 286
284/* PM_EVGENCTRL_MPU */ 287/* PM_EVGENCTRL_MPU */
285#define OMAP3430_OFFLOADMODE_SHIFT 3 288#define OMAP3430_OFFLOADMODE_SHIFT 3
diff --git a/arch/arm/mach-omap2/prm.h b/arch/arm/mach-omap2/prm.h
index bbf41fc8e9a9..e4dc4b17881d 100644
--- a/arch/arm/mach-omap2/prm.h
+++ b/arch/arm/mach-omap2/prm.h
@@ -18,7 +18,7 @@
18 18
19#ifndef __ASSEMBLER__ 19#ifndef __ASSEMBLER__
20#define OMAP_PRM_REGADDR(module, reg) \ 20#define OMAP_PRM_REGADDR(module, reg) \
21 (void __iomem *)IO_ADDRESS(OMAP2_PRM_BASE + (module) + (reg)) 21 IO_ADDRESS(OMAP2_PRM_BASE + (module) + (reg))
22#else 22#else
23#define OMAP2420_PRM_REGADDR(module, reg) \ 23#define OMAP2420_PRM_REGADDR(module, reg) \
24 IO_ADDRESS(OMAP2420_PRM_BASE + (module) + (reg)) 24 IO_ADDRESS(OMAP2420_PRM_BASE + (module) + (reg))
@@ -305,7 +305,8 @@ static inline u32 prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
305 * 3430: PM_WKDEP_IVA2, PM_WKDEP_GFX, PM_WKDEP_DSS, PM_WKDEP_CAM, 305 * 3430: PM_WKDEP_IVA2, PM_WKDEP_GFX, PM_WKDEP_DSS, PM_WKDEP_CAM,
306 * PM_WKDEP_PER 306 * PM_WKDEP_PER
307 */ 307 */
308#define OMAP_EN_WKUP (1 << 4) 308#define OMAP_EN_WKUP_SHIFT 4
309#define OMAP_EN_WKUP_MASK (1 << 4)
309 310
310/* 311/*
311 * 24XX: PM_PWSTCTRL_MPU, PM_PWSTCTRL_CORE, PM_PWSTCTRL_GFX, 312 * 24XX: PM_PWSTCTRL_MPU, PM_PWSTCTRL_CORE, PM_PWSTCTRL_GFX,
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 7d9444adc5df..4dcf39c285b9 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * OMAP2 serial support. 4 * OMAP2 serial support.
5 * 5 *
6 * Copyright (C) 2005 Nokia Corporation 6 * Copyright (C) 2005-2008 Nokia Corporation
7 * Author: Paul Mundt <paul.mundt@nokia.com> 7 * Author: Paul Mundt <paul.mundt@nokia.com>
8 * 8 *
9 * Based off of arch/arm/mach-omap/omap1/serial.c 9 * Based off of arch/arm/mach-omap/omap1/serial.c
@@ -22,38 +22,34 @@
22#include <mach/common.h> 22#include <mach/common.h>
23#include <mach/board.h> 23#include <mach/board.h>
24 24
25static struct clk * uart1_ick = NULL; 25static struct clk *uart_ick[OMAP_MAX_NR_PORTS];
26static struct clk * uart1_fck = NULL; 26static struct clk *uart_fck[OMAP_MAX_NR_PORTS];
27static struct clk * uart2_ick = NULL;
28static struct clk * uart2_fck = NULL;
29static struct clk * uart3_ick = NULL;
30static struct clk * uart3_fck = NULL;
31 27
32static struct plat_serial8250_port serial_platform_data[] = { 28static struct plat_serial8250_port serial_platform_data[] = {
33 { 29 {
34 .membase = (char *)IO_ADDRESS(OMAP_UART1_BASE), 30 .membase = IO_ADDRESS(OMAP_UART1_BASE),
35 .mapbase = (unsigned long)OMAP_UART1_BASE, 31 .mapbase = OMAP_UART1_BASE,
36 .irq = 72, 32 .irq = 72,
37 .flags = UPF_BOOT_AUTOCONF, 33 .flags = UPF_BOOT_AUTOCONF,
38 .iotype = UPIO_MEM, 34 .iotype = UPIO_MEM,
39 .regshift = 2, 35 .regshift = 2,
40 .uartclk = OMAP16XX_BASE_BAUD * 16, 36 .uartclk = OMAP24XX_BASE_BAUD * 16,
41 }, { 37 }, {
42 .membase = (char *)IO_ADDRESS(OMAP_UART2_BASE), 38 .membase = IO_ADDRESS(OMAP_UART2_BASE),
43 .mapbase = (unsigned long)OMAP_UART2_BASE, 39 .mapbase = OMAP_UART2_BASE,
44 .irq = 73, 40 .irq = 73,
45 .flags = UPF_BOOT_AUTOCONF, 41 .flags = UPF_BOOT_AUTOCONF,
46 .iotype = UPIO_MEM, 42 .iotype = UPIO_MEM,
47 .regshift = 2, 43 .regshift = 2,
48 .uartclk = OMAP16XX_BASE_BAUD * 16, 44 .uartclk = OMAP24XX_BASE_BAUD * 16,
49 }, { 45 }, {
50 .membase = (char *)IO_ADDRESS(OMAP_UART3_BASE), 46 .membase = IO_ADDRESS(OMAP_UART3_BASE),
51 .mapbase = (unsigned long)OMAP_UART3_BASE, 47 .mapbase = OMAP_UART3_BASE,
52 .irq = 74, 48 .irq = 74,
53 .flags = UPF_BOOT_AUTOCONF, 49 .flags = UPF_BOOT_AUTOCONF,
54 .iotype = UPIO_MEM, 50 .iotype = UPIO_MEM,
55 .regshift = 2, 51 .regshift = 2,
56 .uartclk = OMAP16XX_BASE_BAUD * 16, 52 .uartclk = OMAP24XX_BASE_BAUD * 16,
57 }, { 53 }, {
58 .flags = 0 54 .flags = 0
59 } 55 }
@@ -70,7 +66,7 @@ static inline void serial_write_reg(struct plat_serial8250_port *p, int offset,
70 int value) 66 int value)
71{ 67{
72 offset <<= p->regshift; 68 offset <<= p->regshift;
73 __raw_writeb(value, (unsigned long)(p->membase + offset)); 69 __raw_writeb(value, p->membase + offset);
74} 70}
75 71
76/* 72/*
@@ -86,10 +82,27 @@ static inline void __init omap_serial_reset(struct plat_serial8250_port *p)
86 serial_write_reg(p, UART_OMAP_SYSC, (0x02 << 3) | (1 << 2) | (1 << 0)); 82 serial_write_reg(p, UART_OMAP_SYSC, (0x02 << 3) | (1 << 2) | (1 << 0));
87} 83}
88 84
89void __init omap_serial_init() 85void omap_serial_enable_clocks(int enable)
86{
87 int i;
88 for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
89 if (uart_ick[i] && uart_fck[i]) {
90 if (enable) {
91 clk_enable(uart_ick[i]);
92 clk_enable(uart_fck[i]);
93 } else {
94 clk_disable(uart_ick[i]);
95 clk_disable(uart_fck[i]);
96 }
97 }
98 }
99}
100
101void __init omap_serial_init(void)
90{ 102{
91 int i; 103 int i;
92 const struct omap_uart_config *info; 104 const struct omap_uart_config *info;
105 char name[16];
93 106
94 /* 107 /*
95 * Make sure the serial ports are muxed on at this point. 108 * Make sure the serial ports are muxed on at this point.
@@ -97,8 +110,7 @@ void __init omap_serial_init()
97 * if not needed. 110 * if not needed.
98 */ 111 */
99 112
100 info = omap_get_config(OMAP_TAG_UART, 113 info = omap_get_config(OMAP_TAG_UART, struct omap_uart_config);
101 struct omap_uart_config);
102 114
103 if (info == NULL) 115 if (info == NULL)
104 return; 116 return;
@@ -107,58 +119,26 @@ void __init omap_serial_init()
107 struct plat_serial8250_port *p = serial_platform_data + i; 119 struct plat_serial8250_port *p = serial_platform_data + i;
108 120
109 if (!(info->enabled_uarts & (1 << i))) { 121 if (!(info->enabled_uarts & (1 << i))) {
110 p->membase = 0; 122 p->membase = NULL;
111 p->mapbase = 0; 123 p->mapbase = 0;
112 continue; 124 continue;
113 } 125 }
114 126
115 switch (i) { 127 sprintf(name, "uart%d_ick", i+1);
116 case 0: 128 uart_ick[i] = clk_get(NULL, name);
117 uart1_ick = clk_get(NULL, "uart1_ick"); 129 if (IS_ERR(uart_ick[i])) {
118 if (IS_ERR(uart1_ick)) 130 printk(KERN_ERR "Could not get uart%d_ick\n", i+1);
119 printk("Could not get uart1_ick\n"); 131 uart_ick[i] = NULL;
120 else { 132 } else
121 clk_enable(uart1_ick); 133 clk_enable(uart_ick[i]);
122 } 134
123 135 sprintf(name, "uart%d_fck", i+1);
124 uart1_fck = clk_get(NULL, "uart1_fck"); 136 uart_fck[i] = clk_get(NULL, name);
125 if (IS_ERR(uart1_fck)) 137 if (IS_ERR(uart_fck[i])) {
126 printk("Could not get uart1_fck\n"); 138 printk(KERN_ERR "Could not get uart%d_fck\n", i+1);
127 else { 139 uart_fck[i] = NULL;
128 clk_enable(uart1_fck); 140 } else
129 } 141 clk_enable(uart_fck[i]);
130 break;
131 case 1:
132 uart2_ick = clk_get(NULL, "uart2_ick");
133 if (IS_ERR(uart2_ick))
134 printk("Could not get uart2_ick\n");
135 else {
136 clk_enable(uart2_ick);
137 }
138
139 uart2_fck = clk_get(NULL, "uart2_fck");
140 if (IS_ERR(uart2_fck))
141 printk("Could not get uart2_fck\n");
142 else {
143 clk_enable(uart2_fck);
144 }
145 break;
146 case 2:
147 uart3_ick = clk_get(NULL, "uart3_ick");
148 if (IS_ERR(uart3_ick))
149 printk("Could not get uart3_ick\n");
150 else {
151 clk_enable(uart3_ick);
152 }
153
154 uart3_fck = clk_get(NULL, "uart3_fck");
155 if (IS_ERR(uart3_fck))
156 printk("Could not get uart3_fck\n");
157 else {
158 clk_enable(uart3_fck);
159 }
160 break;
161 }
162 142
163 omap_serial_reset(p); 143 omap_serial_reset(p);
164 } 144 }
diff --git a/arch/arm/mach-omap2/sleep.S b/arch/arm/mach-omap2/sleep24xx.S
index 87a706fd5f82..43336b93b21c 100644
--- a/arch/arm/mach-omap2/sleep.S
+++ b/arch/arm/mach-omap2/sleep24xx.S
@@ -5,6 +5,10 @@
5 * Texas Instruments, <www.ti.com> 5 * Texas Instruments, <www.ti.com>
6 * Richard Woodruff <r-woodruff2@ti.com> 6 * Richard Woodruff <r-woodruff2@ti.com>
7 * 7 *
8 * (C) Copyright 2006 Nokia Corporation
9 * Fixed idle loop sleep
10 * Igor Stoppa <igor.stoppa@nokia.com>
11 *
8 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 13 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 14 * published by the Free Software Foundation; either version 2 of
@@ -26,6 +30,8 @@
26#include <mach/io.h> 30#include <mach/io.h>
27#include <mach/pm.h> 31#include <mach/pm.h>
28 32
33#include <mach/omap24xx.h>
34
29#include "sdrc.h" 35#include "sdrc.h"
30 36
31/* First address of reserved address space? apparently valid for OMAP2 & 3 */ 37/* First address of reserved address space? apparently valid for OMAP2 & 3 */
@@ -52,15 +58,14 @@ ENTRY(omap24xx_idle_loop_suspend_sz)
52 .word . - omap24xx_idle_loop_suspend 58 .word . - omap24xx_idle_loop_suspend
53 59
54/* 60/*
55 * omap242x_cpu_suspend() - Forces OMAP into deep sleep state by completing 61 * omap24xx_cpu_suspend() - Forces OMAP into deep sleep state by completing
56 * SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore 62 * SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore
57 * SDRC. 63 * SDRC.
58 * 64 *
59 * Input: 65 * Input:
60 * R0 : DLL ctrl value pre-Sleep 66 * R0 : DLL ctrl value pre-Sleep
61 * R1 : Processor+Revision 67 * R1 : SDRC_DLLA_CTRL
62 * 2420: 0x21 = 242xES1, 0x26 = 242xES2.2 68 * R2 : SDRC_POWER
63 * 2430: 0x31 = 2430ES1, 0x32 = 2430ES2
64 * 69 *
65 * The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on 70 * The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on
66 * when we get called, but the DLL probably isn't. We will wait a bit more in 71 * when we get called, but the DLL probably isn't. We will wait a bit more in
@@ -80,15 +85,14 @@ ENTRY(omap24xx_idle_loop_suspend_sz)
80 */ 85 */
81ENTRY(omap24xx_cpu_suspend) 86ENTRY(omap24xx_cpu_suspend)
82 stmfd sp!, {r0 - r12, lr} @ save registers on stack 87 stmfd sp!, {r0 - r12, lr} @ save registers on stack
83 mov r3, #0x0 @ clear for mrc call 88 mov r3, #0x0 @ clear for mcr call
84 mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished 89 mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished
85 nop 90 nop
86 nop 91 nop
87 ldr r3, A_SDRC_POWER @ addr of sdrc power 92 ldr r4, [r2] @ read SDRC_POWER
88 ldr r4, [r3] @ value of sdrc power
89 orr r4, r4, #0x40 @ enable self refresh on idle req 93 orr r4, r4, #0x40 @ enable self refresh on idle req
90 mov r5, #0x2000 @ set delay (DPLL relock + DLL relock) 94 mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
91 str r4, [r3] @ make it so 95 str r4, [r2] @ make it so
92 mov r2, #0 96 mov r2, #0
93 nop 97 nop
94 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt 98 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
@@ -97,14 +101,13 @@ loop:
97 subs r5, r5, #0x1 @ awake, wait just a bit 101 subs r5, r5, #0x1 @ awake, wait just a bit
98 bne loop 102 bne loop
99 103
100 /* The DPLL has on before we take the DDR out of self refresh */ 104 /* The DPLL has to be on before we take the DDR out of self refresh */
101 bic r4, r4, #0x40 @ now clear self refresh bit. 105 bic r4, r4, #0x40 @ now clear self refresh bit.
102 str r4, [r3] @ put vlaue back. 106 str r4, [r2] @ write to SDRC_POWER
103 ldr r4, A_SDRC0 @ make a clock happen 107 ldr r4, A_SDRC0 @ make a clock happen
104 ldr r4, [r4] 108 ldr r4, [r4] @ read A_SDRC0
105 nop @ start auto refresh only after clk ok 109 nop @ start auto refresh only after clk ok
106 movs r0, r0 @ see if DDR or SDR 110 movs r0, r0 @ see if DDR or SDR
107 ldrne r1, A_SDRC_DLLA_CTRL_S @ get addr of DLL ctrl
108 strne r0, [r1] @ rewrite DLLA to force DLL reload 111 strne r0, [r1] @ rewrite DLLA to force DLL reload
109 addne r1, r1, #0x8 @ move to DLLB 112 addne r1, r1, #0x8 @ move to DLLB
110 strne r0, [r1] @ rewrite DLLB to force DLL reload 113 strne r0, [r1] @ rewrite DLLB to force DLL reload
@@ -116,13 +119,8 @@ loop2:
116 /* resume*/ 119 /* resume*/
117 ldmfd sp!, {r0 - r12, pc} @ restore regs and return 120 ldmfd sp!, {r0 - r12, pc} @ restore regs and return
118 121
119A_SDRC_POWER:
120 .word OMAP242X_SDRC_REGADDR(SDRC_POWER)
121A_SDRC0: 122A_SDRC0:
122 .word A_SDRC0_V 123 .word A_SDRC0_V
123A_SDRC_DLLA_CTRL_S:
124 .word OMAP242X_SDRC_REGADDR(SDRC_DLLA_CTRL)
125 124
126ENTRY(omap24xx_cpu_suspend_sz) 125ENTRY(omap24xx_cpu_suspend_sz)
127 .word . - omap24xx_cpu_suspend 126 .word . - omap24xx_cpu_suspend
128
diff --git a/arch/arm/mach-omap2/sram34xx.S b/arch/arm/mach-omap2/sram34xx.S
new file mode 100644
index 000000000000..2c7146136342
--- /dev/null
+++ b/arch/arm/mach-omap2/sram34xx.S
@@ -0,0 +1,179 @@
1/*
2 * linux/arch/arm/mach-omap3/sram.S
3 *
4 * Omap3 specific functions that need to be run in internal SRAM
5 *
6 * (C) Copyright 2007
7 * Texas Instruments Inc.
8 * Rajendra Nayak <rnayak@ti.com>
9 *
10 * (C) Copyright 2004
11 * Texas Instruments, <www.ti.com>
12 * Richard Woodruff <r-woodruff2@ti.com>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
29#include <linux/linkage.h>
30#include <asm/assembler.h>
31#include <mach/hardware.h>
32
33#include <mach/io.h>
34
35#include "sdrc.h"
36#include "cm.h"
37
38 .text
39
40/*
41 * Change frequency of core dpll
42 * r0 = sdrc_rfr_ctrl r1 = sdrc_actim_ctrla r2 = sdrc_actim_ctrlb r3 = M2
43 */
44ENTRY(omap3_sram_configure_core_dpll)
45 stmfd sp!, {r1-r12, lr} @ store regs to stack
46 cmp r3, #0x2
47 blne configure_sdrc
48 cmp r3, #0x2
49 blne lock_dll
50 cmp r3, #0x1
51 blne unlock_dll
52 bl sdram_in_selfrefresh @ put the SDRAM in self refresh
53 bl configure_core_dpll
54 bl enable_sdrc
55 cmp r3, #0x1
56 blne wait_dll_unlock
57 cmp r3, #0x2
58 blne wait_dll_lock
59 cmp r3, #0x1
60 blne configure_sdrc
61 mov r0, #0 @ return value
62 ldmfd sp!, {r1-r12, pc} @ restore regs and return
63unlock_dll:
64 ldr r4, omap3_sdrc_dlla_ctrl
65 ldr r5, [r4]
66 orr r5, r5, #0x4
67 str r5, [r4]
68 bx lr
69lock_dll:
70 ldr r4, omap3_sdrc_dlla_ctrl
71 ldr r5, [r4]
72 bic r5, r5, #0x4
73 str r5, [r4]
74 bx lr
75sdram_in_selfrefresh:
76 mov r5, #0x0 @ Move 0 to R5
77 mcr p15, 0, r5, c7, c10, 5 @ memory barrier
78 ldr r4, omap3_sdrc_power @ read the SDRC_POWER register
79 ldr r5, [r4] @ read the contents of SDRC_POWER
80 orr r5, r5, #0x40 @ enable self refresh on idle req
81 str r5, [r4] @ write back to SDRC_POWER register
82 ldr r4, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg
83 ldr r5, [r4]
84 bic r5, r5, #0x2 @ disable iclk bit for SRDC
85 str r5, [r4]
86wait_sdrc_idle:
87 ldr r4, omap3_cm_idlest1_core
88 ldr r5, [r4]
89 and r5, r5, #0x2 @ check for SDRC idle
90 cmp r5, #2
91 bne wait_sdrc_idle
92 bx lr
93configure_core_dpll:
94 ldr r4, omap3_cm_clksel1_pll
95 ldr r5, [r4]
96 ldr r6, core_m2_mask_val @ modify m2 for core dpll
97 and r5, r5, r6
98 orr r5, r5, r3, lsl #0x1B @ r3 contains the M2 val
99 str r5, [r4]
100 mov r5, #0x800 @ wait for the clock to stabilise
101 cmp r3, #2
102 bne wait_clk_stable
103 bx lr
104wait_clk_stable:
105 subs r5, r5, #1
106 bne wait_clk_stable
107 nop
108 nop
109 nop
110 nop
111 nop
112 nop
113 nop
114 nop
115 nop
116 nop
117 bx lr
118enable_sdrc:
119 ldr r4, omap3_cm_iclken1_core
120 ldr r5, [r4]
121 orr r5, r5, #0x2 @ enable iclk bit for SDRC
122 str r5, [r4]
123wait_sdrc_idle1:
124 ldr r4, omap3_cm_idlest1_core
125 ldr r5, [r4]
126 and r5, r5, #0x2
127 cmp r5, #0
128 bne wait_sdrc_idle1
129 ldr r4, omap3_sdrc_power
130 ldr r5, [r4]
131 bic r5, r5, #0x40
132 str r5, [r4]
133 bx lr
134wait_dll_lock:
135 ldr r4, omap3_sdrc_dlla_status
136 ldr r5, [r4]
137 and r5, r5, #0x4
138 cmp r5, #0x4
139 bne wait_dll_lock
140 bx lr
141wait_dll_unlock:
142 ldr r4, omap3_sdrc_dlla_status
143 ldr r5, [r4]
144 and r5, r5, #0x4
145 cmp r5, #0x0
146 bne wait_dll_unlock
147 bx lr
148configure_sdrc:
149 ldr r4, omap3_sdrc_rfr_ctrl
150 str r0, [r4]
151 ldr r4, omap3_sdrc_actim_ctrla
152 str r1, [r4]
153 ldr r4, omap3_sdrc_actim_ctrlb
154 str r2, [r4]
155 bx lr
156
157omap3_sdrc_power:
158 .word OMAP34XX_SDRC_REGADDR(SDRC_POWER)
159omap3_cm_clksel1_pll:
160 .word OMAP34XX_CM_REGADDR(PLL_MOD, CM_CLKSEL1)
161omap3_cm_idlest1_core:
162 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST)
163omap3_cm_iclken1_core:
164 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1)
165omap3_sdrc_rfr_ctrl:
166 .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0)
167omap3_sdrc_actim_ctrla:
168 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0)
169omap3_sdrc_actim_ctrlb:
170 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0)
171omap3_sdrc_dlla_status:
172 .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
173omap3_sdrc_dlla_ctrl:
174 .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
175core_m2_mask_val:
176 .word 0x07FFFFFF
177
178ENTRY(omap3_sram_configure_core_dpll_sz)
179 .word . - omap3_sram_configure_core_dpll
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index f27f6b3d6e6f..f781873431f3 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -257,7 +257,6 @@ config MACH_ARMCORE
257 bool "CompuLab CM-X255/CM-X270 modules" 257 bool "CompuLab CM-X255/CM-X270 modules"
258 select PXA27x 258 select PXA27x
259 select IWMMXT 259 select IWMMXT
260 select ZONE_DMA if PCI
261 select PXA25x 260 select PXA25x
262 select PXA_SSP 261 select PXA_SSP
263 262
diff --git a/arch/arm/mach-pxa/cm-x270.c b/arch/arm/mach-pxa/cm-x270.c
index a82dad1a8cc8..df83b97f303f 100644
--- a/arch/arm/mach-pxa/cm-x270.c
+++ b/arch/arm/mach-pxa/cm-x270.c
@@ -162,7 +162,7 @@ static void __init cmx270_init_rtc(void)
162 platform_device_register(&cmx270_rtc_device); 162 platform_device_register(&cmx270_rtc_device);
163} 163}
164#else 164#else
165static inline void cmx2xx_init_rtc(void) {} 165static inline void cmx270_init_rtc(void) {}
166#endif 166#endif
167 167
168/* 2700G graphics */ 168/* 2700G graphics */
diff --git a/arch/arm/mach-pxa/cpufreq-pxa2xx.c b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
index d82528e74bd0..1f272ea83f36 100644
--- a/arch/arm/mach-pxa/cpufreq-pxa2xx.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
@@ -335,9 +335,6 @@ static __init int pxa_cpufreq_init(struct cpufreq_policy *policy)
335 pxa27x_guess_max_freq(); 335 pxa27x_guess_max_freq();
336 336
337 /* set default policy and cpuinfo */ 337 /* set default policy and cpuinfo */
338 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
339 if (cpu_is_pxa25x())
340 policy->policy = CPUFREQ_POLICY_PERFORMANCE;
341 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ 338 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
342 policy->cur = get_clk_frequency_khz(0); /* current freq */ 339 policy->cur = get_clk_frequency_khz(0); /* current freq */
343 policy->min = policy->max = policy->cur; 340 policy->min = policy->max = policy->cur;
diff --git a/arch/arm/mach-pxa/cpufreq-pxa3xx.c b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
index 1ea0c9c0adaf..968c8309ec37 100644
--- a/arch/arm/mach-pxa/cpufreq-pxa3xx.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
@@ -210,7 +210,6 @@ static __init int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
210 int ret = -EINVAL; 210 int ret = -EINVAL;
211 211
212 /* set default policy and cpuinfo */ 212 /* set default policy and cpuinfo */
213 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
214 policy->cpuinfo.min_freq = 104000; 213 policy->cpuinfo.min_freq = 104000;
215 policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000; 214 policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000;
216 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ 215 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
diff --git a/arch/arm/mach-pxa/include/mach/irqs.h b/arch/arm/mach-pxa/include/mach/irqs.h
index 9c163e19ada9..32bb4a2eb7f1 100644
--- a/arch/arm/mach-pxa/include/mach/irqs.h
+++ b/arch/arm/mach-pxa/include/mach/irqs.h
@@ -9,7 +9,8 @@
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12#ifndef __ASM_MACH_IRQS_H
13#define __ASM_MACH_IRQS_H
13 14
14#ifdef CONFIG_PXA_HAVE_ISA_IRQS 15#ifdef CONFIG_PXA_HAVE_ISA_IRQS
15#define PXA_ISA_IRQ(x) (x) 16#define PXA_ISA_IRQ(x) (x)
@@ -264,3 +265,5 @@
264#endif 265#endif
265 266
266#endif /* CONFIG_PCI_HOST_ITE8152 */ 267#endif /* CONFIG_PCI_HOST_ITE8152 */
268
269#endif /* __ASM_MACH_IRQS_H */
diff --git a/arch/arm/mach-pxa/pwm.c b/arch/arm/mach-pxa/pwm.c
index 316cd986da5c..74e2ead8cee8 100644
--- a/arch/arm/mach-pxa/pwm.c
+++ b/arch/arm/mach-pxa/pwm.c
@@ -60,7 +60,7 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
60 do_div(c, 1000000000); 60 do_div(c, 1000000000);
61 period_cycles = c; 61 period_cycles = c;
62 62
63 if (period_cycles < 0) 63 if (period_cycles < 1)
64 period_cycles = 1; 64 period_cycles = 1;
65 prescale = (period_cycles - 1) / 1024; 65 prescale = (period_cycles - 1) / 1024;
66 pv = period_cycles / (prescale + 1) - 1; 66 pv = period_cycles / (prescale + 1) - 1;
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index d7632f63603c..4b3120dbc049 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -204,25 +204,54 @@ static void viper_set_core_cpu_voltage(unsigned long khz, int force)
204 204
205/* Interrupt handling */ 205/* Interrupt handling */
206static unsigned long viper_irq_enabled_mask; 206static unsigned long viper_irq_enabled_mask;
207static const int viper_isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, 9, 14, 15 };
208static const int viper_isa_irq_map[] = {
209 0, /* ISA irq #0, invalid */
210 0, /* ISA irq #1, invalid */
211 0, /* ISA irq #2, invalid */
212 1 << 0, /* ISA irq #3 */
213 1 << 1, /* ISA irq #4 */
214 1 << 2, /* ISA irq #5 */
215 1 << 3, /* ISA irq #6 */
216 1 << 4, /* ISA irq #7 */
217 0, /* ISA irq #8, invalid */
218 1 << 8, /* ISA irq #9 */
219 1 << 5, /* ISA irq #10 */
220 1 << 6, /* ISA irq #11 */
221 1 << 7, /* ISA irq #12 */
222 0, /* ISA irq #13, invalid */
223 1 << 9, /* ISA irq #14 */
224 1 << 10, /* ISA irq #15 */
225};
226
227static inline int viper_irq_to_bitmask(unsigned int irq)
228{
229 return viper_isa_irq_map[irq - PXA_ISA_IRQ(0)];
230}
231
232static inline int viper_bit_to_irq(int bit)
233{
234 return viper_isa_irqs[bit] + PXA_ISA_IRQ(0);
235}
207 236
208static void viper_ack_irq(unsigned int irq) 237static void viper_ack_irq(unsigned int irq)
209{ 238{
210 int viper_irq = irq - PXA_ISA_IRQ(0); 239 int viper_irq = viper_irq_to_bitmask(irq);
211 240
212 if (viper_irq < 8) 241 if (viper_irq & 0xff)
213 VIPER_LO_IRQ_STATUS = 1 << viper_irq; 242 VIPER_LO_IRQ_STATUS = viper_irq;
214 else 243 else
215 VIPER_HI_IRQ_STATUS = 1 << (viper_irq - 8); 244 VIPER_HI_IRQ_STATUS = (viper_irq >> 8);
216} 245}
217 246
218static void viper_mask_irq(unsigned int irq) 247static void viper_mask_irq(unsigned int irq)
219{ 248{
220 viper_irq_enabled_mask &= ~(1 << (irq - PXA_ISA_IRQ(0))); 249 viper_irq_enabled_mask &= ~(viper_irq_to_bitmask(irq));
221} 250}
222 251
223static void viper_unmask_irq(unsigned int irq) 252static void viper_unmask_irq(unsigned int irq)
224{ 253{
225 viper_irq_enabled_mask |= (1 << (irq - PXA_ISA_IRQ(0))); 254 viper_irq_enabled_mask |= viper_irq_to_bitmask(irq);
226} 255}
227 256
228static inline unsigned long viper_irq_pending(void) 257static inline unsigned long viper_irq_pending(void)
@@ -237,8 +266,12 @@ static void viper_irq_handler(unsigned int irq, struct irq_desc *desc)
237 266
238 pending = viper_irq_pending(); 267 pending = viper_irq_pending();
239 do { 268 do {
269 /* we're in a chained irq handler,
270 * so ack the interrupt by hand */
271 GEDR(VIPER_CPLD_GPIO) = GPIO_bit(VIPER_CPLD_GPIO);
272
240 if (likely(pending)) { 273 if (likely(pending)) {
241 irq = PXA_ISA_IRQ(0) + __ffs(pending); 274 irq = viper_bit_to_irq(__ffs(pending));
242 generic_handle_irq(irq); 275 generic_handle_irq(irq);
243 } 276 }
244 pending = viper_irq_pending(); 277 pending = viper_irq_pending();
@@ -254,15 +287,14 @@ static struct irq_chip viper_irq_chip = {
254 287
255static void __init viper_init_irq(void) 288static void __init viper_init_irq(void)
256{ 289{
257 const int isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, 9, 14, 15 }; 290 int level;
258 int irq;
259 int isa_irq; 291 int isa_irq;
260 292
261 pxa25x_init_irq(); 293 pxa25x_init_irq();
262 294
263 /* setup ISA IRQs */ 295 /* setup ISA IRQs */
264 for (irq = 0; irq < ARRAY_SIZE(isa_irqs); irq++) { 296 for (level = 0; level < ARRAY_SIZE(viper_isa_irqs); level++) {
265 isa_irq = isa_irqs[irq]; 297 isa_irq = viper_bit_to_irq(level);
266 set_irq_chip(isa_irq, &viper_irq_chip); 298 set_irq_chip(isa_irq, &viper_irq_chip);
267 set_irq_handler(isa_irq, handle_edge_irq); 299 set_irq_handler(isa_irq, handle_edge_irq);
268 set_irq_flags(isa_irq, IRQF_VALID | IRQF_PROBE); 300 set_irq_flags(isa_irq, IRQF_VALID | IRQF_PROBE);
diff --git a/arch/arm/mach-s3c2410/bast-irq.c b/arch/arm/mach-s3c2410/bast-irq.c
index 75738000272b..9a37c87152b0 100644
--- a/arch/arm/mach-s3c2410/bast-irq.c
+++ b/arch/arm/mach-s3c2410/bast-irq.c
@@ -38,7 +38,7 @@
38#include <mach/bast-map.h> 38#include <mach/bast-map.h>
39#include <mach/bast-irq.h> 39#include <mach/bast-irq.h>
40 40
41#include <asm/plat-s3c24xx/irq.h> 41#include <plat/irq.h>
42 42
43#if 0 43#if 0
44#include <asm/debug-ll.h> 44#include <asm/debug-ll.h>
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index fef646c36b54..4e07943c1e29 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -37,13 +37,13 @@
37 37
38#include <mach/hardware.h> 38#include <mach/hardware.h>
39 39
40#include <asm/plat-s3c/regs-serial.h> 40#include <plat/regs-serial.h>
41#include <mach/regs-clock.h> 41#include <mach/regs-clock.h>
42#include <mach/regs-gpio.h> 42#include <mach/regs-gpio.h>
43 43
44#include <asm/plat-s3c24xx/s3c2410.h> 44#include <plat/s3c2410.h>
45#include <asm/plat-s3c24xx/clock.h> 45#include <plat/clock.h>
46#include <asm/plat-s3c24xx/cpu.h> 46#include <plat/cpu.h>
47 47
48int s3c2410_clkcon_enable(struct clk *clk, int enable) 48int s3c2410_clkcon_enable(struct clk *clk, int enable)
49{ 49{
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
index 8730797749e3..7d914a470b6c 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c2410/dma.c
@@ -20,10 +20,10 @@
20#include <asm/dma.h> 20#include <asm/dma.h>
21#include <mach/dma.h> 21#include <mach/dma.h>
22 22
23#include <asm/plat-s3c24xx/cpu.h> 23#include <plat/cpu.h>
24#include <asm/plat-s3c24xx/dma.h> 24#include <plat/dma.h>
25 25
26#include <asm/plat-s3c/regs-serial.h> 26#include <plat/regs-serial.h>
27#include <mach/regs-gpio.h> 27#include <mach/regs-gpio.h>
28#include <asm/plat-s3c/regs-ac97.h> 28#include <asm/plat-s3c/regs-ac97.h>
29#include <mach/regs-mem.h> 29#include <mach/regs-mem.h>
diff --git a/arch/arm/mach-s3c2410/include/mach/debug-macro.S b/arch/arm/mach-s3c2410/include/mach/debug-macro.S
index 682df23087ab..4c29a89ad077 100644
--- a/arch/arm/mach-s3c2410/include/mach/debug-macro.S
+++ b/arch/arm/mach-s3c2410/include/mach/debug-macro.S
@@ -14,7 +14,7 @@
14 14
15#include <mach/map.h> 15#include <mach/map.h>
16#include <mach/regs-gpio.h> 16#include <mach/regs-gpio.h>
17#include <asm/plat-s3c/regs-serial.h> 17#include <plat/regs-serial.h>
18 18
19#define S3C2410_UART1_OFF (0x4000) 19#define S3C2410_UART1_OFF (0x4000)
20#define SHIFT_2440TXF (14-9) 20#define SHIFT_2440TXF (14-9)
@@ -99,4 +99,4 @@
99 99
100/* include the reset of the code which will do the work */ 100/* include the reset of the code which will do the work */
101 101
102#include <asm/plat-s3c/debug-macro.S> 102#include <plat/debug-macro.S>
diff --git a/arch/arm/mach-s3c2410/include/mach/map.h b/arch/arm/mach-s3c2410/include/mach/map.h
index 64bf7e94a5bf..23c470c2e5b1 100644
--- a/arch/arm/mach-s3c2410/include/mach/map.h
+++ b/arch/arm/mach-s3c2410/include/mach/map.h
@@ -13,7 +13,7 @@
13#ifndef __ASM_ARCH_MAP_H 13#ifndef __ASM_ARCH_MAP_H
14#define __ASM_ARCH_MAP_H 14#define __ASM_ARCH_MAP_H
15 15
16#include <asm/plat-s3c/map.h> 16#include <plat/map.h>
17 17
18#define S3C2410_ADDR(x) S3C_ADDR(x) 18#define S3C2410_ADDR(x) S3C_ADDR(x)
19 19
diff --git a/arch/arm/mach-s3c2410/include/mach/spi.h b/arch/arm/mach-s3c2410/include/mach/spi.h
index 921b13b4f0a0..46d46f5b99f2 100644
--- a/arch/arm/mach-s3c2410/include/mach/spi.h
+++ b/arch/arm/mach-s3c2410/include/mach/spi.h
@@ -18,6 +18,7 @@ struct s3c2410_spi_info {
18 unsigned int num_cs; /* total chipselects */ 18 unsigned int num_cs; /* total chipselects */
19 int bus_num; /* bus number to use. */ 19 int bus_num; /* bus number to use. */
20 20
21 void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable);
21 void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); 22 void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol);
22}; 23};
23 24
diff --git a/arch/arm/mach-s3c2410/include/mach/uncompress.h b/arch/arm/mach-s3c2410/include/mach/uncompress.h
index 708e47459ffc..ab39491beee2 100644
--- a/arch/arm/mach-s3c2410/include/mach/uncompress.h
+++ b/arch/arm/mach-s3c2410/include/mach/uncompress.h
@@ -21,7 +21,7 @@
21#undef S3C2410_GPIOREG 21#undef S3C2410_GPIOREG
22#define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x))) 22#define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x)))
23 23
24#include <asm/plat-s3c/uncompress.h> 24#include <plat/uncompress.h>
25 25
26static inline int is_arm926(void) 26static inline int is_arm926(void)
27{ 27{
diff --git a/arch/arm/mach-s3c2410/irq.c b/arch/arm/mach-s3c2410/irq.c
index f5c5c53e1cc1..92150399563b 100644
--- a/arch/arm/mach-s3c2410/irq.c
+++ b/arch/arm/mach-s3c2410/irq.c
@@ -25,8 +25,8 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27 27
28#include <asm/plat-s3c24xx/cpu.h> 28#include <plat/cpu.h>
29#include <asm/plat-s3c24xx/pm.h> 29#include <plat/pm.h>
30 30
31static int s3c2410_irq_add(struct sys_device *sysdev) 31static int s3c2410_irq_add(struct sys_device *sysdev)
32{ 32{
diff --git a/arch/arm/mach-s3c2410/mach-amlm5900.c b/arch/arm/mach-s3c2410/mach-amlm5900.c
index 527f88a288ec..d061fea01900 100644
--- a/arch/arm/mach-s3c2410/mach-amlm5900.c
+++ b/arch/arm/mach-s3c2410/mach-amlm5900.c
@@ -48,12 +48,12 @@
48#include <asm/mach-types.h> 48#include <asm/mach-types.h>
49#include <mach/fb.h> 49#include <mach/fb.h>
50 50
51#include <asm/plat-s3c/regs-serial.h> 51#include <plat/regs-serial.h>
52#include <mach/regs-lcd.h> 52#include <mach/regs-lcd.h>
53#include <mach/regs-gpio.h> 53#include <mach/regs-gpio.h>
54 54
55#include <asm/plat-s3c24xx/devs.h> 55#include <plat/devs.h>
56#include <asm/plat-s3c24xx/cpu.h> 56#include <plat/cpu.h>
57 57
58#ifdef CONFIG_MTD_PARTITIONS 58#ifdef CONFIG_MTD_PARTITIONS
59 59
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index e4368e6e7e6c..8db9c700e3c2 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -39,7 +39,7 @@
39#include <asm/mach-types.h> 39#include <asm/mach-types.h>
40 40
41//#include <asm/debug-ll.h> 41//#include <asm/debug-ll.h>
42#include <asm/plat-s3c/regs-serial.h> 42#include <plat/regs-serial.h>
43#include <mach/regs-gpio.h> 43#include <mach/regs-gpio.h>
44#include <mach/regs-mem.h> 44#include <mach/regs-mem.h>
45#include <mach/regs-lcd.h> 45#include <mach/regs-lcd.h>
@@ -55,9 +55,9 @@
55 55
56#include <linux/serial_8250.h> 56#include <linux/serial_8250.h>
57 57
58#include <asm/plat-s3c24xx/clock.h> 58#include <plat/clock.h>
59#include <asm/plat-s3c24xx/devs.h> 59#include <plat/devs.h>
60#include <asm/plat-s3c24xx/cpu.h> 60#include <plat/cpu.h>
61 61
62#include "usb-simtec.h" 62#include "usb-simtec.h"
63#include "nor-simtec.h" 63#include "nor-simtec.h"
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 85e710f2863b..98716d0108e9 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -30,7 +30,7 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32 32
33#include <asm/plat-s3c/regs-serial.h> 33#include <plat/regs-serial.h>
34#include <mach/regs-lcd.h> 34#include <mach/regs-lcd.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36#include <mach/regs-clock.h> 36#include <mach/regs-clock.h>
@@ -40,10 +40,10 @@
40#include <mach/fb.h> 40#include <mach/fb.h>
41#include <asm/plat-s3c24xx/udc.h> 41#include <asm/plat-s3c24xx/udc.h>
42 42
43#include <asm/plat-s3c24xx/clock.h> 43#include <plat/clock.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <plat/devs.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46#include <asm/plat-s3c24xx/pm.h> 46#include <plat/pm.h>
47 47
48static struct map_desc h1940_iodesc[] __initdata = { 48static struct map_desc h1940_iodesc[] __initdata = {
49 [0] = { 49 [0] = {
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 3ece2d04934e..82505517846c 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -41,12 +41,12 @@
41#include <asm/mach/map.h> 41#include <asm/mach/map.h>
42 42
43#include <asm/plat-s3c/iic.h> 43#include <asm/plat-s3c/iic.h>
44#include <asm/plat-s3c/regs-serial.h> 44#include <plat/regs-serial.h>
45 45
46#include <asm/plat-s3c24xx/clock.h> 46#include <plat/clock.h>
47#include <asm/plat-s3c24xx/cpu.h> 47#include <plat/cpu.h>
48#include <asm/plat-s3c24xx/devs.h> 48#include <plat/devs.h>
49#include <asm/plat-s3c24xx/s3c2410.h> 49#include <plat/s3c2410.h>
50#include <asm/plat-s3c24xx/udc.h> 50#include <asm/plat-s3c24xx/udc.h>
51 51
52static struct map_desc n30_iodesc[] __initdata = { 52static struct map_desc n30_iodesc[] __initdata = {
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c2410/mach-otom.c
index c4dfe3eabe1d..d8255cf87e44 100644
--- a/arch/arm/mach-s3c2410/mach-otom.c
+++ b/arch/arm/mach-s3c2410/mach-otom.c
@@ -29,13 +29,13 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31 31
32#include <asm/plat-s3c/regs-serial.h> 32#include <plat/regs-serial.h>
33#include <mach/regs-gpio.h> 33#include <mach/regs-gpio.h>
34 34
35#include <asm/plat-s3c24xx/s3c2410.h> 35#include <plat/s3c2410.h>
36#include <asm/plat-s3c24xx/clock.h> 36#include <plat/clock.h>
37#include <asm/plat-s3c24xx/devs.h> 37#include <plat/devs.h>
38#include <asm/plat-s3c24xx/cpu.h> 38#include <plat/cpu.h>
39 39
40static struct map_desc otom11_iodesc[] __initdata = { 40static struct map_desc otom11_iodesc[] __initdata = {
41 /* Device area */ 41 /* Device area */
diff --git a/arch/arm/mach-s3c2410/mach-qt2410.c b/arch/arm/mach-s3c2410/mach-qt2410.c
index 97c13192315b..661807e14e8a 100644
--- a/arch/arm/mach-s3c2410/mach-qt2410.c
+++ b/arch/arm/mach-s3c2410/mach-qt2410.c
@@ -48,17 +48,17 @@
48 48
49#include <mach/regs-gpio.h> 49#include <mach/regs-gpio.h>
50#include <mach/leds-gpio.h> 50#include <mach/leds-gpio.h>
51#include <asm/plat-s3c/regs-serial.h> 51#include <plat/regs-serial.h>
52#include <mach/fb.h> 52#include <mach/fb.h>
53#include <asm/plat-s3c/nand.h> 53#include <asm/plat-s3c/nand.h>
54#include <asm/plat-s3c24xx/udc.h> 54#include <asm/plat-s3c24xx/udc.h>
55#include <mach/spi.h> 55#include <mach/spi.h>
56#include <mach/spi-gpio.h> 56#include <mach/spi-gpio.h>
57 57
58#include <asm/plat-s3c24xx/common-smdk.h> 58#include <plat/common-smdk.h>
59#include <asm/plat-s3c24xx/devs.h> 59#include <plat/devs.h>
60#include <asm/plat-s3c24xx/cpu.h> 60#include <plat/cpu.h>
61#include <asm/plat-s3c24xx/pm.h> 61#include <plat/pm.h>
62 62
63static struct map_desc qt2410_iodesc[] __initdata = { 63static struct map_desc qt2410_iodesc[] __initdata = {
64 { 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE } 64 { 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE }
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
index d49e58acb03b..152527bb2872 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c
@@ -46,12 +46,12 @@
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/mach-types.h> 47#include <asm/mach-types.h>
48 48
49#include <asm/plat-s3c/regs-serial.h> 49#include <plat/regs-serial.h>
50 50
51#include <asm/plat-s3c24xx/devs.h> 51#include <plat/devs.h>
52#include <asm/plat-s3c24xx/cpu.h> 52#include <plat/cpu.h>
53 53
54#include <asm/plat-s3c24xx/common-smdk.h> 54#include <plat/common-smdk.h>
55 55
56static struct map_desc smdk2410_iodesc[] __initdata = { 56static struct map_desc smdk2410_iodesc[] __initdata = {
57 /* nothing here yet */ 57 /* nothing here yet */
diff --git a/arch/arm/mach-s3c2410/mach-tct_hammer.c b/arch/arm/mach-s3c2410/mach-tct_hammer.c
index cc2e79fe4f9f..309dcf4c870a 100644
--- a/arch/arm/mach-s3c2410/mach-tct_hammer.c
+++ b/arch/arm/mach-s3c2410/mach-tct_hammer.c
@@ -44,9 +44,9 @@
44#include <asm/irq.h> 44#include <asm/irq.h>
45#include <asm/mach-types.h> 45#include <asm/mach-types.h>
46 46
47#include <asm/plat-s3c/regs-serial.h> 47#include <plat/regs-serial.h>
48#include <asm/plat-s3c24xx/devs.h> 48#include <plat/devs.h>
49#include <asm/plat-s3c24xx/cpu.h> 49#include <plat/cpu.h>
50 50
51#ifdef CONFIG_MTD_PARTITIONS 51#ifdef CONFIG_MTD_PARTITIONS
52 52
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
index ed3acb05c855..941353af16dc 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c
@@ -40,13 +40,13 @@
40#include <asm/irq.h> 40#include <asm/irq.h>
41#include <asm/mach-types.h> 41#include <asm/mach-types.h>
42 42
43#include <asm/plat-s3c/regs-serial.h> 43#include <plat/regs-serial.h>
44#include <mach/regs-gpio.h> 44#include <mach/regs-gpio.h>
45#include <mach/leds-gpio.h> 45#include <mach/leds-gpio.h>
46 46
47#include <asm/plat-s3c24xx/clock.h> 47#include <plat/clock.h>
48#include <asm/plat-s3c24xx/devs.h> 48#include <plat/devs.h>
49#include <asm/plat-s3c24xx/cpu.h> 49#include <plat/cpu.h>
50 50
51#include "usb-simtec.h" 51#include "usb-simtec.h"
52#include "nor-simtec.h" 52#include "nor-simtec.h"
diff --git a/arch/arm/mach-s3c2410/pm.c b/arch/arm/mach-s3c2410/pm.c
index 733f8a227775..a6970f613192 100644
--- a/arch/arm/mach-s3c2410/pm.c
+++ b/arch/arm/mach-s3c2410/pm.c
@@ -34,8 +34,8 @@
34#include <mach/regs-gpio.h> 34#include <mach/regs-gpio.h>
35#include <mach/h1940.h> 35#include <mach/h1940.h>
36 36
37#include <asm/plat-s3c24xx/cpu.h> 37#include <plat/cpu.h>
38#include <asm/plat-s3c24xx/pm.h> 38#include <plat/pm.h>
39 39
40#ifdef CONFIG_S3C2410_PM_DEBUG 40#ifdef CONFIG_S3C2410_PM_DEBUG
41extern void pm_dbg(const char *fmt, ...); 41extern void pm_dbg(const char *fmt, ...);
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
index b1e658c917a0..ac79b536c4c3 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c2410/s3c2410.c
@@ -29,12 +29,12 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <mach/regs-clock.h> 31#include <mach/regs-clock.h>
32#include <asm/plat-s3c/regs-serial.h> 32#include <plat/regs-serial.h>
33 33
34#include <asm/plat-s3c24xx/s3c2410.h> 34#include <plat/s3c2410.h>
35#include <asm/plat-s3c24xx/cpu.h> 35#include <plat/cpu.h>
36#include <asm/plat-s3c24xx/devs.h> 36#include <plat/devs.h>
37#include <asm/plat-s3c24xx/clock.h> 37#include <plat/clock.h>
38 38
39/* Initial IO mappings */ 39/* Initial IO mappings */
40 40
diff --git a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c2410/sleep.S
index be37f221a177..dd5b6388a5a5 100644
--- a/arch/arm/mach-s3c2410/sleep.S
+++ b/arch/arm/mach-s3c2410/sleep.S
@@ -32,7 +32,7 @@
32#include <mach/regs-gpio.h> 32#include <mach/regs-gpio.h>
33#include <mach/regs-clock.h> 33#include <mach/regs-clock.h>
34#include <mach/regs-mem.h> 34#include <mach/regs-mem.h>
35#include <asm/plat-s3c/regs-serial.h> 35#include <plat/regs-serial.h>
36 36
37 /* s3c2410_cpu_suspend 37 /* s3c2410_cpu_suspend
38 * 38 *
diff --git a/arch/arm/mach-s3c2410/usb-simtec.c b/arch/arm/mach-s3c2410/usb-simtec.c
index eb6fc0bfd47e..6078f09b7df5 100644
--- a/arch/arm/mach-s3c2410/usb-simtec.c
+++ b/arch/arm/mach-s3c2410/usb-simtec.c
@@ -35,7 +35,7 @@
35#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <asm/irq.h> 36#include <asm/irq.h>
37 37
38#include <asm/plat-s3c24xx/devs.h> 38#include <plat/devs.h>
39#include "usb-simtec.h" 39#include "usb-simtec.h"
40 40
41/* control power and monitor over-current events on various Simtec 41/* control power and monitor over-current events on various Simtec
diff --git a/arch/arm/mach-s3c2412/clock.c b/arch/arm/mach-s3c2412/clock.c
index 5fbaac6054f8..96d9eb15424f 100644
--- a/arch/arm/mach-s3c2412/clock.c
+++ b/arch/arm/mach-s3c2412/clock.c
@@ -37,13 +37,13 @@
37 37
38#include <mach/hardware.h> 38#include <mach/hardware.h>
39 39
40#include <asm/plat-s3c/regs-serial.h> 40#include <plat/regs-serial.h>
41#include <mach/regs-clock.h> 41#include <mach/regs-clock.h>
42#include <mach/regs-gpio.h> 42#include <mach/regs-gpio.h>
43 43
44#include <asm/plat-s3c24xx/s3c2412.h> 44#include <plat/s3c2412.h>
45#include <asm/plat-s3c24xx/clock.h> 45#include <plat/clock.h>
46#include <asm/plat-s3c24xx/cpu.h> 46#include <plat/cpu.h>
47 47
48/* We currently have to assume that the system is running 48/* We currently have to assume that the system is running
49 * from the XTPll input, and that all ***REFCLKs are being 49 * from the XTPll input, and that all ***REFCLKs are being
diff --git a/arch/arm/mach-s3c2412/dma.c b/arch/arm/mach-s3c2412/dma.c
index dcfff6b8b958..ba0591e71f32 100644
--- a/arch/arm/mach-s3c2412/dma.c
+++ b/arch/arm/mach-s3c2412/dma.c
@@ -21,10 +21,10 @@
21#include <asm/dma.h> 21#include <asm/dma.h>
22#include <mach/dma.h> 22#include <mach/dma.h>
23 23
24#include <asm/plat-s3c24xx/dma.h> 24#include <plat/dma.h>
25#include <asm/plat-s3c24xx/cpu.h> 25#include <plat/cpu.h>
26 26
27#include <asm/plat-s3c/regs-serial.h> 27#include <plat/regs-serial.h>
28#include <mach/regs-gpio.h> 28#include <mach/regs-gpio.h>
29#include <asm/plat-s3c/regs-ac97.h> 29#include <asm/plat-s3c/regs-ac97.h>
30#include <mach/regs-mem.h> 30#include <mach/regs-mem.h>
diff --git a/arch/arm/mach-s3c2412/irq.c b/arch/arm/mach-s3c2412/irq.c
index 41720f2c1fea..6000ca9d1815 100644
--- a/arch/arm/mach-s3c2412/irq.c
+++ b/arch/arm/mach-s3c2412/irq.c
@@ -35,9 +35,9 @@
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36#include <mach/regs-power.h> 36#include <mach/regs-power.h>
37 37
38#include <asm/plat-s3c24xx/cpu.h> 38#include <plat/cpu.h>
39#include <asm/plat-s3c24xx/irq.h> 39#include <plat/irq.h>
40#include <asm/plat-s3c24xx/pm.h> 40#include <plat/pm.h>
41 41
42#define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1) 42#define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1)
43#define INTMSK_SUB(start, end) (INTMSK(start, end) << ((start - S3C2410_IRQSUB(0)))) 43#define INTMSK_SUB(start, end) (INTMSK(start, end) << ((start - S3C2410_IRQSUB(0))))
diff --git a/arch/arm/mach-s3c2412/mach-jive.c b/arch/arm/mach-s3c2412/mach-jive.c
index ad980a1690c2..b08f18c8c47a 100644
--- a/arch/arm/mach-s3c2412/mach-jive.c
+++ b/arch/arm/mach-s3c2412/mach-jive.c
@@ -30,7 +30,7 @@
30#include <asm/mach/map.h> 30#include <asm/mach/map.h>
31#include <asm/mach/irq.h> 31#include <asm/mach/irq.h>
32 32
33#include <asm/plat-s3c/regs-serial.h> 33#include <plat/regs-serial.h>
34#include <asm/plat-s3c/nand.h> 34#include <asm/plat-s3c/nand.h>
35#include <asm/plat-s3c/iic.h> 35#include <asm/plat-s3c/iic.h>
36 36
@@ -48,10 +48,10 @@
48#include <linux/mtd/nand_ecc.h> 48#include <linux/mtd/nand_ecc.h>
49#include <linux/mtd/partitions.h> 49#include <linux/mtd/partitions.h>
50 50
51#include <asm/plat-s3c24xx/clock.h> 51#include <plat/clock.h>
52#include <asm/plat-s3c24xx/devs.h> 52#include <plat/devs.h>
53#include <asm/plat-s3c24xx/cpu.h> 53#include <plat/cpu.h>
54#include <asm/plat-s3c24xx/pm.h> 54#include <plat/pm.h>
55#include <asm/plat-s3c24xx/udc.h> 55#include <asm/plat-s3c24xx/udc.h>
56 56
57static struct map_desc jive_iodesc[] __initdata = { 57static struct map_desc jive_iodesc[] __initdata = {
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c2412/mach-smdk2413.c
index 8f8d9117b968..c719b5a740a9 100644
--- a/arch/arm/mach-s3c2412/mach-smdk2413.c
+++ b/arch/arm/mach-s3c2412/mach-smdk2413.c
@@ -32,7 +32,7 @@
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34//#include <asm/debug-ll.h> 34//#include <asm/debug-ll.h>
35#include <asm/plat-s3c/regs-serial.h> 35#include <plat/regs-serial.h>
36#include <mach/regs-gpio.h> 36#include <mach/regs-gpio.h>
37#include <mach/regs-lcd.h> 37#include <mach/regs-lcd.h>
38 38
@@ -40,13 +40,13 @@
40#include <asm/plat-s3c24xx/udc.h> 40#include <asm/plat-s3c24xx/udc.h>
41#include <mach/fb.h> 41#include <mach/fb.h>
42 42
43#include <asm/plat-s3c24xx/s3c2410.h> 43#include <plat/s3c2410.h>
44#include <asm/plat-s3c24xx/s3c2412.h> 44#include <plat/s3c2412.h>
45#include <asm/plat-s3c24xx/clock.h> 45#include <plat/clock.h>
46#include <asm/plat-s3c24xx/devs.h> 46#include <plat/devs.h>
47#include <asm/plat-s3c24xx/cpu.h> 47#include <plat/cpu.h>
48 48
49#include <asm/plat-s3c24xx/common-smdk.h> 49#include <plat/common-smdk.h>
50 50
51static struct map_desc smdk2413_iodesc[] __initdata = { 51static struct map_desc smdk2413_iodesc[] __initdata = {
52}; 52};
diff --git a/arch/arm/mach-s3c2412/mach-vstms.c b/arch/arm/mach-s3c2412/mach-vstms.c
index bb9bf63b2e02..4cfa19ad9be0 100644
--- a/arch/arm/mach-s3c2412/mach-vstms.c
+++ b/arch/arm/mach-s3c2412/mach-vstms.c
@@ -32,7 +32,7 @@
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/mach-types.h> 33#include <asm/mach-types.h>
34 34
35#include <asm/plat-s3c/regs-serial.h> 35#include <plat/regs-serial.h>
36#include <mach/regs-gpio.h> 36#include <mach/regs-gpio.h>
37#include <mach/regs-lcd.h> 37#include <mach/regs-lcd.h>
38 38
@@ -41,11 +41,11 @@
41 41
42#include <asm/plat-s3c/nand.h> 42#include <asm/plat-s3c/nand.h>
43 43
44#include <asm/plat-s3c24xx/s3c2410.h> 44#include <plat/s3c2410.h>
45#include <asm/plat-s3c24xx/s3c2412.h> 45#include <plat/s3c2412.h>
46#include <asm/plat-s3c24xx/clock.h> 46#include <plat/clock.h>
47#include <asm/plat-s3c24xx/devs.h> 47#include <plat/devs.h>
48#include <asm/plat-s3c24xx/cpu.h> 48#include <plat/cpu.h>
49 49
50 50
51static struct map_desc vstms_iodesc[] __initdata = { 51static struct map_desc vstms_iodesc[] __initdata = {
diff --git a/arch/arm/mach-s3c2412/pm.c b/arch/arm/mach-s3c2412/pm.c
index 9540ef752f73..217e9e4ed45f 100644
--- a/arch/arm/mach-s3c2412/pm.c
+++ b/arch/arm/mach-s3c2412/pm.c
@@ -28,10 +28,10 @@
28#include <mach/regs-gpio.h> 28#include <mach/regs-gpio.h>
29#include <mach/regs-dsc.h> 29#include <mach/regs-dsc.h>
30 30
31#include <asm/plat-s3c24xx/cpu.h> 31#include <plat/cpu.h>
32#include <asm/plat-s3c24xx/pm.h> 32#include <plat/pm.h>
33 33
34#include <asm/plat-s3c24xx/s3c2412.h> 34#include <plat/s3c2412.h>
35 35
36extern void s3c2412_sleep_enter(void); 36extern void s3c2412_sleep_enter(void);
37 37
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index 42440fc55681..313759c3da69 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -34,7 +34,7 @@
34#include <mach/idle.h> 34#include <mach/idle.h>
35 35
36#include <mach/regs-clock.h> 36#include <mach/regs-clock.h>
37#include <asm/plat-s3c/regs-serial.h> 37#include <plat/regs-serial.h>
38#include <mach/regs-power.h> 38#include <mach/regs-power.h>
39#include <mach/regs-gpio.h> 39#include <mach/regs-gpio.h>
40#include <mach/regs-gpioj.h> 40#include <mach/regs-gpioj.h>
@@ -42,11 +42,11 @@
42#include <asm/plat-s3c24xx/regs-spi.h> 42#include <asm/plat-s3c24xx/regs-spi.h>
43#include <mach/regs-s3c2412.h> 43#include <mach/regs-s3c2412.h>
44 44
45#include <asm/plat-s3c24xx/s3c2412.h> 45#include <plat/s3c2412.h>
46#include <asm/plat-s3c24xx/cpu.h> 46#include <plat/cpu.h>
47#include <asm/plat-s3c24xx/devs.h> 47#include <plat/devs.h>
48#include <asm/plat-s3c24xx/clock.h> 48#include <plat/clock.h>
49#include <asm/plat-s3c24xx/pm.h> 49#include <plat/pm.h>
50 50
51#ifndef CONFIG_CPU_S3C2412_ONLY 51#ifndef CONFIG_CPU_S3C2412_ONLY
52void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; 52void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
diff --git a/arch/arm/mach-s3c2440/clock.c b/arch/arm/mach-s3c2440/clock.c
index 40503a65bacf..d1c29b2537cd 100644
--- a/arch/arm/mach-s3c2440/clock.c
+++ b/arch/arm/mach-s3c2440/clock.c
@@ -41,8 +41,8 @@
41 41
42#include <mach/regs-clock.h> 42#include <mach/regs-clock.h>
43 43
44#include <asm/plat-s3c24xx/clock.h> 44#include <plat/clock.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46 46
47/* S3C2440 extended clock support */ 47/* S3C2440 extended clock support */
48 48
diff --git a/arch/arm/mach-s3c2440/dma.c b/arch/arm/mach-s3c2440/dma.c
index cdd4e6e79ac0..32303f6a8321 100644
--- a/arch/arm/mach-s3c2440/dma.c
+++ b/arch/arm/mach-s3c2440/dma.c
@@ -20,10 +20,10 @@
20#include <asm/dma.h> 20#include <asm/dma.h>
21#include <mach/dma.h> 21#include <mach/dma.h>
22 22
23#include <asm/plat-s3c24xx/dma.h> 23#include <plat/dma.h>
24#include <asm/plat-s3c24xx/cpu.h> 24#include <plat/cpu.h>
25 25
26#include <asm/plat-s3c/regs-serial.h> 26#include <plat/regs-serial.h>
27#include <mach/regs-gpio.h> 27#include <mach/regs-gpio.h>
28#include <asm/plat-s3c/regs-ac97.h> 28#include <asm/plat-s3c/regs-ac97.h>
29#include <mach/regs-mem.h> 29#include <mach/regs-mem.h>
diff --git a/arch/arm/mach-s3c2440/dsc.c b/arch/arm/mach-s3c2440/dsc.c
index 4f7d06baf0d3..554044272771 100644
--- a/arch/arm/mach-s3c2440/dsc.c
+++ b/arch/arm/mach-s3c2440/dsc.c
@@ -27,8 +27,8 @@
27#include <mach/regs-gpio.h> 27#include <mach/regs-gpio.h>
28#include <mach/regs-dsc.h> 28#include <mach/regs-dsc.h>
29 29
30#include <asm/plat-s3c24xx/cpu.h> 30#include <plat/cpu.h>
31#include <asm/plat-s3c24xx/s3c2440.h> 31#include <plat/s3c2440.h>
32 32
33int s3c2440_set_dsc(unsigned int pin, unsigned int value) 33int s3c2440_set_dsc(unsigned int pin, unsigned int value)
34{ 34{
diff --git a/arch/arm/mach-s3c2440/irq.c b/arch/arm/mach-s3c2440/irq.c
index 33e3ede0a2b3..63c5ab65727f 100644
--- a/arch/arm/mach-s3c2440/irq.c
+++ b/arch/arm/mach-s3c2440/irq.c
@@ -34,9 +34,9 @@
34#include <mach/regs-irq.h> 34#include <mach/regs-irq.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36 36
37#include <asm/plat-s3c24xx/cpu.h> 37#include <plat/cpu.h>
38#include <asm/plat-s3c24xx/pm.h> 38#include <plat/pm.h>
39#include <asm/plat-s3c24xx/irq.h> 39#include <plat/irq.h>
40 40
41/* WDT/AC97 */ 41/* WDT/AC97 */
42 42
diff --git a/arch/arm/mach-s3c2440/mach-anubis.c b/arch/arm/mach-s3c2440/mach-anubis.c
index 19eb0e5269ac..e2beca470484 100644
--- a/arch/arm/mach-s3c2440/mach-anubis.c
+++ b/arch/arm/mach-s3c2440/mach-anubis.c
@@ -35,7 +35,7 @@
35#include <asm/irq.h> 35#include <asm/irq.h>
36#include <asm/mach-types.h> 36#include <asm/mach-types.h>
37 37
38#include <asm/plat-s3c/regs-serial.h> 38#include <plat/regs-serial.h>
39#include <mach/regs-gpio.h> 39#include <mach/regs-gpio.h>
40#include <mach/regs-mem.h> 40#include <mach/regs-mem.h>
41#include <mach/regs-lcd.h> 41#include <mach/regs-lcd.h>
@@ -48,9 +48,9 @@
48 48
49#include <net/ax88796.h> 49#include <net/ax88796.h>
50 50
51#include <asm/plat-s3c24xx/clock.h> 51#include <plat/clock.h>
52#include <asm/plat-s3c24xx/devs.h> 52#include <plat/devs.h>
53#include <asm/plat-s3c24xx/cpu.h> 53#include <plat/cpu.h>
54 54
55#define COPYRIGHT ", (c) 2005 Simtec Electronics" 55#define COPYRIGHT ", (c) 2005 Simtec Electronics"
56 56
diff --git a/arch/arm/mach-s3c2440/mach-at2440evb.c b/arch/arm/mach-s3c2440/mach-at2440evb.c
index f0f0cc6afcf4..66876c6f2f1c 100644
--- a/arch/arm/mach-s3c2440/mach-at2440evb.c
+++ b/arch/arm/mach-s3c2440/mach-at2440evb.c
@@ -31,7 +31,7 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34#include <asm/plat-s3c/regs-serial.h> 34#include <plat/regs-serial.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36#include <mach/regs-mem.h> 36#include <mach/regs-mem.h>
37#include <mach/regs-lcd.h> 37#include <mach/regs-lcd.h>
@@ -42,9 +42,9 @@
42#include <linux/mtd/nand_ecc.h> 42#include <linux/mtd/nand_ecc.h>
43#include <linux/mtd/partitions.h> 43#include <linux/mtd/partitions.h>
44 44
45#include <asm/plat-s3c24xx/clock.h> 45#include <plat/clock.h>
46#include <asm/plat-s3c24xx/devs.h> 46#include <plat/devs.h>
47#include <asm/plat-s3c24xx/cpu.h> 47#include <plat/cpu.h>
48 48
49static struct map_desc at2440evb_iodesc[] __initdata = { 49static struct map_desc at2440evb_iodesc[] __initdata = {
50 /* Nothing here */ 50 /* Nothing here */
diff --git a/arch/arm/mach-s3c2440/mach-nexcoder.c b/arch/arm/mach-s3c2440/mach-nexcoder.c
index 49e828d1d4d8..a546307fd53d 100644
--- a/arch/arm/mach-s3c2440/mach-nexcoder.c
+++ b/arch/arm/mach-s3c2440/mach-nexcoder.c
@@ -36,13 +36,13 @@
36 36
37//#include <asm/debug-ll.h> 37//#include <asm/debug-ll.h>
38#include <mach/regs-gpio.h> 38#include <mach/regs-gpio.h>
39#include <asm/plat-s3c/regs-serial.h> 39#include <plat/regs-serial.h>
40 40
41#include <asm/plat-s3c24xx/s3c2410.h> 41#include <plat/s3c2410.h>
42#include <asm/plat-s3c24xx/s3c2440.h> 42#include <plat/s3c2440.h>
43#include <asm/plat-s3c24xx/clock.h> 43#include <plat/clock.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <plat/devs.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46 46
47static struct map_desc nexcoder_iodesc[] __initdata = { 47static struct map_desc nexcoder_iodesc[] __initdata = {
48 /* nothing here yet */ 48 /* nothing here yet */
diff --git a/arch/arm/mach-s3c2440/mach-osiris.c b/arch/arm/mach-s3c2440/mach-osiris.c
index 85144aa52c27..2361d606abc5 100644
--- a/arch/arm/mach-s3c2440/mach-osiris.c
+++ b/arch/arm/mach-s3c2440/mach-osiris.c
@@ -33,7 +33,7 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35 35
36#include <asm/plat-s3c/regs-serial.h> 36#include <plat/regs-serial.h>
37#include <mach/regs-gpio.h> 37#include <mach/regs-gpio.h>
38#include <mach/regs-mem.h> 38#include <mach/regs-mem.h>
39#include <mach/regs-lcd.h> 39#include <mach/regs-lcd.h>
@@ -44,9 +44,9 @@
44#include <linux/mtd/nand_ecc.h> 44#include <linux/mtd/nand_ecc.h>
45#include <linux/mtd/partitions.h> 45#include <linux/mtd/partitions.h>
46 46
47#include <asm/plat-s3c24xx/clock.h> 47#include <plat/clock.h>
48#include <asm/plat-s3c24xx/devs.h> 48#include <plat/devs.h>
49#include <asm/plat-s3c24xx/cpu.h> 49#include <plat/cpu.h>
50 50
51/* onboard perihperal map */ 51/* onboard perihperal map */
52 52
diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c2440/mach-rx3715.c
index a4c690456d19..4d14c7cff892 100644
--- a/arch/arm/mach-s3c2440/mach-rx3715.c
+++ b/arch/arm/mach-s3c2440/mach-rx3715.c
@@ -37,7 +37,7 @@
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/mach-types.h> 38#include <asm/mach-types.h>
39 39
40#include <asm/plat-s3c/regs-serial.h> 40#include <plat/regs-serial.h>
41#include <mach/regs-gpio.h> 41#include <mach/regs-gpio.h>
42#include <mach/regs-lcd.h> 42#include <mach/regs-lcd.h>
43 43
@@ -45,10 +45,10 @@
45#include <asm/plat-s3c/nand.h> 45#include <asm/plat-s3c/nand.h>
46#include <mach/fb.h> 46#include <mach/fb.h>
47 47
48#include <asm/plat-s3c24xx/clock.h> 48#include <plat/clock.h>
49#include <asm/plat-s3c24xx/devs.h> 49#include <plat/devs.h>
50#include <asm/plat-s3c24xx/cpu.h> 50#include <plat/cpu.h>
51#include <asm/plat-s3c24xx/pm.h> 51#include <plat/pm.h>
52 52
53static struct map_desc rx3715_iodesc[] __initdata = { 53static struct map_desc rx3715_iodesc[] __initdata = {
54 /* dump ISA space somewhere unused */ 54 /* dump ISA space somewhere unused */
diff --git a/arch/arm/mach-s3c2440/mach-smdk2440.c b/arch/arm/mach-s3c2440/mach-smdk2440.c
index 7ac60b869e7f..fefeaaa4155f 100644
--- a/arch/arm/mach-s3c2440/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2440/mach-smdk2440.c
@@ -31,20 +31,20 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34#include <asm/plat-s3c/regs-serial.h> 34#include <plat/regs-serial.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36#include <mach/regs-lcd.h> 36#include <mach/regs-lcd.h>
37 37
38#include <mach/idle.h> 38#include <mach/idle.h>
39#include <mach/fb.h> 39#include <mach/fb.h>
40 40
41#include <asm/plat-s3c24xx/s3c2410.h> 41#include <plat/s3c2410.h>
42#include <asm/plat-s3c24xx/s3c2440.h> 42#include <plat/s3c2440.h>
43#include <asm/plat-s3c24xx/clock.h> 43#include <plat/clock.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <plat/devs.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46 46
47#include <asm/plat-s3c24xx/common-smdk.h> 47#include <plat/common-smdk.h>
48 48
49static struct map_desc smdk2440_iodesc[] __initdata = { 49static struct map_desc smdk2440_iodesc[] __initdata = {
50 /* ISA IO Space map (memory space selected by A24) */ 50 /* ISA IO Space map (memory space selected by A24) */
diff --git a/arch/arm/mach-s3c2440/s3c2440.c b/arch/arm/mach-s3c2440/s3c2440.c
index c81cdb330712..ac1f7ea5f405 100644
--- a/arch/arm/mach-s3c2440/s3c2440.c
+++ b/arch/arm/mach-s3c2440/s3c2440.c
@@ -29,9 +29,9 @@
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <asm/plat-s3c24xx/s3c2440.h> 32#include <plat/s3c2440.h>
33#include <asm/plat-s3c24xx/devs.h> 33#include <plat/devs.h>
34#include <asm/plat-s3c24xx/cpu.h> 34#include <plat/cpu.h>
35 35
36static struct sys_device s3c2440_sysdev = { 36static struct sys_device s3c2440_sysdev = {
37 .cls = &s3c2440_sysclass, 37 .cls = &s3c2440_sysclass,
diff --git a/arch/arm/mach-s3c2442/clock.c b/arch/arm/mach-s3c2442/clock.c
index 18f2ce4d7b23..ea1aa1f5157a 100644
--- a/arch/arm/mach-s3c2442/clock.c
+++ b/arch/arm/mach-s3c2442/clock.c
@@ -41,8 +41,8 @@
41 41
42#include <mach/regs-clock.h> 42#include <mach/regs-clock.h>
43 43
44#include <asm/plat-s3c24xx/clock.h> 44#include <plat/clock.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46 46
47/* S3C2442 extended clock support */ 47/* S3C2442 extended clock support */
48 48
diff --git a/arch/arm/mach-s3c2442/s3c2442.c b/arch/arm/mach-s3c2442/s3c2442.c
index fbf8264249da..4663bdc7fff6 100644
--- a/arch/arm/mach-s3c2442/s3c2442.c
+++ b/arch/arm/mach-s3c2442/s3c2442.c
@@ -19,8 +19,8 @@
19#include <linux/serial_core.h> 19#include <linux/serial_core.h>
20#include <linux/sysdev.h> 20#include <linux/sysdev.h>
21 21
22#include <asm/plat-s3c24xx/s3c2442.h> 22#include <plat/s3c2442.h>
23#include <asm/plat-s3c24xx/cpu.h> 23#include <plat/cpu.h>
24 24
25static struct sys_device s3c2442_sysdev = { 25static struct sys_device s3c2442_sysdev = {
26 .cls = &s3c2442_sysclass, 26 .cls = &s3c2442_sysclass,
diff --git a/arch/arm/mach-s3c2443/clock.c b/arch/arm/mach-s3c2443/clock.c
index 803e24cd29c4..f854e7385e3c 100644
--- a/arch/arm/mach-s3c2443/clock.c
+++ b/arch/arm/mach-s3c2443/clock.c
@@ -39,9 +39,9 @@
39 39
40#include <mach/regs-s3c2443-clock.h> 40#include <mach/regs-s3c2443-clock.h>
41 41
42#include <asm/plat-s3c24xx/s3c2443.h> 42#include <plat/s3c2443.h>
43#include <asm/plat-s3c24xx/clock.h> 43#include <plat/clock.h>
44#include <asm/plat-s3c24xx/cpu.h> 44#include <plat/cpu.h>
45 45
46/* We currently have to assume that the system is running 46/* We currently have to assume that the system is running
47 * from the XTPll input, and that all ***REFCLKs are being 47 * from the XTPll input, and that all ***REFCLKs are being
diff --git a/arch/arm/mach-s3c2443/dma.c b/arch/arm/mach-s3c2443/dma.c
index 5d9ee772659b..f73ccb25ff94 100644
--- a/arch/arm/mach-s3c2443/dma.c
+++ b/arch/arm/mach-s3c2443/dma.c
@@ -21,10 +21,10 @@
21#include <asm/dma.h> 21#include <asm/dma.h>
22#include <mach/dma.h> 22#include <mach/dma.h>
23 23
24#include <asm/plat-s3c24xx/dma.h> 24#include <plat/dma.h>
25#include <asm/plat-s3c24xx/cpu.h> 25#include <plat/cpu.h>
26 26
27#include <asm/plat-s3c/regs-serial.h> 27#include <plat/regs-serial.h>
28#include <mach/regs-gpio.h> 28#include <mach/regs-gpio.h>
29#include <asm/plat-s3c/regs-ac97.h> 29#include <asm/plat-s3c/regs-ac97.h>
30#include <mach/regs-mem.h> 30#include <mach/regs-mem.h>
diff --git a/arch/arm/mach-s3c2443/irq.c b/arch/arm/mach-s3c2443/irq.c
index e44341d7dfef..0e0d693f3974 100644
--- a/arch/arm/mach-s3c2443/irq.c
+++ b/arch/arm/mach-s3c2443/irq.c
@@ -34,9 +34,9 @@
34#include <mach/regs-irq.h> 34#include <mach/regs-irq.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36 36
37#include <asm/plat-s3c24xx/cpu.h> 37#include <plat/cpu.h>
38#include <asm/plat-s3c24xx/pm.h> 38#include <plat/pm.h>
39#include <asm/plat-s3c24xx/irq.h> 39#include <plat/irq.h>
40 40
41#define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1) 41#define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1)
42 42
diff --git a/arch/arm/mach-s3c2443/mach-smdk2443.c b/arch/arm/mach-s3c2443/mach-smdk2443.c
index f0d119dc0409..a7fe65f3dcc1 100644
--- a/arch/arm/mach-s3c2443/mach-smdk2443.c
+++ b/arch/arm/mach-s3c2443/mach-smdk2443.c
@@ -31,20 +31,20 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34#include <asm/plat-s3c/regs-serial.h> 34#include <plat/regs-serial.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36#include <mach/regs-lcd.h> 36#include <mach/regs-lcd.h>
37 37
38#include <mach/idle.h> 38#include <mach/idle.h>
39#include <mach/fb.h> 39#include <mach/fb.h>
40 40
41#include <asm/plat-s3c24xx/s3c2410.h> 41#include <plat/s3c2410.h>
42#include <asm/plat-s3c24xx/s3c2440.h> 42#include <plat/s3c2440.h>
43#include <asm/plat-s3c24xx/clock.h> 43#include <plat/clock.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <plat/devs.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46 46
47#include <asm/plat-s3c24xx/common-smdk.h> 47#include <plat/common-smdk.h>
48 48
49static struct map_desc smdk2443_iodesc[] __initdata = { 49static struct map_desc smdk2443_iodesc[] __initdata = {
50 /* ISA IO Space map (memory space selected by A24) */ 50 /* ISA IO Space map (memory space selected by A24) */
diff --git a/arch/arm/mach-s3c2443/s3c2443.c b/arch/arm/mach-s3c2443/s3c2443.c
index c973b68cc735..bbeddf9ddcb1 100644
--- a/arch/arm/mach-s3c2443/s3c2443.c
+++ b/arch/arm/mach-s3c2443/s3c2443.c
@@ -32,9 +32,9 @@
32#include <mach/regs-s3c2443-clock.h> 32#include <mach/regs-s3c2443-clock.h>
33#include <mach/reset.h> 33#include <mach/reset.h>
34 34
35#include <asm/plat-s3c24xx/s3c2443.h> 35#include <plat/s3c2443.h>
36#include <asm/plat-s3c24xx/devs.h> 36#include <plat/devs.h>
37#include <asm/plat-s3c24xx/cpu.h> 37#include <plat/cpu.h>
38 38
39static struct map_desc s3c2443_iodesc[] __initdata = { 39static struct map_desc s3c2443_iodesc[] __initdata = {
40 IODESC_ENT(WATCHDOG), 40 IODESC_ENT(WATCHDOG),
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index f7fa03478efd..244d5956312c 100644
--- a/arch/arm/mach-sa1100/cpu-sa1100.c
+++ b/arch/arm/mach-sa1100/cpu-sa1100.c
@@ -224,7 +224,6 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
224 if (policy->cpu != 0) 224 if (policy->cpu != 0)
225 return -EINVAL; 225 return -EINVAL;
226 policy->cur = policy->min = policy->max = sa11x0_getspeed(0); 226 policy->cur = policy->min = policy->max = sa11x0_getspeed(0);
227 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
228 policy->cpuinfo.min_freq = 59000; 227 policy->cpuinfo.min_freq = 59000;
229 policy->cpuinfo.max_freq = 287000; 228 policy->cpuinfo.max_freq = 287000;
230 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; 229 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 330814d1ee25..d1193884d76d 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -428,7 +428,7 @@ config CPU_32v6K
428# ARMv7 428# ARMv7
429config CPU_V7 429config CPU_V7
430 bool "Support ARM V7 processor" 430 bool "Support ARM V7 processor"
431 depends on ARCH_INTEGRATOR || MACH_REALVIEW_EB 431 depends on ARCH_INTEGRATOR || MACH_REALVIEW_EB || ARCH_OMAP3
432 select CPU_32v6K 432 select CPU_32v6K
433 select CPU_32v7 433 select CPU_32v7
434 select CPU_ABRT_EV7 434 select CPU_ABRT_EV7
diff --git a/arch/arm/mm/cache-v4.S b/arch/arm/mm/cache-v4.S
index 33926c9fcda6..5786adf10040 100644
--- a/arch/arm/mm/cache-v4.S
+++ b/arch/arm/mm/cache-v4.S
@@ -29,7 +29,7 @@ ENTRY(v4_flush_user_cache_all)
29 * Clean and invalidate the entire cache. 29 * Clean and invalidate the entire cache.
30 */ 30 */
31ENTRY(v4_flush_kern_cache_all) 31ENTRY(v4_flush_kern_cache_all)
32#ifdef CPU_CP15 32#ifdef CONFIG_CPU_CP15
33 mov r0, #0 33 mov r0, #0
34 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache 34 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache
35 mov pc, lr 35 mov pc, lr
@@ -48,7 +48,7 @@ ENTRY(v4_flush_kern_cache_all)
48 * - flags - vma_area_struct flags describing address space 48 * - flags - vma_area_struct flags describing address space
49 */ 49 */
50ENTRY(v4_flush_user_cache_range) 50ENTRY(v4_flush_user_cache_range)
51#ifdef CPU_CP15 51#ifdef CONFIG_CPU_CP15
52 mov ip, #0 52 mov ip, #0
53 mcreq p15, 0, ip, c7, c7, 0 @ flush ID cache 53 mcreq p15, 0, ip, c7, c7, 0 @ flush ID cache
54 mov pc, lr 54 mov pc, lr
@@ -116,7 +116,7 @@ ENTRY(v4_dma_inv_range)
116 * - end - virtual end address 116 * - end - virtual end address
117 */ 117 */
118ENTRY(v4_dma_flush_range) 118ENTRY(v4_dma_flush_range)
119#ifdef CPU_CP15 119#ifdef CONFIG_CPU_CP15
120 mov r0, #0 120 mov r0, #0
121 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache 121 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache
122#endif 122#endif
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index b917206ee906..a94f0c44ebc8 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -15,6 +15,9 @@ config ARCH_OMAP1
15config ARCH_OMAP2 15config ARCH_OMAP2
16 bool "TI OMAP2" 16 bool "TI OMAP2"
17 17
18config ARCH_OMAP3
19 bool "TI OMAP3"
20
18endchoice 21endchoice
19 22
20comment "OMAP Feature Selections" 23comment "OMAP Feature Selections"
@@ -29,6 +32,30 @@ config OMAP_DEBUG_LEDS
29 depends on OMAP_DEBUG_DEVICES 32 depends on OMAP_DEBUG_DEVICES
30 default y if LEDS || LEDS_OMAP_DEBUG 33 default y if LEDS || LEDS_OMAP_DEBUG
31 34
35config OMAP_DEBUG_POWERDOMAIN
36 bool "Emit debug messages from powerdomain layer"
37 depends on ARCH_OMAP2 || ARCH_OMAP3
38 default n
39 help
40 Say Y here if you want to compile in powerdomain layer
41 debugging messages for OMAP2/3. These messages can
42 provide more detail as to why some powerdomain calls
43 may be failing, and will also emit a descriptive message
44 for every powerdomain register write. However, the
45 extra detail costs some memory.
46
47config OMAP_DEBUG_CLOCKDOMAIN
48 bool "Emit debug messages from clockdomain layer"
49 depends on ARCH_OMAP2 || ARCH_OMAP3
50 default n
51 help
52 Say Y here if you want to compile in clockdomain layer
53 debugging messages for OMAP2/3. These messages can
54 provide more detail as to why some clockdomain calls
55 may be failing, and will also emit a descriptive message
56 for every clockdomain register write. However, the
57 extra detail costs some memory.
58
32config OMAP_RESET_CLOCKS 59config OMAP_RESET_CLOCKS
33 bool "Reset unused clocks during boot" 60 bool "Reset unused clocks during boot"
34 depends on ARCH_OMAP 61 depends on ARCH_OMAP
@@ -88,13 +115,13 @@ config OMAP_MPU_TIMER
88 115
89config OMAP_32K_TIMER 116config OMAP_32K_TIMER
90 bool "Use 32KHz timer" 117 bool "Use 32KHz timer"
91 depends on ARCH_OMAP16XX || ARCH_OMAP24XX 118 depends on ARCH_OMAP16XX || ARCH_OMAP24XX || ARCH_OMAP34XX
92 help 119 help
93 Select this option if you want to enable the OMAP 32KHz timer. 120 Select this option if you want to enable the OMAP 32KHz timer.
94 This timer saves power compared to the OMAP_MPU_TIMER, and has 121 This timer saves power compared to the OMAP_MPU_TIMER, and has
95 support for no tick during idle. The 32KHz timer provides less 122 support for no tick during idle. The 32KHz timer provides less
96 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is 123 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is
97 currently only available for OMAP16XX and 24XX. 124 currently only available for OMAP16XX, 24XX and 34XX.
98 125
99endchoice 126endchoice
100 127
@@ -109,7 +136,7 @@ config OMAP_32K_TIMER_HZ
109 136
110config OMAP_DM_TIMER 137config OMAP_DM_TIMER
111 bool "Use dual-mode timer" 138 bool "Use dual-mode timer"
112 depends on ARCH_OMAP16XX || ARCH_OMAP24XX 139 depends on ARCH_OMAP16XX || ARCH_OMAP24XX || ARCH_OMAP34XX
113 help 140 help
114 Select this option if you want to use OMAP Dual-Mode timers. 141 Select this option if you want to use OMAP Dual-Mode timers.
115 142
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 2c4051cc79a1..deaff58878a2 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -4,7 +4,7 @@
4 4
5# Common support 5# Common support
6obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \ 6obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \
7 usb.o fb.o 7 usb.o fb.o io.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 8bdf0ead0cf3..0843b8882f93 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -248,6 +248,7 @@ static struct omap_globals *omap2_globals;
248 248
249static void __init __omap2_set_globals(void) 249static void __init __omap2_set_globals(void)
250{ 250{
251 omap2_set_globals_tap(omap2_globals);
251 omap2_set_globals_memory(omap2_globals); 252 omap2_set_globals_memory(omap2_globals);
252 omap2_set_globals_control(omap2_globals); 253 omap2_set_globals_control(omap2_globals);
253 omap2_set_globals_prcm(omap2_globals); 254 omap2_set_globals_prcm(omap2_globals);
@@ -258,12 +259,13 @@ static void __init __omap2_set_globals(void)
258#if defined(CONFIG_ARCH_OMAP2420) 259#if defined(CONFIG_ARCH_OMAP2420)
259 260
260static struct omap_globals omap242x_globals = { 261static struct omap_globals omap242x_globals = {
261 .tap = (__force void __iomem *)OMAP2_IO_ADDRESS(0x48014000), 262 .class = OMAP242X_CLASS,
262 .sdrc = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_SDRC_BASE), 263 .tap = OMAP2_IO_ADDRESS(0x48014000),
263 .sms = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_SMS_BASE), 264 .sdrc = OMAP2_IO_ADDRESS(OMAP2420_SDRC_BASE),
264 .ctrl = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_CTRL_BASE), 265 .sms = OMAP2_IO_ADDRESS(OMAP2420_SMS_BASE),
265 .prm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_PRM_BASE), 266 .ctrl = OMAP2_IO_ADDRESS(OMAP2420_CTRL_BASE),
266 .cm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_CM_BASE), 267 .prm = OMAP2_IO_ADDRESS(OMAP2420_PRM_BASE),
268 .cm = OMAP2_IO_ADDRESS(OMAP2420_CM_BASE),
267}; 269};
268 270
269void __init omap2_set_globals_242x(void) 271void __init omap2_set_globals_242x(void)
@@ -276,12 +278,13 @@ void __init omap2_set_globals_242x(void)
276#if defined(CONFIG_ARCH_OMAP2430) 278#if defined(CONFIG_ARCH_OMAP2430)
277 279
278static struct omap_globals omap243x_globals = { 280static struct omap_globals omap243x_globals = {
279 .tap = (__force void __iomem *)OMAP2_IO_ADDRESS(0x4900a000), 281 .class = OMAP243X_CLASS,
280 .sdrc = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP243X_SDRC_BASE), 282 .tap = OMAP2_IO_ADDRESS(0x4900a000),
281 .sms = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP243X_SMS_BASE), 283 .sdrc = OMAP2_IO_ADDRESS(OMAP243X_SDRC_BASE),
282 .ctrl = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP243X_CTRL_BASE), 284 .sms = OMAP2_IO_ADDRESS(OMAP243X_SMS_BASE),
283 .prm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2430_PRM_BASE), 285 .ctrl = OMAP2_IO_ADDRESS(OMAP243X_CTRL_BASE),
284 .cm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2430_CM_BASE), 286 .prm = OMAP2_IO_ADDRESS(OMAP2430_PRM_BASE),
287 .cm = OMAP2_IO_ADDRESS(OMAP2430_CM_BASE),
285}; 288};
286 289
287void __init omap2_set_globals_243x(void) 290void __init omap2_set_globals_243x(void)
@@ -294,12 +297,13 @@ void __init omap2_set_globals_243x(void)
294#if defined(CONFIG_ARCH_OMAP3430) 297#if defined(CONFIG_ARCH_OMAP3430)
295 298
296static struct omap_globals omap343x_globals = { 299static struct omap_globals omap343x_globals = {
297 .tap = (__force void __iomem *)OMAP2_IO_ADDRESS(0x4830A000), 300 .class = OMAP343X_CLASS,
298 .sdrc = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP343X_SDRC_BASE), 301 .tap = OMAP2_IO_ADDRESS(0x4830A000),
299 .sms = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP343X_SMS_BASE), 302 .sdrc = OMAP2_IO_ADDRESS(OMAP343X_SDRC_BASE),
300 .ctrl = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP343X_CTRL_BASE), 303 .sms = OMAP2_IO_ADDRESS(OMAP343X_SMS_BASE),
301 .prm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP3430_PRM_BASE), 304 .ctrl = OMAP2_IO_ADDRESS(OMAP343X_CTRL_BASE),
302 .cm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP3430_CM_BASE), 305 .prm = OMAP2_IO_ADDRESS(OMAP3430_PRM_BASE),
306 .cm = OMAP2_IO_ADDRESS(OMAP3430_CM_BASE),
303}; 307};
304 308
305void __init omap2_set_globals_343x(void) 309void __init omap2_set_globals_343x(void)
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index 97187fa0ae52..0cb2b22388e9 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -20,17 +20,17 @@
20#include <asm/mach/map.h> 20#include <asm/mach/map.h>
21 21
22#include <mach/tc.h> 22#include <mach/tc.h>
23#include <mach/control.h>
23#include <mach/board.h> 24#include <mach/board.h>
24#include <mach/mmc.h> 25#include <mach/mmc.h>
25#include <mach/mux.h> 26#include <mach/mux.h>
26#include <mach/gpio.h> 27#include <mach/gpio.h>
27#include <mach/menelaus.h> 28#include <mach/menelaus.h>
28#include <mach/mcbsp.h> 29#include <mach/mcbsp.h>
30#include <mach/dsp_common.h>
29 31
30#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE) 32#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
31 33
32#include "../plat-omap/dsp/dsp_common.h"
33
34static struct dsp_platform_data dsp_pdata = { 34static struct dsp_platform_data dsp_pdata = {
35 .kdev_list = LIST_HEAD_INIT(dsp_pdata.kdev_list), 35 .kdev_list = LIST_HEAD_INIT(dsp_pdata.kdev_list),
36}; 36};
@@ -76,7 +76,7 @@ int dsp_kfunc_device_register(struct dsp_kfunc_device *kdev)
76{ 76{
77 static DEFINE_MUTEX(dsp_pdata_lock); 77 static DEFINE_MUTEX(dsp_pdata_lock);
78 78
79 mutex_init(&kdev->lock); 79 spin_lock_init(&kdev->lock);
80 80
81 mutex_lock(&dsp_pdata_lock); 81 mutex_lock(&dsp_pdata_lock);
82 list_add_tail(&kdev->entry, &dsp_pdata.kdev_list); 82 list_add_tail(&kdev->entry, &dsp_pdata.kdev_list);
@@ -95,6 +95,10 @@ static inline void omap_init_dsp(void) { }
95 95
96static void omap_init_kp(void) 96static void omap_init_kp(void)
97{ 97{
98 /* 2430 and 34xx keypad is on TWL4030 */
99 if (cpu_is_omap2430() || cpu_is_omap34xx())
100 return;
101
98 if (machine_is_omap_h2() || machine_is_omap_h3()) { 102 if (machine_is_omap_h2() || machine_is_omap_h3()) {
99 omap_cfg_reg(F18_1610_KBC0); 103 omap_cfg_reg(F18_1610_KBC0);
100 omap_cfg_reg(D20_1610_KBC1); 104 omap_cfg_reg(D20_1610_KBC1);
@@ -156,13 +160,6 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
156{ 160{
157 int i; 161 int i;
158 162
159 if (size > OMAP_MAX_MCBSP_COUNT) {
160 printk(KERN_WARNING "Registered too many McBSPs platform_data."
161 " Using maximum (%d) available.\n",
162 OMAP_MAX_MCBSP_COUNT);
163 size = OMAP_MAX_MCBSP_COUNT;
164 }
165
166 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *), 163 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
167 GFP_KERNEL); 164 GFP_KERNEL);
168 if (!omap_mcbsp_devices) { 165 if (!omap_mcbsp_devices) {
@@ -530,10 +527,6 @@ static inline void omap_init_rng(void) {}
530 */ 527 */
531static int __init omap_init_devices(void) 528static int __init omap_init_devices(void)
532{ 529{
533/*
534 * Need to enable relevant once for 2430 SDP
535 */
536#ifndef CONFIG_MACH_OMAP_2430SDP
537 /* please keep these calls, and their implementations above, 530 /* please keep these calls, and their implementations above,
538 * in alphabetical order so they're easier to sort through. 531 * in alphabetical order so they're easier to sort through.
539 */ 532 */
@@ -543,7 +536,6 @@ static int __init omap_init_devices(void)
543 omap_init_uwire(); 536 omap_init_uwire();
544 omap_init_wdt(); 537 omap_init_wdt();
545 omap_init_rng(); 538 omap_init_rng();
546#endif
547 return 0; 539 return 0;
548} 540}
549arch_initcall(omap_init_devices); 541arch_initcall(omap_init_devices);
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index a63b644ad305..50f8b4ad9a09 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -1233,7 +1233,7 @@ int omap_request_dma_chain(int dev_id, const char *dev_name,
1233 /* request and reserve DMA channels for the chain */ 1233 /* request and reserve DMA channels for the chain */
1234 for (i = 0; i < no_of_chans; i++) { 1234 for (i = 0; i < no_of_chans; i++) {
1235 err = omap_request_dma(dev_id, dev_name, 1235 err = omap_request_dma(dev_id, dev_name,
1236 callback, 0, &channels[i]); 1236 callback, NULL, &channels[i]);
1237 if (err < 0) { 1237 if (err < 0) {
1238 int j; 1238 int j;
1239 for (j = 0; j < i; j++) 1239 for (j = 0; j < i; j++)
@@ -2297,13 +2297,13 @@ static int __init omap_init_dma(void)
2297 int ch, r; 2297 int ch, r;
2298 2298
2299 if (cpu_class_is_omap1()) { 2299 if (cpu_class_is_omap1()) {
2300 omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP1_DMA_BASE); 2300 omap_dma_base = IO_ADDRESS(OMAP1_DMA_BASE);
2301 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; 2301 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT;
2302 } else if (cpu_is_omap24xx()) { 2302 } else if (cpu_is_omap24xx()) {
2303 omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP24XX_DMA4_BASE); 2303 omap_dma_base = IO_ADDRESS(OMAP24XX_DMA4_BASE);
2304 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2304 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2305 } else if (cpu_is_omap34xx()) { 2305 } else if (cpu_is_omap34xx()) {
2306 omap_dma_base = (void __iomem *)IO_ADDRESS(OMAP34XX_DMA4_BASE); 2306 omap_dma_base = IO_ADDRESS(OMAP34XX_DMA4_BASE);
2307 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2307 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2308 } else { 2308 } else {
2309 pr_err("DMA init failed for unsupported omap\n"); 2309 pr_err("DMA init failed for unsupported omap\n");
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 606fcffdcefc..963c31cd1541 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -693,7 +693,7 @@ int __init omap_dm_timer_init(void)
693 693
694 for (i = 0; i < dm_timer_count; i++) { 694 for (i = 0; i < dm_timer_count; i++) {
695 timer = &dm_timers[i]; 695 timer = &dm_timers[i];
696 timer->io_base = (void __iomem *)io_p2v(timer->phys_base); 696 timer->io_base = IO_ADDRESS(timer->phys_base);
697#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 697#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
698 if (cpu_class_is_omap2()) { 698 if (cpu_class_is_omap2()) {
699 char clk_name[16]; 699 char clk_name[16];
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 5935ae4e550b..8679fbca6bbe 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -28,7 +28,7 @@
28/* 28/*
29 * OMAP1510 GPIO registers 29 * OMAP1510 GPIO registers
30 */ 30 */
31#define OMAP1510_GPIO_BASE (void __iomem *)0xfffce000 31#define OMAP1510_GPIO_BASE IO_ADDRESS(0xfffce000)
32#define OMAP1510_GPIO_DATA_INPUT 0x00 32#define OMAP1510_GPIO_DATA_INPUT 0x00
33#define OMAP1510_GPIO_DATA_OUTPUT 0x04 33#define OMAP1510_GPIO_DATA_OUTPUT 0x04
34#define OMAP1510_GPIO_DIR_CONTROL 0x08 34#define OMAP1510_GPIO_DIR_CONTROL 0x08
@@ -42,10 +42,10 @@
42/* 42/*
43 * OMAP1610 specific GPIO registers 43 * OMAP1610 specific GPIO registers
44 */ 44 */
45#define OMAP1610_GPIO1_BASE (void __iomem *)0xfffbe400 45#define OMAP1610_GPIO1_BASE IO_ADDRESS(0xfffbe400)
46#define OMAP1610_GPIO2_BASE (void __iomem *)0xfffbec00 46#define OMAP1610_GPIO2_BASE IO_ADDRESS(0xfffbec00)
47#define OMAP1610_GPIO3_BASE (void __iomem *)0xfffbb400 47#define OMAP1610_GPIO3_BASE IO_ADDRESS(0xfffbb400)
48#define OMAP1610_GPIO4_BASE (void __iomem *)0xfffbbc00 48#define OMAP1610_GPIO4_BASE IO_ADDRESS(0xfffbbc00)
49#define OMAP1610_GPIO_REVISION 0x0000 49#define OMAP1610_GPIO_REVISION 0x0000
50#define OMAP1610_GPIO_SYSCONFIG 0x0010 50#define OMAP1610_GPIO_SYSCONFIG 0x0010
51#define OMAP1610_GPIO_SYSSTATUS 0x0014 51#define OMAP1610_GPIO_SYSSTATUS 0x0014
@@ -67,12 +67,12 @@
67/* 67/*
68 * OMAP730 specific GPIO registers 68 * OMAP730 specific GPIO registers
69 */ 69 */
70#define OMAP730_GPIO1_BASE (void __iomem *)0xfffbc000 70#define OMAP730_GPIO1_BASE IO_ADDRESS(0xfffbc000)
71#define OMAP730_GPIO2_BASE (void __iomem *)0xfffbc800 71#define OMAP730_GPIO2_BASE IO_ADDRESS(0xfffbc800)
72#define OMAP730_GPIO3_BASE (void __iomem *)0xfffbd000 72#define OMAP730_GPIO3_BASE IO_ADDRESS(0xfffbd000)
73#define OMAP730_GPIO4_BASE (void __iomem *)0xfffbd800 73#define OMAP730_GPIO4_BASE IO_ADDRESS(0xfffbd800)
74#define OMAP730_GPIO5_BASE (void __iomem *)0xfffbe000 74#define OMAP730_GPIO5_BASE IO_ADDRESS(0xfffbe000)
75#define OMAP730_GPIO6_BASE (void __iomem *)0xfffbe800 75#define OMAP730_GPIO6_BASE IO_ADDRESS(0xfffbe800)
76#define OMAP730_GPIO_DATA_INPUT 0x00 76#define OMAP730_GPIO_DATA_INPUT 0x00
77#define OMAP730_GPIO_DATA_OUTPUT 0x04 77#define OMAP730_GPIO_DATA_OUTPUT 0x04
78#define OMAP730_GPIO_DIR_CONTROL 0x08 78#define OMAP730_GPIO_DIR_CONTROL 0x08
@@ -83,16 +83,16 @@
83/* 83/*
84 * omap24xx specific GPIO registers 84 * omap24xx specific GPIO registers
85 */ 85 */
86#define OMAP242X_GPIO1_BASE (void __iomem *)0x48018000 86#define OMAP242X_GPIO1_BASE IO_ADDRESS(0x48018000)
87#define OMAP242X_GPIO2_BASE (void __iomem *)0x4801a000 87#define OMAP242X_GPIO2_BASE IO_ADDRESS(0x4801a000)
88#define OMAP242X_GPIO3_BASE (void __iomem *)0x4801c000 88#define OMAP242X_GPIO3_BASE IO_ADDRESS(0x4801c000)
89#define OMAP242X_GPIO4_BASE (void __iomem *)0x4801e000 89#define OMAP242X_GPIO4_BASE IO_ADDRESS(0x4801e000)
90 90
91#define OMAP243X_GPIO1_BASE (void __iomem *)0x4900C000 91#define OMAP243X_GPIO1_BASE IO_ADDRESS(0x4900C000)
92#define OMAP243X_GPIO2_BASE (void __iomem *)0x4900E000 92#define OMAP243X_GPIO2_BASE IO_ADDRESS(0x4900E000)
93#define OMAP243X_GPIO3_BASE (void __iomem *)0x49010000 93#define OMAP243X_GPIO3_BASE IO_ADDRESS(0x49010000)
94#define OMAP243X_GPIO4_BASE (void __iomem *)0x49012000 94#define OMAP243X_GPIO4_BASE IO_ADDRESS(0x49012000)
95#define OMAP243X_GPIO5_BASE (void __iomem *)0x480B6000 95#define OMAP243X_GPIO5_BASE IO_ADDRESS(0x480B6000)
96 96
97#define OMAP24XX_GPIO_REVISION 0x0000 97#define OMAP24XX_GPIO_REVISION 0x0000
98#define OMAP24XX_GPIO_SYSCONFIG 0x0010 98#define OMAP24XX_GPIO_SYSCONFIG 0x0010
@@ -122,13 +122,14 @@
122 * omap34xx specific GPIO registers 122 * omap34xx specific GPIO registers
123 */ 123 */
124 124
125#define OMAP34XX_GPIO1_BASE (void __iomem *)0x48310000 125#define OMAP34XX_GPIO1_BASE IO_ADDRESS(0x48310000)
126#define OMAP34XX_GPIO2_BASE (void __iomem *)0x49050000 126#define OMAP34XX_GPIO2_BASE IO_ADDRESS(0x49050000)
127#define OMAP34XX_GPIO3_BASE (void __iomem *)0x49052000 127#define OMAP34XX_GPIO3_BASE IO_ADDRESS(0x49052000)
128#define OMAP34XX_GPIO4_BASE (void __iomem *)0x49054000 128#define OMAP34XX_GPIO4_BASE IO_ADDRESS(0x49054000)
129#define OMAP34XX_GPIO5_BASE (void __iomem *)0x49056000 129#define OMAP34XX_GPIO5_BASE IO_ADDRESS(0x49056000)
130#define OMAP34XX_GPIO6_BASE (void __iomem *)0x49058000 130#define OMAP34XX_GPIO6_BASE IO_ADDRESS(0x49058000)
131 131
132#define OMAP_MPUIO_VBASE IO_ADDRESS(OMAP_MPUIO_BASE)
132 133
133struct gpio_bank { 134struct gpio_bank {
134 void __iomem *base; 135 void __iomem *base;
@@ -160,7 +161,7 @@ struct gpio_bank {
160 161
161#ifdef CONFIG_ARCH_OMAP16XX 162#ifdef CONFIG_ARCH_OMAP16XX
162static struct gpio_bank gpio_bank_1610[5] = { 163static struct gpio_bank gpio_bank_1610[5] = {
163 { OMAP_MPUIO_BASE, INT_MPUIO, IH_MPUIO_BASE, METHOD_MPUIO}, 164 { OMAP_MPUIO_VBASE, INT_MPUIO, IH_MPUIO_BASE, METHOD_MPUIO},
164 { OMAP1610_GPIO1_BASE, INT_GPIO_BANK1, IH_GPIO_BASE, METHOD_GPIO_1610 }, 165 { OMAP1610_GPIO1_BASE, INT_GPIO_BANK1, IH_GPIO_BASE, METHOD_GPIO_1610 },
165 { OMAP1610_GPIO2_BASE, INT_1610_GPIO_BANK2, IH_GPIO_BASE + 16, METHOD_GPIO_1610 }, 166 { OMAP1610_GPIO2_BASE, INT_1610_GPIO_BANK2, IH_GPIO_BASE + 16, METHOD_GPIO_1610 },
166 { OMAP1610_GPIO3_BASE, INT_1610_GPIO_BANK3, IH_GPIO_BASE + 32, METHOD_GPIO_1610 }, 167 { OMAP1610_GPIO3_BASE, INT_1610_GPIO_BANK3, IH_GPIO_BASE + 32, METHOD_GPIO_1610 },
@@ -170,14 +171,14 @@ static struct gpio_bank gpio_bank_1610[5] = {
170 171
171#ifdef CONFIG_ARCH_OMAP15XX 172#ifdef CONFIG_ARCH_OMAP15XX
172static struct gpio_bank gpio_bank_1510[2] = { 173static struct gpio_bank gpio_bank_1510[2] = {
173 { OMAP_MPUIO_BASE, INT_MPUIO, IH_MPUIO_BASE, METHOD_MPUIO }, 174 { OMAP_MPUIO_VBASE, INT_MPUIO, IH_MPUIO_BASE, METHOD_MPUIO },
174 { OMAP1510_GPIO_BASE, INT_GPIO_BANK1, IH_GPIO_BASE, METHOD_GPIO_1510 } 175 { OMAP1510_GPIO_BASE, INT_GPIO_BANK1, IH_GPIO_BASE, METHOD_GPIO_1510 }
175}; 176};
176#endif 177#endif
177 178
178#ifdef CONFIG_ARCH_OMAP730 179#ifdef CONFIG_ARCH_OMAP730
179static struct gpio_bank gpio_bank_730[7] = { 180static struct gpio_bank gpio_bank_730[7] = {
180 { OMAP_MPUIO_BASE, INT_730_MPUIO, IH_MPUIO_BASE, METHOD_MPUIO }, 181 { OMAP_MPUIO_VBASE, INT_730_MPUIO, IH_MPUIO_BASE, METHOD_MPUIO },
181 { OMAP730_GPIO1_BASE, INT_730_GPIO_BANK1, IH_GPIO_BASE, METHOD_GPIO_730 }, 182 { OMAP730_GPIO1_BASE, INT_730_GPIO_BANK1, IH_GPIO_BASE, METHOD_GPIO_730 },
182 { OMAP730_GPIO2_BASE, INT_730_GPIO_BANK2, IH_GPIO_BASE + 32, METHOD_GPIO_730 }, 183 { OMAP730_GPIO2_BASE, INT_730_GPIO_BANK2, IH_GPIO_BASE + 32, METHOD_GPIO_730 },
183 { OMAP730_GPIO3_BASE, INT_730_GPIO_BANK3, IH_GPIO_BASE + 64, METHOD_GPIO_730 }, 184 { OMAP730_GPIO3_BASE, INT_730_GPIO_BANK3, IH_GPIO_BASE + 64, METHOD_GPIO_730 },
@@ -1389,7 +1390,7 @@ static int __init _omap_gpio_init(void)
1389 1390
1390 gpio_bank_count = 5; 1391 gpio_bank_count = 5;
1391 gpio_bank = gpio_bank_1610; 1392 gpio_bank = gpio_bank_1610;
1392 rev = omap_readw(gpio_bank[1].base + OMAP1610_GPIO_REVISION); 1393 rev = __raw_readw(gpio_bank[1].base + OMAP1610_GPIO_REVISION);
1393 printk(KERN_INFO "OMAP GPIO hardware version %d.%d\n", 1394 printk(KERN_INFO "OMAP GPIO hardware version %d.%d\n",
1394 (rev >> 4) & 0x0f, rev & 0x0f); 1395 (rev >> 4) & 0x0f, rev & 0x0f);
1395 } 1396 }
@@ -1408,7 +1409,7 @@ static int __init _omap_gpio_init(void)
1408 1409
1409 gpio_bank_count = 4; 1410 gpio_bank_count = 4;
1410 gpio_bank = gpio_bank_242x; 1411 gpio_bank = gpio_bank_242x;
1411 rev = omap_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION); 1412 rev = __raw_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION);
1412 printk(KERN_INFO "OMAP242x GPIO hardware version %d.%d\n", 1413 printk(KERN_INFO "OMAP242x GPIO hardware version %d.%d\n",
1413 (rev >> 4) & 0x0f, rev & 0x0f); 1414 (rev >> 4) & 0x0f, rev & 0x0f);
1414 } 1415 }
@@ -1417,7 +1418,7 @@ static int __init _omap_gpio_init(void)
1417 1418
1418 gpio_bank_count = 5; 1419 gpio_bank_count = 5;
1419 gpio_bank = gpio_bank_243x; 1420 gpio_bank = gpio_bank_243x;
1420 rev = omap_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION); 1421 rev = __raw_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION);
1421 printk(KERN_INFO "OMAP243x GPIO hardware version %d.%d\n", 1422 printk(KERN_INFO "OMAP243x GPIO hardware version %d.%d\n",
1422 (rev >> 4) & 0x0f, rev & 0x0f); 1423 (rev >> 4) & 0x0f, rev & 0x0f);
1423 } 1424 }
@@ -1428,7 +1429,7 @@ static int __init _omap_gpio_init(void)
1428 1429
1429 gpio_bank_count = OMAP34XX_NR_GPIOS; 1430 gpio_bank_count = OMAP34XX_NR_GPIOS;
1430 gpio_bank = gpio_bank_34xx; 1431 gpio_bank = gpio_bank_34xx;
1431 rev = omap_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION); 1432 rev = __raw_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION);
1432 printk(KERN_INFO "OMAP34xx GPIO hardware version %d.%d\n", 1433 printk(KERN_INFO "OMAP34xx GPIO hardware version %d.%d\n",
1433 (rev >> 4) & 0x0f, rev & 0x0f); 1434 (rev >> 4) & 0x0f, rev & 0x0f);
1434 } 1435 }
@@ -1437,10 +1438,9 @@ static int __init _omap_gpio_init(void)
1437 int j, gpio_count = 16; 1438 int j, gpio_count = 16;
1438 1439
1439 bank = &gpio_bank[i]; 1440 bank = &gpio_bank[i];
1440 bank->base = IO_ADDRESS(bank->base);
1441 spin_lock_init(&bank->lock); 1441 spin_lock_init(&bank->lock);
1442 if (bank_is_mpuio(bank)) 1442 if (bank_is_mpuio(bank))
1443 omap_writew(0xFFFF, OMAP_MPUIO_BASE + OMAP_MPUIO_GPIO_MASKIT); 1443 __raw_writew(0xffff, bank->base + OMAP_MPUIO_GPIO_MASKIT);
1444 if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) { 1444 if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) {
1445 __raw_writew(0xffff, bank->base + OMAP1510_GPIO_INT_MASK); 1445 __raw_writew(0xffff, bank->base + OMAP1510_GPIO_INT_MASK);
1446 __raw_writew(0x0000, bank->base + OMAP1510_GPIO_INT_STATUS); 1446 __raw_writew(0x0000, bank->base + OMAP1510_GPIO_INT_STATUS);
diff --git a/arch/arm/plat-omap/include/mach/board-2430sdp.h b/arch/arm/plat-omap/include/mach/board-2430sdp.h
index cf1dc0223949..10d449ea7ed0 100644
--- a/arch/arm/plat-omap/include/mach/board-2430sdp.h
+++ b/arch/arm/plat-omap/include/mach/board-2430sdp.h
@@ -30,10 +30,12 @@
30#define __ASM_ARCH_OMAP_2430SDP_H 30#define __ASM_ARCH_OMAP_2430SDP_H
31 31
32/* Placeholder for 2430SDP specific defines */ 32/* Placeholder for 2430SDP specific defines */
33#define OMAP24XX_ETHR_START 0x08000300 33#define OMAP24XX_ETHR_START 0x08000300
34#define OMAP24XX_ETHR_GPIO_IRQ 149 34#define OMAP24XX_ETHR_GPIO_IRQ 149
35#define SDP2430_CS0_BASE 0x04000000 35#define SDP2430_CS0_BASE 0x04000000
36 36
37#define TWL4030_IRQNUM INT_24XX_SYS_NIRQ 37/* Function prototypes */
38extern void sdp2430_flash_init(void);
39extern void sdp2430_usb_init(void);
38 40
39#endif /* __ASM_ARCH_OMAP_2430SDP_H */ 41#endif /* __ASM_ARCH_OMAP_2430SDP_H */
diff --git a/arch/arm/plat-omap/include/mach/board-apollon.h b/arch/arm/plat-omap/include/mach/board-apollon.h
index d6f2a8e963d5..731c858cf3fe 100644
--- a/arch/arm/plat-omap/include/mach/board-apollon.h
+++ b/arch/arm/plat-omap/include/mach/board-apollon.h
@@ -31,6 +31,12 @@
31 31
32extern void apollon_mmc_init(void); 32extern void apollon_mmc_init(void);
33 33
34static inline int apollon_plus(void)
35{
36 /* The apollon plus has IDCODE revision 5 */
37 return system_rev & 0xc0;
38}
39
34/* Placeholder for APOLLON specific defines */ 40/* Placeholder for APOLLON specific defines */
35#define APOLLON_ETHR_GPIO_IRQ 74 41#define APOLLON_ETHR_GPIO_IRQ 74
36 42
diff --git a/arch/arm/plat-omap/include/mach/board-h4.h b/arch/arm/plat-omap/include/mach/board-h4.h
index 1470cd3e519b..7c3fa0f0a65e 100644
--- a/arch/arm/plat-omap/include/mach/board-h4.h
+++ b/arch/arm/plat-omap/include/mach/board-h4.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/plat-omap/include/mach/board-h4.h 2 * arch/arm/plat-omap/include/mach/board-h4.h
3 * 3 *
4 * Hardware definitions for TI OMAP1610 H4 board. 4 * Hardware definitions for TI OMAP2420 H4 board.
5 * 5 *
6 * Initial creation by Dirk Behme <dirk.behme@de.bosch.com> 6 * Initial creation by Dirk Behme <dirk.behme@de.bosch.com>
7 * 7 *
@@ -29,6 +29,9 @@
29#ifndef __ASM_ARCH_OMAP_H4_H 29#ifndef __ASM_ARCH_OMAP_H4_H
30#define __ASM_ARCH_OMAP_H4_H 30#define __ASM_ARCH_OMAP_H4_H
31 31
32/* MMC Prototypes */
33extern void h4_mmc_init(void);
34
32/* Placeholder for H4 specific defines */ 35/* Placeholder for H4 specific defines */
33#define OMAP24XX_ETHR_GPIO_IRQ 92 36#define OMAP24XX_ETHR_GPIO_IRQ 92
34#endif /* __ASM_ARCH_OMAP_H4_H */ 37#endif /* __ASM_ARCH_OMAP_H4_H */
diff --git a/arch/arm/plat-omap/include/mach/board-ldp.h b/arch/arm/plat-omap/include/mach/board-ldp.h
new file mode 100644
index 000000000000..66e2746c04ca
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/board-ldp.h
@@ -0,0 +1,36 @@
1/*
2 * arch/arm/plat-omap/include/mach/board-ldp.h
3 *
4 * Hardware definitions for TI OMAP3 LDP.
5 *
6 * Copyright (C) 2008 Texas Instruments Inc.
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 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28
29#ifndef __ASM_ARCH_OMAP_LDP_H
30#define __ASM_ARCH_OMAP_LDP_H
31
32extern void twl4030_bci_battery_init(void);
33
34#define TWL4030_IRQNUM INT_34XX_SYS_NIRQ
35
36#endif /* __ASM_ARCH_OMAP_LDP_H */
diff --git a/arch/arm/plat-omap/include/mach/board-omap3beagle.h b/arch/arm/plat-omap/include/mach/board-omap3beagle.h
new file mode 100644
index 000000000000..3080d52d877a
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/board-omap3beagle.h
@@ -0,0 +1,33 @@
1/*
2 * arch/arm/plat-omap/include/mach/board-omap3beagle.h
3 *
4 * Hardware definitions for TI OMAP3 BEAGLE.
5 *
6 * Initial creation by Syed Mohammed Khasim <khasim@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28
29#ifndef __ASM_ARCH_OMAP3_BEAGLE_H
30#define __ASM_ARCH_OMAP3_BEAGLE_H
31
32#endif /* __ASM_ARCH_OMAP3_BEAGLE_H */
33
diff --git a/arch/arm/plat-omap/include/mach/board-overo.h b/arch/arm/plat-omap/include/mach/board-overo.h
new file mode 100644
index 000000000000..7ecae66966d1
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/board-overo.h
@@ -0,0 +1,26 @@
1/*
2 * board-overo.h (Gumstix Overo)
3 *
4 * Initial code: Steve Sakoman <steve@sakoman.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
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 * 675 Mass Ave, Cambridge, MA 02139, USA.
14 */
15
16#ifndef __ASM_ARCH_OVERO_H
17#define __ASM_ARCH_OVERO_H
18
19#define OVERO_GPIO_BT_XGATE 15
20#define OVERO_GPIO_W2W_NRESET 16
21#define OVERO_GPIO_BT_NRESET 164
22#define OVERO_GPIO_USBH_CPEN 168
23#define OVERO_GPIO_USBH_NRESET 183
24
25#endif /* ____ASM_ARCH_OVERO_H */
26
diff --git a/arch/arm/plat-omap/include/mach/board.h b/arch/arm/plat-omap/include/mach/board.h
index 54445642f35d..c23c12ccb353 100644
--- a/arch/arm/plat-omap/include/mach/board.h
+++ b/arch/arm/plat-omap/include/mach/board.h
@@ -45,6 +45,8 @@ struct omap_mmc_conf {
45 unsigned cover:1; 45 unsigned cover:1;
46 /* 4 wire signaling is optional, and is only used for SD/SDIO */ 46 /* 4 wire signaling is optional, and is only used for SD/SDIO */
47 unsigned wire4:1; 47 unsigned wire4:1;
48 /* use the internal clock */
49 unsigned internal_clock:1;
48 s16 power_pin; 50 s16 power_pin;
49 s16 switch_pin; 51 s16 switch_pin;
50 s16 wp_pin; 52 s16 wp_pin;
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index 92f7c7238fcd..719298554ed7 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -15,6 +15,7 @@
15 15
16struct module; 16struct module;
17struct clk; 17struct clk;
18struct clockdomain;
18 19
19#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 20#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
20 21
@@ -79,6 +80,8 @@ struct clk {
79 u32 clksel_mask; 80 u32 clksel_mask;
80 const struct clksel *clksel; 81 const struct clksel *clksel;
81 struct dpll_data *dpll_data; 82 struct dpll_data *dpll_data;
83 const char *clkdm_name;
84 struct clockdomain *clkdm;
82#else 85#else
83 __u8 rate_offset; 86 __u8 rate_offset;
84 __u8 src_offset; 87 __u8 src_offset;
diff --git a/arch/arm/plat-omap/include/mach/clockdomain.h b/arch/arm/plat-omap/include/mach/clockdomain.h
new file mode 100644
index 000000000000..1f51f0173784
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/clockdomain.h
@@ -0,0 +1,106 @@
1/*
2 * linux/include/asm-arm/arch-omap/clockdomain.h
3 *
4 * OMAP2/3 clockdomain framework functions
5 *
6 * Copyright (C) 2008 Texas Instruments, Inc.
7 * Copyright (C) 2008 Nokia Corporation
8 *
9 * Written by Paul Walmsley
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#ifndef __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H
17#define __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H
18
19#include <mach/powerdomain.h>
20#include <mach/clock.h>
21#include <mach/cpu.h>
22
23/* Clockdomain capability flags */
24#define CLKDM_CAN_FORCE_SLEEP (1 << 0)
25#define CLKDM_CAN_FORCE_WAKEUP (1 << 1)
26#define CLKDM_CAN_ENABLE_AUTO (1 << 2)
27#define CLKDM_CAN_DISABLE_AUTO (1 << 3)
28
29#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)
30#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
31#define CLKDM_CAN_HWSUP_SWSUP (CLKDM_CAN_SWSUP | CLKDM_CAN_HWSUP)
32
33/* OMAP24XX CM_CLKSTCTRL_*.AUTOSTATE_* register bit values */
34#define OMAP24XX_CLKSTCTRL_DISABLE_AUTO 0x0
35#define OMAP24XX_CLKSTCTRL_ENABLE_AUTO 0x1
36
37/* OMAP3XXX CM_CLKSTCTRL_*.CLKTRCTRL_* register bit values */
38#define OMAP34XX_CLKSTCTRL_DISABLE_AUTO 0x0
39#define OMAP34XX_CLKSTCTRL_FORCE_SLEEP 0x1
40#define OMAP34XX_CLKSTCTRL_FORCE_WAKEUP 0x2
41#define OMAP34XX_CLKSTCTRL_ENABLE_AUTO 0x3
42
43/*
44 * struct clkdm_pwrdm_autodep - a powerdomain that should have wkdeps
45 * and sleepdeps added when a powerdomain should stay active in hwsup mode;
46 * and conversely, removed when the powerdomain should be allowed to go
47 * inactive in hwsup mode.
48 */
49struct clkdm_pwrdm_autodep {
50
51 /* Name of the powerdomain to add a wkdep/sleepdep on */
52 const char *pwrdm_name;
53
54 /* Powerdomain pointer (looked up at clkdm_init() time) */
55 struct powerdomain *pwrdm;
56
57 /* OMAP chip types that this clockdomain dep is valid on */
58 const struct omap_chip_id omap_chip;
59
60};
61
62struct clockdomain {
63
64 /* Clockdomain name */
65 const char *name;
66
67 /* Powerdomain enclosing this clockdomain */
68 const char *pwrdm_name;
69
70 /* CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg */
71 const u16 clktrctrl_mask;
72
73 /* Clockdomain capability flags */
74 const u8 flags;
75
76 /* OMAP chip types that this clockdomain is valid on */
77 const struct omap_chip_id omap_chip;
78
79 /* Usecount tracking */
80 atomic_t usecount;
81
82 /* Powerdomain pointer assigned at clkdm_register() */
83 struct powerdomain *pwrdm;
84
85 struct list_head node;
86
87};
88
89void clkdm_init(struct clockdomain **clkdms, struct clkdm_pwrdm_autodep *autodeps);
90int clkdm_register(struct clockdomain *clkdm);
91int clkdm_unregister(struct clockdomain *clkdm);
92struct clockdomain *clkdm_lookup(const char *name);
93
94int clkdm_for_each(int (*fn)(struct clockdomain *clkdm));
95struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm);
96
97void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
98void omap2_clkdm_deny_idle(struct clockdomain *clkdm);
99
100int omap2_clkdm_wakeup(struct clockdomain *clkdm);
101int omap2_clkdm_sleep(struct clockdomain *clkdm);
102
103int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
104int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
105
106#endif
diff --git a/arch/arm/plat-omap/include/mach/common.h b/arch/arm/plat-omap/include/mach/common.h
index 06093112b665..ef70e2b0f054 100644
--- a/arch/arm/plat-omap/include/mach/common.h
+++ b/arch/arm/plat-omap/include/mach/common.h
@@ -34,6 +34,7 @@ struct sys_timer;
34extern void omap_map_common_io(void); 34extern void omap_map_common_io(void);
35extern struct sys_timer omap_timer; 35extern struct sys_timer omap_timer;
36extern void omap_serial_init(void); 36extern void omap_serial_init(void);
37extern void omap_serial_enable_clocks(int enable);
37#ifdef CONFIG_I2C_OMAP 38#ifdef CONFIG_I2C_OMAP
38extern int omap_register_i2c_bus(int bus_id, u32 clkrate, 39extern int omap_register_i2c_bus(int bus_id, u32 clkrate,
39 struct i2c_board_info const *info, 40 struct i2c_board_info const *info,
@@ -49,6 +50,7 @@ static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
49 50
50/* IO bases for various OMAP processors */ 51/* IO bases for various OMAP processors */
51struct omap_globals { 52struct omap_globals {
53 u32 class; /* OMAP class to detect */
52 void __iomem *tap; /* Control module ID code */ 54 void __iomem *tap; /* Control module ID code */
53 void __iomem *sdrc; /* SDRAM Controller */ 55 void __iomem *sdrc; /* SDRAM Controller */
54 void __iomem *sms; /* SDRAM Memory Scheduler */ 56 void __iomem *sms; /* SDRAM Memory Scheduler */
@@ -62,6 +64,7 @@ void omap2_set_globals_243x(void);
62void omap2_set_globals_343x(void); 64void omap2_set_globals_343x(void);
63 65
64/* These get called from omap2_set_globals_xxxx(), do not call these */ 66/* These get called from omap2_set_globals_xxxx(), do not call these */
67void omap2_set_globals_tap(struct omap_globals *);
65void omap2_set_globals_memory(struct omap_globals *); 68void omap2_set_globals_memory(struct omap_globals *);
66void omap2_set_globals_control(struct omap_globals *); 69void omap2_set_globals_control(struct omap_globals *);
67void omap2_set_globals_prcm(struct omap_globals *); 70void omap2_set_globals_prcm(struct omap_globals *);
diff --git a/arch/arm/plat-omap/include/mach/control.h b/arch/arm/plat-omap/include/mach/control.h
index e3fd62d9a995..dc9886760577 100644
--- a/arch/arm/plat-omap/include/mach/control.h
+++ b/arch/arm/plat-omap/include/mach/control.h
@@ -1,13 +1,10 @@
1#ifndef __ASM_ARCH_CONTROL_H
2#define __ASM_ARCH_CONTROL_H
3
4/* 1/*
5 * arch/arm/plat-omap/include/mach/control.h 2 * arch/arm/plat-omap/include/mach/control.h
6 * 3 *
7 * OMAP2/3 System Control Module definitions 4 * OMAP2/3 System Control Module definitions
8 * 5 *
9 * Copyright (C) 2007 Texas Instruments, Inc. 6 * Copyright (C) 2007-2008 Texas Instruments, Inc.
10 * Copyright (C) 2007 Nokia Corporation 7 * Copyright (C) 2007-2008 Nokia Corporation
11 * 8 *
12 * Written by Paul Walmsley 9 * Written by Paul Walmsley
13 * 10 *
@@ -16,14 +13,23 @@
16 * the Free Software Foundation. 13 * the Free Software Foundation.
17 */ 14 */
18 15
16#ifndef __ASM_ARCH_CONTROL_H
17#define __ASM_ARCH_CONTROL_H
18
19#include <mach/io.h> 19#include <mach/io.h>
20 20
21#ifndef __ASSEMBLY__
21#define OMAP242X_CTRL_REGADDR(reg) \ 22#define OMAP242X_CTRL_REGADDR(reg) \
22 (void __iomem *)IO_ADDRESS(OMAP242X_CTRL_BASE + (reg)) 23 IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
23#define OMAP243X_CTRL_REGADDR(reg) \ 24#define OMAP243X_CTRL_REGADDR(reg) \
24 (void __iomem *)IO_ADDRESS(OMAP243X_CTRL_BASE + (reg)) 25 IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
25#define OMAP343X_CTRL_REGADDR(reg) \ 26#define OMAP343X_CTRL_REGADDR(reg) \
26 (void __iomem *)IO_ADDRESS(OMAP343X_CTRL_BASE + (reg)) 27 IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
28#else
29#define OMAP242X_CTRL_REGADDR(reg) IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
30#define OMAP243X_CTRL_REGADDR(reg) IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
31#define OMAP343X_CTRL_REGADDR(reg) IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
32#endif /* __ASSEMBLY__ */
27 33
28/* 34/*
29 * As elsewhere, the "OMAP2_" prefix indicates that the macro is valid for 35 * As elsewhere, the "OMAP2_" prefix indicates that the macro is valid for
@@ -134,6 +140,7 @@
134#define OMAP343X_CONTROL_TEST_KEY_13 (OMAP2_CONTROL_GENERAL + 0x00fc) 140#define OMAP343X_CONTROL_TEST_KEY_13 (OMAP2_CONTROL_GENERAL + 0x00fc)
135#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190) 141#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
136#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194) 142#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
143#define OMAP343X_CONTROL_TEMP_SENSOR (OMAP2_CONTROL_GENERAL + 0x02b4)
137 144
138/* 145/*
139 * REVISIT: This list of registers is not comprehensive - there are more 146 * REVISIT: This list of registers is not comprehensive - there are more
diff --git a/arch/arm/plat-omap/include/mach/cpu.h b/arch/arm/plat-omap/include/mach/cpu.h
index 05aee0eda34f..e0464187209d 100644
--- a/arch/arm/plat-omap/include/mach/cpu.h
+++ b/arch/arm/plat-omap/include/mach/cpu.h
@@ -346,9 +346,14 @@ IS_OMAP_TYPE(3430, 0x3430)
346 get_sil_revision(system_rev) 346 get_sil_revision(system_rev)
347 347
348/* Various silicon macros defined here */ 348/* Various silicon macros defined here */
349#define OMAP242X_CLASS 0x24200000
349#define OMAP2420_REV_ES1_0 0x24200000 350#define OMAP2420_REV_ES1_0 0x24200000
350#define OMAP2420_REV_ES2_0 0x24201000 351#define OMAP2420_REV_ES2_0 0x24201000
352
353#define OMAP243X_CLASS 0x24300000
351#define OMAP2430_REV_ES1_0 0x24300000 354#define OMAP2430_REV_ES1_0 0x24300000
355
356#define OMAP343X_CLASS 0x34300000
352#define OMAP3430_REV_ES1_0 0x34300000 357#define OMAP3430_REV_ES1_0 0x34300000
353#define OMAP3430_REV_ES2_0 0x34301000 358#define OMAP3430_REV_ES2_0 0x34301000
354#define OMAP3430_REV_ES2_1 0x34302000 359#define OMAP3430_REV_ES2_1 0x34302000
diff --git a/arch/arm/plat-omap/include/mach/debug-macro.S b/arch/arm/plat-omap/include/mach/debug-macro.S
index 1b0039bdeb4e..1b11f5c6a2d9 100644
--- a/arch/arm/plat-omap/include/mach/debug-macro.S
+++ b/arch/arm/plat-omap/include/mach/debug-macro.S
@@ -35,6 +35,18 @@
35#ifdef CONFIG_OMAP_LL_DEBUG_UART3 35#ifdef CONFIG_OMAP_LL_DEBUG_UART3
36 add \rx, \rx, #0x00004000 @ UART 3 36 add \rx, \rx, #0x00004000 @ UART 3
37#endif 37#endif
38
39#elif CONFIG_ARCH_OMAP3
40 moveq \rx, #0x48000000 @ physical base address
41 movne \rx, #0xd8000000 @ virtual base
42 orr \rx, \rx, #0x0006a000
43#ifdef CONFIG_OMAP_LL_DEBUG_UART2
44 add \rx, \rx, #0x00002000 @ UART 2
45#endif
46#ifdef CONFIG_OMAP_LL_DEBUG_UART3
47 add \rx, \rx, #0x00fb0000 @ UART 3
48 add \rx, \rx, #0x00006000
49#endif
38#endif 50#endif
39 .endm 51 .endm
40 52
diff --git a/arch/arm/plat-omap/include/mach/entry-macro.S b/arch/arm/plat-omap/include/mach/entry-macro.S
index d4e9043bf201..030118ee204a 100644
--- a/arch/arm/plat-omap/include/mach/entry-macro.S
+++ b/arch/arm/plat-omap/include/mach/entry-macro.S
@@ -55,9 +55,17 @@
551510: 551510:
56 .endm 56 .endm
57 57
58#elif defined(CONFIG_ARCH_OMAP24XX) 58#endif
59#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
59 60
61#if defined(CONFIG_ARCH_OMAP24XX)
60#include <mach/omap24xx.h> 62#include <mach/omap24xx.h>
63#endif
64#if defined(CONFIG_ARCH_OMAP34XX)
65#include <mach/omap34xx.h>
66#endif
67
68#define INTCPS_SIR_IRQ_OFFSET 0x0040 /* Active interrupt number */
61 69
62 .macro disable_fiq 70 .macro disable_fiq
63 .endm 71 .endm
@@ -79,7 +87,7 @@
79 ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */ 87 ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
80 cmp \irqnr, #0x0 88 cmp \irqnr, #0x0
812222: 892222:
82 ldrne \irqnr, [\base, #IRQ_SIR_IRQ] 90 ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
83 91
84 .endm 92 .endm
85 93
diff --git a/arch/arm/plat-omap/include/mach/fpga.h b/arch/arm/plat-omap/include/mach/fpga.h
index c92e4b42b289..f1864a652f7a 100644
--- a/arch/arm/plat-omap/include/mach/fpga.h
+++ b/arch/arm/plat-omap/include/mach/fpga.h
@@ -34,9 +34,9 @@ extern void omap1510_fpga_init_irq(void);
34 * --------------------------------------------------------------------------- 34 * ---------------------------------------------------------------------------
35 */ 35 */
36/* maps in the FPGA registers and the ETHR registers */ 36/* maps in the FPGA registers and the ETHR registers */
37#define H2P2_DBG_FPGA_BASE 0xE8000000 /* VA */ 37#define H2P2_DBG_FPGA_BASE IOMEM(0xE8000000) /* VA */
38#define H2P2_DBG_FPGA_SIZE SZ_4K /* SIZE */ 38#define H2P2_DBG_FPGA_SIZE SZ_4K /* SIZE */
39#define H2P2_DBG_FPGA_START 0x04000000 /* PA */ 39#define H2P2_DBG_FPGA_START 0x04000000 /* PA */
40 40
41#define H2P2_DBG_FPGA_ETHR_START (H2P2_DBG_FPGA_START + 0x300) 41#define H2P2_DBG_FPGA_ETHR_START (H2P2_DBG_FPGA_START + 0x300)
42#define H2P2_DBG_FPGA_FPGA_REV (H2P2_DBG_FPGA_BASE + 0x10) /* FPGA Revision */ 42#define H2P2_DBG_FPGA_FPGA_REV (H2P2_DBG_FPGA_BASE + 0x10) /* FPGA Revision */
@@ -85,9 +85,9 @@ struct h2p2_dbg_fpga {
85 * OMAP-1510 FPGA 85 * OMAP-1510 FPGA
86 * --------------------------------------------------------------------------- 86 * ---------------------------------------------------------------------------
87 */ 87 */
88#define OMAP1510_FPGA_BASE 0xE8000000 /* Virtual */ 88#define OMAP1510_FPGA_BASE IOMEM(0xE8000000) /* VA */
89#define OMAP1510_FPGA_SIZE SZ_4K 89#define OMAP1510_FPGA_SIZE SZ_4K
90#define OMAP1510_FPGA_START 0x08000000 /* Physical */ 90#define OMAP1510_FPGA_START 0x08000000 /* PA */
91 91
92/* Revision */ 92/* Revision */
93#define OMAP1510_FPGA_REV_LOW (OMAP1510_FPGA_BASE + 0x0) 93#define OMAP1510_FPGA_REV_LOW (OMAP1510_FPGA_BASE + 0x0)
diff --git a/arch/arm/plat-omap/include/mach/gpio.h b/arch/arm/plat-omap/include/mach/gpio.h
index 8c71e288860f..98e9008b7e9d 100644
--- a/arch/arm/plat-omap/include/mach/gpio.h
+++ b/arch/arm/plat-omap/include/mach/gpio.h
@@ -29,7 +29,7 @@
29#include <linux/io.h> 29#include <linux/io.h>
30#include <mach/irqs.h> 30#include <mach/irqs.h>
31 31
32#define OMAP_MPUIO_BASE (void __iomem *)0xfffb5000 32#define OMAP_MPUIO_BASE 0xfffb5000
33 33
34#ifdef CONFIG_ARCH_OMAP730 34#ifdef CONFIG_ARCH_OMAP730
35#define OMAP_MPUIO_INPUT_LATCH 0x00 35#define OMAP_MPUIO_INPUT_LATCH 0x00
@@ -76,6 +76,8 @@ extern void omap_free_gpio(int gpio);
76extern void omap_set_gpio_direction(int gpio, int is_input); 76extern void omap_set_gpio_direction(int gpio, int is_input);
77extern void omap_set_gpio_dataout(int gpio, int enable); 77extern void omap_set_gpio_dataout(int gpio, int enable);
78extern int omap_get_gpio_datain(int gpio); 78extern int omap_get_gpio_datain(int gpio);
79extern void omap2_gpio_prepare_for_retention(void);
80extern void omap2_gpio_resume_after_retention(void);
79extern void omap_set_gpio_debounce(int gpio, int enable); 81extern void omap_set_gpio_debounce(int gpio, int enable);
80extern void omap_set_gpio_debounce_time(int gpio, int enable); 82extern void omap_set_gpio_debounce_time(int gpio, int enable);
81 83
diff --git a/arch/arm/plat-omap/include/mach/gpmc.h b/arch/arm/plat-omap/include/mach/gpmc.h
index 6a8e07ffc2d0..45b678439bb7 100644
--- a/arch/arm/plat-omap/include/mach/gpmc.h
+++ b/arch/arm/plat-omap/include/mach/gpmc.h
@@ -11,6 +11,9 @@
11#ifndef __OMAP2_GPMC_H 11#ifndef __OMAP2_GPMC_H
12#define __OMAP2_GPMC_H 12#define __OMAP2_GPMC_H
13 13
14/* Maximum Number of Chip Selects */
15#define GPMC_CS_NUM 8
16
14#define GPMC_CS_CONFIG1 0x00 17#define GPMC_CS_CONFIG1 0x00
15#define GPMC_CS_CONFIG2 0x04 18#define GPMC_CS_CONFIG2 0x04
16#define GPMC_CS_CONFIG3 0x08 19#define GPMC_CS_CONFIG3 0x08
@@ -22,6 +25,9 @@
22#define GPMC_CS_NAND_ADDRESS 0x20 25#define GPMC_CS_NAND_ADDRESS 0x20
23#define GPMC_CS_NAND_DATA 0x24 26#define GPMC_CS_NAND_DATA 0x24
24 27
28#define GPMC_CONFIG 0x50
29#define GPMC_STATUS 0x54
30
25#define GPMC_CONFIG1_WRAPBURST_SUPP (1 << 31) 31#define GPMC_CONFIG1_WRAPBURST_SUPP (1 << 31)
26#define GPMC_CONFIG1_READMULTIPLE_SUPP (1 << 30) 32#define GPMC_CONFIG1_READMULTIPLE_SUPP (1 << 30)
27#define GPMC_CONFIG1_READTYPE_ASYNC (0 << 29) 33#define GPMC_CONFIG1_READTYPE_ASYNC (0 << 29)
@@ -78,9 +84,14 @@ struct gpmc_timings {
78 u16 access; /* Start-cycle to first data valid delay */ 84 u16 access; /* Start-cycle to first data valid delay */
79 u16 rd_cycle; /* Total read cycle time */ 85 u16 rd_cycle; /* Total read cycle time */
80 u16 wr_cycle; /* Total write cycle time */ 86 u16 wr_cycle; /* Total write cycle time */
87
88 /* The following are only on OMAP3430 */
89 u16 wr_access; /* WRACCESSTIME */
90 u16 wr_data_mux_bus; /* WRDATAONADMUXBUS */
81}; 91};
82 92
83extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns); 93extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns);
94extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
84extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns); 95extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns);
85extern unsigned long gpmc_get_fclk_period(void); 96extern unsigned long gpmc_get_fclk_period(void);
86 97
@@ -92,5 +103,6 @@ extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
92extern void gpmc_cs_free(int cs); 103extern void gpmc_cs_free(int cs);
93extern int gpmc_cs_set_reserved(int cs, int reserved); 104extern int gpmc_cs_set_reserved(int cs, int reserved);
94extern int gpmc_cs_reserved(int cs); 105extern int gpmc_cs_reserved(int cs);
106extern void gpmc_init(void);
95 107
96#endif 108#endif
diff --git a/arch/arm/plat-omap/include/mach/hardware.h b/arch/arm/plat-omap/include/mach/hardware.h
index 07f5d7f21528..6589ddbb63b2 100644
--- a/arch/arm/plat-omap/include/mach/hardware.h
+++ b/arch/arm/plat-omap/include/mach/hardware.h
@@ -89,7 +89,7 @@
89#define DPLL_CTL (0xfffecf00) 89#define DPLL_CTL (0xfffecf00)
90 90
91/* DSP clock control. Must use __raw_readw() and __raw_writew() with these */ 91/* DSP clock control. Must use __raw_readw() and __raw_writew() with these */
92#define DSP_CONFIG_REG_BASE (0xe1008000) 92#define DSP_CONFIG_REG_BASE IOMEM(0xe1008000)
93#define DSP_CKCTL (DSP_CONFIG_REG_BASE + 0x0) 93#define DSP_CKCTL (DSP_CONFIG_REG_BASE + 0x0)
94#define DSP_IDLECT1 (DSP_CONFIG_REG_BASE + 0x4) 94#define DSP_IDLECT1 (DSP_CONFIG_REG_BASE + 0x4)
95#define DSP_IDLECT2 (DSP_CONFIG_REG_BASE + 0x8) 95#define DSP_IDLECT2 (DSP_CONFIG_REG_BASE + 0x8)
@@ -282,8 +282,8 @@
282 282
283#include "omap730.h" 283#include "omap730.h"
284#include "omap1510.h" 284#include "omap1510.h"
285#include "omap24xx.h"
286#include "omap16xx.h" 285#include "omap16xx.h"
286#include "omap24xx.h"
287#include "omap34xx.h" 287#include "omap34xx.h"
288 288
289#ifndef __ASSEMBLER__ 289#ifndef __ASSEMBLER__
@@ -322,6 +322,14 @@
322#include "board-2430sdp.h" 322#include "board-2430sdp.h"
323#endif 323#endif
324 324
325#ifdef CONFIG_MACH_OMAP3_BEAGLE
326#include "board-omap3beagle.h"
327#endif
328
329#ifdef CONFIG_MACH_OMAP_LDP
330#include "board-ldp.h"
331#endif
332
325#ifdef CONFIG_MACH_OMAP_APOLLON 333#ifdef CONFIG_MACH_OMAP_APOLLON
326#include "board-apollon.h" 334#include "board-apollon.h"
327#endif 335#endif
diff --git a/arch/arm/plat-omap/include/mach/io.h b/arch/arm/plat-omap/include/mach/io.h
index 2a30b7d88cde..adc83b7b8205 100644
--- a/arch/arm/plat-omap/include/mach/io.h
+++ b/arch/arm/plat-omap/include/mach/io.h
@@ -55,14 +55,13 @@
55 55
56#if defined(CONFIG_ARCH_OMAP1) 56#if defined(CONFIG_ARCH_OMAP1)
57 57
58#define IO_PHYS 0xFFFB0000 58#define IO_PHYS 0xFFFB0000
59#define IO_OFFSET 0x01000000 /* Virtual IO = 0xfefb0000 */ 59#define IO_OFFSET 0x01000000 /* Virtual IO = 0xfefb0000 */
60#define IO_SIZE 0x40000 60#define IO_SIZE 0x40000
61#define IO_VIRT (IO_PHYS - IO_OFFSET) 61#define IO_VIRT (IO_PHYS - IO_OFFSET)
62#define IO_ADDRESS(pa) ((pa) - IO_OFFSET) 62#define __IO_ADDRESS(pa) ((pa) - IO_OFFSET)
63#define OMAP1_IO_ADDRESS(pa) ((pa) - IO_OFFSET) 63#define __OMAP1_IO_ADDRESS(pa) ((pa) - IO_OFFSET)
64#define io_p2v(pa) ((pa) - IO_OFFSET) 64#define io_v2p(va) ((va) + IO_OFFSET)
65#define io_v2p(va) ((va) + IO_OFFSET)
66 65
67#elif defined(CONFIG_ARCH_OMAP2) 66#elif defined(CONFIG_ARCH_OMAP2)
68 67
@@ -74,7 +73,6 @@
74#define L4_24XX_VIRT 0xd8000000 73#define L4_24XX_VIRT 0xd8000000
75#define L4_24XX_SIZE SZ_1M /* 1MB of 128MB used, want 1MB sect */ 74#define L4_24XX_SIZE SZ_1M /* 1MB of 128MB used, want 1MB sect */
76 75
77#ifdef CONFIG_ARCH_OMAP2430
78#define L4_WK_243X_PHYS L4_WK_243X_BASE /* 0x49000000 */ 76#define L4_WK_243X_PHYS L4_WK_243X_BASE /* 0x49000000 */
79#define L4_WK_243X_VIRT 0xd9000000 77#define L4_WK_243X_VIRT 0xd9000000
80#define L4_WK_243X_SIZE SZ_1M 78#define L4_WK_243X_SIZE SZ_1M
@@ -88,13 +86,10 @@
88#define OMAP243X_SMS_VIRT 0xFC000000 86#define OMAP243X_SMS_VIRT 0xFC000000
89#define OMAP243X_SMS_SIZE SZ_1M 87#define OMAP243X_SMS_SIZE SZ_1M
90 88
91#endif 89#define IO_OFFSET 0x90000000
92 90#define __IO_ADDRESS(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */
93#define IO_OFFSET 0x90000000 91#define __OMAP2_IO_ADDRESS(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */
94#define IO_ADDRESS(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */ 92#define io_v2p(va) ((va) - IO_OFFSET) /* Works for L3 and L4 */
95#define OMAP2_IO_ADDRESS(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */
96#define io_p2v(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */
97#define io_v2p(va) ((va) - IO_OFFSET) /* Works for L3 and L4 */
98 93
99/* DSP */ 94/* DSP */
100#define DSP_MEM_24XX_PHYS OMAP2420_DSP_MEM_BASE /* 0x58000000 */ 95#define DSP_MEM_24XX_PHYS OMAP2420_DSP_MEM_BASE /* 0x58000000 */
@@ -149,9 +144,8 @@
149 144
150 145
151#define IO_OFFSET 0x90000000 146#define IO_OFFSET 0x90000000
152#define IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ 147#define __IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */
153#define OMAP2_IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ 148#define __OMAP2_IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */
154#define io_p2v(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */
155#define io_v2p(va) ((va) - IO_OFFSET)/* Works for L3 and L4 */ 149#define io_v2p(va) ((va) - IO_OFFSET)/* Works for L3 and L4 */
156 150
157/* DSP */ 151/* DSP */
@@ -167,7 +161,14 @@
167 161
168#endif 162#endif
169 163
170#ifndef __ASSEMBLER__ 164#define IO_ADDRESS(pa) IOMEM(__IO_ADDRESS(pa))
165#define OMAP1_IO_ADDRESS(pa) IOMEM(__OMAP1_IO_ADDRESS(pa))
166#define OMAP2_IO_ADDRESS(pa) IOMEM(__OMAP2_IO_ADDRESS(pa))
167
168#ifdef __ASSEMBLER__
169#define IOMEM(x) x
170#else
171#define IOMEM(x) ((void __force __iomem *)(x))
171 172
172/* 173/*
173 * Functions to access the OMAP IO region 174 * Functions to access the OMAP IO region
@@ -178,13 +179,13 @@
178 * - DO NOT use hardcoded virtual addresses to allow changing the 179 * - DO NOT use hardcoded virtual addresses to allow changing the
179 * IO address space again if needed 180 * IO address space again if needed
180 */ 181 */
181#define omap_readb(a) (*(volatile unsigned char *)IO_ADDRESS(a)) 182#define omap_readb(a) __raw_readb(IO_ADDRESS(a))
182#define omap_readw(a) (*(volatile unsigned short *)IO_ADDRESS(a)) 183#define omap_readw(a) __raw_readw(IO_ADDRESS(a))
183#define omap_readl(a) (*(volatile unsigned int *)IO_ADDRESS(a)) 184#define omap_readl(a) __raw_readl(IO_ADDRESS(a))
184 185
185#define omap_writeb(v,a) (*(volatile unsigned char *)IO_ADDRESS(a) = (v)) 186#define omap_writeb(v,a) __raw_writeb(v, IO_ADDRESS(a))
186#define omap_writew(v,a) (*(volatile unsigned short *)IO_ADDRESS(a) = (v)) 187#define omap_writew(v,a) __raw_writew(v, IO_ADDRESS(a))
187#define omap_writel(v,a) (*(volatile unsigned int *)IO_ADDRESS(a) = (v)) 188#define omap_writel(v,a) __raw_writel(v, IO_ADDRESS(a))
188 189
189extern void omap1_map_common_io(void); 190extern void omap1_map_common_io(void);
190extern void omap1_init_common_hw(void); 191extern void omap1_init_common_hw(void);
@@ -192,6 +193,12 @@ extern void omap1_init_common_hw(void);
192extern void omap2_map_common_io(void); 193extern void omap2_map_common_io(void);
193extern void omap2_init_common_hw(void); 194extern void omap2_init_common_hw(void);
194 195
196#define __arch_ioremap(p,s,t) omap_ioremap(p,s,t)
197#define __arch_iounmap(v) omap_iounmap(v)
198
199void __iomem *omap_ioremap(unsigned long phys, size_t size, unsigned int type);
200void omap_iounmap(volatile void __iomem *addr);
201
195#endif 202#endif
196 203
197#endif 204#endif
diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-omap/include/mach/irqs.h
index 62aa7dfb9464..a2929ac8c687 100644
--- a/arch/arm/plat-omap/include/mach/irqs.h
+++ b/arch/arm/plat-omap/include/mach/irqs.h
@@ -125,6 +125,7 @@
125#define INT_UART2 (15 + IH2_BASE) 125#define INT_UART2 (15 + IH2_BASE)
126#define INT_BT_MCSI1TX (16 + IH2_BASE) 126#define INT_BT_MCSI1TX (16 + IH2_BASE)
127#define INT_BT_MCSI1RX (17 + IH2_BASE) 127#define INT_BT_MCSI1RX (17 + IH2_BASE)
128#define INT_SOSSI_MATCH (19 + IH2_BASE)
128#define INT_USB_W2FC (20 + IH2_BASE) 129#define INT_USB_W2FC (20 + IH2_BASE)
129#define INT_1WIRE (21 + IH2_BASE) 130#define INT_1WIRE (21 + IH2_BASE)
130#define INT_OS_TIMER (22 + IH2_BASE) 131#define INT_OS_TIMER (22 + IH2_BASE)
@@ -176,6 +177,7 @@
176#define INT_1610_DMA_CH14 (61 + IH2_BASE) 177#define INT_1610_DMA_CH14 (61 + IH2_BASE)
177#define INT_1610_DMA_CH15 (62 + IH2_BASE) 178#define INT_1610_DMA_CH15 (62 + IH2_BASE)
178#define INT_1610_NAND (63 + IH2_BASE) 179#define INT_1610_NAND (63 + IH2_BASE)
180#define INT_1610_SHA1MD5 (91 + IH2_BASE)
179 181
180/* 182/*
181 * OMAP-730 specific IRQ numbers for interrupt handler 2 183 * OMAP-730 specific IRQ numbers for interrupt handler 2
@@ -263,12 +265,18 @@
263#define INT_24XX_GPTIMER10 46 265#define INT_24XX_GPTIMER10 46
264#define INT_24XX_GPTIMER11 47 266#define INT_24XX_GPTIMER11 47
265#define INT_24XX_GPTIMER12 48 267#define INT_24XX_GPTIMER12 48
268#define INT_24XX_SHA1MD5 51
269#define INT_24XX_MCBSP4_IRQ_TX 54
270#define INT_24XX_MCBSP4_IRQ_RX 55
266#define INT_24XX_I2C1_IRQ 56 271#define INT_24XX_I2C1_IRQ 56
267#define INT_24XX_I2C2_IRQ 57 272#define INT_24XX_I2C2_IRQ 57
273#define INT_24XX_HDQ_IRQ 58
268#define INT_24XX_MCBSP1_IRQ_TX 59 274#define INT_24XX_MCBSP1_IRQ_TX 59
269#define INT_24XX_MCBSP1_IRQ_RX 60 275#define INT_24XX_MCBSP1_IRQ_RX 60
270#define INT_24XX_MCBSP2_IRQ_TX 62 276#define INT_24XX_MCBSP2_IRQ_TX 62
271#define INT_24XX_MCBSP2_IRQ_RX 63 277#define INT_24XX_MCBSP2_IRQ_RX 63
278#define INT_24XX_SPI1_IRQ 65
279#define INT_24XX_SPI2_IRQ 66
272#define INT_24XX_UART1_IRQ 72 280#define INT_24XX_UART1_IRQ 72
273#define INT_24XX_UART2_IRQ 73 281#define INT_24XX_UART2_IRQ 73
274#define INT_24XX_UART3_IRQ 74 282#define INT_24XX_UART3_IRQ 74
@@ -278,7 +286,58 @@
278#define INT_24XX_USB_IRQ_HGEN 78 286#define INT_24XX_USB_IRQ_HGEN 78
279#define INT_24XX_USB_IRQ_HSOF 79 287#define INT_24XX_USB_IRQ_HSOF 79
280#define INT_24XX_USB_IRQ_OTG 80 288#define INT_24XX_USB_IRQ_OTG 80
289#define INT_24XX_MCBSP5_IRQ_TX 81
290#define INT_24XX_MCBSP5_IRQ_RX 82
281#define INT_24XX_MMC_IRQ 83 291#define INT_24XX_MMC_IRQ 83
292#define INT_24XX_MMC2_IRQ 86
293#define INT_24XX_MCBSP3_IRQ_TX 89
294#define INT_24XX_MCBSP3_IRQ_RX 90
295#define INT_24XX_SPI3_IRQ 91
296
297#define INT_243X_MCBSP2_IRQ 16
298#define INT_243X_MCBSP3_IRQ 17
299#define INT_243X_MCBSP4_IRQ 18
300#define INT_243X_MCBSP5_IRQ 19
301#define INT_243X_MCBSP1_IRQ 64
302#define INT_243X_HS_USB_MC 92
303#define INT_243X_HS_USB_DMA 93
304#define INT_243X_CARKIT_IRQ 94
305
306#define INT_34XX_BENCH_MPU_EMUL 3
307#define INT_34XX_ST_MCBSP2_IRQ 4
308#define INT_34XX_ST_MCBSP3_IRQ 5
309#define INT_34XX_SSM_ABORT_IRQ 6
310#define INT_34XX_SYS_NIRQ 7
311#define INT_34XX_D2D_FW_IRQ 8
312#define INT_34XX_PRCM_MPU_IRQ 11
313#define INT_34XX_MCBSP1_IRQ 16
314#define INT_34XX_MCBSP2_IRQ 17
315#define INT_34XX_MCBSP3_IRQ 22
316#define INT_34XX_MCBSP4_IRQ 23
317#define INT_34XX_CAM_IRQ 24
318#define INT_34XX_MCBSP5_IRQ 27
319#define INT_34XX_GPIO_BANK1 29
320#define INT_34XX_GPIO_BANK2 30
321#define INT_34XX_GPIO_BANK3 31
322#define INT_34XX_GPIO_BANK4 32
323#define INT_34XX_GPIO_BANK5 33
324#define INT_34XX_GPIO_BANK6 34
325#define INT_34XX_USIM_IRQ 35
326#define INT_34XX_WDT3_IRQ 36
327#define INT_34XX_SPI4_IRQ 48
328#define INT_34XX_SHA1MD52_IRQ 49
329#define INT_34XX_FPKA_READY_IRQ 50
330#define INT_34XX_SHA1MD51_IRQ 51
331#define INT_34XX_RNG_IRQ 52
332#define INT_34XX_I2C3_IRQ 61
333#define INT_34XX_FPKA_ERROR_IRQ 64
334#define INT_34XX_PBIAS_IRQ 75
335#define INT_34XX_OHCI_IRQ 76
336#define INT_34XX_EHCI_IRQ 77
337#define INT_34XX_TLL_IRQ 78
338#define INT_34XX_PARTHASH_IRQ 79
339#define INT_34XX_MMC3_IRQ 94
340#define INT_34XX_GPT12_IRQ 95
282 341
283#define INT_34XX_BENCH_MPU_EMUL 3 342#define INT_34XX_BENCH_MPU_EMUL 3
284 343
diff --git a/arch/arm/plat-omap/include/mach/mcbsp.h b/arch/arm/plat-omap/include/mach/mcbsp.h
index 8fdb95e26fcd..6a0d1a0a24a7 100644
--- a/arch/arm/plat-omap/include/mach/mcbsp.h
+++ b/arch/arm/plat-omap/include/mach/mcbsp.h
@@ -43,9 +43,15 @@
43 43
44#define OMAP24XX_MCBSP1_BASE 0x48074000 44#define OMAP24XX_MCBSP1_BASE 0x48074000
45#define OMAP24XX_MCBSP2_BASE 0x48076000 45#define OMAP24XX_MCBSP2_BASE 0x48076000
46#define OMAP2430_MCBSP3_BASE 0x4808c000
47#define OMAP2430_MCBSP4_BASE 0x4808e000
48#define OMAP2430_MCBSP5_BASE 0x48096000
46 49
47#define OMAP34XX_MCBSP1_BASE 0x48074000 50#define OMAP34XX_MCBSP1_BASE 0x48074000
48#define OMAP34XX_MCBSP2_BASE 0x49022000 51#define OMAP34XX_MCBSP2_BASE 0x49022000
52#define OMAP34XX_MCBSP3_BASE 0x49024000
53#define OMAP34XX_MCBSP4_BASE 0x49026000
54#define OMAP34XX_MCBSP5_BASE 0x48096000
49 55
50#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730) 56#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
51 57
@@ -81,9 +87,6 @@
81#define OMAP_MCBSP_REG_XCERG 0x3A 87#define OMAP_MCBSP_REG_XCERG 0x3A
82#define OMAP_MCBSP_REG_XCERH 0x3C 88#define OMAP_MCBSP_REG_XCERH 0x3C
83 89
84#define OMAP_MAX_MCBSP_COUNT 3
85#define MAX_MCBSP_CLOCKS 3
86
87#define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1) 90#define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1)
88#define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1) 91#define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1)
89 92
@@ -91,12 +94,14 @@
91#define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX 94#define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX
92#define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX 95#define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX
93 96
94#elif defined(CONFIG_ARCH_OMAP24XX) 97#elif defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
95 98
96#define OMAP_MCBSP_REG_DRR2 0x00 99#define OMAP_MCBSP_REG_DRR2 0x00
97#define OMAP_MCBSP_REG_DRR1 0x04 100#define OMAP_MCBSP_REG_DRR1 0x04
98#define OMAP_MCBSP_REG_DXR2 0x08 101#define OMAP_MCBSP_REG_DXR2 0x08
99#define OMAP_MCBSP_REG_DXR1 0x0C 102#define OMAP_MCBSP_REG_DXR1 0x0C
103#define OMAP_MCBSP_REG_DRR 0x00
104#define OMAP_MCBSP_REG_DXR 0x08
100#define OMAP_MCBSP_REG_SPCR2 0x10 105#define OMAP_MCBSP_REG_SPCR2 0x10
101#define OMAP_MCBSP_REG_SPCR1 0x14 106#define OMAP_MCBSP_REG_SPCR1 0x14
102#define OMAP_MCBSP_REG_RCR2 0x18 107#define OMAP_MCBSP_REG_RCR2 0x18
@@ -124,9 +129,9 @@
124#define OMAP_MCBSP_REG_RCERH 0x70 129#define OMAP_MCBSP_REG_RCERH 0x70
125#define OMAP_MCBSP_REG_XCERG 0x74 130#define OMAP_MCBSP_REG_XCERG 0x74
126#define OMAP_MCBSP_REG_XCERH 0x78 131#define OMAP_MCBSP_REG_XCERH 0x78
127 132#define OMAP_MCBSP_REG_SYSCON 0x8C
128#define OMAP_MAX_MCBSP_COUNT 2 133#define OMAP_MCBSP_REG_XCCR 0xAC
129#define MAX_MCBSP_CLOCKS 2 134#define OMAP_MCBSP_REG_RCCR 0xB0
130 135
131#define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1) 136#define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
132#define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1) 137#define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
@@ -137,10 +142,6 @@
137 142
138#endif 143#endif
139 144
140#define OMAP_MCBSP_READ(base, reg) __raw_readw((base) + OMAP_MCBSP_REG_##reg)
141#define OMAP_MCBSP_WRITE(base, reg, val) __raw_writew((val), (base) + OMAP_MCBSP_REG_##reg)
142
143
144/************************** McBSP SPCR1 bit definitions ***********************/ 145/************************** McBSP SPCR1 bit definitions ***********************/
145#define RRST 0x0001 146#define RRST 0x0001
146#define RRDY 0x0002 147#define RRDY 0x0002
@@ -151,6 +152,7 @@
151#define DXENA 0x0080 152#define DXENA 0x0080
152#define CLKSTP(value) ((value)<<11) /* bits 11:12 */ 153#define CLKSTP(value) ((value)<<11) /* bits 11:12 */
153#define RJUST(value) ((value)<<13) /* bits 13:14 */ 154#define RJUST(value) ((value)<<13) /* bits 13:14 */
155#define ALB 0x8000
154#define DLB 0x8000 156#define DLB 0x8000
155 157
156/************************** McBSP SPCR2 bit definitions ***********************/ 158/************************** McBSP SPCR2 bit definitions ***********************/
@@ -228,6 +230,17 @@
228#define XPABLK(value) ((value)<<5) /* Bits 5:6 */ 230#define XPABLK(value) ((value)<<5) /* Bits 5:6 */
229#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */ 231#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
230 232
233/*********************** McBSP XCCR bit definitions *************************/
234#define DILB 0x0020
235#define XDMAEN 0x0008
236#define XDISABLE 0x0001
237
238/********************** McBSP RCCR bit definitions *************************/
239#define RDMAEN 0x0008
240#define RDISABLE 0x0001
241
242/********************** McBSP SYSCONFIG bit definitions ********************/
243#define SOFTRST 0x0002
231 244
232/* we don't do multichannel for now */ 245/* we don't do multichannel for now */
233struct omap_mcbsp_reg_cfg { 246struct omap_mcbsp_reg_cfg {
@@ -260,6 +273,8 @@ typedef enum {
260 OMAP_MCBSP1 = 0, 273 OMAP_MCBSP1 = 0,
261 OMAP_MCBSP2, 274 OMAP_MCBSP2,
262 OMAP_MCBSP3, 275 OMAP_MCBSP3,
276 OMAP_MCBSP4,
277 OMAP_MCBSP5
263} omap_mcbsp_id; 278} omap_mcbsp_id;
264 279
265typedef int __bitwise omap_mcbsp_io_type_t; 280typedef int __bitwise omap_mcbsp_io_type_t;
@@ -311,12 +326,10 @@ struct omap_mcbsp_spi_cfg {
311struct omap_mcbsp_ops { 326struct omap_mcbsp_ops {
312 void (*request)(unsigned int); 327 void (*request)(unsigned int);
313 void (*free)(unsigned int); 328 void (*free)(unsigned int);
314 int (*check)(unsigned int);
315}; 329};
316 330
317struct omap_mcbsp_platform_data { 331struct omap_mcbsp_platform_data {
318 unsigned long phys_base; 332 unsigned long phys_base;
319 u32 virt_base;
320 u8 dma_rx_sync, dma_tx_sync; 333 u8 dma_rx_sync, dma_tx_sync;
321 u16 rx_irq, tx_irq; 334 u16 rx_irq, tx_irq;
322 struct omap_mcbsp_ops *ops; 335 struct omap_mcbsp_ops *ops;
@@ -326,7 +339,7 @@ struct omap_mcbsp_platform_data {
326struct omap_mcbsp { 339struct omap_mcbsp {
327 struct device *dev; 340 struct device *dev;
328 unsigned long phys_base; 341 unsigned long phys_base;
329 u32 io_base; 342 void __iomem *io_base;
330 u8 id; 343 u8 id;
331 u8 free; 344 u8 free;
332 omap_mcbsp_word_length rx_word_length; 345 omap_mcbsp_word_length rx_word_length;
@@ -354,6 +367,8 @@ struct omap_mcbsp {
354 struct omap_mcbsp_platform_data *pdata; 367 struct omap_mcbsp_platform_data *pdata;
355 struct clk *clk; 368 struct clk *clk;
356}; 369};
370extern struct omap_mcbsp **mcbsp_ptr;
371extern int omap_mcbsp_count;
357 372
358int omap_mcbsp_init(void); 373int omap_mcbsp_init(void);
359void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, 374void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
@@ -378,5 +393,6 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
378/* Polled read/write functions */ 393/* Polled read/write functions */
379int omap_mcbsp_pollread(unsigned int id, u16 * buf); 394int omap_mcbsp_pollread(unsigned int id, u16 * buf);
380int omap_mcbsp_pollwrite(unsigned int id, u16 buf); 395int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
396int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
381 397
382#endif 398#endif
diff --git a/arch/arm/plat-omap/include/mach/memory.h b/arch/arm/plat-omap/include/mach/memory.h
index a325caf80d04..d40cac60b959 100644
--- a/arch/arm/plat-omap/include/mach/memory.h
+++ b/arch/arm/plat-omap/include/mach/memory.h
@@ -38,7 +38,7 @@
38 */ 38 */
39#if defined(CONFIG_ARCH_OMAP1) 39#if defined(CONFIG_ARCH_OMAP1)
40#define PHYS_OFFSET UL(0x10000000) 40#define PHYS_OFFSET UL(0x10000000)
41#elif defined(CONFIG_ARCH_OMAP2) 41#elif defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
42#define PHYS_OFFSET UL(0x80000000) 42#define PHYS_OFFSET UL(0x80000000)
43#endif 43#endif
44 44
diff --git a/arch/arm/plat-omap/include/mach/mux.h b/arch/arm/plat-omap/include/mach/mux.h
index 614b2c1327c7..6bbf1789bed5 100644
--- a/arch/arm/plat-omap/include/mach/mux.h
+++ b/arch/arm/plat-omap/include/mach/mux.h
@@ -125,20 +125,64 @@
125 .pu_pd_val = pull_mode, \ 125 .pu_pd_val = pull_mode, \
126}, 126},
127 127
128 128/* 24xx/34xx mux bit defines */
129#define PULL_DISABLED 0 129#define OMAP2_PULL_ENA (1 << 3)
130#define PULL_ENABLED 1 130#define OMAP2_PULL_UP (1 << 4)
131 131#define OMAP2_ALTELECTRICALSEL (1 << 5)
132#define PULL_DOWN 0 132
133#define PULL_UP 1 133/* 34xx specific mux bit defines */
134#define OMAP3_INPUT_EN (1 << 8)
135#define OMAP3_OFF_EN (1 << 9)
136#define OMAP3_OFFOUT_EN (1 << 10)
137#define OMAP3_OFFOUT_VAL (1 << 11)
138#define OMAP3_OFF_PULL_EN (1 << 12)
139#define OMAP3_OFF_PULL_UP (1 << 13)
140#define OMAP3_WAKEUP_EN (1 << 14)
141
142/* 34xx mux mode options for each pin. See TRM for options */
143#define OMAP34XX_MUX_MODE0 0
144#define OMAP34XX_MUX_MODE1 1
145#define OMAP34XX_MUX_MODE2 2
146#define OMAP34XX_MUX_MODE3 3
147#define OMAP34XX_MUX_MODE4 4
148#define OMAP34XX_MUX_MODE5 5
149#define OMAP34XX_MUX_MODE6 6
150#define OMAP34XX_MUX_MODE7 7
151
152/* 34xx active pin states */
153#define OMAP34XX_PIN_OUTPUT 0
154#define OMAP34XX_PIN_INPUT OMAP3_INPUT_EN
155#define OMAP34XX_PIN_INPUT_PULLUP (OMAP2_PULL_ENA | OMAP3_INPUT_EN \
156 | OMAP2_PULL_UP)
157#define OMAP34XX_PIN_INPUT_PULLDOWN (OMAP2_PULL_ENA | OMAP3_INPUT_EN)
158
159/* 34xx off mode states */
160#define OMAP34XX_PIN_OFF_NONE 0
161#define OMAP34XX_PIN_OFF_OUTPUT_HIGH (OMAP3_OFF_EN | OMAP3_OFFOUT_EN \
162 | OMAP3_OFFOUT_VAL)
163#define OMAP34XX_PIN_OFF_OUTPUT_LOW (OMAP3_OFF_EN | OMAP3_OFFOUT_EN)
164#define OMAP34XX_PIN_OFF_INPUT_PULLUP (OMAP3_OFF_EN | OMAP3_OFF_PULL_EN \
165 | OMAP3_OFF_PULL_UP)
166#define OMAP34XX_PIN_OFF_INPUT_PULLDOWN (OMAP3_OFF_EN | OMAP3_OFF_PULL_EN)
167#define OMAP34XX_PIN_OFF_WAKEUPENABLE OMAP3_WAKEUP_EN
168
169#define MUX_CFG_34XX(desc, reg_offset, mux_value) { \
170 .name = desc, \
171 .debug = 0, \
172 .mux_reg = reg_offset, \
173 .mux_val = mux_value \
174},
134 175
135struct pin_config { 176struct pin_config {
136 char *name; 177 char *name;
137 unsigned char busy; 178 const unsigned int mux_reg;
138 unsigned char debug; 179 unsigned char debug;
139 180
140 const char *mux_reg_name; 181#if defined(CONFIG_ARCH_OMAP34XX)
141 const unsigned int mux_reg; 182 u16 mux_val; /* Wake-up, off mode, pull, mux mode */
183#endif
184
185#if defined(CONFIG_ARCH_OMAP1) || defined(CONFIG_ARCH_OMAP24XX)
142 const unsigned char mask_offset; 186 const unsigned char mask_offset;
143 const unsigned char mask; 187 const unsigned char mask;
144 188
@@ -150,6 +194,12 @@ struct pin_config {
150 const char *pu_pd_name; 194 const char *pu_pd_name;
151 const unsigned int pu_pd_reg; 195 const unsigned int pu_pd_reg;
152 const unsigned char pu_pd_val; 196 const unsigned char pu_pd_val;
197#endif
198
199#if defined(CONFIG_OMAP_MUX_DEBUG) || defined(CONFIG_OMAP_MUX_WARNINGS)
200 const char *mux_reg_name;
201#endif
202
153}; 203};
154 204
155enum omap730_index { 205enum omap730_index {
@@ -593,6 +643,114 @@ enum omap24xx_index {
593 643
594}; 644};
595 645
646enum omap34xx_index {
647 /* 34xx I2C */
648 K21_34XX_I2C1_SCL,
649 J21_34XX_I2C1_SDA,
650 AF15_34XX_I2C2_SCL,
651 AE15_34XX_I2C2_SDA,
652 AF14_34XX_I2C3_SCL,
653 AG14_34XX_I2C3_SDA,
654 AD26_34XX_I2C4_SCL,
655 AE26_34XX_I2C4_SDA,
656
657 /* PHY - HSUSB: 12-pin ULPI PHY: Port 1*/
658 Y8_3430_USB1HS_PHY_CLK,
659 Y9_3430_USB1HS_PHY_STP,
660 AA14_3430_USB1HS_PHY_DIR,
661 AA11_3430_USB1HS_PHY_NXT,
662 W13_3430_USB1HS_PHY_DATA0,
663 W12_3430_USB1HS_PHY_DATA1,
664 W11_3430_USB1HS_PHY_DATA2,
665 Y11_3430_USB1HS_PHY_DATA3,
666 W9_3430_USB1HS_PHY_DATA4,
667 Y12_3430_USB1HS_PHY_DATA5,
668 W8_3430_USB1HS_PHY_DATA6,
669 Y13_3430_USB1HS_PHY_DATA7,
670
671 /* PHY - HSUSB: 12-pin ULPI PHY: Port 2*/
672 AA8_3430_USB2HS_PHY_CLK,
673 AA10_3430_USB2HS_PHY_STP,
674 AA9_3430_USB2HS_PHY_DIR,
675 AB11_3430_USB2HS_PHY_NXT,
676 AB10_3430_USB2HS_PHY_DATA0,
677 AB9_3430_USB2HS_PHY_DATA1,
678 W3_3430_USB2HS_PHY_DATA2,
679 T4_3430_USB2HS_PHY_DATA3,
680 T3_3430_USB2HS_PHY_DATA4,
681 R3_3430_USB2HS_PHY_DATA5,
682 R4_3430_USB2HS_PHY_DATA6,
683 T2_3430_USB2HS_PHY_DATA7,
684
685
686 /* TLL - HSUSB: 12-pin TLL Port 1*/
687 Y8_3430_USB1HS_TLL_CLK,
688 Y9_3430_USB1HS_TLL_STP,
689 AA14_3430_USB1HS_TLL_DIR,
690 AA11_3430_USB1HS_TLL_NXT,
691 W13_3430_USB1HS_TLL_DATA0,
692 W12_3430_USB1HS_TLL_DATA1,
693 W11_3430_USB1HS_TLL_DATA2,
694 Y11_3430_USB1HS_TLL_DATA3,
695 W9_3430_USB1HS_TLL_DATA4,
696 Y12_3430_USB1HS_TLL_DATA5,
697 W8_3430_USB1HS_TLL_DATA6,
698 Y13_3430_USB1HS_TLL_DATA7,
699
700 /* TLL - HSUSB: 12-pin TLL Port 2*/
701 AA8_3430_USB2HS_TLL_CLK,
702 AA10_3430_USB2HS_TLL_STP,
703 AA9_3430_USB2HS_TLL_DIR,
704 AB11_3430_USB2HS_TLL_NXT,
705 AB10_3430_USB2HS_TLL_DATA0,
706 AB9_3430_USB2HS_TLL_DATA1,
707 W3_3430_USB2HS_TLL_DATA2,
708 T4_3430_USB2HS_TLL_DATA3,
709 T3_3430_USB2HS_TLL_DATA4,
710 R3_3430_USB2HS_TLL_DATA5,
711 R4_3430_USB2HS_TLL_DATA6,
712 T2_3430_USB2HS_TLL_DATA7,
713
714 /* TLL - HSUSB: 12-pin TLL Port 3*/
715 AA6_3430_USB3HS_TLL_CLK,
716 AB3_3430_USB3HS_TLL_STP,
717 AA3_3430_USB3HS_TLL_DIR,
718 Y3_3430_USB3HS_TLL_NXT,
719 AA5_3430_USB3HS_TLL_DATA0,
720 Y4_3430_USB3HS_TLL_DATA1,
721 Y5_3430_USB3HS_TLL_DATA2,
722 W5_3430_USB3HS_TLL_DATA3,
723 AB12_3430_USB3HS_TLL_DATA4,
724 AB13_3430_USB3HS_TLL_DATA5,
725 AA13_3430_USB3HS_TLL_DATA6,
726 AA12_3430_USB3HS_TLL_DATA7,
727
728 /* PHY FSUSB: FS Serial for Port 1 (multiple PHY modes supported) */
729 AF10_3430_USB1FS_PHY_MM1_RXDP,
730 AG9_3430_USB1FS_PHY_MM1_RXDM,
731 W13_3430_USB1FS_PHY_MM1_RXRCV,
732 W12_3430_USB1FS_PHY_MM1_TXSE0,
733 W11_3430_USB1FS_PHY_MM1_TXDAT,
734 Y11_3430_USB1FS_PHY_MM1_TXEN_N,
735
736 /* PHY FSUSB: FS Serial for Port 2 (multiple PHY modes supported) */
737 AF7_3430_USB2FS_PHY_MM2_RXDP,
738 AH7_3430_USB2FS_PHY_MM2_RXDM,
739 AB10_3430_USB2FS_PHY_MM2_RXRCV,
740 AB9_3430_USB2FS_PHY_MM2_TXSE0,
741 W3_3430_USB2FS_PHY_MM2_TXDAT,
742 T4_3430_USB2FS_PHY_MM2_TXEN_N,
743
744 /* PHY FSUSB: FS Serial for Port 3 (multiple PHY modes supported) */
745 AH3_3430_USB3FS_PHY_MM3_RXDP,
746 AE3_3430_USB3FS_PHY_MM3_RXDM,
747 AD1_3430_USB3FS_PHY_MM3_RXRCV,
748 AE1_3430_USB3FS_PHY_MM3_TXSE0,
749 AD2_3430_USB3FS_PHY_MM3_TXDAT,
750 AC1_3430_USB3FS_PHY_MM3_TXEN_N,
751
752};
753
596struct omap_mux_cfg { 754struct omap_mux_cfg {
597 struct pin_config *pins; 755 struct pin_config *pins;
598 unsigned long size; 756 unsigned long size;
diff --git a/arch/arm/plat-omap/include/mach/omap1510.h b/arch/arm/plat-omap/include/mach/omap1510.h
index 505a38af8b22..d24004668138 100644
--- a/arch/arm/plat-omap/include/mach/omap1510.h
+++ b/arch/arm/plat-omap/include/mach/omap1510.h
@@ -44,5 +44,7 @@
44#define OMAP1510_DSPREG_SIZE SZ_128K 44#define OMAP1510_DSPREG_SIZE SZ_128K
45#define OMAP1510_DSPREG_START 0xE1000000 45#define OMAP1510_DSPREG_START 0xE1000000
46 46
47#define OMAP1510_DSP_MMU_BASE (0xfffed200)
48
47#endif /* __ASM_ARCH_OMAP15XX_H */ 49#endif /* __ASM_ARCH_OMAP15XX_H */
48 50
diff --git a/arch/arm/plat-omap/include/mach/omap16xx.h b/arch/arm/plat-omap/include/mach/omap16xx.h
index c6c93afb2788..0e69b504c25f 100644
--- a/arch/arm/plat-omap/include/mach/omap16xx.h
+++ b/arch/arm/plat-omap/include/mach/omap16xx.h
@@ -44,6 +44,11 @@
44#define OMAP16XX_DSPREG_SIZE SZ_128K 44#define OMAP16XX_DSPREG_SIZE SZ_128K
45#define OMAP16XX_DSPREG_START 0xE1000000 45#define OMAP16XX_DSPREG_START 0xE1000000
46 46
47#define OMAP16XX_SEC_BASE 0xFFFE4000
48#define OMAP16XX_SEC_DES (OMAP16XX_SEC_BASE + 0x0000)
49#define OMAP16XX_SEC_SHA1MD5 (OMAP16XX_SEC_BASE + 0x0800)
50#define OMAP16XX_SEC_RNG (OMAP16XX_SEC_BASE + 0x1000)
51
47/* 52/*
48 * --------------------------------------------------------------------------- 53 * ---------------------------------------------------------------------------
49 * Interrupts 54 * Interrupts
@@ -190,7 +195,7 @@
190#define WSPR_DISABLE_0 (0x0000aaaa) 195#define WSPR_DISABLE_0 (0x0000aaaa)
191#define WSPR_DISABLE_1 (0x00005555) 196#define WSPR_DISABLE_1 (0x00005555)
192 197
193/* Mailbox */ 198#define OMAP16XX_DSP_MMU_BASE (0xfffed200)
194#define OMAP16XX_MAILBOX_BASE (0xfffcf000) 199#define OMAP16XX_MAILBOX_BASE (0xfffcf000)
195 200
196#endif /* __ASM_ARCH_OMAP16XX_H */ 201#endif /* __ASM_ARCH_OMAP16XX_H */
diff --git a/arch/arm/plat-omap/include/mach/omap24xx.h b/arch/arm/plat-omap/include/mach/omap24xx.h
index bb8319d66e9f..24335d4932f5 100644
--- a/arch/arm/plat-omap/include/mach/omap24xx.h
+++ b/arch/arm/plat-omap/include/mach/omap24xx.h
@@ -39,7 +39,6 @@
39/* interrupt controller */ 39/* interrupt controller */
40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000) 40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000)
41#define OMAP24XX_IVA_INTC_BASE 0x40000000 41#define OMAP24XX_IVA_INTC_BASE 0x40000000
42#define IRQ_SIR_IRQ 0x0040
43 42
44#define OMAP2420_CTRL_BASE L4_24XX_BASE 43#define OMAP2420_CTRL_BASE L4_24XX_BASE
45#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000) 44#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000)
@@ -48,6 +47,7 @@
48#define OMAP2420_PRM_BASE OMAP2420_CM_BASE 47#define OMAP2420_PRM_BASE OMAP2420_CM_BASE
49#define OMAP2420_SDRC_BASE (L3_24XX_BASE + 0x9000) 48#define OMAP2420_SDRC_BASE (L3_24XX_BASE + 0x9000)
50#define OMAP2420_SMS_BASE 0x68008000 49#define OMAP2420_SMS_BASE 0x68008000
50#define OMAP2420_GPMC_BASE 0x6800a000
51 51
52#define OMAP2430_32KSYNCT_BASE (L4_WK_243X_BASE + 0x20000) 52#define OMAP2430_32KSYNCT_BASE (L4_WK_243X_BASE + 0x20000)
53#define OMAP2430_PRCM_BASE (L4_WK_243X_BASE + 0x6000) 53#define OMAP2430_PRCM_BASE (L4_WK_243X_BASE + 0x6000)
diff --git a/arch/arm/plat-omap/include/mach/omapfb.h b/arch/arm/plat-omap/include/mach/omapfb.h
index cae037d13079..ec67fb428607 100644
--- a/arch/arm/plat-omap/include/mach/omapfb.h
+++ b/arch/arm/plat-omap/include/mach/omapfb.h
@@ -62,6 +62,7 @@
62#define OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE 0x00010000 62#define OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE 0x00010000
63#define OMAPFB_CAPS_WINDOW_SCALE 0x00020000 63#define OMAPFB_CAPS_WINDOW_SCALE 0x00020000
64#define OMAPFB_CAPS_WINDOW_OVERLAY 0x00040000 64#define OMAPFB_CAPS_WINDOW_OVERLAY 0x00040000
65#define OMAPFB_CAPS_WINDOW_ROTATE 0x00080000
65#define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000 66#define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000
66 67
67/* Values from DSP must map to lower 16-bits */ 68/* Values from DSP must map to lower 16-bits */
@@ -305,6 +306,7 @@ struct lcd_ctrl {
305 int screen_width, 306 int screen_width,
306 int pos_x, int pos_y, int width, 307 int pos_x, int pos_y, int width,
307 int height, int color_mode); 308 int height, int color_mode);
309 int (*set_rotate) (int angle);
308 int (*setup_mem) (int plane, size_t size, 310 int (*setup_mem) (int plane, size_t size,
309 int mem_type, unsigned long *paddr); 311 int mem_type, unsigned long *paddr);
310 int (*mmap) (struct fb_info *info, 312 int (*mmap) (struct fb_info *info,
@@ -374,6 +376,7 @@ extern struct lcd_ctrl omap1_lcd_ctrl;
374extern struct lcd_ctrl omap2_disp_ctrl; 376extern struct lcd_ctrl omap2_disp_ctrl;
375#endif 377#endif
376 378
379extern void omapfb_reserve_sdram(void);
377extern void omapfb_register_panel(struct lcd_panel *panel); 380extern void omapfb_register_panel(struct lcd_panel *panel);
378extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval); 381extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
379extern void omapfb_notify_clients(struct omapfb_device *fbdev, 382extern void omapfb_notify_clients(struct omapfb_device *fbdev,
diff --git a/arch/arm/plat-omap/include/mach/pm.h b/arch/arm/plat-omap/include/mach/pm.h
index bfa09325a5ff..768eb6e7abcf 100644
--- a/arch/arm/plat-omap/include/mach/pm.h
+++ b/arch/arm/plat-omap/include/mach/pm.h
@@ -39,11 +39,11 @@
39 * Register and offset definitions to be used in PM assembler code 39 * Register and offset definitions to be used in PM assembler code
40 * ---------------------------------------------------------------------------- 40 * ----------------------------------------------------------------------------
41 */ 41 */
42#define CLKGEN_REG_ASM_BASE io_p2v(0xfffece00) 42#define CLKGEN_REG_ASM_BASE IO_ADDRESS(0xfffece00)
43#define ARM_IDLECT1_ASM_OFFSET 0x04 43#define ARM_IDLECT1_ASM_OFFSET 0x04
44#define ARM_IDLECT2_ASM_OFFSET 0x08 44#define ARM_IDLECT2_ASM_OFFSET 0x08
45 45
46#define TCMIF_ASM_BASE io_p2v(0xfffecc00) 46#define TCMIF_ASM_BASE IO_ADDRESS(0xfffecc00)
47#define EMIFS_CONFIG_ASM_OFFSET 0x0c 47#define EMIFS_CONFIG_ASM_OFFSET 0x0c
48#define EMIFF_SDRAM_CONFIG_ASM_OFFSET 0x20 48#define EMIFF_SDRAM_CONFIG_ASM_OFFSET 0x20
49 49
@@ -135,7 +135,8 @@ extern void omap_pm_suspend(void);
135extern void omap730_cpu_suspend(unsigned short, unsigned short); 135extern void omap730_cpu_suspend(unsigned short, unsigned short);
136extern void omap1510_cpu_suspend(unsigned short, unsigned short); 136extern void omap1510_cpu_suspend(unsigned short, unsigned short);
137extern void omap1610_cpu_suspend(unsigned short, unsigned short); 137extern void omap1610_cpu_suspend(unsigned short, unsigned short);
138extern void omap24xx_cpu_suspend(u32 dll_ctrl, u32 cpu_revision); 138extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl,
139 void __iomem *sdrc_power);
139extern void omap730_idle_loop_suspend(void); 140extern void omap730_idle_loop_suspend(void);
140extern void omap1510_idle_loop_suspend(void); 141extern void omap1510_idle_loop_suspend(void);
141extern void omap1610_idle_loop_suspend(void); 142extern void omap1610_idle_loop_suspend(void);
diff --git a/arch/arm/plat-omap/include/mach/powerdomain.h b/arch/arm/plat-omap/include/mach/powerdomain.h
new file mode 100644
index 000000000000..2806a9c8e4d7
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/powerdomain.h
@@ -0,0 +1,166 @@
1/*
2 * OMAP2/3 powerdomain control
3 *
4 * Copyright (C) 2007-8 Texas Instruments, Inc.
5 * Copyright (C) 2007-8 Nokia Corporation
6 *
7 * Written by Paul Walmsley
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#ifndef ASM_ARM_ARCH_OMAP_POWERDOMAIN
15#define ASM_ARM_ARCH_OMAP_POWERDOMAIN
16
17#include <linux/types.h>
18#include <linux/list.h>
19
20#include <asm/atomic.h>
21
22#include <mach/cpu.h>
23
24
25/* Powerdomain basic power states */
26#define PWRDM_POWER_OFF 0x0
27#define PWRDM_POWER_RET 0x1
28#define PWRDM_POWER_INACTIVE 0x2
29#define PWRDM_POWER_ON 0x3
30
31/* Powerdomain allowable state bitfields */
32#define PWRSTS_OFF_ON ((1 << PWRDM_POWER_OFF) | \
33 (1 << PWRDM_POWER_ON))
34
35#define PWRSTS_OFF_RET ((1 << PWRDM_POWER_OFF) | \
36 (1 << PWRDM_POWER_RET))
37
38#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON))
39
40
41/* Powerdomain flags */
42#define PWRDM_HAS_HDWR_SAR (1 << 0) /* hardware save-and-restore support */
43
44
45/*
46 * Number of memory banks that are power-controllable. On OMAP3430, the
47 * maximum is 4.
48 */
49#define PWRDM_MAX_MEM_BANKS 4
50
51/*
52 * Maximum number of clockdomains that can be associated with a powerdomain.
53 * CORE powerdomain is probably the worst case.
54 */
55#define PWRDM_MAX_CLKDMS 3
56
57/* XXX A completely arbitrary number. What is reasonable here? */
58#define PWRDM_TRANSITION_BAILOUT 100000
59
60struct clockdomain;
61struct powerdomain;
62
63/* Encodes dependencies between powerdomains - statically defined */
64struct pwrdm_dep {
65
66 /* Powerdomain name */
67 const char *pwrdm_name;
68
69 /* Powerdomain pointer - resolved by the powerdomain code */
70 struct powerdomain *pwrdm;
71
72 /* Flags to mark OMAP chip restrictions, etc. */
73 const struct omap_chip_id omap_chip;
74
75};
76
77struct powerdomain {
78
79 /* Powerdomain name */
80 const char *name;
81
82 /* the address offset from CM_BASE/PRM_BASE */
83 const s16 prcm_offs;
84
85 /* Used to represent the OMAP chip types containing this pwrdm */
86 const struct omap_chip_id omap_chip;
87
88 /* Bit shift of this powerdomain's PM_WKDEP/CM_SLEEPDEP bit */
89 const u8 dep_bit;
90
91 /* Powerdomains that can be told to wake this powerdomain up */
92 struct pwrdm_dep *wkdep_srcs;
93
94 /* Powerdomains that can be told to keep this pwrdm from inactivity */
95 struct pwrdm_dep *sleepdep_srcs;
96
97 /* Possible powerdomain power states */
98 const u8 pwrsts;
99
100 /* Possible logic power states when pwrdm in RETENTION */
101 const u8 pwrsts_logic_ret;
102
103 /* Powerdomain flags */
104 const u8 flags;
105
106 /* Number of software-controllable memory banks in this powerdomain */
107 const u8 banks;
108
109 /* Possible memory bank pwrstates when pwrdm in RETENTION */
110 const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
111
112 /* Possible memory bank pwrstates when pwrdm is ON */
113 const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
114
115 /* Clockdomains in this powerdomain */
116 struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
117
118 struct list_head node;
119
120};
121
122
123void pwrdm_init(struct powerdomain **pwrdm_list);
124
125int pwrdm_register(struct powerdomain *pwrdm);
126int pwrdm_unregister(struct powerdomain *pwrdm);
127struct powerdomain *pwrdm_lookup(const char *name);
128
129int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm));
130
131int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
132int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
133int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
134 int (*fn)(struct powerdomain *pwrdm,
135 struct clockdomain *clkdm));
136
137int pwrdm_add_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
138int pwrdm_del_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
139int pwrdm_read_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
140int pwrdm_add_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
141int pwrdm_del_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
142int pwrdm_read_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
143
144int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
145
146int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
147int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
148int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
149int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
150
151int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst);
152int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
153int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
154
155int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm);
156int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm);
157int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
158int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
159
160int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
161int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
162bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
163
164int pwrdm_wait_transition(struct powerdomain *pwrdm);
165
166#endif
diff --git a/arch/arm/plat-omap/include/mach/sdrc.h b/arch/arm/plat-omap/include/mach/sdrc.h
index 787b7acec546..a98c6c3beb2c 100644
--- a/arch/arm/plat-omap/include/mach/sdrc.h
+++ b/arch/arm/plat-omap/include/mach/sdrc.h
@@ -25,6 +25,8 @@
25#define SDRC_DLLB_STATUS 0x06C 25#define SDRC_DLLB_STATUS 0x06C
26#define SDRC_POWER 0x070 26#define SDRC_POWER 0x070
27#define SDRC_MR_0 0x084 27#define SDRC_MR_0 0x084
28#define SDRC_ACTIM_CTRL_A_0 0x09c
29#define SDRC_ACTIM_CTRL_B_0 0x0a0
28#define SDRC_RFR_CTRL_0 0x0a4 30#define SDRC_RFR_CTRL_0 0x0a4
29 31
30/* 32/*
@@ -63,9 +65,9 @@
63 */ 65 */
64 66
65 67
66#define OMAP242X_SMS_REGADDR(reg) (void __iomem *)IO_ADDRESS(OMAP2420_SMS_BASE + reg) 68#define OMAP242X_SMS_REGADDR(reg) IO_ADDRESS(OMAP2420_SMS_BASE + reg)
67#define OMAP243X_SMS_REGADDR(reg) (void __iomem *)IO_ADDRESS(OMAP243X_SMS_BASE + reg) 69#define OMAP243X_SMS_REGADDR(reg) IO_ADDRESS(OMAP243X_SMS_BASE + reg)
68#define OMAP343X_SMS_REGADDR(reg) (void __iomem *)IO_ADDRESS(OMAP343X_SMS_BASE + reg) 70#define OMAP343X_SMS_REGADDR(reg) IO_ADDRESS(OMAP343X_SMS_BASE + reg)
69 71
70/* SMS register offsets - read/write with sms_{read,write}_reg() */ 72/* SMS register offsets - read/write with sms_{read,write}_reg() */
71 73
diff --git a/arch/arm/plat-omap/include/mach/serial.h b/arch/arm/plat-omap/include/mach/serial.h
index cc6bfa51ccb5..8a676a04be48 100644
--- a/arch/arm/plat-omap/include/mach/serial.h
+++ b/arch/arm/plat-omap/include/mach/serial.h
@@ -20,18 +20,24 @@
20#define OMAP_UART1_BASE 0x4806a000 20#define OMAP_UART1_BASE 0x4806a000
21#define OMAP_UART2_BASE 0x4806c000 21#define OMAP_UART2_BASE 0x4806c000
22#define OMAP_UART3_BASE 0x4806e000 22#define OMAP_UART3_BASE 0x4806e000
23#elif defined(CONFIG_ARCH_OMAP3)
24/* OMAP3 serial ports */
25#define OMAP_UART1_BASE 0x4806a000
26#define OMAP_UART2_BASE 0x4806c000
27#define OMAP_UART3_BASE 0x49020000
23#endif 28#endif
24 29
25#define OMAP_MAX_NR_PORTS 3 30#define OMAP_MAX_NR_PORTS 3
26#define OMAP1510_BASE_BAUD (12000000/16) 31#define OMAP1510_BASE_BAUD (12000000/16)
27#define OMAP16XX_BASE_BAUD (48000000/16) 32#define OMAP16XX_BASE_BAUD (48000000/16)
33#define OMAP24XX_BASE_BAUD (48000000/16)
28 34
29#define is_omap_port(p) ({int __ret = 0; \ 35#define is_omap_port(pt) ({int __ret = 0; \
30 if (p == IO_ADDRESS(OMAP_UART1_BASE) || \ 36 if ((pt)->port.mapbase == OMAP_UART1_BASE || \
31 p == IO_ADDRESS(OMAP_UART2_BASE) || \ 37 (pt)->port.mapbase == OMAP_UART2_BASE || \
32 p == IO_ADDRESS(OMAP_UART3_BASE)) \ 38 (pt)->port.mapbase == OMAP_UART3_BASE) \
33 __ret = 1; \ 39 __ret = 1; \
34 __ret; \ 40 __ret; \
35 }) 41 })
36 42
37#endif 43#endif
diff --git a/arch/arm/plat-omap/include/mach/sram.h b/arch/arm/plat-omap/include/mach/sram.h
index e09323449981..ab35d622dcf5 100644
--- a/arch/arm/plat-omap/include/mach/sram.h
+++ b/arch/arm/plat-omap/include/mach/sram.h
@@ -21,6 +21,10 @@ extern void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
21 u32 mem_type); 21 u32 mem_type);
22extern u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass); 22extern u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass);
23 23
24extern u32 omap3_configure_core_dpll(u32 sdrc_rfr_ctrl,
25 u32 sdrc_actim_ctrla,
26 u32 sdrc_actim_ctrlb, u32 m2);
27
24/* Do not use these */ 28/* Do not use these */
25extern void omap1_sram_reprogram_clock(u32 ckctl, u32 dpllctl); 29extern void omap1_sram_reprogram_clock(u32 ckctl, u32 dpllctl);
26extern unsigned long omap1_sram_reprogram_clock_sz; 30extern unsigned long omap1_sram_reprogram_clock_sz;
@@ -53,4 +57,10 @@ extern void omap243x_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
53 u32 mem_type); 57 u32 mem_type);
54extern unsigned long omap243x_sram_reprogram_sdrc_sz; 58extern unsigned long omap243x_sram_reprogram_sdrc_sz;
55 59
60
61extern u32 omap3_sram_configure_core_dpll(u32 sdrc_rfr_ctrl,
62 u32 sdrc_actim_ctrla,
63 u32 sdrc_actim_ctrlb, u32 m2);
64extern unsigned long omap3_sram_configure_core_dpll_sz;
65
56#endif 66#endif
diff --git a/arch/arm/plat-omap/include/mach/system.h b/arch/arm/plat-omap/include/mach/system.h
index 06a28c7b98de..06923f261545 100644
--- a/arch/arm/plat-omap/include/mach/system.h
+++ b/arch/arm/plat-omap/include/mach/system.h
@@ -40,7 +40,7 @@ static inline void omap1_arch_reset(char mode)
40 40
41static inline void arch_reset(char mode) 41static inline void arch_reset(char mode)
42{ 42{
43 if (!cpu_is_omap24xx()) 43 if (!cpu_class_is_omap2())
44 omap1_arch_reset(mode); 44 omap1_arch_reset(mode);
45 else 45 else
46 omap_prcm_arch_reset(mode); 46 omap_prcm_arch_reset(mode);
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
new file mode 100644
index 000000000000..af326efc1ad3
--- /dev/null
+++ b/arch/arm/plat-omap/io.c
@@ -0,0 +1,107 @@
1#include <linux/module.h>
2#include <linux/io.h>
3#include <linux/mm.h>
4
5#include <mach/omap730.h>
6#include <mach/omap1510.h>
7#include <mach/omap16xx.h>
8#include <mach/omap24xx.h>
9#include <mach/omap34xx.h>
10
11#define BETWEEN(p,st,sz) ((p) >= (st) && (p) < ((st) + (sz)))
12#define XLATE(p,pst,vst) ((void __iomem *)((p) - (pst) + (vst)))
13
14/*
15 * Intercept ioremap() requests for addresses in our fixed mapping regions.
16 */
17void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
18{
19#ifdef CONFIG_ARCH_OMAP1
20 if (cpu_class_is_omap1()) {
21 if (BETWEEN(p, IO_PHYS, IO_SIZE))
22 return XLATE(p, IO_PHYS, IO_VIRT);
23 }
24 if (cpu_is_omap730()) {
25 if (BETWEEN(p, OMAP730_DSP_BASE, OMAP730_DSP_SIZE))
26 return XLATE(p, OMAP730_DSP_BASE, OMAP730_DSP_START);
27
28 if (BETWEEN(p, OMAP730_DSPREG_BASE, OMAP730_DSPREG_SIZE))
29 return XLATE(p, OMAP730_DSPREG_BASE,
30 OMAP730_DSPREG_START);
31 }
32 if (cpu_is_omap15xx()) {
33 if (BETWEEN(p, OMAP1510_DSP_BASE, OMAP1510_DSP_SIZE))
34 return XLATE(p, OMAP1510_DSP_BASE, OMAP1510_DSP_START);
35
36 if (BETWEEN(p, OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_SIZE))
37 return XLATE(p, OMAP1510_DSPREG_BASE,
38 OMAP1510_DSPREG_START);
39 }
40 if (cpu_is_omap16xx()) {
41 if (BETWEEN(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_SIZE))
42 return XLATE(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_START);
43
44 if (BETWEEN(p, OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_SIZE))
45 return XLATE(p, OMAP16XX_DSPREG_BASE,
46 OMAP16XX_DSPREG_START);
47 }
48#endif
49#ifdef CONFIG_ARCH_OMAP2
50 if (cpu_is_omap24xx()) {
51 if (BETWEEN(p, L3_24XX_PHYS, L3_24XX_SIZE))
52 return XLATE(p, L3_24XX_PHYS, L3_24XX_VIRT);
53 if (BETWEEN(p, L4_24XX_PHYS, L4_24XX_SIZE))
54 return XLATE(p, L4_24XX_PHYS, L4_24XX_VIRT);
55 }
56 if (cpu_is_omap2420()) {
57 if (BETWEEN(p, DSP_MEM_24XX_PHYS, DSP_MEM_24XX_SIZE))
58 return XLATE(p, DSP_MEM_24XX_PHYS, DSP_MEM_24XX_VIRT);
59 if (BETWEEN(p, DSP_IPI_24XX_PHYS, DSP_IPI_24XX_SIZE))
60 return XLATE(p, DSP_IPI_24XX_PHYS, DSP_IPI_24XX_SIZE);
61 if (BETWEEN(p, DSP_MMU_24XX_PHYS, DSP_MMU_24XX_SIZE))
62 return XLATE(p, DSP_MMU_24XX_PHYS, DSP_MMU_24XX_VIRT);
63 }
64 if (cpu_is_omap2430()) {
65 if (BETWEEN(p, L4_WK_243X_PHYS, L4_WK_243X_SIZE))
66 return XLATE(p, L4_WK_243X_PHYS, L4_WK_243X_VIRT);
67 if (BETWEEN(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_SIZE))
68 return XLATE(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_VIRT);
69 if (BETWEEN(p, OMAP243X_SDRC_PHYS, OMAP243X_SDRC_SIZE))
70 return XLATE(p, OMAP243X_SDRC_PHYS, OMAP243X_SDRC_VIRT);
71 if (BETWEEN(p, OMAP243X_SMS_PHYS, OMAP243X_SMS_SIZE))
72 return XLATE(p, OMAP243X_SMS_PHYS, OMAP243X_SMS_VIRT);
73 }
74#endif
75#ifdef CONFIG_ARCH_OMAP3
76 if (cpu_is_omap34xx()) {
77 if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
78 return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
79 if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
80 return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
81 if (BETWEEN(p, L4_WK_34XX_PHYS, L4_WK_34XX_SIZE))
82 return XLATE(p, L4_WK_34XX_PHYS, L4_WK_34XX_VIRT);
83 if (BETWEEN(p, OMAP34XX_GPMC_PHYS, OMAP34XX_GPMC_SIZE))
84 return XLATE(p, OMAP34XX_GPMC_PHYS, OMAP34XX_GPMC_VIRT);
85 if (BETWEEN(p, OMAP343X_SMS_PHYS, OMAP343X_SMS_SIZE))
86 return XLATE(p, OMAP343X_SMS_PHYS, OMAP343X_SMS_VIRT);
87 if (BETWEEN(p, OMAP343X_SDRC_PHYS, OMAP343X_SDRC_SIZE))
88 return XLATE(p, OMAP343X_SDRC_PHYS, OMAP343X_SDRC_VIRT);
89 if (BETWEEN(p, L4_PER_34XX_PHYS, L4_PER_34XX_SIZE))
90 return XLATE(p, L4_PER_34XX_PHYS, L4_PER_34XX_VIRT);
91 if (BETWEEN(p, L4_EMU_34XX_PHYS, L4_EMU_34XX_SIZE))
92 return XLATE(p, L4_EMU_34XX_PHYS, L4_EMU_34XX_VIRT);
93 }
94#endif
95
96 return __arm_ioremap(p, size, type);
97}
98EXPORT_SYMBOL(omap_ioremap);
99
100void omap_iounmap(volatile void __iomem *addr)
101{
102 unsigned long virt = (unsigned long)addr;
103
104 if (virt >= VMALLOC_START && virt < VMALLOC_END)
105 __iounmap(addr);
106}
107EXPORT_SYMBOL(omap_iounmap);
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 014d26574bb6..af33fc713e1a 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -27,43 +27,65 @@
27#include <mach/dma.h> 27#include <mach/dma.h>
28#include <mach/mcbsp.h> 28#include <mach/mcbsp.h>
29 29
30static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT]; 30struct omap_mcbsp **mcbsp_ptr;
31int omap_mcbsp_count;
31 32
32#define omap_mcbsp_check_valid_id(id) (mcbsp[id].pdata && \ 33void omap_mcbsp_write(void __iomem *io_base, u16 reg, u32 val)
33 mcbsp[id].pdata->ops && \ 34{
34 mcbsp[id].pdata->ops->check && \ 35 if (cpu_class_is_omap1() || cpu_is_omap2420())
35 (mcbsp[id].pdata->ops->check(id) == 0)) 36 __raw_writew((u16)val, io_base + reg);
37 else
38 __raw_writel(val, io_base + reg);
39}
40
41int omap_mcbsp_read(void __iomem *io_base, u16 reg)
42{
43 if (cpu_class_is_omap1() || cpu_is_omap2420())
44 return __raw_readw(io_base + reg);
45 else
46 return __raw_readl(io_base + reg);
47}
48
49#define OMAP_MCBSP_READ(base, reg) \
50 omap_mcbsp_read(base, OMAP_MCBSP_REG_##reg)
51#define OMAP_MCBSP_WRITE(base, reg, val) \
52 omap_mcbsp_write(base, OMAP_MCBSP_REG_##reg, val)
53
54#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
55#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
36 56
37static void omap_mcbsp_dump_reg(u8 id) 57static void omap_mcbsp_dump_reg(u8 id)
38{ 58{
39 dev_dbg(mcbsp[id].dev, "**** McBSP%d regs ****\n", mcbsp[id].id); 59 struct omap_mcbsp *mcbsp = id_to_mcbsp_ptr(id);
40 dev_dbg(mcbsp[id].dev, "DRR2: 0x%04x\n", 60
41 OMAP_MCBSP_READ(mcbsp[id].io_base, DRR2)); 61 dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id);
42 dev_dbg(mcbsp[id].dev, "DRR1: 0x%04x\n", 62 dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n",
43 OMAP_MCBSP_READ(mcbsp[id].io_base, DRR1)); 63 OMAP_MCBSP_READ(mcbsp->io_base, DRR2));
44 dev_dbg(mcbsp[id].dev, "DXR2: 0x%04x\n", 64 dev_dbg(mcbsp->dev, "DRR1: 0x%04x\n",
45 OMAP_MCBSP_READ(mcbsp[id].io_base, DXR2)); 65 OMAP_MCBSP_READ(mcbsp->io_base, DRR1));
46 dev_dbg(mcbsp[id].dev, "DXR1: 0x%04x\n", 66 dev_dbg(mcbsp->dev, "DXR2: 0x%04x\n",
47 OMAP_MCBSP_READ(mcbsp[id].io_base, DXR1)); 67 OMAP_MCBSP_READ(mcbsp->io_base, DXR2));
48 dev_dbg(mcbsp[id].dev, "SPCR2: 0x%04x\n", 68 dev_dbg(mcbsp->dev, "DXR1: 0x%04x\n",
49 OMAP_MCBSP_READ(mcbsp[id].io_base, SPCR2)); 69 OMAP_MCBSP_READ(mcbsp->io_base, DXR1));
50 dev_dbg(mcbsp[id].dev, "SPCR1: 0x%04x\n", 70 dev_dbg(mcbsp->dev, "SPCR2: 0x%04x\n",
51 OMAP_MCBSP_READ(mcbsp[id].io_base, SPCR1)); 71 OMAP_MCBSP_READ(mcbsp->io_base, SPCR2));
52 dev_dbg(mcbsp[id].dev, "RCR2: 0x%04x\n", 72 dev_dbg(mcbsp->dev, "SPCR1: 0x%04x\n",
53 OMAP_MCBSP_READ(mcbsp[id].io_base, RCR2)); 73 OMAP_MCBSP_READ(mcbsp->io_base, SPCR1));
54 dev_dbg(mcbsp[id].dev, "RCR1: 0x%04x\n", 74 dev_dbg(mcbsp->dev, "RCR2: 0x%04x\n",
55 OMAP_MCBSP_READ(mcbsp[id].io_base, RCR1)); 75 OMAP_MCBSP_READ(mcbsp->io_base, RCR2));
56 dev_dbg(mcbsp[id].dev, "XCR2: 0x%04x\n", 76 dev_dbg(mcbsp->dev, "RCR1: 0x%04x\n",
57 OMAP_MCBSP_READ(mcbsp[id].io_base, XCR2)); 77 OMAP_MCBSP_READ(mcbsp->io_base, RCR1));
58 dev_dbg(mcbsp[id].dev, "XCR1: 0x%04x\n", 78 dev_dbg(mcbsp->dev, "XCR2: 0x%04x\n",
59 OMAP_MCBSP_READ(mcbsp[id].io_base, XCR1)); 79 OMAP_MCBSP_READ(mcbsp->io_base, XCR2));
60 dev_dbg(mcbsp[id].dev, "SRGR2: 0x%04x\n", 80 dev_dbg(mcbsp->dev, "XCR1: 0x%04x\n",
61 OMAP_MCBSP_READ(mcbsp[id].io_base, SRGR2)); 81 OMAP_MCBSP_READ(mcbsp->io_base, XCR1));
62 dev_dbg(mcbsp[id].dev, "SRGR1: 0x%04x\n", 82 dev_dbg(mcbsp->dev, "SRGR2: 0x%04x\n",
63 OMAP_MCBSP_READ(mcbsp[id].io_base, SRGR1)); 83 OMAP_MCBSP_READ(mcbsp->io_base, SRGR2));
64 dev_dbg(mcbsp[id].dev, "PCR0: 0x%04x\n", 84 dev_dbg(mcbsp->dev, "SRGR1: 0x%04x\n",
65 OMAP_MCBSP_READ(mcbsp[id].io_base, PCR0)); 85 OMAP_MCBSP_READ(mcbsp->io_base, SRGR1));
66 dev_dbg(mcbsp[id].dev, "***********************\n"); 86 dev_dbg(mcbsp->dev, "PCR0: 0x%04x\n",
87 OMAP_MCBSP_READ(mcbsp->io_base, PCR0));
88 dev_dbg(mcbsp->dev, "***********************\n");
67} 89}
68 90
69static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id) 91static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
@@ -126,16 +148,18 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
126 */ 148 */
127void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config) 149void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
128{ 150{
129 u32 io_base; 151 struct omap_mcbsp *mcbsp;
152 void __iomem *io_base;
130 153
131 if (!omap_mcbsp_check_valid_id(id)) { 154 if (!omap_mcbsp_check_valid_id(id)) {
132 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 155 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
133 return; 156 return;
134 } 157 }
158 mcbsp = id_to_mcbsp_ptr(id);
135 159
136 io_base = mcbsp[id].io_base; 160 io_base = mcbsp->io_base;
137 dev_dbg(mcbsp[id].dev, "Configuring McBSP%d io_base: 0x%8x\n", 161 dev_dbg(mcbsp->dev, "Configuring McBSP%d phys_base: 0x%08lx\n",
138 mcbsp[id].id, io_base); 162 mcbsp->id, mcbsp->phys_base);
139 163
140 /* We write the given config */ 164 /* We write the given config */
141 OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2); 165 OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
@@ -158,23 +182,26 @@ EXPORT_SYMBOL(omap_mcbsp_config);
158 */ 182 */
159int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type) 183int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
160{ 184{
185 struct omap_mcbsp *mcbsp;
186
161 if (!omap_mcbsp_check_valid_id(id)) { 187 if (!omap_mcbsp_check_valid_id(id)) {
162 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 188 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
163 return -ENODEV; 189 return -ENODEV;
164 } 190 }
191 mcbsp = id_to_mcbsp_ptr(id);
165 192
166 spin_lock(&mcbsp[id].lock); 193 spin_lock(&mcbsp->lock);
167 194
168 if (!mcbsp[id].free) { 195 if (!mcbsp->free) {
169 dev_err(mcbsp[id].dev, "McBSP%d is currently in use\n", 196 dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
170 mcbsp[id].id); 197 mcbsp->id);
171 spin_unlock(&mcbsp[id].lock); 198 spin_unlock(&mcbsp->lock);
172 return -EINVAL; 199 return -EINVAL;
173 } 200 }
174 201
175 mcbsp[id].io_type = io_type; 202 mcbsp->io_type = io_type;
176 203
177 spin_unlock(&mcbsp[id].lock); 204 spin_unlock(&mcbsp->lock);
178 205
179 return 0; 206 return 0;
180} 207}
@@ -182,53 +209,60 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type);
182 209
183int omap_mcbsp_request(unsigned int id) 210int omap_mcbsp_request(unsigned int id)
184{ 211{
212 struct omap_mcbsp *mcbsp;
185 int err; 213 int err;
186 214
187 if (!omap_mcbsp_check_valid_id(id)) { 215 if (!omap_mcbsp_check_valid_id(id)) {
188 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 216 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
189 return -ENODEV; 217 return -ENODEV;
190 } 218 }
219 mcbsp = id_to_mcbsp_ptr(id);
191 220
192 if (mcbsp[id].pdata->ops->request) 221 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
193 mcbsp[id].pdata->ops->request(id); 222 mcbsp->pdata->ops->request(id);
194 223
195 clk_enable(mcbsp[id].clk); 224 clk_enable(mcbsp->clk);
196 225
197 spin_lock(&mcbsp[id].lock); 226 spin_lock(&mcbsp->lock);
198 if (!mcbsp[id].free) { 227 if (!mcbsp->free) {
199 dev_err(mcbsp[id].dev, "McBSP%d is currently in use\n", 228 dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
200 mcbsp[id].id); 229 mcbsp->id);
201 spin_unlock(&mcbsp[id].lock); 230 spin_unlock(&mcbsp->lock);
202 return -1; 231 return -1;
203 } 232 }
204 233
205 mcbsp[id].free = 0; 234 mcbsp->free = 0;
206 spin_unlock(&mcbsp[id].lock); 235 spin_unlock(&mcbsp->lock);
236
237 /*
238 * Make sure that transmitter, receiver and sample-rate generator are
239 * not running before activating IRQs.
240 */
241 OMAP_MCBSP_WRITE(mcbsp->io_base, SPCR1, 0);
242 OMAP_MCBSP_WRITE(mcbsp->io_base, SPCR2, 0);
207 243
208 if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) { 244 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
209 /* We need to get IRQs here */ 245 /* We need to get IRQs here */
210 err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 246 init_completion(&mcbsp->tx_irq_completion);
211 0, "McBSP", (void *) (&mcbsp[id])); 247 err = request_irq(mcbsp->tx_irq, omap_mcbsp_tx_irq_handler,
248 0, "McBSP", (void *)mcbsp);
212 if (err != 0) { 249 if (err != 0) {
213 dev_err(mcbsp[id].dev, "Unable to request TX IRQ %d " 250 dev_err(mcbsp->dev, "Unable to request TX IRQ %d "
214 "for McBSP%d\n", mcbsp[id].tx_irq, 251 "for McBSP%d\n", mcbsp->tx_irq,
215 mcbsp[id].id); 252 mcbsp->id);
216 return err; 253 return err;
217 } 254 }
218 255
219 init_completion(&(mcbsp[id].tx_irq_completion)); 256 init_completion(&mcbsp->rx_irq_completion);
220 257 err = request_irq(mcbsp->rx_irq, omap_mcbsp_rx_irq_handler,
221 err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 258 0, "McBSP", (void *)mcbsp);
222 0, "McBSP", (void *) (&mcbsp[id]));
223 if (err != 0) { 259 if (err != 0) {
224 dev_err(mcbsp[id].dev, "Unable to request RX IRQ %d " 260 dev_err(mcbsp->dev, "Unable to request RX IRQ %d "
225 "for McBSP%d\n", mcbsp[id].rx_irq, 261 "for McBSP%d\n", mcbsp->rx_irq,
226 mcbsp[id].id); 262 mcbsp->id);
227 free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id])); 263 free_irq(mcbsp->tx_irq, (void *)mcbsp);
228 return err; 264 return err;
229 } 265 }
230
231 init_completion(&(mcbsp[id].rx_irq_completion));
232 } 266 }
233 267
234 return 0; 268 return 0;
@@ -237,31 +271,34 @@ EXPORT_SYMBOL(omap_mcbsp_request);
237 271
238void omap_mcbsp_free(unsigned int id) 272void omap_mcbsp_free(unsigned int id)
239{ 273{
274 struct omap_mcbsp *mcbsp;
275
240 if (!omap_mcbsp_check_valid_id(id)) { 276 if (!omap_mcbsp_check_valid_id(id)) {
241 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 277 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
242 return; 278 return;
243 } 279 }
280 mcbsp = id_to_mcbsp_ptr(id);
244 281
245 if (mcbsp[id].pdata->ops->free) 282 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
246 mcbsp[id].pdata->ops->free(id); 283 mcbsp->pdata->ops->free(id);
247 284
248 clk_disable(mcbsp[id].clk); 285 clk_disable(mcbsp->clk);
249 286
250 spin_lock(&mcbsp[id].lock); 287 spin_lock(&mcbsp->lock);
251 if (mcbsp[id].free) { 288 if (mcbsp->free) {
252 dev_err(mcbsp[id].dev, "McBSP%d was not reserved\n", 289 dev_err(mcbsp->dev, "McBSP%d was not reserved\n",
253 mcbsp[id].id); 290 mcbsp->id);
254 spin_unlock(&mcbsp[id].lock); 291 spin_unlock(&mcbsp->lock);
255 return; 292 return;
256 } 293 }
257 294
258 mcbsp[id].free = 1; 295 mcbsp->free = 1;
259 spin_unlock(&mcbsp[id].lock); 296 spin_unlock(&mcbsp->lock);
260 297
261 if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) { 298 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
262 /* Free IRQs */ 299 /* Free IRQs */
263 free_irq(mcbsp[id].rx_irq, (void *) (&mcbsp[id])); 300 free_irq(mcbsp->rx_irq, (void *)mcbsp);
264 free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id])); 301 free_irq(mcbsp->tx_irq, (void *)mcbsp);
265 } 302 }
266} 303}
267EXPORT_SYMBOL(omap_mcbsp_free); 304EXPORT_SYMBOL(omap_mcbsp_free);
@@ -273,18 +310,19 @@ EXPORT_SYMBOL(omap_mcbsp_free);
273 */ 310 */
274void omap_mcbsp_start(unsigned int id) 311void omap_mcbsp_start(unsigned int id)
275{ 312{
276 u32 io_base; 313 struct omap_mcbsp *mcbsp;
314 void __iomem *io_base;
277 u16 w; 315 u16 w;
278 316
279 if (!omap_mcbsp_check_valid_id(id)) { 317 if (!omap_mcbsp_check_valid_id(id)) {
280 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 318 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
281 return; 319 return;
282 } 320 }
321 mcbsp = id_to_mcbsp_ptr(id);
322 io_base = mcbsp->io_base;
283 323
284 io_base = mcbsp[id].io_base; 324 mcbsp->rx_word_length = (OMAP_MCBSP_READ(io_base, RCR1) >> 5) & 0x7;
285 325 mcbsp->tx_word_length = (OMAP_MCBSP_READ(io_base, XCR1) >> 5) & 0x7;
286 mcbsp[id].rx_word_length = (OMAP_MCBSP_READ(io_base, RCR1) >> 5) & 0x7;
287 mcbsp[id].tx_word_length = (OMAP_MCBSP_READ(io_base, XCR1) >> 5) & 0x7;
288 326
289 /* Start the sample generator */ 327 /* Start the sample generator */
290 w = OMAP_MCBSP_READ(io_base, SPCR2); 328 w = OMAP_MCBSP_READ(io_base, SPCR2);
@@ -310,7 +348,8 @@ EXPORT_SYMBOL(omap_mcbsp_start);
310 348
311void omap_mcbsp_stop(unsigned int id) 349void omap_mcbsp_stop(unsigned int id)
312{ 350{
313 u32 io_base; 351 struct omap_mcbsp *mcbsp;
352 void __iomem *io_base;
314 u16 w; 353 u16 w;
315 354
316 if (!omap_mcbsp_check_valid_id(id)) { 355 if (!omap_mcbsp_check_valid_id(id)) {
@@ -318,7 +357,8 @@ void omap_mcbsp_stop(unsigned int id)
318 return; 357 return;
319 } 358 }
320 359
321 io_base = mcbsp[id].io_base; 360 mcbsp = id_to_mcbsp_ptr(id);
361 io_base = mcbsp->io_base;
322 362
323 /* Reset transmitter */ 363 /* Reset transmitter */
324 w = OMAP_MCBSP_READ(io_base, SPCR2); 364 w = OMAP_MCBSP_READ(io_base, SPCR2);
@@ -337,14 +377,17 @@ EXPORT_SYMBOL(omap_mcbsp_stop);
337/* polled mcbsp i/o operations */ 377/* polled mcbsp i/o operations */
338int omap_mcbsp_pollwrite(unsigned int id, u16 buf) 378int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
339{ 379{
340 u32 base; 380 struct omap_mcbsp *mcbsp;
381 void __iomem *base;
341 382
342 if (!omap_mcbsp_check_valid_id(id)) { 383 if (!omap_mcbsp_check_valid_id(id)) {
343 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 384 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
344 return -ENODEV; 385 return -ENODEV;
345 } 386 }
346 387
347 base = mcbsp[id].io_base; 388 mcbsp = id_to_mcbsp_ptr(id);
389 base = mcbsp->io_base;
390
348 writew(buf, base + OMAP_MCBSP_REG_DXR1); 391 writew(buf, base + OMAP_MCBSP_REG_DXR1);
349 /* if frame sync error - clear the error */ 392 /* if frame sync error - clear the error */
350 if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) { 393 if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) {
@@ -366,8 +409,8 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
366 (XRST), 409 (XRST),
367 base + OMAP_MCBSP_REG_SPCR2); 410 base + OMAP_MCBSP_REG_SPCR2);
368 udelay(10); 411 udelay(10);
369 dev_err(mcbsp[id].dev, "Could not write to" 412 dev_err(mcbsp->dev, "Could not write to"
370 " McBSP%d Register\n", mcbsp[id].id); 413 " McBSP%d Register\n", mcbsp->id);
371 return -2; 414 return -2;
372 } 415 }
373 } 416 }
@@ -379,14 +422,16 @@ EXPORT_SYMBOL(omap_mcbsp_pollwrite);
379 422
380int omap_mcbsp_pollread(unsigned int id, u16 *buf) 423int omap_mcbsp_pollread(unsigned int id, u16 *buf)
381{ 424{
382 u32 base; 425 struct omap_mcbsp *mcbsp;
426 void __iomem *base;
383 427
384 if (!omap_mcbsp_check_valid_id(id)) { 428 if (!omap_mcbsp_check_valid_id(id)) {
385 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 429 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
386 return -ENODEV; 430 return -ENODEV;
387 } 431 }
432 mcbsp = id_to_mcbsp_ptr(id);
388 433
389 base = mcbsp[id].io_base; 434 base = mcbsp->io_base;
390 /* if frame sync error - clear the error */ 435 /* if frame sync error - clear the error */
391 if (readw(base + OMAP_MCBSP_REG_SPCR1) & RSYNC_ERR) { 436 if (readw(base + OMAP_MCBSP_REG_SPCR1) & RSYNC_ERR) {
392 /* clear error */ 437 /* clear error */
@@ -407,8 +452,8 @@ int omap_mcbsp_pollread(unsigned int id, u16 *buf)
407 (RRST), 452 (RRST),
408 base + OMAP_MCBSP_REG_SPCR1); 453 base + OMAP_MCBSP_REG_SPCR1);
409 udelay(10); 454 udelay(10);
410 dev_err(mcbsp[id].dev, "Could not read from" 455 dev_err(mcbsp->dev, "Could not read from"
411 " McBSP%d Register\n", mcbsp[id].id); 456 " McBSP%d Register\n", mcbsp->id);
412 return -2; 457 return -2;
413 } 458 }
414 } 459 }
@@ -424,7 +469,8 @@ EXPORT_SYMBOL(omap_mcbsp_pollread);
424 */ 469 */
425void omap_mcbsp_xmit_word(unsigned int id, u32 word) 470void omap_mcbsp_xmit_word(unsigned int id, u32 word)
426{ 471{
427 u32 io_base; 472 struct omap_mcbsp *mcbsp;
473 void __iomem *io_base;
428 omap_mcbsp_word_length word_length; 474 omap_mcbsp_word_length word_length;
429 475
430 if (!omap_mcbsp_check_valid_id(id)) { 476 if (!omap_mcbsp_check_valid_id(id)) {
@@ -432,10 +478,11 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
432 return; 478 return;
433 } 479 }
434 480
435 io_base = mcbsp[id].io_base; 481 mcbsp = id_to_mcbsp_ptr(id);
436 word_length = mcbsp[id].tx_word_length; 482 io_base = mcbsp->io_base;
483 word_length = mcbsp->tx_word_length;
437 484
438 wait_for_completion(&(mcbsp[id].tx_irq_completion)); 485 wait_for_completion(&mcbsp->tx_irq_completion);
439 486
440 if (word_length > OMAP_MCBSP_WORD_16) 487 if (word_length > OMAP_MCBSP_WORD_16)
441 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16); 488 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
@@ -445,7 +492,8 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_word);
445 492
446u32 omap_mcbsp_recv_word(unsigned int id) 493u32 omap_mcbsp_recv_word(unsigned int id)
447{ 494{
448 u32 io_base; 495 struct omap_mcbsp *mcbsp;
496 void __iomem *io_base;
449 u16 word_lsb, word_msb = 0; 497 u16 word_lsb, word_msb = 0;
450 omap_mcbsp_word_length word_length; 498 omap_mcbsp_word_length word_length;
451 499
@@ -453,11 +501,12 @@ u32 omap_mcbsp_recv_word(unsigned int id)
453 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 501 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
454 return -ENODEV; 502 return -ENODEV;
455 } 503 }
504 mcbsp = id_to_mcbsp_ptr(id);
456 505
457 word_length = mcbsp[id].rx_word_length; 506 word_length = mcbsp->rx_word_length;
458 io_base = mcbsp[id].io_base; 507 io_base = mcbsp->io_base;
459 508
460 wait_for_completion(&(mcbsp[id].rx_irq_completion)); 509 wait_for_completion(&mcbsp->rx_irq_completion);
461 510
462 if (word_length > OMAP_MCBSP_WORD_16) 511 if (word_length > OMAP_MCBSP_WORD_16)
463 word_msb = OMAP_MCBSP_READ(io_base, DRR2); 512 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
@@ -469,7 +518,8 @@ EXPORT_SYMBOL(omap_mcbsp_recv_word);
469 518
470int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word) 519int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
471{ 520{
472 u32 io_base; 521 struct omap_mcbsp *mcbsp;
522 void __iomem *io_base;
473 omap_mcbsp_word_length tx_word_length; 523 omap_mcbsp_word_length tx_word_length;
474 omap_mcbsp_word_length rx_word_length; 524 omap_mcbsp_word_length rx_word_length;
475 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0; 525 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
@@ -478,10 +528,10 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
478 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 528 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
479 return -ENODEV; 529 return -ENODEV;
480 } 530 }
481 531 mcbsp = id_to_mcbsp_ptr(id);
482 io_base = mcbsp[id].io_base; 532 io_base = mcbsp->io_base;
483 tx_word_length = mcbsp[id].tx_word_length; 533 tx_word_length = mcbsp->tx_word_length;
484 rx_word_length = mcbsp[id].rx_word_length; 534 rx_word_length = mcbsp->rx_word_length;
485 535
486 if (tx_word_length != rx_word_length) 536 if (tx_word_length != rx_word_length)
487 return -EINVAL; 537 return -EINVAL;
@@ -496,8 +546,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
496 udelay(10); 546 udelay(10);
497 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST); 547 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
498 udelay(10); 548 udelay(10);
499 dev_err(mcbsp[id].dev, "McBSP%d transmitter not " 549 dev_err(mcbsp->dev, "McBSP%d transmitter not "
500 "ready\n", mcbsp[id].id); 550 "ready\n", mcbsp->id);
501 return -EAGAIN; 551 return -EAGAIN;
502 } 552 }
503 } 553 }
@@ -517,8 +567,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
517 udelay(10); 567 udelay(10);
518 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST); 568 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
519 udelay(10); 569 udelay(10);
520 dev_err(mcbsp[id].dev, "McBSP%d receiver not " 570 dev_err(mcbsp->dev, "McBSP%d receiver not "
521 "ready\n", mcbsp[id].id); 571 "ready\n", mcbsp->id);
522 return -EAGAIN; 572 return -EAGAIN;
523 } 573 }
524 } 574 }
@@ -534,7 +584,9 @@ EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
534 584
535int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word) 585int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
536{ 586{
537 u32 io_base, clock_word = 0; 587 struct omap_mcbsp *mcbsp;
588 u32 clock_word = 0;
589 void __iomem *io_base;
538 omap_mcbsp_word_length tx_word_length; 590 omap_mcbsp_word_length tx_word_length;
539 omap_mcbsp_word_length rx_word_length; 591 omap_mcbsp_word_length rx_word_length;
540 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0; 592 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
@@ -544,9 +596,11 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
544 return -ENODEV; 596 return -ENODEV;
545 } 597 }
546 598
547 io_base = mcbsp[id].io_base; 599 mcbsp = id_to_mcbsp_ptr(id);
548 tx_word_length = mcbsp[id].tx_word_length; 600 io_base = mcbsp->io_base;
549 rx_word_length = mcbsp[id].rx_word_length; 601
602 tx_word_length = mcbsp->tx_word_length;
603 rx_word_length = mcbsp->rx_word_length;
550 604
551 if (tx_word_length != rx_word_length) 605 if (tx_word_length != rx_word_length)
552 return -EINVAL; 606 return -EINVAL;
@@ -561,8 +615,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
561 udelay(10); 615 udelay(10);
562 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST); 616 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
563 udelay(10); 617 udelay(10);
564 dev_err(mcbsp[id].dev, "McBSP%d transmitter not " 618 dev_err(mcbsp->dev, "McBSP%d transmitter not "
565 "ready\n", mcbsp[id].id); 619 "ready\n", mcbsp->id);
566 return -EAGAIN; 620 return -EAGAIN;
567 } 621 }
568 } 622 }
@@ -582,8 +636,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
582 udelay(10); 636 udelay(10);
583 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST); 637 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
584 udelay(10); 638 udelay(10);
585 dev_err(mcbsp[id].dev, "McBSP%d receiver not " 639 dev_err(mcbsp->dev, "McBSP%d receiver not "
586 "ready\n", mcbsp[id].id); 640 "ready\n", mcbsp->id);
587 return -EAGAIN; 641 return -EAGAIN;
588 } 642 }
589 } 643 }
@@ -609,6 +663,7 @@ EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
609int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, 663int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
610 unsigned int length) 664 unsigned int length)
611{ 665{
666 struct omap_mcbsp *mcbsp;
612 int dma_tx_ch; 667 int dma_tx_ch;
613 int src_port = 0; 668 int src_port = 0;
614 int dest_port = 0; 669 int dest_port = 0;
@@ -618,50 +673,51 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
618 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 673 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
619 return -ENODEV; 674 return -ENODEV;
620 } 675 }
676 mcbsp = id_to_mcbsp_ptr(id);
621 677
622 if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX", 678 if (omap_request_dma(mcbsp->dma_tx_sync, "McBSP TX",
623 omap_mcbsp_tx_dma_callback, 679 omap_mcbsp_tx_dma_callback,
624 &mcbsp[id], 680 mcbsp,
625 &dma_tx_ch)) { 681 &dma_tx_ch)) {
626 dev_err(mcbsp[id].dev, " Unable to request DMA channel for " 682 dev_err(mcbsp->dev, " Unable to request DMA channel for "
627 "McBSP%d TX. Trying IRQ based TX\n", 683 "McBSP%d TX. Trying IRQ based TX\n",
628 mcbsp[id].id); 684 mcbsp->id);
629 return -EAGAIN; 685 return -EAGAIN;
630 } 686 }
631 mcbsp[id].dma_tx_lch = dma_tx_ch; 687 mcbsp->dma_tx_lch = dma_tx_ch;
632 688
633 dev_err(mcbsp[id].dev, "McBSP%d TX DMA on channel %d\n", mcbsp[id].id, 689 dev_err(mcbsp->dev, "McBSP%d TX DMA on channel %d\n", mcbsp->id,
634 dma_tx_ch); 690 dma_tx_ch);
635 691
636 init_completion(&(mcbsp[id].tx_dma_completion)); 692 init_completion(&mcbsp->tx_dma_completion);
637 693
638 if (cpu_class_is_omap1()) { 694 if (cpu_class_is_omap1()) {
639 src_port = OMAP_DMA_PORT_TIPB; 695 src_port = OMAP_DMA_PORT_TIPB;
640 dest_port = OMAP_DMA_PORT_EMIFF; 696 dest_port = OMAP_DMA_PORT_EMIFF;
641 } 697 }
642 if (cpu_class_is_omap2()) 698 if (cpu_class_is_omap2())
643 sync_dev = mcbsp[id].dma_tx_sync; 699 sync_dev = mcbsp->dma_tx_sync;
644 700
645 omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch, 701 omap_set_dma_transfer_params(mcbsp->dma_tx_lch,
646 OMAP_DMA_DATA_TYPE_S16, 702 OMAP_DMA_DATA_TYPE_S16,
647 length >> 1, 1, 703 length >> 1, 1,
648 OMAP_DMA_SYNC_ELEMENT, 704 OMAP_DMA_SYNC_ELEMENT,
649 sync_dev, 0); 705 sync_dev, 0);
650 706
651 omap_set_dma_dest_params(mcbsp[id].dma_tx_lch, 707 omap_set_dma_dest_params(mcbsp->dma_tx_lch,
652 src_port, 708 src_port,
653 OMAP_DMA_AMODE_CONSTANT, 709 OMAP_DMA_AMODE_CONSTANT,
654 mcbsp[id].phys_base + OMAP_MCBSP_REG_DXR1, 710 mcbsp->phys_base + OMAP_MCBSP_REG_DXR1,
655 0, 0); 711 0, 0);
656 712
657 omap_set_dma_src_params(mcbsp[id].dma_tx_lch, 713 omap_set_dma_src_params(mcbsp->dma_tx_lch,
658 dest_port, 714 dest_port,
659 OMAP_DMA_AMODE_POST_INC, 715 OMAP_DMA_AMODE_POST_INC,
660 buffer, 716 buffer,
661 0, 0); 717 0, 0);
662 718
663 omap_start_dma(mcbsp[id].dma_tx_lch); 719 omap_start_dma(mcbsp->dma_tx_lch);
664 wait_for_completion(&(mcbsp[id].tx_dma_completion)); 720 wait_for_completion(&mcbsp->tx_dma_completion);
665 721
666 return 0; 722 return 0;
667} 723}
@@ -670,6 +726,7 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
670int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, 726int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
671 unsigned int length) 727 unsigned int length)
672{ 728{
729 struct omap_mcbsp *mcbsp;
673 int dma_rx_ch; 730 int dma_rx_ch;
674 int src_port = 0; 731 int src_port = 0;
675 int dest_port = 0; 732 int dest_port = 0;
@@ -679,50 +736,51 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
679 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 736 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
680 return -ENODEV; 737 return -ENODEV;
681 } 738 }
739 mcbsp = id_to_mcbsp_ptr(id);
682 740
683 if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX", 741 if (omap_request_dma(mcbsp->dma_rx_sync, "McBSP RX",
684 omap_mcbsp_rx_dma_callback, 742 omap_mcbsp_rx_dma_callback,
685 &mcbsp[id], 743 mcbsp,
686 &dma_rx_ch)) { 744 &dma_rx_ch)) {
687 dev_err(mcbsp[id].dev, "Unable to request DMA channel for " 745 dev_err(mcbsp->dev, "Unable to request DMA channel for "
688 "McBSP%d RX. Trying IRQ based RX\n", 746 "McBSP%d RX. Trying IRQ based RX\n",
689 mcbsp[id].id); 747 mcbsp->id);
690 return -EAGAIN; 748 return -EAGAIN;
691 } 749 }
692 mcbsp[id].dma_rx_lch = dma_rx_ch; 750 mcbsp->dma_rx_lch = dma_rx_ch;
693 751
694 dev_err(mcbsp[id].dev, "McBSP%d RX DMA on channel %d\n", mcbsp[id].id, 752 dev_err(mcbsp->dev, "McBSP%d RX DMA on channel %d\n", mcbsp->id,
695 dma_rx_ch); 753 dma_rx_ch);
696 754
697 init_completion(&(mcbsp[id].rx_dma_completion)); 755 init_completion(&mcbsp->rx_dma_completion);
698 756
699 if (cpu_class_is_omap1()) { 757 if (cpu_class_is_omap1()) {
700 src_port = OMAP_DMA_PORT_TIPB; 758 src_port = OMAP_DMA_PORT_TIPB;
701 dest_port = OMAP_DMA_PORT_EMIFF; 759 dest_port = OMAP_DMA_PORT_EMIFF;
702 } 760 }
703 if (cpu_class_is_omap2()) 761 if (cpu_class_is_omap2())
704 sync_dev = mcbsp[id].dma_rx_sync; 762 sync_dev = mcbsp->dma_rx_sync;
705 763
706 omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch, 764 omap_set_dma_transfer_params(mcbsp->dma_rx_lch,
707 OMAP_DMA_DATA_TYPE_S16, 765 OMAP_DMA_DATA_TYPE_S16,
708 length >> 1, 1, 766 length >> 1, 1,
709 OMAP_DMA_SYNC_ELEMENT, 767 OMAP_DMA_SYNC_ELEMENT,
710 sync_dev, 0); 768 sync_dev, 0);
711 769
712 omap_set_dma_src_params(mcbsp[id].dma_rx_lch, 770 omap_set_dma_src_params(mcbsp->dma_rx_lch,
713 src_port, 771 src_port,
714 OMAP_DMA_AMODE_CONSTANT, 772 OMAP_DMA_AMODE_CONSTANT,
715 mcbsp[id].phys_base + OMAP_MCBSP_REG_DRR1, 773 mcbsp->phys_base + OMAP_MCBSP_REG_DRR1,
716 0, 0); 774 0, 0);
717 775
718 omap_set_dma_dest_params(mcbsp[id].dma_rx_lch, 776 omap_set_dma_dest_params(mcbsp->dma_rx_lch,
719 dest_port, 777 dest_port,
720 OMAP_DMA_AMODE_POST_INC, 778 OMAP_DMA_AMODE_POST_INC,
721 buffer, 779 buffer,
722 0, 0); 780 0, 0);
723 781
724 omap_start_dma(mcbsp[id].dma_rx_lch); 782 omap_start_dma(mcbsp->dma_rx_lch);
725 wait_for_completion(&(mcbsp[id].rx_dma_completion)); 783 wait_for_completion(&mcbsp->rx_dma_completion);
726 784
727 return 0; 785 return 0;
728} 786}
@@ -737,12 +795,14 @@ EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
737void omap_mcbsp_set_spi_mode(unsigned int id, 795void omap_mcbsp_set_spi_mode(unsigned int id,
738 const struct omap_mcbsp_spi_cfg *spi_cfg) 796 const struct omap_mcbsp_spi_cfg *spi_cfg)
739{ 797{
798 struct omap_mcbsp *mcbsp;
740 struct omap_mcbsp_reg_cfg mcbsp_cfg; 799 struct omap_mcbsp_reg_cfg mcbsp_cfg;
741 800
742 if (!omap_mcbsp_check_valid_id(id)) { 801 if (!omap_mcbsp_check_valid_id(id)) {
743 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 802 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
744 return; 803 return;
745 } 804 }
805 mcbsp = id_to_mcbsp_ptr(id);
746 806
747 memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg)); 807 memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
748 808
@@ -803,9 +863,10 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
803 * McBSP1 and McBSP3 are directly mapped on 1610 and 1510. 863 * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
804 * 730 has only 2 McBSP, and both of them are MPU peripherals. 864 * 730 has only 2 McBSP, and both of them are MPU peripherals.
805 */ 865 */
806static int __init omap_mcbsp_probe(struct platform_device *pdev) 866static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
807{ 867{
808 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; 868 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
869 struct omap_mcbsp *mcbsp;
809 int id = pdev->id - 1; 870 int id = pdev->id - 1;
810 int ret = 0; 871 int ret = 0;
811 872
@@ -818,47 +879,63 @@ static int __init omap_mcbsp_probe(struct platform_device *pdev)
818 879
819 dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id); 880 dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id);
820 881
821 if (id >= OMAP_MAX_MCBSP_COUNT) { 882 if (id >= omap_mcbsp_count) {
822 dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id); 883 dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id);
823 ret = -EINVAL; 884 ret = -EINVAL;
824 goto exit; 885 goto exit;
825 } 886 }
826 887
827 spin_lock_init(&mcbsp[id].lock); 888 mcbsp = kzalloc(sizeof(struct omap_mcbsp), GFP_KERNEL);
828 mcbsp[id].id = id + 1; 889 if (!mcbsp) {
829 mcbsp[id].free = 1; 890 ret = -ENOMEM;
830 mcbsp[id].dma_tx_lch = -1; 891 goto exit;
831 mcbsp[id].dma_rx_lch = -1; 892 }
893 mcbsp_ptr[id] = mcbsp;
894
895 spin_lock_init(&mcbsp->lock);
896 mcbsp->id = id + 1;
897 mcbsp->free = 1;
898 mcbsp->dma_tx_lch = -1;
899 mcbsp->dma_rx_lch = -1;
900
901 mcbsp->phys_base = pdata->phys_base;
902 mcbsp->io_base = ioremap(pdata->phys_base, SZ_4K);
903 if (!mcbsp->io_base) {
904 ret = -ENOMEM;
905 goto err_ioremap;
906 }
832 907
833 mcbsp[id].phys_base = pdata->phys_base;
834 mcbsp[id].io_base = pdata->virt_base;
835 /* Default I/O is IRQ based */ 908 /* Default I/O is IRQ based */
836 mcbsp[id].io_type = OMAP_MCBSP_IRQ_IO; 909 mcbsp->io_type = OMAP_MCBSP_IRQ_IO;
837 mcbsp[id].tx_irq = pdata->tx_irq; 910 mcbsp->tx_irq = pdata->tx_irq;
838 mcbsp[id].rx_irq = pdata->rx_irq; 911 mcbsp->rx_irq = pdata->rx_irq;
839 mcbsp[id].dma_rx_sync = pdata->dma_rx_sync; 912 mcbsp->dma_rx_sync = pdata->dma_rx_sync;
840 mcbsp[id].dma_tx_sync = pdata->dma_tx_sync; 913 mcbsp->dma_tx_sync = pdata->dma_tx_sync;
841 914
842 if (pdata->clk_name) 915 if (pdata->clk_name)
843 mcbsp[id].clk = clk_get(&pdev->dev, pdata->clk_name); 916 mcbsp->clk = clk_get(&pdev->dev, pdata->clk_name);
844 if (IS_ERR(mcbsp[id].clk)) { 917 if (IS_ERR(mcbsp->clk)) {
845 mcbsp[id].free = 0;
846 dev_err(&pdev->dev, 918 dev_err(&pdev->dev,
847 "Invalid clock configuration for McBSP%d.\n", 919 "Invalid clock configuration for McBSP%d.\n",
848 mcbsp[id].id); 920 mcbsp->id);
849 ret = -EINVAL; 921 ret = PTR_ERR(mcbsp->clk);
850 goto exit; 922 goto err_clk;
851 } 923 }
852 924
853 mcbsp[id].pdata = pdata; 925 mcbsp->pdata = pdata;
854 mcbsp[id].dev = &pdev->dev; 926 mcbsp->dev = &pdev->dev;
855 platform_set_drvdata(pdev, &mcbsp[id]); 927 platform_set_drvdata(pdev, mcbsp);
928 return 0;
856 929
930err_clk:
931 iounmap(mcbsp->io_base);
932err_ioremap:
933 mcbsp->free = 0;
857exit: 934exit:
858 return ret; 935 return ret;
859} 936}
860 937
861static int omap_mcbsp_remove(struct platform_device *pdev) 938static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
862{ 939{
863 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); 940 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
864 941
@@ -872,6 +949,8 @@ static int omap_mcbsp_remove(struct platform_device *pdev)
872 clk_disable(mcbsp->clk); 949 clk_disable(mcbsp->clk);
873 clk_put(mcbsp->clk); 950 clk_put(mcbsp->clk);
874 951
952 iounmap(mcbsp->io_base);
953
875 mcbsp->clk = NULL; 954 mcbsp->clk = NULL;
876 mcbsp->free = 0; 955 mcbsp->free = 0;
877 mcbsp->dev = NULL; 956 mcbsp->dev = NULL;
@@ -882,7 +961,7 @@ static int omap_mcbsp_remove(struct platform_device *pdev)
882 961
883static struct platform_driver omap_mcbsp_driver = { 962static struct platform_driver omap_mcbsp_driver = {
884 .probe = omap_mcbsp_probe, 963 .probe = omap_mcbsp_probe,
885 .remove = omap_mcbsp_remove, 964 .remove = __devexit_p(omap_mcbsp_remove),
886 .driver = { 965 .driver = {
887 .name = "omap-mcbsp", 966 .name = "omap-mcbsp",
888 }, 967 },
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index e0003e0746e7..9f9a921829c0 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -271,7 +271,7 @@ int __init omap1_sram_init(void)
271#define omap1_sram_init() do {} while (0) 271#define omap1_sram_init() do {} while (0)
272#endif 272#endif
273 273
274#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 274#if defined(CONFIG_ARCH_OMAP2)
275 275
276static void (*_omap2_sram_ddr_init)(u32 *slow_dll_ctrl, u32 fast_dll_ctrl, 276static void (*_omap2_sram_ddr_init)(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,
277 u32 base_cs, u32 force_unlock); 277 u32 base_cs, u32 force_unlock);
@@ -352,23 +352,19 @@ static inline int omap243x_sram_init(void)
352 352
353#ifdef CONFIG_ARCH_OMAP3 353#ifdef CONFIG_ARCH_OMAP3
354 354
355static u32 (*_omap2_sram_reprogram_gpmc)(u32 perf_level); 355static u32 (*_omap3_sram_configure_core_dpll)(u32 sdrc_rfr_ctrl,
356u32 omap2_sram_reprogram_gpmc(u32 perf_level) 356 u32 sdrc_actim_ctrla,
357{ 357 u32 sdrc_actim_ctrlb,
358 if (!_omap2_sram_reprogram_gpmc) 358 u32 m2);
359 omap_sram_error(); 359u32 omap3_configure_core_dpll(u32 sdrc_rfr_ctrl, u32 sdrc_actim_ctrla,
360 360 u32 sdrc_actim_ctrlb, u32 m2)
361 return _omap2_sram_reprogram_gpmc(perf_level);
362}
363
364static u32 (*_omap2_sram_configure_core_dpll)(u32 m, u32 n,
365 u32 freqsel, u32 m2);
366u32 omap2_sram_configure_core_dpll(u32 m, u32 n, u32 freqsel, u32 m2)
367{ 361{
368 if (!_omap2_sram_configure_core_dpll) 362 if (!_omap3_sram_configure_core_dpll)
369 omap_sram_error(); 363 omap_sram_error();
370 364
371 return _omap2_sram_configure_core_dpll(m, n, freqsel, m2); 365 return _omap3_sram_configure_core_dpll(sdrc_rfr_ctrl,
366 sdrc_actim_ctrla,
367 sdrc_actim_ctrlb, m2);
372} 368}
373 369
374/* REVISIT: Should this be same as omap34xx_sram_init() after off-idle? */ 370/* REVISIT: Should this be same as omap34xx_sram_init() after off-idle? */
@@ -376,31 +372,16 @@ void restore_sram_functions(void)
376{ 372{
377 omap_sram_ceil = omap_sram_base + omap_sram_size; 373 omap_sram_ceil = omap_sram_base + omap_sram_size;
378 374
379 _omap2_sram_reprogram_gpmc = omap_sram_push(omap34xx_sram_reprogram_gpmc, 375 _omap3_sram_configure_core_dpll =
380 omap34xx_sram_reprogram_gpmc_sz); 376 omap_sram_push(omap3_sram_configure_core_dpll,
381 377 omap3_sram_configure_core_dpll_sz);
382 _omap2_sram_configure_core_dpll =
383 omap_sram_push(omap34xx_sram_configure_core_dpll,
384 omap34xx_sram_configure_core_dpll_sz);
385} 378}
386 379
387int __init omap34xx_sram_init(void) 380int __init omap34xx_sram_init(void)
388{ 381{
389 _omap2_sram_ddr_init = omap_sram_push(omap34xx_sram_ddr_init, 382 _omap3_sram_configure_core_dpll =
390 omap34xx_sram_ddr_init_sz); 383 omap_sram_push(omap3_sram_configure_core_dpll,
391 384 omap3_sram_configure_core_dpll_sz);
392 _omap2_sram_reprogram_sdrc = omap_sram_push(omap34xx_sram_reprogram_sdrc,
393 omap34xx_sram_reprogram_sdrc_sz);
394
395 _omap2_set_prcm = omap_sram_push(omap34xx_sram_set_prcm,
396 omap34xx_sram_set_prcm_sz);
397
398 _omap2_sram_reprogram_gpmc = omap_sram_push(omap34xx_sram_reprogram_gpmc,
399 omap34xx_sram_reprogram_gpmc_sz);
400
401 _omap2_sram_configure_core_dpll =
402 omap_sram_push(omap34xx_sram_configure_core_dpll,
403 omap34xx_sram_configure_core_dpll_sz);
404 385
405 return 0; 386 return 0;
406} 387}
diff --git a/arch/arm/plat-s3c/Makefile b/arch/arm/plat-s3c/Makefile
new file mode 100644
index 000000000000..f03d7b35ba37
--- /dev/null
+++ b/arch/arm/plat-s3c/Makefile
@@ -0,0 +1,3 @@
1# dummy makefile, currently just including asm/arm/plat-s3c/include/plat
2
3obj-n := dummy.o
diff --git a/include/asm-arm/plat-s3c/debug-macro.S b/arch/arm/plat-s3c/include/plat/debug-macro.S
index 84c40b847da8..4aa7e2e6c001 100644
--- a/include/asm-arm/plat-s3c/debug-macro.S
+++ b/arch/arm/plat-s3c/include/plat/debug-macro.S
@@ -9,7 +9,7 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10*/ 10*/
11 11
12#include <asm/plat-s3c/regs-serial.h> 12#include <plat/regs-serial.h>
13 13
14/* The S3C2440 implementations are used by default as they are the 14/* The S3C2440 implementations are used by default as they are the
15 * most widely re-used */ 15 * most widely re-used */
diff --git a/include/asm-arm/plat-s3c/map.h b/arch/arm/plat-s3c/include/plat/map.h
index b84289d32a54..b84289d32a54 100644
--- a/include/asm-arm/plat-s3c/map.h
+++ b/arch/arm/plat-s3c/include/plat/map.h
diff --git a/include/asm-arm/plat-s3c/regs-adc.h b/arch/arm/plat-s3c/include/plat/regs-adc.h
index 4323cccc86cd..4323cccc86cd 100644
--- a/include/asm-arm/plat-s3c/regs-adc.h
+++ b/arch/arm/plat-s3c/include/plat/regs-adc.h
diff --git a/include/asm-arm/plat-s3c/regs-serial.h b/arch/arm/plat-s3c/include/plat/regs-serial.h
index a0daa647b92c..a0daa647b92c 100644
--- a/include/asm-arm/plat-s3c/regs-serial.h
+++ b/arch/arm/plat-s3c/include/plat/regs-serial.h
diff --git a/include/asm-arm/plat-s3c/regs-timer.h b/arch/arm/plat-s3c/include/plat/regs-timer.h
index cc0eedd53e38..cc0eedd53e38 100644
--- a/include/asm-arm/plat-s3c/regs-timer.h
+++ b/arch/arm/plat-s3c/include/plat/regs-timer.h
diff --git a/include/asm-arm/plat-s3c/uncompress.h b/arch/arm/plat-s3c/include/plat/uncompress.h
index 19b9eda39485..4df006b9cc10 100644
--- a/include/asm-arm/plat-s3c/uncompress.h
+++ b/arch/arm/plat-s3c/include/plat/uncompress.h
@@ -27,7 +27,7 @@ static void arch_detect_cpu(void);
27 27
28/* defines for UART registers */ 28/* defines for UART registers */
29 29
30#include <asm/plat-s3c/regs-serial.h> 30#include <plat/regs-serial.h>
31#include <asm/plat-s3c/regs-watchdog.h> 31#include <asm/plat-s3c/regs-watchdog.h>
32 32
33/* working in physical space... */ 33/* working in physical space... */
diff --git a/arch/arm/plat-s3c24xx/clock.c b/arch/arm/plat-s3c24xx/clock.c
index 400541359bfb..a005ddbd9ef3 100644
--- a/arch/arm/plat-s3c24xx/clock.c
+++ b/arch/arm/plat-s3c24xx/clock.c
@@ -47,8 +47,8 @@
47#include <mach/regs-clock.h> 47#include <mach/regs-clock.h>
48#include <mach/regs-gpio.h> 48#include <mach/regs-gpio.h>
49 49
50#include <asm/plat-s3c24xx/clock.h> 50#include <plat/clock.h>
51#include <asm/plat-s3c24xx/cpu.h> 51#include <plat/cpu.h>
52 52
53/* clock information */ 53/* clock information */
54 54
diff --git a/arch/arm/plat-s3c24xx/common-smdk.c b/arch/arm/plat-s3c24xx/common-smdk.c
index d528f460f6bc..3098736c65d9 100644
--- a/arch/arm/plat-s3c24xx/common-smdk.c
+++ b/arch/arm/plat-s3c24xx/common-smdk.c
@@ -40,9 +40,9 @@
40 40
41#include <asm/plat-s3c/nand.h> 41#include <asm/plat-s3c/nand.h>
42 42
43#include <asm/plat-s3c24xx/common-smdk.h> 43#include <plat/common-smdk.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <plat/devs.h>
45#include <asm/plat-s3c24xx/pm.h> 45#include <plat/pm.h>
46 46
47/* LED devices */ 47/* LED devices */
48 48
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c
index 9c607bbc9343..22a329513c0f 100644
--- a/arch/arm/plat-s3c24xx/cpu.c
+++ b/arch/arm/plat-s3c24xx/cpu.c
@@ -42,18 +42,18 @@
42#include <mach/system-reset.h> 42#include <mach/system-reset.h>
43 43
44#include <mach/regs-gpio.h> 44#include <mach/regs-gpio.h>
45#include <asm/plat-s3c/regs-serial.h> 45#include <plat/regs-serial.h>
46 46
47#include <asm/plat-s3c24xx/cpu.h> 47#include <plat/cpu.h>
48#include <asm/plat-s3c24xx/devs.h> 48#include <plat/devs.h>
49#include <asm/plat-s3c24xx/clock.h> 49#include <plat/clock.h>
50#include <asm/plat-s3c24xx/s3c2400.h> 50#include <plat/s3c2400.h>
51#include <asm/plat-s3c24xx/s3c2410.h> 51#include <plat/s3c2410.h>
52#include <asm/plat-s3c24xx/s3c2412.h> 52#include <plat/s3c2412.h>
53#include "s3c244x.h" 53#include "s3c244x.h"
54#include <asm/plat-s3c24xx/s3c2440.h> 54#include <plat/s3c2440.h>
55#include <asm/plat-s3c24xx/s3c2442.h> 55#include <plat/s3c2442.h>
56#include <asm/plat-s3c24xx/s3c2443.h> 56#include <plat/s3c2443.h>
57 57
58struct cpu_table { 58struct cpu_table {
59 unsigned long idcode; 59 unsigned long idcode;
diff --git a/arch/arm/plat-s3c24xx/devs.c b/arch/arm/plat-s3c24xx/devs.c
index 6b13b5455dfc..e93f8bf6d338 100644
--- a/arch/arm/plat-s3c24xx/devs.c
+++ b/arch/arm/plat-s3c24xx/devs.c
@@ -28,11 +28,11 @@
28#include <mach/hardware.h> 28#include <mach/hardware.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <asm/plat-s3c/regs-serial.h> 31#include <plat/regs-serial.h>
32#include <asm/plat-s3c24xx/udc.h> 32#include <asm/plat-s3c24xx/udc.h>
33 33
34#include <asm/plat-s3c24xx/devs.h> 34#include <plat/devs.h>
35#include <asm/plat-s3c24xx/cpu.h> 35#include <plat/cpu.h>
36#include <asm/plat-s3c24xx/regs-spi.h> 36#include <asm/plat-s3c24xx/regs-spi.h>
37 37
38/* Serial port registrations */ 38/* Serial port registrations */
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
index d6344461a83b..1baf941d1930 100644
--- a/arch/arm/plat-s3c24xx/dma.c
+++ b/arch/arm/plat-s3c24xx/dma.c
@@ -36,7 +36,7 @@
36#include <asm/mach/dma.h> 36#include <asm/mach/dma.h>
37#include <mach/map.h> 37#include <mach/map.h>
38 38
39#include <asm/plat-s3c24xx/dma.h> 39#include <plat/dma.h>
40 40
41/* io map for dma */ 41/* io map for dma */
42static void __iomem *dma_base; 42static void __iomem *dma_base;
diff --git a/include/asm-arm/plat-s3c24xx/clock.h b/arch/arm/plat-s3c24xx/include/plat/clock.h
index 235b753cd877..235b753cd877 100644
--- a/include/asm-arm/plat-s3c24xx/clock.h
+++ b/arch/arm/plat-s3c24xx/include/plat/clock.h
diff --git a/include/asm-arm/plat-s3c24xx/common-smdk.h b/arch/arm/plat-s3c24xx/include/plat/common-smdk.h
index 58d9094c935c..58d9094c935c 100644
--- a/include/asm-arm/plat-s3c24xx/common-smdk.h
+++ b/arch/arm/plat-s3c24xx/include/plat/common-smdk.h
diff --git a/include/asm-arm/plat-s3c24xx/cpu.h b/arch/arm/plat-s3c24xx/include/plat/cpu.h
index 23e420e8bd5b..23e420e8bd5b 100644
--- a/include/asm-arm/plat-s3c24xx/cpu.h
+++ b/arch/arm/plat-s3c24xx/include/plat/cpu.h
diff --git a/include/asm-arm/plat-s3c24xx/devs.h b/arch/arm/plat-s3c24xx/include/plat/devs.h
index badaac9d64a8..badaac9d64a8 100644
--- a/include/asm-arm/plat-s3c24xx/devs.h
+++ b/arch/arm/plat-s3c24xx/include/plat/devs.h
diff --git a/include/asm-arm/plat-s3c24xx/dma.h b/arch/arm/plat-s3c24xx/include/plat/dma.h
index c78efe316fc8..c78efe316fc8 100644
--- a/include/asm-arm/plat-s3c24xx/dma.h
+++ b/arch/arm/plat-s3c24xx/include/plat/dma.h
diff --git a/include/asm-arm/plat-s3c24xx/irq.h b/arch/arm/plat-s3c24xx/include/plat/irq.h
index 45746a995343..45746a995343 100644
--- a/include/asm-arm/plat-s3c24xx/irq.h
+++ b/arch/arm/plat-s3c24xx/include/plat/irq.h
diff --git a/include/asm-arm/plat-s3c24xx/pm.h b/arch/arm/plat-s3c24xx/include/plat/pm.h
index cc623667e48a..cc623667e48a 100644
--- a/include/asm-arm/plat-s3c24xx/pm.h
+++ b/arch/arm/plat-s3c24xx/include/plat/pm.h
diff --git a/include/asm-arm/plat-s3c24xx/s3c2400.h b/arch/arm/plat-s3c24xx/include/plat/s3c2400.h
index 3a5a16821af8..3a5a16821af8 100644
--- a/include/asm-arm/plat-s3c24xx/s3c2400.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2400.h
diff --git a/include/asm-arm/plat-s3c24xx/s3c2410.h b/arch/arm/plat-s3c24xx/include/plat/s3c2410.h
index 3cd1ec677b3f..3cd1ec677b3f 100644
--- a/include/asm-arm/plat-s3c24xx/s3c2410.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2410.h
diff --git a/include/asm-arm/plat-s3c24xx/s3c2412.h b/arch/arm/plat-s3c24xx/include/plat/s3c2412.h
index 3ec97685e781..3ec97685e781 100644
--- a/include/asm-arm/plat-s3c24xx/s3c2412.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2412.h
diff --git a/include/asm-arm/plat-s3c24xx/s3c2440.h b/arch/arm/plat-s3c24xx/include/plat/s3c2440.h
index 107853bf9481..107853bf9481 100644
--- a/include/asm-arm/plat-s3c24xx/s3c2440.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2440.h
diff --git a/include/asm-arm/plat-s3c24xx/s3c2442.h b/arch/arm/plat-s3c24xx/include/plat/s3c2442.h
index 451a23a2092a..451a23a2092a 100644
--- a/include/asm-arm/plat-s3c24xx/s3c2442.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2442.h
diff --git a/include/asm-arm/plat-s3c24xx/s3c2443.h b/arch/arm/plat-s3c24xx/include/plat/s3c2443.h
index 11d83b5c84e6..11d83b5c84e6 100644
--- a/include/asm-arm/plat-s3c24xx/s3c2443.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2443.h
diff --git a/arch/arm/plat-s3c24xx/irq.c b/arch/arm/plat-s3c24xx/irq.c
index 590fc5a3ab06..963f7a4f26f2 100644
--- a/arch/arm/plat-s3c24xx/irq.c
+++ b/arch/arm/plat-s3c24xx/irq.c
@@ -65,9 +65,9 @@
65#include <mach/regs-irq.h> 65#include <mach/regs-irq.h>
66#include <mach/regs-gpio.h> 66#include <mach/regs-gpio.h>
67 67
68#include <asm/plat-s3c24xx/cpu.h> 68#include <plat/cpu.h>
69#include <asm/plat-s3c24xx/pm.h> 69#include <plat/pm.h>
70#include <asm/plat-s3c24xx/irq.h> 70#include <plat/irq.h>
71 71
72/* wakeup irq control */ 72/* wakeup irq control */
73 73
diff --git a/arch/arm/plat-s3c24xx/pm-simtec.c b/arch/arm/plat-s3c24xx/pm-simtec.c
index 0a074d35890a..21dfa74773d1 100644
--- a/arch/arm/plat-s3c24xx/pm-simtec.c
+++ b/arch/arm/plat-s3c24xx/pm-simtec.c
@@ -33,7 +33,7 @@
33 33
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35 35
36#include <asm/plat-s3c24xx/pm.h> 36#include <plat/pm.h>
37 37
38#define COPYRIGHT ", (c) 2005 Simtec Electronics" 38#define COPYRIGHT ", (c) 2005 Simtec Electronics"
39 39
diff --git a/arch/arm/plat-s3c24xx/pm.c b/arch/arm/plat-s3c24xx/pm.c
index d3934b1119a9..8efb57ad5019 100644
--- a/arch/arm/plat-s3c24xx/pm.c
+++ b/arch/arm/plat-s3c24xx/pm.c
@@ -40,7 +40,7 @@
40#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
41#include <mach/hardware.h> 41#include <mach/hardware.h>
42 42
43#include <asm/plat-s3c/regs-serial.h> 43#include <plat/regs-serial.h>
44#include <mach/regs-clock.h> 44#include <mach/regs-clock.h>
45#include <mach/regs-gpio.h> 45#include <mach/regs-gpio.h>
46#include <mach/regs-mem.h> 46#include <mach/regs-mem.h>
@@ -48,7 +48,7 @@
48 48
49#include <asm/mach/time.h> 49#include <asm/mach/time.h>
50 50
51#include <asm/plat-s3c24xx/pm.h> 51#include <plat/pm.h>
52 52
53/* for external use */ 53/* for external use */
54 54
diff --git a/arch/arm/plat-s3c24xx/pwm-clock.c b/arch/arm/plat-s3c24xx/pwm-clock.c
index d41cccd6a25f..3fad68a1e6bc 100644
--- a/arch/arm/plat-s3c24xx/pwm-clock.c
+++ b/arch/arm/plat-s3c24xx/pwm-clock.c
@@ -24,10 +24,10 @@
24#include <mach/regs-clock.h> 24#include <mach/regs-clock.h>
25#include <mach/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include <asm/plat-s3c24xx/clock.h> 27#include <plat/clock.h>
28#include <asm/plat-s3c24xx/cpu.h> 28#include <plat/cpu.h>
29 29
30#include <asm/plat-s3c/regs-timer.h> 30#include <plat/regs-timer.h>
31 31
32/* Each of the timers 0 through 5 go through the following 32/* Each of the timers 0 through 5 go through the following
33 * clock tree, with the inputs depending on the timers. 33 * clock tree, with the inputs depending on the timers.
diff --git a/arch/arm/plat-s3c24xx/pwm.c b/arch/arm/plat-s3c24xx/pwm.c
index cbc06067d9ce..ec56b88866c4 100644
--- a/arch/arm/plat-s3c24xx/pwm.c
+++ b/arch/arm/plat-s3c24xx/pwm.c
@@ -19,8 +19,8 @@
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/pwm.h> 20#include <linux/pwm.h>
21 21
22#include <asm/plat-s3c24xx/devs.h> 22#include <plat/devs.h>
23#include <asm/plat-s3c/regs-timer.h> 23#include <plat/regs-timer.h>
24 24
25struct pwm_device { 25struct pwm_device {
26 struct list_head list; 26 struct list_head list;
diff --git a/arch/arm/plat-s3c24xx/s3c244x-clock.c b/arch/arm/plat-s3c24xx/s3c244x-clock.c
index 119647a5eaa6..7c09773ff9fc 100644
--- a/arch/arm/plat-s3c24xx/s3c244x-clock.c
+++ b/arch/arm/plat-s3c24xx/s3c244x-clock.c
@@ -41,8 +41,8 @@
41 41
42#include <mach/regs-clock.h> 42#include <mach/regs-clock.h>
43 43
44#include <asm/plat-s3c24xx/clock.h> 44#include <plat/clock.h>
45#include <asm/plat-s3c24xx/cpu.h> 45#include <plat/cpu.h>
46 46
47static int s3c2440_setparent_armclk(struct clk *clk, struct clk *parent) 47static int s3c2440_setparent_armclk(struct clk *clk, struct clk *parent)
48{ 48{
diff --git a/arch/arm/plat-s3c24xx/s3c244x-irq.c b/arch/arm/plat-s3c24xx/s3c244x-irq.c
index 0601c5f3230b..0902afd227ca 100644
--- a/arch/arm/plat-s3c24xx/s3c244x-irq.c
+++ b/arch/arm/plat-s3c24xx/s3c244x-irq.c
@@ -34,9 +34,9 @@
34#include <mach/regs-irq.h> 34#include <mach/regs-irq.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36 36
37#include <asm/plat-s3c24xx/cpu.h> 37#include <plat/cpu.h>
38#include <asm/plat-s3c24xx/pm.h> 38#include <plat/pm.h>
39#include <asm/plat-s3c24xx/irq.h> 39#include <plat/irq.h>
40 40
41/* camera irq */ 41/* camera irq */
42 42
diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c
index 146863a69aeb..c0344fac4a94 100644
--- a/arch/arm/plat-s3c24xx/s3c244x.c
+++ b/arch/arm/plat-s3c24xx/s3c244x.c
@@ -30,18 +30,18 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <mach/regs-clock.h> 32#include <mach/regs-clock.h>
33#include <asm/plat-s3c/regs-serial.h> 33#include <plat/regs-serial.h>
34#include <mach/regs-gpio.h> 34#include <mach/regs-gpio.h>
35#include <mach/regs-gpioj.h> 35#include <mach/regs-gpioj.h>
36#include <mach/regs-dsc.h> 36#include <mach/regs-dsc.h>
37 37
38#include <asm/plat-s3c24xx/s3c2410.h> 38#include <plat/s3c2410.h>
39#include <asm/plat-s3c24xx/s3c2440.h> 39#include <plat/s3c2440.h>
40#include "s3c244x.h" 40#include "s3c244x.h"
41#include <asm/plat-s3c24xx/clock.h> 41#include <plat/clock.h>
42#include <asm/plat-s3c24xx/devs.h> 42#include <plat/devs.h>
43#include <asm/plat-s3c24xx/cpu.h> 43#include <plat/cpu.h>
44#include <asm/plat-s3c24xx/pm.h> 44#include <plat/pm.h>
45 45
46static struct map_desc s3c244x_iodesc[] __initdata = { 46static struct map_desc s3c244x_iodesc[] __initdata = {
47 IODESC_ENT(CLKPWR), 47 IODESC_ENT(CLKPWR),
diff --git a/arch/arm/plat-s3c24xx/sleep.S b/arch/arm/plat-s3c24xx/sleep.S
index 4981a08b6ebb..76594b212802 100644
--- a/arch/arm/plat-s3c24xx/sleep.S
+++ b/arch/arm/plat-s3c24xx/sleep.S
@@ -32,7 +32,7 @@
32#include <mach/regs-gpio.h> 32#include <mach/regs-gpio.h>
33#include <mach/regs-clock.h> 33#include <mach/regs-clock.h>
34#include <mach/regs-mem.h> 34#include <mach/regs-mem.h>
35#include <asm/plat-s3c/regs-serial.h> 35#include <plat/regs-serial.h>
36 36
37/* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not 37/* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not
38 * reset the UART configuration, only enable if you really need this! 38 * reset the UART configuration, only enable if you really need this!
diff --git a/arch/arm/plat-s3c24xx/time.c b/arch/arm/plat-s3c24xx/time.c
index 64bfa19ae951..c51916236ac0 100644
--- a/arch/arm/plat-s3c24xx/time.c
+++ b/arch/arm/plat-s3c24xx/time.c
@@ -33,12 +33,12 @@
33 33
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 <plat/regs-timer.h>
37#include <mach/regs-irq.h> 37#include <mach/regs-irq.h>
38#include <asm/mach/time.h> 38#include <asm/mach/time.h>
39 39
40#include <asm/plat-s3c24xx/clock.h> 40#include <plat/clock.h>
41#include <asm/plat-s3c24xx/cpu.h> 41#include <plat/cpu.h>
42 42
43static unsigned long timer_startval; 43static unsigned long timer_startval;
44static unsigned long timer_usec_ticks; 44static unsigned long timer_usec_ticks;
diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
index 64ce40ee1d58..d5d1d41c600a 100644
--- a/arch/avr32/include/asm/elf.h
+++ b/arch/avr32/include/asm/elf.h
@@ -103,6 +103,6 @@ typedef struct user_fpu_struct elf_fpregset_t;
103 103
104#define ELF_PLATFORM (NULL) 104#define ELF_PLATFORM (NULL)
105 105
106#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) 106#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
107 107
108#endif /* __ASM_AVR32_ELF_H */ 108#endif /* __ASM_AVR32_ELF_H */
diff --git a/arch/avr32/mach-at32ap/cpufreq.c b/arch/avr32/mach-at32ap/cpufreq.c
index 5dd8d25428bf..d84efe4984ab 100644
--- a/arch/avr32/mach-at32ap/cpufreq.c
+++ b/arch/avr32/mach-at32ap/cpufreq.c
@@ -87,7 +87,6 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
87 policy->cur = at32_get_speed(0); 87 policy->cur = at32_get_speed(0);
88 policy->min = policy->cpuinfo.min_freq; 88 policy->min = policy->cpuinfo.min_freq;
89 policy->max = policy->cpuinfo.max_freq; 89 policy->max = policy->cpuinfo.max_freq;
90 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
91 90
92 printk("cpufreq: AT32AP CPU frequency driver\n"); 91 printk("cpufreq: AT32AP CPU frequency driver\n");
93 92
diff --git a/arch/blackfin/configs/BF526-EZBRD_defconfig b/arch/blackfin/configs/BF526-EZBRD_defconfig
index c33bf6f83813..4443a47e516f 100644
--- a/arch/blackfin/configs/BF526-EZBRD_defconfig
+++ b/arch/blackfin/configs/BF526-EZBRD_defconfig
@@ -748,7 +748,7 @@ CONFIG_BFIN_OTP=y
748# 748#
749# CONFIG_CAN4LINUX is not set 749# CONFIG_CAN4LINUX is not set
750# CONFIG_IPMI_HANDLER is not set 750# CONFIG_IPMI_HANDLER is not set
751CONFIG_HW_RANDOM=y 751# CONFIG_HW_RANDOM is not set
752# CONFIG_R3964 is not set 752# CONFIG_R3964 is not set
753# CONFIG_RAW_DRIVER is not set 753# CONFIG_RAW_DRIVER is not set
754# CONFIG_TCG_TPM is not set 754# CONFIG_TCG_TPM is not set
diff --git a/arch/blackfin/configs/BF527-EZKIT_defconfig b/arch/blackfin/configs/BF527-EZKIT_defconfig
index 66854a83c0de..4a2a660a6b35 100644
--- a/arch/blackfin/configs/BF527-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF527-EZKIT_defconfig
@@ -772,7 +772,7 @@ CONFIG_UNIX98_PTYS=y
772# 772#
773# CONFIG_CAN4LINUX is not set 773# CONFIG_CAN4LINUX is not set
774# CONFIG_IPMI_HANDLER is not set 774# CONFIG_IPMI_HANDLER is not set
775CONFIG_HW_RANDOM=y 775# CONFIG_HW_RANDOM is not set
776# CONFIG_GEN_RTC is not set 776# CONFIG_GEN_RTC is not set
777# CONFIG_R3964 is not set 777# CONFIG_R3964 is not set
778# CONFIG_RAW_DRIVER is not set 778# CONFIG_RAW_DRIVER is not set
diff --git a/arch/blackfin/configs/BF533-EZKIT_defconfig b/arch/blackfin/configs/BF533-EZKIT_defconfig
index 6bc11db12690..deeb5e45effb 100644
--- a/arch/blackfin/configs/BF533-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF533-EZKIT_defconfig
@@ -674,7 +674,7 @@ CONFIG_UNIX98_PTYS=y
674# 674#
675# CONFIG_CAN4LINUX is not set 675# CONFIG_CAN4LINUX is not set
676# CONFIG_IPMI_HANDLER is not set 676# CONFIG_IPMI_HANDLER is not set
677CONFIG_HW_RANDOM=y 677# CONFIG_HW_RANDOM is not set
678# CONFIG_GEN_RTC is not set 678# CONFIG_GEN_RTC is not set
679# CONFIG_R3964 is not set 679# CONFIG_R3964 is not set
680# CONFIG_RAW_DRIVER is not set 680# CONFIG_RAW_DRIVER is not set
@@ -740,7 +740,7 @@ CONFIG_SSB_POSSIBLE=y
740# 740#
741# CONFIG_VIDEO_DEV is not set 741# CONFIG_VIDEO_DEV is not set
742# CONFIG_DVB_CORE is not set 742# CONFIG_DVB_CORE is not set
743CONFIG_DAB=y 743# CONFIG_DAB is not set
744 744
745# 745#
746# Graphics support 746# Graphics support
diff --git a/arch/blackfin/configs/BF533-STAMP_defconfig b/arch/blackfin/configs/BF533-STAMP_defconfig
index d77d991a1f61..c23267ed880b 100644
--- a/arch/blackfin/configs/BF533-STAMP_defconfig
+++ b/arch/blackfin/configs/BF533-STAMP_defconfig
@@ -681,7 +681,7 @@ CONFIG_UNIX98_PTYS=y
681# 681#
682# CONFIG_CAN4LINUX is not set 682# CONFIG_CAN4LINUX is not set
683# CONFIG_IPMI_HANDLER is not set 683# CONFIG_IPMI_HANDLER is not set
684CONFIG_HW_RANDOM=y 684# CONFIG_HW_RANDOM is not set
685# CONFIG_GEN_RTC is not set 685# CONFIG_GEN_RTC is not set
686# CONFIG_R3964 is not set 686# CONFIG_R3964 is not set
687# CONFIG_RAW_DRIVER is not set 687# CONFIG_RAW_DRIVER is not set
diff --git a/arch/blackfin/configs/BF537-STAMP_defconfig b/arch/blackfin/configs/BF537-STAMP_defconfig
index 5fd7c4b143df..63a0f854745c 100644
--- a/arch/blackfin/configs/BF537-STAMP_defconfig
+++ b/arch/blackfin/configs/BF537-STAMP_defconfig
@@ -731,7 +731,7 @@ CONFIG_CAN4LINUX=y
731# CONFIG_CAN_UNCTWINCAN is not set 731# CONFIG_CAN_UNCTWINCAN is not set
732CONFIG_CAN_BLACKFIN=m 732CONFIG_CAN_BLACKFIN=m
733# CONFIG_IPMI_HANDLER is not set 733# CONFIG_IPMI_HANDLER is not set
734CONFIG_HW_RANDOM=y 734# CONFIG_HW_RANDOM is not set
735# CONFIG_GEN_RTC is not set 735# CONFIG_GEN_RTC is not set
736# CONFIG_R3964 is not set 736# CONFIG_R3964 is not set
737# CONFIG_RAW_DRIVER is not set 737# CONFIG_RAW_DRIVER is not set
@@ -871,7 +871,7 @@ CONFIG_SSB_POSSIBLE=y
871# 871#
872# CONFIG_VIDEO_DEV is not set 872# CONFIG_VIDEO_DEV is not set
873# CONFIG_DVB_CORE is not set 873# CONFIG_DVB_CORE is not set
874CONFIG_DAB=y 874# CONFIG_DAB is not set
875 875
876# 876#
877# Graphics support 877# Graphics support
diff --git a/arch/blackfin/configs/BF548-EZKIT_defconfig b/arch/blackfin/configs/BF548-EZKIT_defconfig
index 390669e8668e..bf63660815b9 100644
--- a/arch/blackfin/configs/BF548-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF548-EZKIT_defconfig
@@ -855,7 +855,7 @@ CONFIG_UNIX98_PTYS=y
855# 855#
856# CONFIG_CAN4LINUX is not set 856# CONFIG_CAN4LINUX is not set
857# CONFIG_IPMI_HANDLER is not set 857# CONFIG_IPMI_HANDLER is not set
858CONFIG_HW_RANDOM=y 858# CONFIG_HW_RANDOM is not set
859# CONFIG_GEN_RTC is not set 859# CONFIG_GEN_RTC is not set
860# CONFIG_R3964 is not set 860# CONFIG_R3964 is not set
861# CONFIG_RAW_DRIVER is not set 861# CONFIG_RAW_DRIVER is not set
@@ -1001,7 +1001,7 @@ CONFIG_SSB_POSSIBLE=y
1001# 1001#
1002# CONFIG_VIDEO_DEV is not set 1002# CONFIG_VIDEO_DEV is not set
1003# CONFIG_DVB_CORE is not set 1003# CONFIG_DVB_CORE is not set
1004CONFIG_DAB=y 1004# CONFIG_DAB is not set
1005# CONFIG_USB_DABUSB is not set 1005# CONFIG_USB_DABUSB is not set
1006 1006
1007# 1007#
diff --git a/arch/blackfin/configs/BF561-EZKIT_defconfig b/arch/blackfin/configs/BF561-EZKIT_defconfig
index 976a4d7ba175..3c70d6230a12 100644
--- a/arch/blackfin/configs/BF561-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF561-EZKIT_defconfig
@@ -719,7 +719,7 @@ CONFIG_UNIX98_PTYS=y
719# 719#
720# CONFIG_CAN4LINUX is not set 720# CONFIG_CAN4LINUX is not set
721# CONFIG_IPMI_HANDLER is not set 721# CONFIG_IPMI_HANDLER is not set
722CONFIG_HW_RANDOM=y 722# CONFIG_HW_RANDOM is not set
723# CONFIG_GEN_RTC is not set 723# CONFIG_GEN_RTC is not set
724# CONFIG_R3964 is not set 724# CONFIG_R3964 is not set
725# CONFIG_RAW_DRIVER is not set 725# CONFIG_RAW_DRIVER is not set
@@ -785,7 +785,7 @@ CONFIG_SSB_POSSIBLE=y
785# 785#
786# CONFIG_VIDEO_DEV is not set 786# CONFIG_VIDEO_DEV is not set
787# CONFIG_DVB_CORE is not set 787# CONFIG_DVB_CORE is not set
788CONFIG_DAB=y 788# CONFIG_DAB is not set
789 789
790# 790#
791# Graphics support 791# Graphics support
diff --git a/arch/blackfin/configs/CM-BF527_defconfig b/arch/blackfin/configs/CM-BF527_defconfig
index 0799aa9bba9d..b6a14635fb91 100644
--- a/arch/blackfin/configs/CM-BF527_defconfig
+++ b/arch/blackfin/configs/CM-BF527_defconfig
@@ -679,7 +679,7 @@ CONFIG_UNIX98_PTYS=y
679# 679#
680# CONFIG_CAN4LINUX is not set 680# CONFIG_CAN4LINUX is not set
681# CONFIG_IPMI_HANDLER is not set 681# CONFIG_IPMI_HANDLER is not set
682CONFIG_HW_RANDOM=y 682# CONFIG_HW_RANDOM is not set
683# CONFIG_GEN_RTC is not set 683# CONFIG_GEN_RTC is not set
684# CONFIG_R3964 is not set 684# CONFIG_R3964 is not set
685# CONFIG_RAW_DRIVER is not set 685# CONFIG_RAW_DRIVER is not set
diff --git a/arch/blackfin/configs/CM-BF533_defconfig b/arch/blackfin/configs/CM-BF533_defconfig
index 09deea44480b..c3ba9066b935 100644
--- a/arch/blackfin/configs/CM-BF533_defconfig
+++ b/arch/blackfin/configs/CM-BF533_defconfig
@@ -672,7 +672,7 @@ CONFIG_HWMON=y
672# 672#
673# CONFIG_VIDEO_DEV is not set 673# CONFIG_VIDEO_DEV is not set
674# CONFIG_DVB_CORE is not set 674# CONFIG_DVB_CORE is not set
675CONFIG_DAB=y 675# CONFIG_DAB is not set
676 676
677# 677#
678# Graphics support 678# Graphics support
diff --git a/arch/blackfin/configs/CM-BF537E_defconfig b/arch/blackfin/configs/CM-BF537E_defconfig
index 219fc345a5f5..cdc6b7feb59e 100644
--- a/arch/blackfin/configs/CM-BF537E_defconfig
+++ b/arch/blackfin/configs/CM-BF537E_defconfig
@@ -703,7 +703,7 @@ CONFIG_HWMON=y
703# 703#
704# CONFIG_VIDEO_DEV is not set 704# CONFIG_VIDEO_DEV is not set
705# CONFIG_DVB_CORE is not set 705# CONFIG_DVB_CORE is not set
706CONFIG_DAB=y 706# CONFIG_DAB is not set
707 707
708# 708#
709# Graphics support 709# Graphics support
diff --git a/arch/blackfin/configs/CM-BF537U_defconfig b/arch/blackfin/configs/CM-BF537U_defconfig
index 9873d586fc77..f074bdcd1ce5 100644
--- a/arch/blackfin/configs/CM-BF537U_defconfig
+++ b/arch/blackfin/configs/CM-BF537U_defconfig
@@ -683,7 +683,7 @@ CONFIG_HWMON=y
683# 683#
684# CONFIG_VIDEO_DEV is not set 684# CONFIG_VIDEO_DEV is not set
685# CONFIG_DVB_CORE is not set 685# CONFIG_DVB_CORE is not set
686CONFIG_DAB=y 686# CONFIG_DAB is not set
687 687
688# 688#
689# Graphics support 689# Graphics support
diff --git a/arch/blackfin/configs/CM-BF548_defconfig b/arch/blackfin/configs/CM-BF548_defconfig
index 0e3605fdb7b0..5c44fdb8e6e3 100644
--- a/arch/blackfin/configs/CM-BF548_defconfig
+++ b/arch/blackfin/configs/CM-BF548_defconfig
@@ -762,7 +762,7 @@ CONFIG_UNIX98_PTYS=y
762# 762#
763# CONFIG_CAN4LINUX is not set 763# CONFIG_CAN4LINUX is not set
764# CONFIG_IPMI_HANDLER is not set 764# CONFIG_IPMI_HANDLER is not set
765CONFIG_HW_RANDOM=y 765# CONFIG_HW_RANDOM is not set
766# CONFIG_GEN_RTC is not set 766# CONFIG_GEN_RTC is not set
767# CONFIG_R3964 is not set 767# CONFIG_R3964 is not set
768# CONFIG_RAW_DRIVER is not set 768# CONFIG_RAW_DRIVER is not set
@@ -909,7 +909,7 @@ CONFIG_SSB_POSSIBLE=y
909# 909#
910# CONFIG_VIDEO_DEV is not set 910# CONFIG_VIDEO_DEV is not set
911# CONFIG_DVB_CORE is not set 911# CONFIG_DVB_CORE is not set
912CONFIG_DAB=y 912# CONFIG_DAB is not set
913# CONFIG_USB_DABUSB is not set 913# CONFIG_USB_DABUSB is not set
914 914
915# 915#
diff --git a/arch/blackfin/configs/CM-BF561_defconfig b/arch/blackfin/configs/CM-BF561_defconfig
index 59c7cdbee904..086fe5dda495 100644
--- a/arch/blackfin/configs/CM-BF561_defconfig
+++ b/arch/blackfin/configs/CM-BF561_defconfig
@@ -684,7 +684,7 @@ CONFIG_SSB_POSSIBLE=y
684# 684#
685# CONFIG_VIDEO_DEV is not set 685# CONFIG_VIDEO_DEV is not set
686# CONFIG_DVB_CORE is not set 686# CONFIG_DVB_CORE is not set
687CONFIG_DAB=y 687# CONFIG_DAB is not set
688 688
689# 689#
690# Graphics support 690# Graphics support
diff --git a/arch/blackfin/include/asm/cacheflush.h b/arch/blackfin/include/asm/cacheflush.h
index 5ef9e35e9c3b..4403415583fa 100644
--- a/arch/blackfin/include/asm/cacheflush.h
+++ b/arch/blackfin/include/asm/cacheflush.h
@@ -30,11 +30,11 @@
30#ifndef _BLACKFIN_CACHEFLUSH_H 30#ifndef _BLACKFIN_CACHEFLUSH_H
31#define _BLACKFIN_CACHEFLUSH_H 31#define _BLACKFIN_CACHEFLUSH_H
32 32
33extern void blackfin_icache_dcache_flush_range(unsigned int, unsigned int); 33extern void blackfin_icache_dcache_flush_range(unsigned long start_address, unsigned long end_address);
34extern void blackfin_icache_flush_range(unsigned int, unsigned int); 34extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address);
35extern void blackfin_dcache_flush_range(unsigned int, unsigned int); 35extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address);
36extern void blackfin_dcache_invalidate_range(unsigned int, unsigned int); 36extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address);
37extern void blackfin_dflush_page(void *); 37extern void blackfin_dflush_page(void *page);
38 38
39#define flush_dcache_mmap_lock(mapping) do { } while (0) 39#define flush_dcache_mmap_lock(mapping) do { } while (0)
40#define flush_dcache_mmap_unlock(mapping) do { } while (0) 40#define flush_dcache_mmap_unlock(mapping) do { } while (0)
@@ -85,4 +85,21 @@ do { memcpy(dst, src, len); \
85# define flush_dcache_page(page) do { } while (0) 85# define flush_dcache_page(page) do { } while (0)
86#endif 86#endif
87 87
88extern unsigned long reserved_mem_dcache_on;
89extern unsigned long reserved_mem_icache_on;
90
91static inline int bfin_addr_dcachable(unsigned long addr)
92{
93#ifdef CONFIG_BFIN_DCACHE
94 if (addr < (_ramend - DMA_UNCACHED_REGION))
95 return 1;
96#endif
97
98 if (reserved_mem_dcache_on &&
99 addr >= _ramend && addr < physical_mem_end)
100 return 1;
101
102 return 0;
103}
104
88#endif /* _BLACKFIN_ICACHEFLUSH_H */ 105#endif /* _BLACKFIN_ICACHEFLUSH_H */
diff --git a/arch/blackfin/include/asm/cplbinit.h b/arch/blackfin/include/asm/cplbinit.h
index d179b747ff03..f845b41147ba 100644
--- a/arch/blackfin/include/asm/cplbinit.h
+++ b/arch/blackfin/include/asm/cplbinit.h
@@ -87,23 +87,6 @@ extern u_long dpdt_swapcount_table[];
87 87
88#endif /* CONFIG_MPU */ 88#endif /* CONFIG_MPU */
89 89
90extern unsigned long reserved_mem_dcache_on;
91extern unsigned long reserved_mem_icache_on;
92
93extern void generate_cplb_tables(void); 90extern void generate_cplb_tables(void);
94 91
95static inline int bfin_addr_dcachable(unsigned long addr)
96{
97#ifdef CONFIG_BFIN_DCACHE
98 if (addr < (_ramend - DMA_UNCACHED_REGION))
99 return 1;
100#endif
101
102 if (reserved_mem_dcache_on &&
103 addr >= _ramend && addr < physical_mem_end)
104 return 1;
105
106 return 0;
107}
108
109#endif 92#endif
diff --git a/arch/blackfin/include/asm/elf.h b/arch/blackfin/include/asm/elf.h
index 67a03a8a353e..cdbfcfc30f6a 100644
--- a/arch/blackfin/include/asm/elf.h
+++ b/arch/blackfin/include/asm/elf.h
@@ -122,6 +122,6 @@ do { \
122 122
123#define ELF_PLATFORM (NULL) 123#define ELF_PLATFORM (NULL)
124 124
125#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 125#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
126 126
127#endif 127#endif
diff --git a/arch/blackfin/include/asm/io.h b/arch/blackfin/include/asm/io.h
index cbbf7ffdbbff..7dc77a21fdf3 100644
--- a/arch/blackfin/include/asm/io.h
+++ b/arch/blackfin/include/asm/io.h
@@ -134,6 +134,36 @@ extern void dma_insb(unsigned long port, void *addr, unsigned short count);
134extern void dma_insw(unsigned long port, void *addr, unsigned short count); 134extern void dma_insw(unsigned long port, void *addr, unsigned short count);
135extern void dma_insl(unsigned long port, void *addr, unsigned short count); 135extern void dma_insl(unsigned long port, void *addr, unsigned short count);
136 136
137static inline void readsl(const void __iomem *addr, void *buf, int len)
138{
139 insl((unsigned long)addr, buf, len);
140}
141
142static inline void readsw(const void __iomem *addr, void *buf, int len)
143{
144 insw((unsigned long)addr, buf, len);
145}
146
147static inline void readsb(const void __iomem *addr, void *buf, int len)
148{
149 insb((unsigned long)addr, buf, len);
150}
151
152static inline void writesl(const void __iomem *addr, const void *buf, int len)
153{
154 outsl((unsigned long)addr, buf, len);
155}
156
157static inline void writesw(const void __iomem *addr, const void *buf, int len)
158{
159 outsw((unsigned long)addr, buf, len);
160}
161
162static inline void writesb(const void __iomem *addr, const void *buf, int len)
163{
164 outsb((unsigned long)addr, buf, len);
165}
166
137/* 167/*
138 * Map some physical address range into the kernel address space. 168 * Map some physical address range into the kernel address space.
139 */ 169 */
diff --git a/arch/blackfin/include/asm/timex.h b/arch/blackfin/include/asm/timex.h
index 22b0806161bb..248aeb066805 100644
--- a/arch/blackfin/include/asm/timex.h
+++ b/arch/blackfin/include/asm/timex.h
@@ -16,7 +16,7 @@ typedef unsigned long long cycles_t;
16static inline cycles_t get_cycles(void) 16static inline cycles_t get_cycles(void)
17{ 17{
18 unsigned long tmp, tmp2; 18 unsigned long tmp, tmp2;
19 __asm__("%0 = cycles; %1 = cycles2;" : "=d"(tmp), "=d"(tmp2)); 19 __asm__ __volatile__("%0 = cycles; %1 = cycles2;" : "=d"(tmp), "=d"(tmp2));
20 return tmp | ((cycles_t)tmp2 << 32); 20 return tmp | ((cycles_t)tmp2 << 32);
21} 21}
22 22
diff --git a/arch/blackfin/kernel/cplb-mpu/cplbmgr.c b/arch/blackfin/kernel/cplb-mpu/cplbmgr.c
index 5094677fd09e..baa52e261f0d 100644
--- a/arch/blackfin/kernel/cplb-mpu/cplbmgr.c
+++ b/arch/blackfin/kernel/cplb-mpu/cplbmgr.c
@@ -21,6 +21,7 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22 22
23#include <asm/blackfin.h> 23#include <asm/blackfin.h>
24#include <asm/cacheflush.h>
24#include <asm/cplbinit.h> 25#include <asm/cplbinit.h>
25#include <asm/mmu_context.h> 26#include <asm/mmu_context.h>
26 27
@@ -144,9 +145,7 @@ static noinline int dcplb_miss(void)
144 145
145 d_data = CPLB_SUPV_WR | CPLB_VALID | CPLB_DIRTY | PAGE_SIZE_4KB; 146 d_data = CPLB_SUPV_WR | CPLB_VALID | CPLB_DIRTY | PAGE_SIZE_4KB;
146#ifdef CONFIG_BFIN_DCACHE 147#ifdef CONFIG_BFIN_DCACHE
147 if (addr < _ramend - DMA_UNCACHED_REGION || 148 if (bfin_addr_dcachable(addr)) {
148 (reserved_mem_dcache_on && addr >= _ramend &&
149 addr < physical_mem_end)) {
150 d_data |= CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND; 149 d_data |= CPLB_L1_CHBL | ANOMALY_05000158_WORKAROUND;
151#ifdef CONFIG_BFIN_WT 150#ifdef CONFIG_BFIN_WT
152 d_data |= CPLB_L1_AOW | CPLB_WT; 151 d_data |= CPLB_L1_AOW | CPLB_WT;
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbinit.c b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
index 301252e84441..512f8c92ead5 100644
--- a/arch/blackfin/kernel/cplb-nompu/cplbinit.c
+++ b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24 24
25#include <asm/blackfin.h> 25#include <asm/blackfin.h>
26#include <asm/cacheflush.h>
26#include <asm/cplb.h> 27#include <asm/cplb.h>
27#include <asm/cplbinit.h> 28#include <asm/cplbinit.h>
28 29
diff --git a/arch/blackfin/mach-bf527/head.S b/arch/blackfin/mach-bf527/head.S
index 6588170e3845..0eb1da85db73 100644
--- a/arch/blackfin/mach-bf527/head.S
+++ b/arch/blackfin/mach-bf527/head.S
@@ -88,7 +88,7 @@ ENTRY(_start_dma_code)
88 r1 = r1 << 8; /* Shift it over */ 88 r1 = r1 << 8; /* Shift it over */
89 r0 = r1 | r0; /* add them all together */ 89 r0 = r1 | r0; /* add them all together */
90#ifdef ANOMALY_05000265 90#ifdef ANOMALY_05000265
91 r0 = BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */ 91 BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */
92#endif 92#endif
93 93
94 p0.h = hi(PLL_CTL); 94 p0.h = hi(PLL_CTL);
diff --git a/arch/blackfin/mach-bf533/head.S b/arch/blackfin/mach-bf533/head.S
index 619685b94d90..9fc95aaca439 100644
--- a/arch/blackfin/mach-bf533/head.S
+++ b/arch/blackfin/mach-bf533/head.S
@@ -79,7 +79,7 @@ ENTRY(_start_dma_code)
79 r1 = r1 << 8; /* Shift it over */ 79 r1 = r1 << 8; /* Shift it over */
80 r0 = r1 | r0; /* add them all together */ 80 r0 = r1 | r0; /* add them all together */
81#ifdef ANOMALY_05000265 81#ifdef ANOMALY_05000265
82 r0 = BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */ 82 BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */
83#endif 83#endif
84 84
85 p0.h = hi(PLL_CTL); 85 p0.h = hi(PLL_CTL);
diff --git a/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
index 34ab0e4e4242..f3d9e495230c 100644
--- a/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
@@ -158,7 +158,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
158 } 158 }
159 if (uart->rts_pin >= 0) { 159 if (uart->rts_pin >= 0) {
160 gpio_request(uart->rts_pin, DRIVER_NAME); 160 gpio_request(uart->rts_pin, DRIVER_NAME);
161 gpio_direction_input(uart->rts_pin, 0); 161 gpio_direction_output(uart->rts_pin, 0);
162 } 162 }
163#endif 163#endif
164} 164}
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index dc5a30849c15..8d394393201f 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -577,11 +577,6 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
577 577
578#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) 578#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
579#include <linux/spi/ad7879.h> 579#include <linux/spi/ad7879.h>
580static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
581 .enable_dma = 0,
582 .bits_per_word = 16,
583};
584
585static const struct ad7879_platform_data bfin_ad7879_ts_info = { 580static const struct ad7879_platform_data bfin_ad7879_ts_info = {
586 .model = 7879, /* Model = AD7879 */ 581 .model = 7879, /* Model = AD7879 */
587 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */ 582 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
@@ -597,6 +592,13 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
597}; 592};
598#endif 593#endif
599 594
595#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
596static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
597 .enable_dma = 0,
598 .bits_per_word = 16,
599};
600#endif
601
600#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 602#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
601static struct bfin5xx_spi_chip spidev_chip_info = { 603static struct bfin5xx_spi_chip spidev_chip_info = {
602 .enable_dma = 0, 604 .enable_dma = 0,
@@ -750,7 +752,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
750 .controller_data = &spi_ad7877_chip_info, 752 .controller_data = &spi_ad7877_chip_info,
751 }, 753 },
752#endif 754#endif
753#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) 755#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
754 { 756 {
755 .modalias = "ad7879", 757 .modalias = "ad7879",
756 .platform_data = &bfin_ad7879_ts_info, 758 .platform_data = &bfin_ad7879_ts_info,
@@ -935,7 +937,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
935#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) 937#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
936 { 938 {
937 I2C_BOARD_INFO("ad7142_joystick", 0x2C), 939 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
938 .irq = 55, 940 .irq = IRQ_PF5,
939 }, 941 },
940#endif 942#endif
941#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 943#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
@@ -946,7 +948,14 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
946#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) 948#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
947 { 949 {
948 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 950 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
949 .irq = 72, 951 .irq = IRQ_PG6,
952 },
953#endif
954#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
955 {
956 I2C_BOARD_INFO("ad7879", 0x2F),
957 .irq = IRQ_PG5,
958 .platform_data = (void *)&bfin_ad7879_ts_info,
950 }, 959 },
951#endif 960#endif
952}; 961};
diff --git a/arch/blackfin/mach-bf537/head.S b/arch/blackfin/mach-bf537/head.S
index 559a7eef7a38..f5c94bf80e3b 100644
--- a/arch/blackfin/mach-bf537/head.S
+++ b/arch/blackfin/mach-bf537/head.S
@@ -88,7 +88,7 @@ ENTRY(_start_dma_code)
88 r1 = r1 << 8; /* Shift it over */ 88 r1 = r1 << 8; /* Shift it over */
89 r0 = r1 | r0; /* add them all together */ 89 r0 = r1 | r0; /* add them all together */
90#ifdef ANOMALY_05000265 90#ifdef ANOMALY_05000265
91 r0 = BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */ 91 BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */
92#endif 92#endif
93 93
94 p0.h = hi(PLL_CTL); 94 p0.h = hi(PLL_CTL);
diff --git a/arch/blackfin/mach-bf548/head.S b/arch/blackfin/mach-bf548/head.S
index 051b05c88027..93b361dff27b 100644
--- a/arch/blackfin/mach-bf548/head.S
+++ b/arch/blackfin/mach-bf548/head.S
@@ -95,7 +95,7 @@ ENTRY(_start_dma_code)
95 r1 = r1 << 8; /* Shift it over */ 95 r1 = r1 << 8; /* Shift it over */
96 r0 = r1 | r0; /* add them all together */ 96 r0 = r1 | r0; /* add them all together */
97#ifdef ANOMALY_05000265 97#ifdef ANOMALY_05000265
98 r0 = BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */ 98 BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */
99#endif 99#endif
100 100
101 p0.h = hi(PLL_CTL); 101 p0.h = hi(PLL_CTL);
diff --git a/arch/blackfin/mach-bf561/head.S b/arch/blackfin/mach-bf561/head.S
index 0b28137b3dea..31a777a9e699 100644
--- a/arch/blackfin/mach-bf561/head.S
+++ b/arch/blackfin/mach-bf561/head.S
@@ -78,7 +78,7 @@ ENTRY(_start_dma_code)
78 r1 = r1 << 8; /* Shift it over */ 78 r1 = r1 << 8; /* Shift it over */
79 r0 = r1 | r0; /* add them all together */ 79 r0 = r1 | r0; /* add them all together */
80#ifdef ANOMALY_05000265 80#ifdef ANOMALY_05000265
81 r0 = BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */ 81 BITSET(r0, 15); /* Add 250 mV of hysteresis to SPORT input pins */
82#endif 82#endif
83 83
84 p0.h = hi(PLL_CTL); 84 p0.h = hi(PLL_CTL);
diff --git a/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
index f5327264357c..043bfcf26c52 100644
--- a/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
@@ -158,7 +158,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
158 } 158 }
159 if (uart->rts_pin >= 0) { 159 if (uart->rts_pin >= 0) {
160 gpio_request(uart->rts_pin, DRIVER_NAME); 160 gpio_request(uart->rts_pin, DRIVER_NAME);
161 gpio_direction_input(uart->rts_pin, 0); 161 gpio_direction_output(uart->rts_pin, 0);
162 } 162 }
163#endif 163#endif
164} 164}
diff --git a/arch/blackfin/mach-common/cache.S b/arch/blackfin/mach-common/cache.S
index 85f8c79b3c37..db532181fbde 100644
--- a/arch/blackfin/mach-common/cache.S
+++ b/arch/blackfin/mach-common/cache.S
@@ -1,148 +1,91 @@
1/* 1/*
2 * File: arch/blackfin/mach-common/cache.S 2 * Blackfin cache control code
3 * Based on:
4 * Author: LG Soft India
5 * 3 *
6 * Created: 4 * Copyright 2004-2008 Analog Devices Inc.
7 * Description: cache control support
8 * 5 *
9 * Modified: 6 * Enter bugs at http://blackfin.uclinux.org/
10 * Copyright 2004-2006 Analog Devices Inc.
11 * 7 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 8 * Licensed under the GPL-2 or later.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 9 */
29 10
30#include <linux/linkage.h> 11#include <linux/linkage.h>
31#include <asm/cplb.h>
32#include <asm/entry.h>
33#include <asm/blackfin.h> 12#include <asm/blackfin.h>
34#include <asm/cache.h> 13#include <asm/cache.h>
14#include <asm/page.h>
35 15
36.text 16.text
37 17
38/* 18/* Since all L1 caches work the same way, we use the same method for flushing
39 * blackfin_cache_flush_range(start, end) 19 * them. Only the actual flush instruction differs. We write this in asm as
40 * Invalidate all cache lines assocoiated with this 20 * GCC can be hard to coax into writing nice hardware loops.
41 * area of memory.
42 * 21 *
43 * start: Start address 22 * Also, we assume the following register setup:
44 * end: End address 23 * R0 = start address
24 * R1 = end address
45 */ 25 */
46ENTRY(_blackfin_icache_flush_range) 26.macro do_flush flushins:req optflushins optnopins label
27
28 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
29 R1 += -1;
47 R2 = -L1_CACHE_BYTES; 30 R2 = -L1_CACHE_BYTES;
48 R2 = R0 & R2; 31 R1 = R1 & R2;
49 P0 = R2; 32 R1 += L1_CACHE_BYTES;
50 P1 = R1; 33
51 CSYNC(R3); 34 /* count = (end - start) >> L1_CACHE_SHIFT */
52 IFLUSH [P0]; 35 R2 = R1 - R0;
36 R2 >>= L1_CACHE_SHIFT;
37 P1 = R2;
38
39.ifnb \label
40\label :
41.endif
42 P0 = R0;
43 LSETUP (1f, 2f) LC1 = P1;
531: 441:
54 IFLUSH [P0++]; 45.ifnb \optflushins
55 CC = P0 < P1 (iu); 46 \optflushins [P0];
56 IF CC JUMP 1b (bp); 47.endif
57 IFLUSH [P0]; 48.ifb \optnopins
58 SSYNC(R3); 492:
50.endif
51 \flushins [P0++];
52.ifnb \optnopins
532: \optnopins;
54.endif
55
59 RTS; 56 RTS;
60ENDPROC(_blackfin_icache_flush_range) 57.endm
61 58
62/* 59/* Invalidate all instruction cache lines assocoiated with this memory area */
63 * blackfin_icache_dcache_flush_range(start, end) 60ENTRY(_blackfin_icache_flush_range)
64 * FLUSH all cache lines assocoiated with this 61 do_flush IFLUSH, , nop
65 * area of memory. 62ENDPROC(_blackfin_icache_flush_range)
66 *
67 * start: Start address
68 * end: End address
69 */
70 63
64/* Flush all cache lines assocoiated with this area of memory. */
71ENTRY(_blackfin_icache_dcache_flush_range) 65ENTRY(_blackfin_icache_dcache_flush_range)
72 R2 = -L1_CACHE_BYTES; 66 do_flush IFLUSH, FLUSH
73 R2 = R0 & R2;
74 P0 = R2;
75 P1 = R1;
76 CSYNC(R3);
77 IFLUSH [P0];
781:
79 FLUSH [P0];
80 IFLUSH [P0++];
81 CC = P0 < P1 (iu);
82 IF CC JUMP 1b (bp);
83 IFLUSH [P0];
84 FLUSH [P0];
85 SSYNC(R3);
86 RTS;
87ENDPROC(_blackfin_icache_dcache_flush_range) 67ENDPROC(_blackfin_icache_dcache_flush_range)
88 68
89/* Throw away all D-cached data in specified region without any obligation to 69/* Throw away all D-cached data in specified region without any obligation to
90 * write them back. However, we must clean the D-cached entries around the 70 * write them back. Since the Blackfin ISA does not have an "invalidate"
91 * boundaries of the start and/or end address is not cache aligned. 71 * instruction, we use flush/invalidate. Perhaps as a speed optimization we
92 * 72 * could bang on the DTEST MMRs ...
93 * Start: start address,
94 * end : end address.
95 */ 73 */
96
97ENTRY(_blackfin_dcache_invalidate_range) 74ENTRY(_blackfin_dcache_invalidate_range)
98 R2 = -L1_CACHE_BYTES; 75 do_flush FLUSHINV
99 R2 = R0 & R2;
100 P0 = R2;
101 P1 = R1;
102 CSYNC(R3);
103 FLUSHINV[P0];
1041:
105 FLUSHINV[P0++];
106 CC = P0 < P1 (iu);
107 IF CC JUMP 1b (bp);
108
109 /* If the data crosses a cache line, then we'll be pointing to
110 * the last cache line, but won't have flushed/invalidated it yet,
111 * so do one more.
112 */
113 FLUSHINV[P0];
114 SSYNC(R3);
115 RTS;
116ENDPROC(_blackfin_dcache_invalidate_range) 76ENDPROC(_blackfin_dcache_invalidate_range)
117 77
78/* Flush all data cache lines assocoiated with this memory area */
118ENTRY(_blackfin_dcache_flush_range) 79ENTRY(_blackfin_dcache_flush_range)
119 R2 = -L1_CACHE_BYTES; 80 do_flush FLUSH, , , .Ldfr
120 R2 = R0 & R2;
121 P0 = R2;
122 P1 = R1;
123 CSYNC(R3);
124 FLUSH[P0];
1251:
126 FLUSH[P0++];
127 CC = P0 < P1 (iu);
128 IF CC JUMP 1b (bp);
129
130 /* If the data crosses a cache line, then we'll be pointing to
131 * the last cache line, but won't have flushed it yet, so do
132 * one more.
133 */
134 FLUSH[P0];
135 SSYNC(R3);
136 RTS;
137ENDPROC(_blackfin_dcache_flush_range) 81ENDPROC(_blackfin_dcache_flush_range)
138 82
83/* Our headers convert the page structure to an address, so just need to flush
84 * its contents like normal. We know the start address is page aligned (which
85 * greater than our cache alignment), as is the end address. So just jump into
86 * the middle of the dcache flush function.
87 */
139ENTRY(_blackfin_dflush_page) 88ENTRY(_blackfin_dflush_page)
140 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT); 89 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
141 P0 = R0; 90 jump .Ldfr;
142 CSYNC(R3);
143 FLUSH[P0];
144 LSETUP (.Lfl1, .Lfl1) LC0 = P1;
145.Lfl1: FLUSH [P0++];
146 SSYNC(R3);
147 RTS;
148ENDPROC(_blackfin_dflush_page) 91ENDPROC(_blackfin_dflush_page)
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c
index 75cdad291e88..c22c47b60127 100644
--- a/arch/blackfin/mach-common/cpufreq.c
+++ b/arch/blackfin/mach-common/cpufreq.c
@@ -158,8 +158,6 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy)
158 dpm_state_table[index].tscale); 158 dpm_state_table[index].tscale);
159 } 159 }
160 160
161 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
162
163 policy->cpuinfo.transition_latency = (bfin_read_PLL_LOCKCNT() / (sclk / 1000000)) * 1000; 161 policy->cpuinfo.transition_latency = (bfin_read_PLL_LOCKCNT() / (sclk / 1000000)) * 1000;
164 /*Now ,only support one cpu */ 162 /*Now ,only support one cpu */
165 policy->cur = cclk; 163 policy->cur = cclk;
diff --git a/arch/blackfin/mach-common/head.S b/arch/blackfin/mach-common/head.S
index 3069df580729..f123a62e2451 100644
--- a/arch/blackfin/mach-common/head.S
+++ b/arch/blackfin/mach-common/head.S
@@ -206,6 +206,60 @@ ENTRY(_real_start)
206 w[p0] = r0; 206 w[p0] = r0;
207 ssync; 207 ssync;
208 208
209#if L1_DATA_A_LENGTH > 0
210 r1.l = __sbss_l1;
211 r1.h = __sbss_l1;
212 r2.l = __ebss_l1;
213 r2.h = __ebss_l1;
214 r0 = 0 (z);
215 r2 = r2 - r1;
216 cc = r2 == 0;
217 if cc jump .L_a_l1_done;
218 r2 >>= 2;
219 p1 = r1;
220 p2 = r2;
221 lsetup (.L_clear_a_l1, .L_clear_a_l1 ) lc0 = p2;
222.L_clear_a_l1:
223 [p1++] = r0;
224.L_a_l1_done:
225#endif
226
227#if L1_DATA_B_LENGTH > 0
228 r1.l = __sbss_b_l1;
229 r1.h = __sbss_b_l1;
230 r2.l = __ebss_b_l1;
231 r2.h = __ebss_b_l1;
232 r0 = 0 (z);
233 r2 = r2 - r1;
234 cc = r2 == 0;
235 if cc jump .L_b_l1_done;
236 r2 >>= 2;
237 p1 = r1;
238 p2 = r2;
239 lsetup (.L_clear_b_l1, .L_clear_b_l1 ) lc0 = p2;
240.L_clear_b_l1:
241 [p1++] = r0;
242.L_b_l1_done:
243#endif
244
245#if L2_LENGTH > 0
246 r1.l = __sbss_l2;
247 r1.h = __sbss_l2;
248 r2.l = __ebss_l2;
249 r2.h = __ebss_l2;
250 r0 = 0 (z);
251 r2 = r2 - r1;
252 cc = r2 == 0;
253 if cc jump .L_l2_done;
254 r2 >>= 2;
255 p1 = r1;
256 p2 = r2;
257 lsetup (.L_clear_l2, .L_clear_l2 ) lc0 = p2;
258.L_clear_l2:
259 [p1++] = r0;
260.L_l2_done:
261#endif
262
209 /* Zero out the bss region 263 /* Zero out the bss region
210 * Note: this will fail if bss is 0 bytes ... 264 * Note: this will fail if bss is 0 bytes ...
211 */ 265 */
diff --git a/arch/cris/arch-v32/mach-a3/cpufreq.c b/arch/cris/arch-v32/mach-a3/cpufreq.c
index 8e5a3cab8ad7..ee391ecb5bc9 100644
--- a/arch/cris/arch-v32/mach-a3/cpufreq.c
+++ b/arch/cris/arch-v32/mach-a3/cpufreq.c
@@ -85,7 +85,6 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
85 int result; 85 int result;
86 86
87 /* cpuinfo and default policy values */ 87 /* cpuinfo and default policy values */
88 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
89 policy->cpuinfo.transition_latency = 1000000; /* 1ms */ 88 policy->cpuinfo.transition_latency = 1000000; /* 1ms */
90 policy->cur = cris_freq_get_cpu_frequency(0); 89 policy->cur = cris_freq_get_cpu_frequency(0);
91 90
diff --git a/arch/cris/arch-v32/mach-fs/cpufreq.c b/arch/cris/arch-v32/mach-fs/cpufreq.c
index d57631c0d8d1..58bd71e5bda9 100644
--- a/arch/cris/arch-v32/mach-fs/cpufreq.c
+++ b/arch/cris/arch-v32/mach-fs/cpufreq.c
@@ -81,7 +81,6 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
81 int result; 81 int result;
82 82
83 /* cpuinfo and default policy values */ 83 /* cpuinfo and default policy values */
84 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
85 policy->cpuinfo.transition_latency = 1000000; /* 1ms */ 84 policy->cpuinfo.transition_latency = 1000000; /* 1ms */
86 policy->cur = cris_freq_get_cpu_frequency(0); 85 policy->cur = cris_freq_get_cpu_frequency(0);
87 86
diff --git a/arch/frv/kernel/pm.c b/arch/frv/kernel/pm.c
index d1113c5031f5..be722fc1acff 100644
--- a/arch/frv/kernel/pm.c
+++ b/arch/frv/kernel/pm.c
@@ -211,7 +211,7 @@ static int cmode_procctl(ctl_table *ctl, int write, struct file *filp,
211 return try_set_cmode(new_cmode)?:*lenp; 211 return try_set_cmode(new_cmode)?:*lenp;
212} 212}
213 213
214static int cmode_sysctl(ctl_table *table, int __user *name, int nlen, 214static int cmode_sysctl(ctl_table *table,
215 void __user *oldval, size_t __user *oldlenp, 215 void __user *oldval, size_t __user *oldlenp,
216 void __user *newval, size_t newlen) 216 void __user *newval, size_t newlen)
217{ 217{
@@ -314,7 +314,7 @@ static int p0_procctl(ctl_table *ctl, int write, struct file *filp,
314 return try_set_p0(new_p0)?:*lenp; 314 return try_set_p0(new_p0)?:*lenp;
315} 315}
316 316
317static int p0_sysctl(ctl_table *table, int __user *name, int nlen, 317static int p0_sysctl(ctl_table *table,
318 void __user *oldval, size_t __user *oldlenp, 318 void __user *oldval, size_t __user *oldlenp,
319 void __user *newval, size_t newlen) 319 void __user *newval, size_t newlen)
320{ 320{
@@ -358,7 +358,7 @@ static int cm_procctl(ctl_table *ctl, int write, struct file *filp,
358 return try_set_cm(new_cm)?:*lenp; 358 return try_set_cm(new_cm)?:*lenp;
359} 359}
360 360
361static int cm_sysctl(ctl_table *table, int __user *name, int nlen, 361static int cm_sysctl(ctl_table *table,
362 void __user *oldval, size_t __user *oldlenp, 362 void __user *oldval, size_t __user *oldlenp,
363 void __user *newval, size_t newlen) 363 void __user *newval, size_t newlen)
364{ 364{
diff --git a/arch/frv/mb93090-mb00/pci-dma-nommu.c b/arch/frv/mb93090-mb00/pci-dma-nommu.c
index 64ee58d748be..52ff9aec799d 100644
--- a/arch/frv/mb93090-mb00/pci-dma-nommu.c
+++ b/arch/frv/mb93090-mb00/pci-dma-nommu.c
@@ -111,7 +111,7 @@ EXPORT_SYMBOL(dma_free_coherent);
111 * The 32-bit bus address to use is returned. 111 * The 32-bit bus address to use is returned.
112 * 112 *
113 * Once the device is given the dma address, the device owns this memory 113 * Once the device is given the dma address, the device owns this memory
114 * until either pci_unmap_single or pci_dma_sync_single is performed. 114 * until either dma_unmap_single or pci_dma_sync_single is performed.
115 */ 115 */
116dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 116dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
117 enum dma_data_direction direction) 117 enum dma_data_direction direction)
@@ -129,7 +129,7 @@ EXPORT_SYMBOL(dma_map_single);
129/* 129/*
130 * Map a set of buffers described by scatterlist in streaming 130 * Map a set of buffers described by scatterlist in streaming
131 * mode for DMA. This is the scather-gather version of the 131 * mode for DMA. This is the scather-gather version of the
132 * above pci_map_single interface. Here the scatter gather list 132 * above dma_map_single interface. Here the scatter gather list
133 * elements are each tagged with the appropriate dma address 133 * elements are each tagged with the appropriate dma address
134 * and length. They are obtained via sg_dma_{address,length}(SG). 134 * and length. They are obtained via sg_dma_{address,length}(SG).
135 * 135 *
@@ -139,7 +139,7 @@ EXPORT_SYMBOL(dma_map_single);
139 * The routine returns the number of addr/length pairs actually 139 * The routine returns the number of addr/length pairs actually
140 * used, at most nents. 140 * used, at most nents.
141 * 141 *
142 * Device ownership issues as mentioned above for pci_map_single are 142 * Device ownership issues as mentioned above for dma_map_single are
143 * the same here. 143 * the same here.
144 */ 144 */
145int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 145int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
@@ -158,3 +158,20 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
158} 158}
159 159
160EXPORT_SYMBOL(dma_map_sg); 160EXPORT_SYMBOL(dma_map_sg);
161
162/*
163 * Map a single page of the indicated size for DMA in streaming mode.
164 * The 32-bit bus address to use is returned.
165 *
166 * Device ownership issues as mentioned above for dma_map_single are
167 * the same here.
168 */
169dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,
170 size_t size, enum dma_data_direction direction)
171{
172 BUG_ON(direction == DMA_NONE);
173 flush_dcache_page(page);
174 return (dma_addr_t) page_to_phys(page) + offset;
175}
176
177EXPORT_SYMBOL(dma_map_page);
diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
index 662f7b12d005..3ddedebc4eb3 100644
--- a/arch/frv/mb93090-mb00/pci-dma.c
+++ b/arch/frv/mb93090-mb00/pci-dma.c
@@ -61,7 +61,7 @@ EXPORT_SYMBOL(dma_map_single);
61/* 61/*
62 * Map a set of buffers described by scatterlist in streaming 62 * Map a set of buffers described by scatterlist in streaming
63 * mode for DMA. This is the scather-gather version of the 63 * mode for DMA. This is the scather-gather version of the
64 * above pci_map_single interface. Here the scatter gather list 64 * above dma_map_single interface. Here the scatter gather list
65 * elements are each tagged with the appropriate dma address 65 * elements are each tagged with the appropriate dma address
66 * and length. They are obtained via sg_dma_{address,length}(SG). 66 * and length. They are obtained via sg_dma_{address,length}(SG).
67 * 67 *
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(dma_map_single);
71 * The routine returns the number of addr/length pairs actually 71 * The routine returns the number of addr/length pairs actually
72 * used, at most nents. 72 * used, at most nents.
73 * 73 *
74 * Device ownership issues as mentioned above for pci_map_single are 74 * Device ownership issues as mentioned above for dma_map_single are
75 * the same here. 75 * the same here.
76 */ 76 */
77int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 77int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
@@ -105,6 +105,13 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
105 105
106EXPORT_SYMBOL(dma_map_sg); 106EXPORT_SYMBOL(dma_map_sg);
107 107
108/*
109 * Map a single page of the indicated size for DMA in streaming mode.
110 * The 32-bit bus address to use is returned.
111 *
112 * Device ownership issues as mentioned above for dma_map_single are
113 * the same here.
114 */
108dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset, 115dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,
109 size_t size, enum dma_data_direction direction) 116 size_t size, enum dma_data_direction direction)
110{ 117{
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index edae117fcc2b..43d67534c712 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -201,38 +201,6 @@ void __init pcibios_resource_survey(void)
201 pcibios_assign_resources(); 201 pcibios_assign_resources();
202} 202}
203 203
204int pcibios_enable_resources(struct pci_dev *dev, int mask)
205{
206 u16 cmd, old_cmd;
207 int idx;
208 struct resource *r;
209
210 pci_read_config_word(dev, PCI_COMMAND, &cmd);
211 old_cmd = cmd;
212 for(idx=0; idx<6; idx++) {
213 /* Only set up the requested stuff */
214 if (!(mask & (1<<idx)))
215 continue;
216
217 r = &dev->resource[idx];
218 if (!r->start && r->end) {
219 printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
220 return -EINVAL;
221 }
222 if (r->flags & IORESOURCE_IO)
223 cmd |= PCI_COMMAND_IO;
224 if (r->flags & IORESOURCE_MEM)
225 cmd |= PCI_COMMAND_MEMORY;
226 }
227 if (dev->resource[PCI_ROM_RESOURCE].start)
228 cmd |= PCI_COMMAND_MEMORY;
229 if (cmd != old_cmd) {
230 printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
231 pci_write_config_word(dev, PCI_COMMAND, cmd);
232 }
233 return 0;
234}
235
236/* 204/*
237 * If we set up a device for bus mastering, we need to check the latency 205 * If we set up a device for bus mastering, we need to check the latency
238 * timer as certain crappy BIOSes forget to set it properly. 206 * timer as certain crappy BIOSes forget to set it properly.
diff --git a/arch/frv/mb93090-mb00/pci-frv.h b/arch/frv/mb93090-mb00/pci-frv.h
index 0c7bf39dc729..f3fe55914793 100644
--- a/arch/frv/mb93090-mb00/pci-frv.h
+++ b/arch/frv/mb93090-mb00/pci-frv.h
@@ -29,7 +29,6 @@ extern unsigned int __nongpreldata pci_probe;
29extern unsigned int pcibios_max_latency; 29extern unsigned int pcibios_max_latency;
30 30
31void pcibios_resource_survey(void); 31void pcibios_resource_survey(void);
32int pcibios_enable_resources(struct pci_dev *, int);
33 32
34/* pci-vdk.c */ 33/* pci-vdk.c */
35 34
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index f003cfa68b7a..0f41c3a72da5 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -412,7 +412,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
412{ 412{
413 int err; 413 int err;
414 414
415 if ((err = pcibios_enable_resources(dev, mask)) < 0) 415 if ((err = pci_enable_resources(dev, mask)) < 0)
416 return err; 416 return err;
417 if (!dev->msi_enabled) 417 if (!dev->msi_enabled)
418 pcibios_enable_irq(dev); 418 pcibios_enable_irq(dev);
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 1b851db34186..0708284f85fb 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -87,8 +87,6 @@ void __init paging_init(void)
87 87
88 pkmap_page_table = alloc_bootmem_pages(PAGE_SIZE); 88 pkmap_page_table = alloc_bootmem_pages(PAGE_SIZE);
89 89
90 memset(pkmap_page_table, 0, PAGE_SIZE);
91
92 pge = swapper_pg_dir + pgd_index_k(PKMAP_BASE); 90 pge = swapper_pg_dir + pgd_index_k(PKMAP_BASE);
93 pue = pud_offset(pge, PKMAP_BASE); 91 pue = pud_offset(pge, PKMAP_BASE);
94 pme = pmd_offset(pue, PKMAP_BASE); 92 pme = pmd_offset(pue, PKMAP_BASE);
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 107cb5bb9f39..c7966746fbfe 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -62,6 +62,10 @@ config GENERIC_TIME
62 bool 62 bool
63 default y 63 default y
64 64
65config GENERIC_BUG
66 bool
67 depends on BUG
68
65config TIME_LOW_RES 69config TIME_LOW_RES
66 bool 70 bool
67 default y 71 default y
diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu
index 582797db9603..b65dcfe51d9c 100644
--- a/arch/h8300/Kconfig.cpu
+++ b/arch/h8300/Kconfig.cpu
@@ -1,5 +1,7 @@
1menu "Processor type and features" 1menu "Processor type and features"
2 2
3source "kernel/time/Kconfig"
4
3choice 5choice
4 prompt "H8/300 platform" 6 prompt "H8/300 platform"
5 default H8300H_GENERIC 7 default H8300H_GENERIC
@@ -11,6 +13,7 @@ config H8300H_GENERIC
11 13
12config H8300H_AKI3068NET 14config H8300H_AKI3068NET
13 bool "AE-3068/69" 15 bool "AE-3068/69"
16 select CONFIG_H83068
14 help 17 help
15 AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support 18 AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support
16 More Information. (Japanese Only) 19 More Information. (Japanese Only)
@@ -21,6 +24,7 @@ config H8300H_AKI3068NET
21 24
22config H8300H_H8MAX 25config H8300H_H8MAX
23 bool "H8MAX" 26 bool "H8MAX"
27 select CONFIG_H83068
24 help 28 help
25 H8MAX Evaluation Board Support 29 H8MAX Evaluation Board Support
26 More Information. (Japanese Only) 30 More Information. (Japanese Only)
@@ -28,6 +32,7 @@ config H8300H_H8MAX
28 32
29config H8300H_SIM 33config H8300H_SIM
30 bool "H8/300H Simulator" 34 bool "H8/300H Simulator"
35 select CONFIG_H83007
31 help 36 help
32 GDB Simulator Support 37 GDB Simulator Support
33 More Information. 38 More Information.
@@ -40,6 +45,7 @@ config H8S_GENERIC
40 45
41config H8S_EDOSK2674 46config H8S_EDOSK2674
42 bool "EDOSK-2674" 47 bool "EDOSK-2674"
48 select CONFIG_H8S2768
43 help 49 help
44 Renesas EDOSK-2674 Evaluation Board Support 50 Renesas EDOSK-2674 Evaluation Board Support
45 More Information. 51 More Information.
@@ -55,44 +61,37 @@ config H8S_SIM
55 61
56endchoice 62endchoice
57 63
58if (H8300H_GENERIC || H8S_GENERIC)
59menu "Detail Selection"
60if (H8300H_GENERIC)
61choice 64choice
62 prompt "CPU Selection" 65 prompt "CPU Selection"
63 66
64config H83002 67config H83002
65 bool "H8/3001,3002,3003" 68 bool "H8/3001,3002,3003"
69 select CPU_H8300H
66 70
67config H83007 71config H83007
68 bool "H8/3006,3007" 72 bool "H8/3006,3007"
73 select CPU_H8300H
69 74
70config H83048 75config H83048
71 bool "H8/3044,3045,3046,3047,3048,3052" 76 bool "H8/3044,3045,3046,3047,3048,3052"
77 select CPU_H8300H
72 78
73config H83068 79config H83068
74 bool "H8/3065,3066,3067,3068,3069" 80 bool "H8/3065,3066,3067,3068,3069"
75endchoice 81 select CPU_H8300H
76endif
77
78if (H8S_GENERIC)
79choice
80 prompt "CPU Selection"
81 82
82config H8S2678 83config H8S2678
83 bool "H8S/2670,2673,2674R,2675,2676" 84 bool "H8S/2670,2673,2674R,2675,2676"
85 select CPU_H8S
86
84endchoice 87endchoice
85endif
86 88
87config CPU_CLOCK 89config CPU_CLOCK
88 int "CPU Clock Frequency (/1KHz)" 90 int "CPU Clock Frequency (/1KHz)"
89 default "20000" 91 default "20000"
90 help 92 help
91 CPU Clock Frequency divide to 1000 93 CPU Clock Frequency divide to 1000
92endmenu
93endif
94 94
95if (H8300H_GENERIC || H8S_GENERIC || H8300H_SIM || H8S_SIM || H8S_EDOSK2674)
96choice 95choice
97 prompt "Kernel executes from" 96 prompt "Kernel executes from"
98 ---help--- 97 ---help---
@@ -107,75 +106,61 @@ config ROMKERNEL
107 bool "ROM" 106 bool "ROM"
108 help 107 help
109 The kernel will be resident in FLASH/ROM when running. 108 The kernel will be resident in FLASH/ROM when running.
110
111endchoice 109endchoice
112endif
113 110
114if (H8300H_AKI3068NET)
115config H83068
116 bool
117 default y
118 111
119config CPU_CLOCK 112config CPU_H8300H
120 int
121 default "20000"
122
123config RAMKERNEL
124 bool 113 bool
114 depends on (H83002 || H83007 || H83048 || H83068)
125 default y 115 default y
126endif
127 116
128if (H8300H_H8MAX) 117config CPU_H8S
129config H83068
130 bool 118 bool
119 depends on H8S2678
131 default y 120 default y
132 121
133config CPU_CLOCK 122choice
134 int 123 prompt "Timer"
135 default 25000 124config H8300_TIMER8
125 bool "8bit timer (2ch cascade)"
126 depends on (H83007 || H83068 || H8S2678)
136 127
137config RAMKERNEL 128config H8300_TIMER16
138 bool 129 bool "16bit timer"
139 default y 130 depends on (H83007 || H83068)
140endif
141 131
142if (H8300H_SIM) 132config H8300_ITU
143config H83007 133 bool "ITU"
144 bool 134 depends on (H83002 || H83048)
145 default y
146 135
147config CPU_CLOCK 136config H8300_TPU
148 int 137 bool "TPU"
149 default "16000" 138 depends on H8S2678
150endif 139endchoice
151 140
152if (H8S_EDOSK2674) 141if H8300_TIMER8
153config H8S2678 142choice
154 bool 143 prompt "Timer Channel"
155 default y 144config H8300_TIMER8_CH0
156config CPU_CLOCK 145 bool "Channel 0"
157 int 146config H8300_TIMER8_CH2
158 default 33000 147 bool "Channel 2"
148 depends on CPU_H8300H
149endchoice
159endif 150endif
160 151
161if (H8S_SIM) 152config H8300_TIMER16_CH
162config H8S2678 153 int "16bit timer channel (0 - 2)"
163 bool 154 depends on H8300_TIMER16
164 default y 155 range 0 2
165config CPU_CLOCK
166 int
167 default 33000
168endif
169 156
170config CPU_H8300H 157config H8300_ITU_CH
171 bool 158 int "ITU channel"
172 depends on (H83002 || H83007 || H83048 || H83068) 159 depends on H8300_ITU
173 default y
174 160
175config CPU_H8S 161config H8300_TPU_CH
176 bool 162 int "TPU channel"
177 depends on H8S2678 163 depends on H8300_TPU
178 default y
179 164
180config PREEMPT 165config PREEMPT
181 bool "Preemptible Kernel" 166 bool "Preemptible Kernel"
diff --git a/arch/h8300/include/asm/bug.h b/arch/h8300/include/asm/bug.h
index edddf5b086e5..887c19773185 100644
--- a/arch/h8300/include/asm/bug.h
+++ b/arch/h8300/include/asm/bug.h
@@ -1,4 +1,8 @@
1#ifndef _H8300_BUG_H 1#ifndef _H8300_BUG_H
2#define _H8300_BUG_H 2#define _H8300_BUG_H
3
4/* always true */
5#define is_valid_bugaddr(addr) (1)
6
3#include <asm-generic/bug.h> 7#include <asm-generic/bug.h>
4#endif 8#endif
diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
index a8b57d1f4128..94e2284c8816 100644
--- a/arch/h8300/include/asm/elf.h
+++ b/arch/h8300/include/asm/elf.h
@@ -55,7 +55,7 @@ typedef unsigned long elf_fpregset_t;
55 55
56#define ELF_PLATFORM (NULL) 56#define ELF_PLATFORM (NULL)
57 57
58#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) 58#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
59 59
60#define R_H8_NONE 0 60#define R_H8_NONE 0
61#define R_H8_DIR32 1 61#define R_H8_DIR32 1
diff --git a/arch/h8300/include/asm/io.h b/arch/h8300/include/asm/io.h
index 26dc6ccd9441..33e842f3284b 100644
--- a/arch/h8300/include/asm/io.h
+++ b/arch/h8300/include/asm/io.h
@@ -295,6 +295,40 @@ static __inline__ void ctrl_outl(unsigned long b, unsigned long addr)
295 *(volatile unsigned long*)addr = b; 295 *(volatile unsigned long*)addr = b;
296} 296}
297 297
298static __inline__ void ctrl_bclr(int b, unsigned long addr)
299{
300 if (__builtin_constant_p(b))
301 switch (b) {
302 case 0: __asm__("bclr #0,@%0"::"r"(addr)); break;
303 case 1: __asm__("bclr #1,@%0"::"r"(addr)); break;
304 case 2: __asm__("bclr #2,@%0"::"r"(addr)); break;
305 case 3: __asm__("bclr #3,@%0"::"r"(addr)); break;
306 case 4: __asm__("bclr #4,@%0"::"r"(addr)); break;
307 case 5: __asm__("bclr #5,@%0"::"r"(addr)); break;
308 case 6: __asm__("bclr #6,@%0"::"r"(addr)); break;
309 case 7: __asm__("bclr #7,@%0"::"r"(addr)); break;
310 }
311 else
312 __asm__("bclr %w0,@%1"::"r"(b), "r"(addr));
313}
314
315static __inline__ void ctrl_bset(int b, unsigned long addr)
316{
317 if (__builtin_constant_p(b))
318 switch (b) {
319 case 0: __asm__("bset #0,@%0"::"r"(addr)); break;
320 case 1: __asm__("bset #1,@%0"::"r"(addr)); break;
321 case 2: __asm__("bset #2,@%0"::"r"(addr)); break;
322 case 3: __asm__("bset #3,@%0"::"r"(addr)); break;
323 case 4: __asm__("bset #4,@%0"::"r"(addr)); break;
324 case 5: __asm__("bset #5,@%0"::"r"(addr)); break;
325 case 6: __asm__("bset #6,@%0"::"r"(addr)); break;
326 case 7: __asm__("bset #7,@%0"::"r"(addr)); break;
327 }
328 else
329 __asm__("bset %w0,@%1"::"r"(b), "r"(addr));
330}
331
298/* Pages to physical address... */ 332/* Pages to physical address... */
299#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT) 333#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
300#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT) 334#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
diff --git a/arch/h8300/include/asm/md.h b/arch/h8300/include/asm/md.h
index 1a47dc6691fb..1b7300e0a175 100644
--- a/arch/h8300/include/asm/md.h
+++ b/arch/h8300/include/asm/md.h
@@ -1,4 +1,4 @@
1/* $Id: md.h,v 1.1 2002/11/19 02:09:26 gerg Exp $ 1/*
2 * md.h: High speed xor_block operation for RAID4/5 2 * md.h: High speed xor_block operation for RAID4/5
3 * 3 *
4 */ 4 */
diff --git a/arch/h8300/include/asm/system.h b/arch/h8300/include/asm/system.h
index 4b8e475908ae..d98d97685f06 100644
--- a/arch/h8300/include/asm/system.h
+++ b/arch/h8300/include/asm/system.h
@@ -155,4 +155,6 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
155 155
156#define arch_align_stack(x) (x) 156#define arch_align_stack(x) (x)
157 157
158void die(char *str, struct pt_regs *fp, unsigned long err);
159
158#endif /* _H8300_SYSTEM_H */ 160#endif /* _H8300_SYSTEM_H */
diff --git a/arch/h8300/kernel/Makefile b/arch/h8300/kernel/Makefile
index 6c248c3c5c3b..8d4d2a54be9e 100644
--- a/arch/h8300/kernel/Makefile
+++ b/arch/h8300/kernel/Makefile
@@ -7,6 +7,6 @@ extra-y := vmlinux.lds
7obj-y := process.o traps.o ptrace.o irq.o \ 7obj-y := process.o traps.o ptrace.o irq.o \
8 sys_h8300.o time.o signal.o \ 8 sys_h8300.o time.o signal.o \
9 setup.o gpio.o init_task.o syscalls.o \ 9 setup.o gpio.o init_task.o syscalls.o \
10 entry.o 10 entry.o timer/
11 11
12obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o 12obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o
diff --git a/arch/h8300/kernel/module.c b/arch/h8300/kernel/module.c
index 4fd7138a6e03..cfc9127d2ced 100644
--- a/arch/h8300/kernel/module.c
+++ b/arch/h8300/kernel/module.c
@@ -114,9 +114,10 @@ int module_finalize(const Elf_Ehdr *hdr,
114 const Elf_Shdr *sechdrs, 114 const Elf_Shdr *sechdrs,
115 struct module *me) 115 struct module *me)
116{ 116{
117 return 0; 117 return module_bug_finalize(hdr, sechdrs, me);
118} 118}
119 119
120void module_arch_cleanup(struct module *mod) 120void module_arch_cleanup(struct module *mod)
121{ 121{
122 module_bug_cleanup(mod);
122} 123}
diff --git a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c
index e37c835e67cf..7f2d6cfbb4b6 100644
--- a/arch/h8300/kernel/time.c
+++ b/arch/h8300/kernel/time.c
@@ -27,27 +27,21 @@
27#include <linux/profile.h> 27#include <linux/profile.h>
28 28
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/target_time.h> 30#include <asm/timer.h>
31 31
32#define TICK_SIZE (tick_nsec / 1000) 32#define TICK_SIZE (tick_nsec / 1000)
33 33
34/* 34void h8300_timer_tick(void)
35 * timer_interrupt() needs to keep up the real-time clock,
36 * as well as call the "do_timer()" routine every clocktick
37 */
38static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
39{ 35{
40 /* may need to kick the hardware timer */ 36 if (current->pid)
41 platform_timer_eoi(); 37 profile_tick(CPU_PROFILING);
42 38 write_seqlock(&xtime_lock);
43 do_timer(1); 39 do_timer(1);
44#ifndef CONFIG_SMP 40 write_sequnlock(&xtime_lock);
45 update_process_times(user_mode(regs)); 41 update_process_times(user_mode(get_irq_regs()));
46#endif
47 profile_tick(CPU_PROFILING);
48} 42}
49 43
50void time_init(void) 44void __init time_init(void)
51{ 45{
52 unsigned int year, mon, day, hour, min, sec; 46 unsigned int year, mon, day, hour, min, sec;
53 47
@@ -57,12 +51,13 @@ void time_init(void)
57 year = 1980; 51 year = 1980;
58 mon = day = 1; 52 mon = day = 1;
59 hour = min = sec = 0; 53 hour = min = sec = 0;
60 platform_gettod (&year, &mon, &day, &hour, &min, &sec); 54#ifdef CONFIG_H8300_GETTOD
61 55 h8300_gettod (&year, &mon, &day, &hour, &min, &sec);
56#endif
62 if ((year += 1900) < 1970) 57 if ((year += 1900) < 1970)
63 year += 100; 58 year += 100;
64 xtime.tv_sec = mktime(year, mon, day, hour, min, sec); 59 xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
65 xtime.tv_nsec = 0; 60 xtime.tv_nsec = 0;
66 61
67 platform_timer_setup(timer_interrupt); 62 h8300_timer_setup();
68} 63}
diff --git a/arch/h8300/kernel/timer/Makefile b/arch/h8300/kernel/timer/Makefile
new file mode 100644
index 000000000000..bef0510ea6ad
--- /dev/null
+++ b/arch/h8300/kernel/timer/Makefile
@@ -0,0 +1,6 @@
1# h8300 internal timer handler
2
3obj-$(CONFIG_H8300_TIMER8) := timer8.o
4obj-$(CONFIG_H8300_TIMER16) := timer16.o
5obj-$(CONFIG_H8300_ITU) := itu.o
6obj-$(CONFIG_H8300_TPU) := tpu.o
diff --git a/arch/h8300/kernel/timer/itu.c b/arch/h8300/kernel/timer/itu.c
new file mode 100644
index 000000000000..d1c926596b08
--- /dev/null
+++ b/arch/h8300/kernel/timer/itu.c
@@ -0,0 +1,83 @@
1/*
2 * linux/arch/h8300/kernel/timer/itu.c
3 *
4 * Yoshinori Sato <ysato@users.sourcefoge.jp>
5 *
6 * ITU Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/timex.h>
19
20#include <asm/segment.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/regs306x.h>
24
25#if CONFIG_H8300_ITU_CH == 0
26#define ITUBASE 0xffff64
27#define ITUIRQ 24
28#elif CONFIG_H8300_ITU_CH == 1
29#define ITUBASE 0xffff6e
30#define ITUIRQ 28
31#elif CONFIG_H8300_ITU_CH == 2
32#define ITUBASE 0xffff78
33#define ITUIRQ 32
34#elif CONFIG_H8300_ITU_CH == 3
35#define ITUBASE 0xffff82
36#define ITUIRQ 36
37#elif CONFIG_H8300_ITU_CH == 4
38#define ITUBASE 0xffff92
39#define ITUIRQ 40
40#else
41#error Unknown timer channel.
42#endif
43
44#define TCR 0
45#define TIOR 1
46#define TIER 2
47#define TSR 3
48#define TCNT 4
49#define GRA 6
50#define GRB 8
51
52static irqreturn_t timer_interrupt(int irq, void *dev_id)
53{
54 h8300_timer_tick();
55 ctrl_bclr(IMFA, ITUBASE + TSR);
56 return IRQ_HANDLED;
57}
58
59static struct irqaction itu_irq = {
60 .name = "itu",
61 .handler = timer_interrupt,
62 .flags = IRQF_DISABLED | IRQF_TIMER,
63 .mask = CPU_MASK_NONE,
64};
65
66static const int __initdata divide_rate[] = {1, 2, 4, 8};
67
68void __init h8300_timer_setup(void)
69{
70 unsigned int div;
71 unsigned int cnt;
72
73 calc_param(cnt, div, divide_rate, 0x10000);
74
75 setup_irq(ITUIRQ, &itu_irq);
76
77 /* initalize timer */
78 ctrl_outb(0, TSTR);
79 ctrl_outb(CCLR0 | div, ITUBASE + TCR);
80 ctrl_outb(0x01, ITUBASE + TIER);
81 ctrl_outw(cnt, ITUBASE + GRA);
82 ctrl_bset(CONFIG_H8300_ITU_CH, TSTR);
83}
diff --git a/arch/h8300/kernel/timer/timer16.c b/arch/h8300/kernel/timer/timer16.c
new file mode 100644
index 000000000000..e14271b72119
--- /dev/null
+++ b/arch/h8300/kernel/timer/timer16.c
@@ -0,0 +1,78 @@
1/*
2 * linux/arch/h8300/kernel/timer/timer16.c
3 *
4 * Yoshinori Sato <ysato@users.sourcefoge.jp>
5 *
6 * 16bit Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/timex.h>
19
20#include <asm/segment.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/regs306x.h>
24
25/* 16bit timer */
26#if CONFIG_H8300_TIMER16_CH == 0
27#define _16BASE 0xffff78
28#define _16IRQ 24
29#elif CONFIG_H8300_TIMER16_CH == 1
30#define _16BASE 0xffff80
31#define _16IRQ 28
32#elif CONFIG_H8300_TIMER16_CH == 2
33#define _16BASE 0xffff88
34#define _16IRQ 32
35#else
36#error Unknown timer channel.
37#endif
38
39#define TCR 0
40#define TIOR 1
41#define TCNT 2
42#define GRA 4
43#define GRB 6
44
45#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*10000 /* Timer input freq. */
46
47static irqreturn_t timer_interrupt(int irq, void *dev_id)
48{
49 h8300_timer_tick();
50 ctrl_bclr(CONFIG_H8300_TIMER16_CH, TISRA);
51 return IRQ_HANDLED;
52}
53
54static struct irqaction timer16_irq = {
55 .name = "timer-16",
56 .handler = timer_interrupt,
57 .flags = IRQF_DISABLED | IRQF_TIMER,
58 .mask = CPU_MASK_NONE,
59};
60
61static const int __initdata divide_rate[] = {1, 2, 4, 8};
62
63void __init h8300_timer_setup(void)
64{
65 unsigned int div;
66 unsigned int cnt;
67
68 calc_param(cnt, div, divide_rate, 0x10000);
69
70 setup_irq(_16IRQ, &timer16_irq);
71
72 /* initalize timer */
73 ctrl_outb(0, TSTR);
74 ctrl_outb(CCLR0 | div, _16BASE + TCR);
75 ctrl_outw(cnt, _16BASE + GRA);
76 ctrl_bset(4 + CONFIG_H8300_TIMER16_CH, TISRA);
77 ctrl_bset(CONFIG_H8300_TIMER16_CH, TSTR);
78}
diff --git a/arch/h8300/kernel/timer/timer8.c b/arch/h8300/kernel/timer/timer8.c
new file mode 100644
index 000000000000..0556d7c7bea6
--- /dev/null
+++ b/arch/h8300/kernel/timer/timer8.c
@@ -0,0 +1,103 @@
1/*
2 * linux/arch/h8300/kernel/cpu/timer/timer8.c
3 *
4 * Yoshinori Sato <ysato@users.sourcefoge.jp>
5 *
6 * 8bit Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/profile.h>
19
20#include <asm/io.h>
21#include <asm/irq.h>
22#include <asm/timer.h>
23#if defined(CONFIG_CPU_H8300H)
24#include <asm/regs306x.h>
25#endif
26#if defined(CONFIG_CPU_H8S)
27#include <asm/regs267x.h>
28#endif
29
30/* 8bit timer x2 */
31#define CMFA 6
32
33#if defined(CONFIG_H8300_TIMER8_CH0)
34#define _8BASE _8TCR0
35#ifdef CONFIG_CPU_H8300H
36#define _8IRQ 36
37#endif
38#ifdef CONFIG_CPU_H8S
39#define _8IRQ 72
40#endif
41#elif defined(CONFIG_H8300_TIMER8_CH2)
42#ifdef CONFIG_CPU_H8300H
43#define _8BASE _8TCR2
44#define _8IRQ 40
45#endif
46#endif
47
48#ifndef _8BASE
49#error Unknown timer channel.
50#endif
51
52#define _8TCR 0
53#define _8TCSR 2
54#define TCORA 4
55#define TCORB 6
56#define _8TCNT 8
57
58#define CMIEA 0x40
59#define CCLR_CMA 0x08
60#define CKS2 0x04
61
62/*
63 * timer_interrupt() needs to keep up the real-time clock,
64 * as well as call the "do_timer()" routine every clocktick
65 */
66
67static irqreturn_t timer_interrupt(int irq, void *dev_id)
68{
69 h8300_timer_tick();
70 ctrl_bclr(CMFA, _8BASE + _8TCSR);
71 return IRQ_HANDLED;
72}
73
74static struct irqaction timer8_irq = {
75 .name = "timer-8",
76 .handler = timer_interrupt,
77 .flags = IRQF_DISABLED | IRQF_TIMER,
78 .mask = CPU_MASK_NONE,
79};
80
81static const int __initdata divide_rate[] = {8, 64, 8192};
82
83void __init h8300_timer_setup(void)
84{
85 unsigned int div;
86 unsigned int cnt;
87
88 calc_param(cnt, div, divide_rate, 0x10000);
89 div++;
90
91 setup_irq(_8IRQ, &timer8_irq);
92
93#if defined(CONFIG_CPU_H8S)
94 /* Timer module enable */
95 ctrl_bclr(0, MSTPCRL)
96#endif
97
98 /* initalize timer */
99 ctrl_outw(cnt, _8BASE + TCORA);
100 ctrl_outw(0x0000, _8BASE + _8TCSR);
101 ctrl_outw((CMIEA|CCLR_CMA|CKS2) << 8 | div,
102 _8BASE + _8TCR);
103}
diff --git a/arch/h8300/kernel/timer/tpu.c b/arch/h8300/kernel/timer/tpu.c
new file mode 100644
index 000000000000..df7f453a9673
--- /dev/null
+++ b/arch/h8300/kernel/timer/tpu.c
@@ -0,0 +1,102 @@
1/*
2 * linux/arch/h8300/kernel/timer/tpu.c
3 *
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
5 *
6 * TPU Timer Handler
7 *
8 */
9
10#include <linux/config.h>
11#include <linux/errno.h>
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/param.h>
15#include <linux/string.h>
16#include <linux/mm.h>
17#include <linux/interrupt.h>
18#include <linux/init.h>
19#include <linux/timex.h>
20
21#include <asm/segment.h>
22#include <asm/io.h>
23#include <asm/irq.h>
24#include <asm/regs267x.h>
25
26/* TPU */
27#if CONFIG_H8300_TPU_CH == 0
28#define TPUBASE 0xffffd0
29#define TPUIRQ 40
30#elif CONFIG_H8300_TPU_CH == 1
31#define TPUBASE 0xffffe0
32#define TPUIRQ 48
33#elif CONFIG_H8300_TPU_CH == 2
34#define TPUBASE 0xfffff0
35#define TPUIRQ 52
36#elif CONFIG_H8300_TPU_CH == 3
37#define TPUBASE 0xfffe80
38#define TPUIRQ 56
39#elif CONFIG_H8300_TPU_CH == 4
40#define TPUBASE 0xfffe90
41#define TPUIRQ 64
42#else
43#error Unknown timer channel.
44#endif
45
46#define _TCR 0
47#define _TMDR 1
48#define _TIOR 2
49#define _TIER 4
50#define _TSR 5
51#define _TCNT 6
52#define _GRA 8
53#define _GRB 10
54
55#define CCLR0 0x20
56
57static irqreturn_t timer_interrupt(int irq, void *dev_id)
58{
59 h8300_timer_tick();
60 ctrl_bclr(0, TPUBASE + _TSR);
61 return IRQ_HANDLED;
62}
63
64static struct irqaction tpu_irq = {
65 .name = "tpu",
66 .handler = timer_interrupt,
67 .flags = IRQF_DISABLED | IRQF_TIMER,
68 .mask = CPU_MASK_NONE,
69};
70
71const static int __initdata divide_rate[] = {
72#if CONFIG_H8300_TPU_CH == 0
73 1,4,16,64,0,0,0,0,
74#elif (CONFIG_H8300_TPU_CH == 1) || (CONFIG_H8300_TPU_CH == 5)
75 1,4,16,64,0,0,256,0,
76#elif (CONFIG_H8300_TPU_CH == 2) || (CONFIG_H8300_TPU_CH == 4)
77 1,4,16,64,0,0,0,1024,
78#elif CONFIG_H8300_TPU_CH == 3
79 1,4,16,64,0,1024,256,4096,
80#endif
81};
82
83void __init h8300_timer_setup(void)
84{
85 unsigned int cnt;
86 unsigned int div;
87
88 calc_param(cnt, div, divide_rate, 0x10000);
89
90 setup_irq(TPUIRQ, &tpu_irq);
91
92 /* TPU module enabled */
93 ctrl_bclr(3, MSTPCRH);
94
95 ctrl_outb(0, TSTR);
96 ctrl_outb(CCLR0 | div, TPUBASE + _TCR);
97 ctrl_outb(0, TPUBASE + _TMDR);
98 ctrl_outw(0, TPUBASE + _TIOR);
99 ctrl_outb(0x01, TPUBASE + _TIER);
100 ctrl_outw(cnt, TPUBASE + _GRA);
101 ctrl_bset(CONFIG_H8300_TPU_CH, TSTR);
102}
diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c
index f8f7d7ea97f1..3c0b66bc669e 100644
--- a/arch/h8300/kernel/traps.c
+++ b/arch/h8300/kernel/traps.c
@@ -20,12 +20,14 @@
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/bug.h>
23 24
24#include <asm/system.h> 25#include <asm/system.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26#include <asm/traps.h> 27#include <asm/traps.h>
27#include <asm/page.h> 28#include <asm/page.h>
28#include <asm/gpio.h> 29
30static DEFINE_SPINLOCK(die_lock);
29 31
30/* 32/*
31 * this must be called very early as the kernel might 33 * this must be called very early as the kernel might
@@ -94,16 +96,19 @@ static void dump(struct pt_regs *fp)
94 printk("\n\n"); 96 printk("\n\n");
95} 97}
96 98
97void die_if_kernel (char *str, struct pt_regs *fp, int nr) 99void die(char *str, struct pt_regs *fp, unsigned long err)
98{ 100{
99 extern int console_loglevel; 101 static int diecount;
100 102
101 if (!(fp->ccr & PS_S)) 103 oops_enter();
102 return;
103 104
104 console_loglevel = 15; 105 console_verbose();
106 spin_lock_irq(&die_lock);
107 report_bug(fp->pc, fp);
108 printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++diecount);
105 dump(fp); 109 dump(fp);
106 110
111 spin_unlock_irq(&die_lock);
107 do_exit(SIGSEGV); 112 do_exit(SIGSEGV);
108} 113}
109 114
diff --git a/arch/h8300/mm/fault.c b/arch/h8300/mm/fault.c
index 29e9af9f0e6a..1d092abebf03 100644
--- a/arch/h8300/mm/fault.c
+++ b/arch/h8300/mm/fault.c
@@ -20,8 +20,6 @@
20#include <asm/system.h> 20#include <asm/system.h>
21#include <asm/pgtable.h> 21#include <asm/pgtable.h>
22 22
23extern void die_if_kernel(char *, struct pt_regs *, long);
24
25/* 23/*
26 * This routine handles page faults. It determines the problem, and 24 * This routine handles page faults. It determines the problem, and
27 * then passes it off to one of the appropriate routines. 25 * then passes it off to one of the appropriate routines.
@@ -50,7 +48,8 @@ asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
50 } else 48 } else
51 printk(KERN_ALERT "Unable to handle kernel access"); 49 printk(KERN_ALERT "Unable to handle kernel access");
52 printk(" at virtual address %08lx\n",address); 50 printk(" at virtual address %08lx\n",address);
53 die_if_kernel("Oops", regs, error_code); 51 if (!user_mode(regs))
52 die("Oops", regs, error_code);
54 do_exit(SIGKILL); 53 do_exit(SIGKILL);
55 54
56 return 1; 55 return 1;
diff --git a/arch/h8300/platform/h8300h/aki3068net/Makefile b/arch/h8300/platform/h8300h/aki3068net/Makefile
index b03c328f8c70..b7ff78050b7f 100644
--- a/arch/h8300/platform/h8300h/aki3068net/Makefile
+++ b/arch/h8300/platform/h8300h/aki3068net/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5extra-y := crt0_ram.o 5extra-y := crt0_ram.o
6obj-y := timer.o
diff --git a/arch/h8300/platform/h8300h/aki3068net/timer.c b/arch/h8300/platform/h8300h/aki3068net/timer.c
deleted file mode 100644
index 27cd85d56128..000000000000
--- a/arch/h8300/platform/h8300h/aki3068net/timer.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * linux/arch/h8300/platform/h8300h/aki3068net/timer.c
3 *
4 * Yoshinori Sato <ysato@users.sourcefoge.jp>
5 *
6 * Platform depend Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/timex.h>
19
20#include <asm/segment.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/regs306x.h>
24
25#define CMFA 6
26
27#define CMIEA 0x40
28#define CCLR_CMA 0x08
29#define CLK_DIV8192 0x03
30
31#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
32
33void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
34{
35 /* setup 8bit timer ch2 */
36 ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
37 ctrl_outb(0x00, _8TCSR2); /* no output */
38 request_irq(40, timer_int, 0, "timer", 0);
39 ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
40}
41
42void platform_timer_eoi(void)
43{
44 *(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
45}
46
47void platform_gettod(int *year, int *mon, int *day, int *hour,
48 int *min, int *sec)
49{
50 *year = *mon = *day = *hour = *min = *sec = 0;
51}
diff --git a/arch/h8300/platform/h8300h/generic/Makefile b/arch/h8300/platform/h8300h/generic/Makefile
index 32b964a9010e..2b12a170209e 100644
--- a/arch/h8300/platform/h8300h/generic/Makefile
+++ b/arch/h8300/platform/h8300h/generic/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5extra-y := crt0_$(MODEL).o 5extra-y := crt0_$(MODEL).o
6obj-y := timer.o
diff --git a/arch/h8300/platform/h8300h/generic/timer.c b/arch/h8300/platform/h8300h/generic/timer.c
deleted file mode 100644
index 6f5cefe0cceb..000000000000
--- a/arch/h8300/platform/h8300h/generic/timer.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * linux/arch/h8300/platform/h8300h/generic/timer.c
3 *
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
5 *
6 * Platform depend Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17
18#include <asm/segment.h>
19#include <asm/io.h>
20#include <asm/irq.h>
21
22#include <linux/timex.h>
23
24#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
25#include <asm/regs306x.h>
26#define CMFA 6
27
28#define CMIEA 0x40
29#define CCLR_CMA 0x08
30#define CLK_DIV8192 0x03
31
32#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
33
34void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
35{
36 /* setup 8bit timer ch2 */
37 ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
38 ctrl_outb(0x00, _8TCSR2); /* no output */
39 request_irq(40, timer_int, 0, "timer", 0);
40 ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
41}
42
43void platform_timer_eoi(void)
44{
45 *(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
46}
47#endif
48
49#if defined(CONFIG_H83002) || defined(CONFIG_H83048)
50/* FIXME! */
51#define TSTR 0x00ffff60
52#define TSNC 0x00ffff61
53#define TMDR 0x00ffff62
54#define TFCR 0x00ffff63
55#define TOER 0x00ffff90
56#define TOCR 0x00ffff91
57/* ITU0 */
58#define TCR 0x00ffff64
59#define TIOR 0x00ffff65
60#define TIER 0x00ffff66
61#define TSR 0x00ffff67
62#define TCNT 0x00ffff68
63#define GRA 0x00ffff6a
64#define GRB 0x00ffff6c
65
66#define CCLR_CMGRA 0x20
67#define CLK_DIV8 0x03
68
69#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8 /* Timer input freq. */
70
71void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
72{
73 *(unsigned short *)GRA= H8300_TIMER_FREQ / HZ; /* set interval */
74 *(unsigned short *)TCNT=0; /* clear counter */
75 ctrl_outb(0x80|CCLR_CMGRA|CLK_DIV8, TCR); /* set ITU0 clock */
76 ctrl_outb(0x88, TIOR); /* no output */
77 request_irq(26, timer_int, 0, "timer", 0);
78 ctrl_outb(0xf9, TIER); /* compare match GRA interrupt */
79 ctrl_outb(ctrl_inb(TSNC) & ~0x01, TSNC); /* ITU0 async */
80 ctrl_outb(ctrl_inb(TMDR) & ~0x01, TMDR); /* ITU0 normal mode */
81 ctrl_outb(ctrl_inb(TSTR) | 0x01, TSTR); /* ITU0 Start */
82 return 0;
83}
84
85void platform_timer_eoi(void)
86{
87 ctrl_outb(ctrl_inb(TSR) & ~0x01,TSR);
88}
89#endif
90
91void platform_gettod(int *year, int *mon, int *day, int *hour,
92 int *min, int *sec)
93{
94 *year = *mon = *day = *hour = *min = *sec = 0;
95}
diff --git a/arch/h8300/platform/h8300h/h8max/Makefile b/arch/h8300/platform/h8300h/h8max/Makefile
index b03c328f8c70..b7ff78050b7f 100644
--- a/arch/h8300/platform/h8300h/h8max/Makefile
+++ b/arch/h8300/platform/h8300h/h8max/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5extra-y := crt0_ram.o 5extra-y := crt0_ram.o
6obj-y := timer.o
diff --git a/arch/h8300/platform/h8300h/h8max/timer.c b/arch/h8300/platform/h8300h/h8max/timer.c
deleted file mode 100644
index 85a574afe9d0..000000000000
--- a/arch/h8300/platform/h8300h/h8max/timer.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * linux/arch/h8300/platform/h8300h/h8max/timer.c
3 *
4 * Yoshinori Sato <ysato@users.sourcefoge.jp>
5 *
6 * Platform depend Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/timex.h>
19
20#include <asm/segment.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/regs306x.h>
24
25#define CMFA 6
26
27#define CMIEA 0x40
28#define CCLR_CMA 0x08
29#define CLK_DIV8192 0x03
30
31#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
32
33void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
34{
35 /* setup 8bit timer ch2 */
36 ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
37 ctrl_outb(0x00, _8TCSR2); /* no output */
38 request_irq(40, timer_int, 0, "timer", 0);
39 ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
40}
41
42void platform_timer_eoi(void)
43{
44 *(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
45}
46
47void platform_gettod(int *year, int *mon, int *day, int *hour,
48 int *min, int *sec)
49{
50 *year = *mon = *day = *hour = *min = *sec = 0;
51}
52
diff --git a/arch/h8300/platform/h8s/edosk2674/Makefile b/arch/h8300/platform/h8s/edosk2674/Makefile
index f763654ac6fe..8e349723bb4f 100644
--- a/arch/h8300/platform/h8s/edosk2674/Makefile
+++ b/arch/h8300/platform/h8s/edosk2674/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5extra-y := crt0_$(MODEL).o 5extra-y := crt0_$(MODEL).o
6obj-y := timer.o
diff --git a/arch/h8300/platform/h8s/edosk2674/timer.c b/arch/h8300/platform/h8s/edosk2674/timer.c
deleted file mode 100644
index bfb1424482f4..000000000000
--- a/arch/h8300/platform/h8s/edosk2674/timer.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * linux/arch/h8300/platform/h8s/edosk2674/timer.c
3 *
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
5 *
6 * Platform depend Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/timex.h>
19
20#include <asm/segment.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/regs267x.h>
24
25#define CMFA 6
26
27#define CMIEA 0x40
28#define CCLR_CMA 0x08
29#define CLK_DIV8192 0x03
30
31#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
32
33void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
34{
35 /* 8bit timer module enabled */
36 ctrl_outb(ctrl_inb(MSTPCRL) & ~0x01, MSTPCRL);
37 /* setup 8bit timer ch1 */
38 ctrl_outb(H8300_TIMER_FREQ / HZ, _8TCORA1); /* set interval */
39 ctrl_outb(0x00, _8TCSR1); /* no output */
40 request_irq(76, timer_int, 0, "timer" ,0);
41 ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR1); /* start count */
42}
43
44void platform_timer_eoi(void)
45{
46 *(volatile unsigned char *)_8TCSR1 &= ~(1 << CMFA);
47}
48
49void platform_gettod(int *year, int *mon, int *day, int *hour,
50 int *min, int *sec)
51{
52/* FIXME! not RTC support */
53 *year = *mon = *day = *hour = *min = *sec = 0;
54}
diff --git a/arch/h8300/platform/h8s/generic/Makefile b/arch/h8300/platform/h8s/generic/Makefile
index 055d53a9811b..44b4685c664c 100644
--- a/arch/h8300/platform/h8s/generic/Makefile
+++ b/arch/h8300/platform/h8s/generic/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5extra-y = crt0_$(MODEL).o 5extra-y = crt0_$(MODEL).o
6obj-y := timer.o
diff --git a/arch/h8300/platform/h8s/generic/timer.c b/arch/h8300/platform/h8s/generic/timer.c
deleted file mode 100644
index c2211c6e79da..000000000000
--- a/arch/h8300/platform/h8s/generic/timer.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * linux/arch/h8300/platform/h8s/generic/timer.c
3 *
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
5 *
6 * Platform depend Timer Handler
7 *
8 */
9
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h>
17#include <linux/init.h>
18#include <linux/timex.h>
19
20#include <asm/segment.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/regs267x.h>
24
25#define CMFA 6
26
27#define CMIEA 0x40
28#define CCLR_CMA 0x08
29#define CLK_DIV8192 0x03
30
31#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
32
33void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
34{
35 /* 8bit timer module enabled */
36 ctrl_outb(ctrl_inb(MSTPCRL) & ~0x01, MSTPCRL);
37 /* setup 8bit timer ch1 */
38 ctrl_outb(H8300_TIMER_FREQ / HZ, _8TCORA1); /* set interval */
39 ctrl_outb(0x00, _8TCSR1); /* no output */
40 request_irq(76, timer_int, 0, "timer" ,0);
41 ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR1); /* start count */
42}
43
44void platform_timer_eoi(void)
45{
46 *(volatile unsigned char *)_8TCSR1 &= ~(1 << CMFA);
47}
48
49void platform_gettod(int *year, int *mon, int *day, int *hour,
50 int *min, int *sec)
51{
52 *year = *mon = *day = *hour = *min = *sec = 0;
53}
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 48e496fe1e75..3b7aa38254a8 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -60,14 +60,6 @@ config RWSEM_XCHGADD_ALGORITHM
60 bool 60 bool
61 default y 61 default y
62 62
63config ARCH_HAS_ILOG2_U32
64 bool
65 default n
66
67config ARCH_HAS_ILOG2_U64
68 bool
69 default n
70
71config HUGETLB_PAGE_SIZE_VARIABLE 63config HUGETLB_PAGE_SIZE_VARIABLE
72 bool 64 bool
73 depends on HUGETLB_PAGE 65 depends on HUGETLB_PAGE
diff --git a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
index 4f0c30c38e99..f92bdaac8976 100644
--- a/arch/ia64/ia32/binfmt_elf32.c
+++ b/arch/ia64/ia32/binfmt_elf32.c
@@ -41,7 +41,7 @@ randomize_stack_top(unsigned long stack_top);
41#define elf_map elf32_map 41#define elf_map elf32_map
42 42
43#undef SET_PERSONALITY 43#undef SET_PERSONALITY
44#define SET_PERSONALITY(ex, ibcs2) elf32_set_personality() 44#define SET_PERSONALITY(ex) elf32_set_personality()
45 45
46#define elf_read_implies_exec(ex, have_pt_gnu_stack) (!(have_pt_gnu_stack)) 46#define elf_read_implies_exec(ex, have_pt_gnu_stack) (!(have_pt_gnu_stack))
47 47
diff --git a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S
index ff88c48c5d19..53505bb04771 100644
--- a/arch/ia64/ia32/ia32_entry.S
+++ b/arch/ia64/ia32/ia32_entry.S
@@ -251,8 +251,8 @@ ia32_syscall_table:
251 data8 compat_sys_setrlimit /* 75 */ 251 data8 compat_sys_setrlimit /* 75 */
252 data8 compat_sys_old_getrlimit 252 data8 compat_sys_old_getrlimit
253 data8 compat_sys_getrusage 253 data8 compat_sys_getrusage
254 data8 sys32_gettimeofday 254 data8 compat_sys_gettimeofday
255 data8 sys32_settimeofday 255 data8 compat_sys_settimeofday
256 data8 sys32_getgroups16 /* 80 */ 256 data8 sys32_getgroups16 /* 80 */
257 data8 sys32_setgroups16 257 data8 sys32_setgroups16
258 data8 sys32_old_select 258 data8 sys32_old_select
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
index dd0c53687a96..0f15349c3c6b 100644
--- a/arch/ia64/ia32/ia32priv.h
+++ b/arch/ia64/ia32/ia32priv.h
@@ -332,8 +332,8 @@ void ia64_elf32_init(struct pt_regs *regs);
332#define ELF_PLATFORM NULL 332#define ELF_PLATFORM NULL
333 333
334#ifdef __KERNEL__ 334#ifdef __KERNEL__
335# define SET_PERSONALITY(EX,IBCS2) \ 335# define SET_PERSONALITY(EX) \
336 (current->personality = (IBCS2) ? PER_SVR4 : PER_LINUX) 336 (current->personality = PER_LINUX)
337#endif 337#endif
338 338
339#define IA32_EFLAG 0x200 339#define IA32_EFLAG 0x200
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index bf196cbb3796..f4430bb4bbdc 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -118,41 +118,6 @@ sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __use
118 return error; 118 return error;
119} 119}
120 120
121int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
122{
123 compat_ino_t ino;
124 int err;
125
126 if ((u64) stat->size > MAX_NON_LFS ||
127 !old_valid_dev(stat->dev) ||
128 !old_valid_dev(stat->rdev))
129 return -EOVERFLOW;
130
131 ino = stat->ino;
132 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
133 return -EOVERFLOW;
134
135 if (clear_user(ubuf, sizeof(*ubuf)))
136 return -EFAULT;
137
138 err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
139 err |= __put_user(ino, &ubuf->st_ino);
140 err |= __put_user(stat->mode, &ubuf->st_mode);
141 err |= __put_user(stat->nlink, &ubuf->st_nlink);
142 err |= __put_user(high2lowuid(stat->uid), &ubuf->st_uid);
143 err |= __put_user(high2lowgid(stat->gid), &ubuf->st_gid);
144 err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
145 err |= __put_user(stat->size, &ubuf->st_size);
146 err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
147 err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
148 err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
149 err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
150 err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
151 err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
152 err |= __put_user(stat->blksize, &ubuf->st_blksize);
153 err |= __put_user(stat->blocks, &ubuf->st_blocks);
154 return err;
155}
156 121
157#if PAGE_SHIFT > IA32_PAGE_SHIFT 122#if PAGE_SHIFT > IA32_PAGE_SHIFT
158 123
@@ -1148,68 +1113,12 @@ sys32_pipe (int __user *fd)
1148 return retval; 1113 return retval;
1149} 1114}
1150 1115
1151static inline long
1152get_tv32 (struct timeval *o, struct compat_timeval __user *i)
1153{
1154 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
1155 (__get_user(o->tv_sec, &i->tv_sec) | __get_user(o->tv_usec, &i->tv_usec)));
1156}
1157
1158static inline long
1159put_tv32 (struct compat_timeval __user *o, struct timeval *i)
1160{
1161 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
1162 (__put_user(i->tv_sec, &o->tv_sec) | __put_user(i->tv_usec, &o->tv_usec)));
1163}
1164
1165asmlinkage unsigned long 1116asmlinkage unsigned long
1166sys32_alarm (unsigned int seconds) 1117sys32_alarm (unsigned int seconds)
1167{ 1118{
1168 return alarm_setitimer(seconds); 1119 return alarm_setitimer(seconds);
1169} 1120}
1170 1121
1171/* Translations due to time_t size differences. Which affects all
1172 sorts of things, like timeval and itimerval. */
1173
1174extern struct timezone sys_tz;
1175
1176asmlinkage long
1177sys32_gettimeofday (struct compat_timeval __user *tv, struct timezone __user *tz)
1178{
1179 if (tv) {
1180 struct timeval ktv;
1181 do_gettimeofday(&ktv);
1182 if (put_tv32(tv, &ktv))
1183 return -EFAULT;
1184 }
1185 if (tz) {
1186 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
1187 return -EFAULT;
1188 }
1189 return 0;
1190}
1191
1192asmlinkage long
1193sys32_settimeofday (struct compat_timeval __user *tv, struct timezone __user *tz)
1194{
1195 struct timeval ktv;
1196 struct timespec kts;
1197 struct timezone ktz;
1198
1199 if (tv) {
1200 if (get_tv32(&ktv, tv))
1201 return -EFAULT;
1202 kts.tv_sec = ktv.tv_sec;
1203 kts.tv_nsec = ktv.tv_usec * 1000;
1204 }
1205 if (tz) {
1206 if (copy_from_user(&ktz, tz, sizeof(ktz)))
1207 return -EFAULT;
1208 }
1209
1210 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
1211}
1212
1213struct sel_arg_struct { 1122struct sel_arg_struct {
1214 unsigned int n; 1123 unsigned int n;
1215 unsigned int inp; 1124 unsigned int inp;
diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
index 2acb6b6543c9..86eddee029cb 100644
--- a/arch/ia64/include/asm/elf.h
+++ b/arch/ia64/include/asm/elf.h
@@ -202,7 +202,7 @@ extern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst);
202 relevant until we have real hardware to play with... */ 202 relevant until we have real hardware to play with... */
203#define ELF_PLATFORM NULL 203#define ELF_PLATFORM NULL
204 204
205#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) 205#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
206#define elf_read_implies_exec(ex, executable_stack) \ 206#define elf_read_implies_exec(ex, executable_stack) \
207 ((executable_stack!=EXSTACK_DISABLE_X) && ((ex).e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK) != 0) 207 ((executable_stack!=EXSTACK_DISABLE_X) && ((ex).e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK) != 0)
208 208
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 1efe513a9941..85db124d37f6 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -132,7 +132,7 @@
132#define GPFN_IOSAPIC (4UL << 60) /* IOSAPIC base */ 132#define GPFN_IOSAPIC (4UL << 60) /* IOSAPIC base */
133#define GPFN_LEGACY_IO (5UL << 60) /* Legacy I/O base */ 133#define GPFN_LEGACY_IO (5UL << 60) /* Legacy I/O base */
134#define GPFN_GFW (6UL << 60) /* Guest Firmware */ 134#define GPFN_GFW (6UL << 60) /* Guest Firmware */
135#define GPFN_HIGH_MMIO (7UL << 60) /* High MMIO range */ 135#define GPFN_PHYS_MMIO (7UL << 60) /* Directed MMIO Range */
136 136
137#define GPFN_IO_MASK (7UL << 60) /* Guest pfn is I/O type */ 137#define GPFN_IO_MASK (7UL << 60) /* Guest pfn is I/O type */
138#define GPFN_INV_MASK (1UL << 63) /* Guest pfn is invalid */ 138#define GPFN_INV_MASK (1UL << 63) /* Guest pfn is invalid */
@@ -413,6 +413,10 @@ struct kvm_arch {
413 struct kvm_ioapic *vioapic; 413 struct kvm_ioapic *vioapic;
414 struct kvm_vm_stat stat; 414 struct kvm_vm_stat stat;
415 struct kvm_sal_data rdv_sal_data; 415 struct kvm_sal_data rdv_sal_data;
416
417 struct list_head assigned_dev_head;
418 struct dmar_domain *intel_iommu_domain;
419 struct hlist_head irq_ack_notifier_list;
416}; 420};
417 421
418union cpuid3_t { 422union cpuid3_t {
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig
index 7914e4828504..8e99fed6b3fd 100644
--- a/arch/ia64/kvm/Kconfig
+++ b/arch/ia64/kvm/Kconfig
@@ -46,4 +46,6 @@ config KVM_INTEL
46config KVM_TRACE 46config KVM_TRACE
47 bool 47 bool
48 48
49source drivers/virtio/Kconfig
50
49endif # VIRTUALIZATION 51endif # VIRTUALIZATION
diff --git a/arch/ia64/kvm/Makefile b/arch/ia64/kvm/Makefile
index bf22fb9e6dcf..cf37f8f490c0 100644
--- a/arch/ia64/kvm/Makefile
+++ b/arch/ia64/kvm/Makefile
@@ -44,7 +44,11 @@ EXTRA_CFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
44EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ 44EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
45 45
46common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ 46common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
47 coalesced_mmio.o) 47 coalesced_mmio.o irq_comm.o)
48
49ifeq ($(CONFIG_DMAR),y)
50common-objs += $(addprefix ../../../virt/kvm/, vtd.o)
51endif
48 52
49kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o 53kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o
50obj-$(CONFIG_KVM) += kvm.o 54obj-$(CONFIG_KVM) += kvm.o
diff --git a/arch/ia64/kvm/irq.h b/arch/ia64/kvm/irq.h
new file mode 100644
index 000000000000..c6786e8b1bf4
--- /dev/null
+++ b/arch/ia64/kvm/irq.h
@@ -0,0 +1,31 @@
1/*
2 * irq.h: In-kernel interrupt controller related definitions
3 * Copyright (c) 2008, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as 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 for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * Authors:
19 * Xiantao Zhang <xiantao.zhang@intel.com>
20 *
21 */
22
23#ifndef __IRQ_H
24#define __IRQ_H
25
26static inline int irqchip_in_kernel(struct kvm *kvm)
27{
28 return 1;
29}
30
31#endif
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index cd0d1a7284b7..c0699f0e35a9 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -31,6 +31,7 @@
31#include <linux/bitops.h> 31#include <linux/bitops.h>
32#include <linux/hrtimer.h> 32#include <linux/hrtimer.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/intel-iommu.h>
34 35
35#include <asm/pgtable.h> 36#include <asm/pgtable.h>
36#include <asm/gcc_intrin.h> 37#include <asm/gcc_intrin.h>
@@ -45,6 +46,7 @@
45#include "iodev.h" 46#include "iodev.h"
46#include "ioapic.h" 47#include "ioapic.h"
47#include "lapic.h" 48#include "lapic.h"
49#include "irq.h"
48 50
49static unsigned long kvm_vmm_base; 51static unsigned long kvm_vmm_base;
50static unsigned long kvm_vsa_base; 52static unsigned long kvm_vsa_base;
@@ -179,12 +181,16 @@ int kvm_dev_ioctl_check_extension(long ext)
179 switch (ext) { 181 switch (ext) {
180 case KVM_CAP_IRQCHIP: 182 case KVM_CAP_IRQCHIP:
181 case KVM_CAP_USER_MEMORY: 183 case KVM_CAP_USER_MEMORY:
184 case KVM_CAP_MP_STATE:
182 185
183 r = 1; 186 r = 1;
184 break; 187 break;
185 case KVM_CAP_COALESCED_MMIO: 188 case KVM_CAP_COALESCED_MMIO:
186 r = KVM_COALESCED_MMIO_PAGE_OFFSET; 189 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
187 break; 190 break;
191 case KVM_CAP_IOMMU:
192 r = intel_iommu_found();
193 break;
188 default: 194 default:
189 r = 0; 195 r = 0;
190 } 196 }
@@ -771,6 +777,7 @@ static void kvm_init_vm(struct kvm *kvm)
771 */ 777 */
772 kvm_build_io_pmt(kvm); 778 kvm_build_io_pmt(kvm);
773 779
780 INIT_LIST_HEAD(&kvm->arch.assigned_dev_head);
774} 781}
775 782
776struct kvm *kvm_arch_create_vm(void) 783struct kvm *kvm_arch_create_vm(void)
@@ -1334,6 +1341,10 @@ static void kvm_release_vm_pages(struct kvm *kvm)
1334 1341
1335void kvm_arch_destroy_vm(struct kvm *kvm) 1342void kvm_arch_destroy_vm(struct kvm *kvm)
1336{ 1343{
1344 kvm_iommu_unmap_guest(kvm);
1345#ifdef KVM_CAP_DEVICE_ASSIGNMENT
1346 kvm_free_all_assigned_devices(kvm);
1347#endif
1337 kfree(kvm->arch.vioapic); 1348 kfree(kvm->arch.vioapic);
1338 kvm_release_vm_pages(kvm); 1349 kvm_release_vm_pages(kvm);
1339 kvm_free_physmem(kvm); 1350 kvm_free_physmem(kvm);
@@ -1435,17 +1446,24 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
1435 int user_alloc) 1446 int user_alloc)
1436{ 1447{
1437 unsigned long i; 1448 unsigned long i;
1438 struct page *page; 1449 unsigned long pfn;
1439 int npages = mem->memory_size >> PAGE_SHIFT; 1450 int npages = mem->memory_size >> PAGE_SHIFT;
1440 struct kvm_memory_slot *memslot = &kvm->memslots[mem->slot]; 1451 struct kvm_memory_slot *memslot = &kvm->memslots[mem->slot];
1441 unsigned long base_gfn = memslot->base_gfn; 1452 unsigned long base_gfn = memslot->base_gfn;
1442 1453
1443 for (i = 0; i < npages; i++) { 1454 for (i = 0; i < npages; i++) {
1444 page = gfn_to_page(kvm, base_gfn + i); 1455 pfn = gfn_to_pfn(kvm, base_gfn + i);
1445 kvm_set_pmt_entry(kvm, base_gfn + i, 1456 if (!kvm_is_mmio_pfn(pfn)) {
1446 page_to_pfn(page) << PAGE_SHIFT, 1457 kvm_set_pmt_entry(kvm, base_gfn + i,
1447 _PAGE_AR_RWX|_PAGE_MA_WB); 1458 pfn << PAGE_SHIFT,
1448 memslot->rmap[i] = (unsigned long)page; 1459 _PAGE_AR_RWX | _PAGE_MA_WB);
1460 memslot->rmap[i] = (unsigned long)pfn_to_page(pfn);
1461 } else {
1462 kvm_set_pmt_entry(kvm, base_gfn + i,
1463 GPFN_PHYS_MMIO | (pfn << PAGE_SHIFT),
1464 _PAGE_MA_UC);
1465 memslot->rmap[i] = 0;
1466 }
1449 } 1467 }
1450 1468
1451 return 0; 1469 return 0;
@@ -1789,11 +1807,43 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
1789int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, 1807int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
1790 struct kvm_mp_state *mp_state) 1808 struct kvm_mp_state *mp_state)
1791{ 1809{
1792 return -EINVAL; 1810 vcpu_load(vcpu);
1811 mp_state->mp_state = vcpu->arch.mp_state;
1812 vcpu_put(vcpu);
1813 return 0;
1814}
1815
1816static int vcpu_reset(struct kvm_vcpu *vcpu)
1817{
1818 int r;
1819 long psr;
1820 local_irq_save(psr);
1821 r = kvm_insert_vmm_mapping(vcpu);
1822 if (r)
1823 goto fail;
1824
1825 vcpu->arch.launched = 0;
1826 kvm_arch_vcpu_uninit(vcpu);
1827 r = kvm_arch_vcpu_init(vcpu);
1828 if (r)
1829 goto fail;
1830
1831 kvm_purge_vmm_mapping(vcpu);
1832 r = 0;
1833fail:
1834 local_irq_restore(psr);
1835 return r;
1793} 1836}
1794 1837
1795int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, 1838int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
1796 struct kvm_mp_state *mp_state) 1839 struct kvm_mp_state *mp_state)
1797{ 1840{
1798 return -EINVAL; 1841 int r = 0;
1842
1843 vcpu_load(vcpu);
1844 vcpu->arch.mp_state = mp_state->mp_state;
1845 if (vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)
1846 r = vcpu_reset(vcpu);
1847 vcpu_put(vcpu);
1848 return r;
1799} 1849}
diff --git a/arch/ia64/kvm/kvm_minstate.h b/arch/ia64/kvm/kvm_minstate.h
index 13980d9b8bcf..2cc41d17cf99 100644
--- a/arch/ia64/kvm/kvm_minstate.h
+++ b/arch/ia64/kvm/kvm_minstate.h
@@ -50,27 +50,18 @@
50 50
51#define PAL_VSA_SYNC_READ \ 51#define PAL_VSA_SYNC_READ \
52 /* begin to call pal vps sync_read */ \ 52 /* begin to call pal vps sync_read */ \
53{.mii; \
53 add r25 = VMM_VPD_BASE_OFFSET, r21; \ 54 add r25 = VMM_VPD_BASE_OFFSET, r21; \
54 adds r20 = VMM_VCPU_VSA_BASE_OFFSET, r21; /* entry point */ \ 55 nop 0x0; \
56 mov r24=ip; \
55 ;; \ 57 ;; \
58} \
59{.mmb \
60 add r24=0x20, r24; \
56 ld8 r25 = [r25]; /* read vpd base */ \ 61 ld8 r25 = [r25]; /* read vpd base */ \
57 ld8 r20 = [r20]; \ 62 br.cond.sptk kvm_vps_sync_read; /*call the service*/ \
58 ;; \
59 add r20 = PAL_VPS_SYNC_READ,r20; \
60 ;; \
61{ .mii; \
62 nop 0x0; \
63 mov r24 = ip; \
64 mov b0 = r20; \
65 ;; \ 63 ;; \
66}; \ 64}; \
67{ .mmb; \
68 add r24 = 0x20, r24; \
69 nop 0x0; \
70 br.cond.sptk b0; /* call the service */ \
71 ;; \
72};
73
74 65
75 66
76#define KVM_MINSTATE_GET_CURRENT(reg) mov reg=r21 67#define KVM_MINSTATE_GET_CURRENT(reg) mov reg=r21
diff --git a/arch/ia64/kvm/optvfault.S b/arch/ia64/kvm/optvfault.S
index e4f15d641b22..634abad979b5 100644
--- a/arch/ia64/kvm/optvfault.S
+++ b/arch/ia64/kvm/optvfault.S
@@ -1,9 +1,12 @@
1/* 1/*
2 * arch/ia64/vmx/optvfault.S 2 * arch/ia64/kvm/optvfault.S
3 * optimize virtualization fault handler 3 * optimize virtualization fault handler
4 * 4 *
5 * Copyright (C) 2006 Intel Co 5 * Copyright (C) 2006 Intel Co
6 * Xuefei Xu (Anthony Xu) <anthony.xu@intel.com> 6 * Xuefei Xu (Anthony Xu) <anthony.xu@intel.com>
7 * Copyright (C) 2008 Intel Co
8 * Add the support for Tukwila processors.
9 * Xiantao Zhang <xiantao.zhang@intel.com>
7 */ 10 */
8 11
9#include <asm/asmmacro.h> 12#include <asm/asmmacro.h>
@@ -20,6 +23,98 @@
20#define ACCE_MOV_TO_PSR 23#define ACCE_MOV_TO_PSR
21#define ACCE_THASH 24#define ACCE_THASH
22 25
26#define VMX_VPS_SYNC_READ \
27 add r16=VMM_VPD_BASE_OFFSET,r21; \
28 mov r17 = b0; \
29 mov r18 = r24; \
30 mov r19 = r25; \
31 mov r20 = r31; \
32 ;; \
33{.mii; \
34 ld8 r16 = [r16]; \
35 nop 0x0; \
36 mov r24 = ip; \
37 ;; \
38}; \
39{.mmb; \
40 add r24=0x20, r24; \
41 mov r25 =r16; \
42 br.sptk.many kvm_vps_sync_read; \
43}; \
44 mov b0 = r17; \
45 mov r24 = r18; \
46 mov r25 = r19; \
47 mov r31 = r20
48
49ENTRY(kvm_vps_entry)
50 adds r29 = VMM_VCPU_VSA_BASE_OFFSET,r21
51 ;;
52 ld8 r29 = [r29]
53 ;;
54 add r29 = r29, r30
55 ;;
56 mov b0 = r29
57 br.sptk.many b0
58END(kvm_vps_entry)
59
60/*
61 * Inputs:
62 * r24 : return address
63 * r25 : vpd
64 * r29 : scratch
65 *
66 */
67GLOBAL_ENTRY(kvm_vps_sync_read)
68 movl r30 = PAL_VPS_SYNC_READ
69 ;;
70 br.sptk.many kvm_vps_entry
71END(kvm_vps_sync_read)
72
73/*
74 * Inputs:
75 * r24 : return address
76 * r25 : vpd
77 * r29 : scratch
78 *
79 */
80GLOBAL_ENTRY(kvm_vps_sync_write)
81 movl r30 = PAL_VPS_SYNC_WRITE
82 ;;
83 br.sptk.many kvm_vps_entry
84END(kvm_vps_sync_write)
85
86/*
87 * Inputs:
88 * r23 : pr
89 * r24 : guest b0
90 * r25 : vpd
91 *
92 */
93GLOBAL_ENTRY(kvm_vps_resume_normal)
94 movl r30 = PAL_VPS_RESUME_NORMAL
95 ;;
96 mov pr=r23,-2
97 br.sptk.many kvm_vps_entry
98END(kvm_vps_resume_normal)
99
100/*
101 * Inputs:
102 * r23 : pr
103 * r24 : guest b0
104 * r25 : vpd
105 * r17 : isr
106 */
107GLOBAL_ENTRY(kvm_vps_resume_handler)
108 movl r30 = PAL_VPS_RESUME_HANDLER
109 ;;
110 ld8 r27=[r25]
111 shr r17=r17,IA64_ISR_IR_BIT
112 ;;
113 dep r27=r17,r27,63,1 // bit 63 of r27 indicate whether enable CFLE
114 mov pr=r23,-2
115 br.sptk.many kvm_vps_entry
116END(kvm_vps_resume_handler)
117
23//mov r1=ar3 118//mov r1=ar3
24GLOBAL_ENTRY(kvm_asm_mov_from_ar) 119GLOBAL_ENTRY(kvm_asm_mov_from_ar)
25#ifndef ACCE_MOV_FROM_AR 120#ifndef ACCE_MOV_FROM_AR
@@ -157,11 +252,11 @@ GLOBAL_ENTRY(kvm_asm_rsm)
157#ifndef ACCE_RSM 252#ifndef ACCE_RSM
158 br.many kvm_virtualization_fault_back 253 br.many kvm_virtualization_fault_back
159#endif 254#endif
160 add r16=VMM_VPD_BASE_OFFSET,r21 255 VMX_VPS_SYNC_READ
256 ;;
161 extr.u r26=r25,6,21 257 extr.u r26=r25,6,21
162 extr.u r27=r25,31,2 258 extr.u r27=r25,31,2
163 ;; 259 ;;
164 ld8 r16=[r16]
165 extr.u r28=r25,36,1 260 extr.u r28=r25,36,1
166 dep r26=r27,r26,21,2 261 dep r26=r27,r26,21,2
167 ;; 262 ;;
@@ -196,7 +291,7 @@ GLOBAL_ENTRY(kvm_asm_rsm)
196 tbit.nz p6,p0=r23,0 291 tbit.nz p6,p0=r23,0
197 ;; 292 ;;
198 tbit.z.or p6,p0=r26,IA64_PSR_DT_BIT 293 tbit.z.or p6,p0=r26,IA64_PSR_DT_BIT
199 (p6) br.dptk kvm_resume_to_guest 294 (p6) br.dptk kvm_resume_to_guest_with_sync
200 ;; 295 ;;
201 add r26=VMM_VCPU_META_RR0_OFFSET,r21 296 add r26=VMM_VCPU_META_RR0_OFFSET,r21
202 add r27=VMM_VCPU_META_RR0_OFFSET+8,r21 297 add r27=VMM_VCPU_META_RR0_OFFSET+8,r21
@@ -212,7 +307,7 @@ GLOBAL_ENTRY(kvm_asm_rsm)
212 mov rr[r28]=r27 307 mov rr[r28]=r27
213 ;; 308 ;;
214 srlz.d 309 srlz.d
215 br.many kvm_resume_to_guest 310 br.many kvm_resume_to_guest_with_sync
216END(kvm_asm_rsm) 311END(kvm_asm_rsm)
217 312
218 313
@@ -221,11 +316,11 @@ GLOBAL_ENTRY(kvm_asm_ssm)
221#ifndef ACCE_SSM 316#ifndef ACCE_SSM
222 br.many kvm_virtualization_fault_back 317 br.many kvm_virtualization_fault_back
223#endif 318#endif
224 add r16=VMM_VPD_BASE_OFFSET,r21 319 VMX_VPS_SYNC_READ
320 ;;
225 extr.u r26=r25,6,21 321 extr.u r26=r25,6,21
226 extr.u r27=r25,31,2 322 extr.u r27=r25,31,2
227 ;; 323 ;;
228 ld8 r16=[r16]
229 extr.u r28=r25,36,1 324 extr.u r28=r25,36,1
230 dep r26=r27,r26,21,2 325 dep r26=r27,r26,21,2
231 ;; //r26 is imm24 326 ;; //r26 is imm24
@@ -271,7 +366,7 @@ kvm_asm_ssm_1:
271 tbit.nz p6,p0=r29,IA64_PSR_I_BIT 366 tbit.nz p6,p0=r29,IA64_PSR_I_BIT
272 ;; 367 ;;
273 tbit.z.or p6,p0=r19,IA64_PSR_I_BIT 368 tbit.z.or p6,p0=r19,IA64_PSR_I_BIT
274 (p6) br.dptk kvm_resume_to_guest 369 (p6) br.dptk kvm_resume_to_guest_with_sync
275 ;; 370 ;;
276 add r29=VPD_VTPR_START_OFFSET,r16 371 add r29=VPD_VTPR_START_OFFSET,r16
277 add r30=VPD_VHPI_START_OFFSET,r16 372 add r30=VPD_VHPI_START_OFFSET,r16
@@ -286,7 +381,7 @@ kvm_asm_ssm_1:
286 ;; 381 ;;
287 cmp.gt p6,p0=r30,r17 382 cmp.gt p6,p0=r30,r17
288 (p6) br.dpnt.few kvm_asm_dispatch_vexirq 383 (p6) br.dpnt.few kvm_asm_dispatch_vexirq
289 br.many kvm_resume_to_guest 384 br.many kvm_resume_to_guest_with_sync
290END(kvm_asm_ssm) 385END(kvm_asm_ssm)
291 386
292 387
@@ -295,10 +390,9 @@ GLOBAL_ENTRY(kvm_asm_mov_to_psr)
295#ifndef ACCE_MOV_TO_PSR 390#ifndef ACCE_MOV_TO_PSR
296 br.many kvm_virtualization_fault_back 391 br.many kvm_virtualization_fault_back
297#endif 392#endif
298 add r16=VMM_VPD_BASE_OFFSET,r21 393 VMX_VPS_SYNC_READ
299 extr.u r26=r25,13,7 //r2
300 ;; 394 ;;
301 ld8 r16=[r16] 395 extr.u r26=r25,13,7 //r2
302 addl r20=@gprel(asm_mov_from_reg),gp 396 addl r20=@gprel(asm_mov_from_reg),gp
303 ;; 397 ;;
304 adds r30=kvm_asm_mov_to_psr_back-asm_mov_from_reg,r20 398 adds r30=kvm_asm_mov_to_psr_back-asm_mov_from_reg,r20
@@ -374,7 +468,7 @@ kvm_asm_mov_to_psr_1:
374 ;; 468 ;;
375 tbit.nz.or p6,p0=r17,IA64_PSR_I_BIT 469 tbit.nz.or p6,p0=r17,IA64_PSR_I_BIT
376 tbit.z.or p6,p0=r30,IA64_PSR_I_BIT 470 tbit.z.or p6,p0=r30,IA64_PSR_I_BIT
377 (p6) br.dpnt.few kvm_resume_to_guest 471 (p6) br.dpnt.few kvm_resume_to_guest_with_sync
378 ;; 472 ;;
379 add r29=VPD_VTPR_START_OFFSET,r16 473 add r29=VPD_VTPR_START_OFFSET,r16
380 add r30=VPD_VHPI_START_OFFSET,r16 474 add r30=VPD_VHPI_START_OFFSET,r16
@@ -389,13 +483,29 @@ kvm_asm_mov_to_psr_1:
389 ;; 483 ;;
390 cmp.gt p6,p0=r30,r17 484 cmp.gt p6,p0=r30,r17
391 (p6) br.dpnt.few kvm_asm_dispatch_vexirq 485 (p6) br.dpnt.few kvm_asm_dispatch_vexirq
392 br.many kvm_resume_to_guest 486 br.many kvm_resume_to_guest_with_sync
393END(kvm_asm_mov_to_psr) 487END(kvm_asm_mov_to_psr)
394 488
395 489
396ENTRY(kvm_asm_dispatch_vexirq) 490ENTRY(kvm_asm_dispatch_vexirq)
397//increment iip 491//increment iip
492 mov r17 = b0
493 mov r18 = r31
494{.mii
495 add r25=VMM_VPD_BASE_OFFSET,r21
496 nop 0x0
497 mov r24 = ip
498 ;;
499}
500{.mmb
501 add r24 = 0x20, r24
502 ld8 r25 = [r25]
503 br.sptk.many kvm_vps_sync_write
504}
505 mov b0 =r17
398 mov r16=cr.ipsr 506 mov r16=cr.ipsr
507 mov r31 = r18
508 mov r19 = 37
399 ;; 509 ;;
400 extr.u r17=r16,IA64_PSR_RI_BIT,2 510 extr.u r17=r16,IA64_PSR_RI_BIT,2
401 tbit.nz p6,p7=r16,IA64_PSR_RI_BIT+1 511 tbit.nz p6,p7=r16,IA64_PSR_RI_BIT+1
@@ -435,25 +545,31 @@ GLOBAL_ENTRY(kvm_asm_thash)
435 ;; 545 ;;
436kvm_asm_thash_back1: 546kvm_asm_thash_back1:
437 shr.u r23=r19,61 // get RR number 547 shr.u r23=r19,61 // get RR number
438 adds r25=VMM_VCPU_VRR0_OFFSET,r21 // get vcpu->arch.vrr[0]'s addr 548 adds r28=VMM_VCPU_VRR0_OFFSET,r21 // get vcpu->arch.vrr[0]'s addr
439 adds r16=VMM_VPD_VPTA_OFFSET,r16 // get vpta 549 adds r16=VMM_VPD_VPTA_OFFSET,r16 // get vpta
440 ;; 550 ;;
441 shladd r27=r23,3,r25 // get vcpu->arch.vrr[r23]'s addr 551 shladd r27=r23,3,r28 // get vcpu->arch.vrr[r23]'s addr
442 ld8 r17=[r16] // get PTA 552 ld8 r17=[r16] // get PTA
443 mov r26=1 553 mov r26=1
444 ;; 554 ;;
445 extr.u r29=r17,2,6 // get pta.size 555 extr.u r29=r17,2,6 // get pta.size
446 ld8 r25=[r27] // get vcpu->arch.vrr[r23]'s value 556 ld8 r28=[r27] // get vcpu->arch.vrr[r23]'s value
447 ;; 557 ;;
448 extr.u r25=r25,2,6 // get rr.ps 558 mov b0=r24
559 //Fallback to C if pta.vf is set
560 tbit.nz p6,p0=r17, 8
561 ;;
562 (p6) mov r24=EVENT_THASH
563 (p6) br.cond.dpnt.many kvm_virtualization_fault_back
564 extr.u r28=r28,2,6 // get rr.ps
449 shl r22=r26,r29 // 1UL << pta.size 565 shl r22=r26,r29 // 1UL << pta.size
450 ;; 566 ;;
451 shr.u r23=r19,r25 // vaddr >> rr.ps 567 shr.u r23=r19,r28 // vaddr >> rr.ps
452 adds r26=3,r29 // pta.size + 3 568 adds r26=3,r29 // pta.size + 3
453 shl r27=r17,3 // pta << 3 569 shl r27=r17,3 // pta << 3
454 ;; 570 ;;
455 shl r23=r23,3 // (vaddr >> rr.ps) << 3 571 shl r23=r23,3 // (vaddr >> rr.ps) << 3
456 shr.u r27=r27,r26 // (pta << 3) >> (pta.size+3) 572 shr.u r27=r27,r26 // (pta << 3) >> (pta.size+3)
457 movl r16=7<<61 573 movl r16=7<<61
458 ;; 574 ;;
459 adds r22=-1,r22 // (1UL << pta.size) - 1 575 adds r22=-1,r22 // (1UL << pta.size) - 1
@@ -724,6 +840,29 @@ END(asm_mov_from_reg)
724 * r31: pr 840 * r31: pr
725 * r24: b0 841 * r24: b0
726 */ 842 */
843ENTRY(kvm_resume_to_guest_with_sync)
844 adds r19=VMM_VPD_BASE_OFFSET,r21
845 mov r16 = r31
846 mov r17 = r24
847 ;;
848{.mii
849 ld8 r25 =[r19]
850 nop 0x0
851 mov r24 = ip
852 ;;
853}
854{.mmb
855 add r24 =0x20, r24
856 nop 0x0
857 br.sptk.many kvm_vps_sync_write
858}
859
860 mov r31 = r16
861 mov r24 =r17
862 ;;
863 br.sptk.many kvm_resume_to_guest
864END(kvm_resume_to_guest_with_sync)
865
727ENTRY(kvm_resume_to_guest) 866ENTRY(kvm_resume_to_guest)
728 adds r16 = VMM_VCPU_SAVED_GP_OFFSET,r21 867 adds r16 = VMM_VCPU_SAVED_GP_OFFSET,r21
729 ;; 868 ;;
diff --git a/arch/ia64/kvm/process.c b/arch/ia64/kvm/process.c
index 5a33f7ed29a0..3417783ae164 100644
--- a/arch/ia64/kvm/process.c
+++ b/arch/ia64/kvm/process.c
@@ -962,9 +962,9 @@ static void kvm_do_resume_op(struct kvm_vcpu *vcpu)
962void vmm_transition(struct kvm_vcpu *vcpu) 962void vmm_transition(struct kvm_vcpu *vcpu)
963{ 963{
964 ia64_call_vsa(PAL_VPS_SAVE, (unsigned long)vcpu->arch.vpd, 964 ia64_call_vsa(PAL_VPS_SAVE, (unsigned long)vcpu->arch.vpd,
965 0, 0, 0, 0, 0, 0); 965 1, 0, 0, 0, 0, 0);
966 vmm_trampoline(&vcpu->arch.guest, &vcpu->arch.host); 966 vmm_trampoline(&vcpu->arch.guest, &vcpu->arch.host);
967 ia64_call_vsa(PAL_VPS_RESTORE, (unsigned long)vcpu->arch.vpd, 967 ia64_call_vsa(PAL_VPS_RESTORE, (unsigned long)vcpu->arch.vpd,
968 0, 0, 0, 0, 0, 0); 968 1, 0, 0, 0, 0, 0);
969 kvm_do_resume_op(vcpu); 969 kvm_do_resume_op(vcpu);
970} 970}
diff --git a/arch/ia64/kvm/vcpu.h b/arch/ia64/kvm/vcpu.h
index b0fcfb62c49e..341e3fee280c 100644
--- a/arch/ia64/kvm/vcpu.h
+++ b/arch/ia64/kvm/vcpu.h
@@ -313,21 +313,21 @@ static inline void vcpu_set_tr(struct thash_data *trp, u64 pte, u64 itir,
313 trp->rid = rid; 313 trp->rid = rid;
314} 314}
315 315
316extern u64 kvm_lookup_mpa(u64 gpfn); 316extern u64 kvm_get_mpt_entry(u64 gpfn);
317extern u64 kvm_gpa_to_mpa(u64 gpa);
318
319/* Return I/O type if trye */
320#define __gpfn_is_io(gpfn) \
321 ({ \
322 u64 pte, ret = 0; \
323 pte = kvm_lookup_mpa(gpfn); \
324 if (!(pte & GPFN_INV_MASK)) \
325 ret = pte & GPFN_IO_MASK; \
326 ret; \
327 })
328 317
318/* Return I/ */
319static inline u64 __gpfn_is_io(u64 gpfn)
320{
321 u64 pte;
322 pte = kvm_get_mpt_entry(gpfn);
323 if (!(pte & GPFN_INV_MASK)) {
324 pte = pte & GPFN_IO_MASK;
325 if (pte != GPFN_PHYS_MMIO)
326 return pte;
327 }
328 return 0;
329}
329#endif 330#endif
330
331#define IA64_NO_FAULT 0 331#define IA64_NO_FAULT 0
332#define IA64_FAULT 1 332#define IA64_FAULT 1
333 333
diff --git a/arch/ia64/kvm/vmm_ivt.S b/arch/ia64/kvm/vmm_ivt.S
index 3ee5f481c06d..c1d7251a1480 100644
--- a/arch/ia64/kvm/vmm_ivt.S
+++ b/arch/ia64/kvm/vmm_ivt.S
@@ -1261,11 +1261,6 @@ kvm_rse_clear_invalid:
1261 adds r19=VMM_VPD_VPSR_OFFSET,r18 1261 adds r19=VMM_VPD_VPSR_OFFSET,r18
1262 ;; 1262 ;;
1263 ld8 r19=[r19] //vpsr 1263 ld8 r19=[r19] //vpsr
1264 adds r20=VMM_VCPU_VSA_BASE_OFFSET,r21
1265 ;;
1266 ld8 r20=[r20]
1267 ;;
1268//vsa_sync_write_start
1269 mov r25=r18 1264 mov r25=r18
1270 adds r16= VMM_VCPU_GP_OFFSET,r21 1265 adds r16= VMM_VCPU_GP_OFFSET,r21
1271 ;; 1266 ;;
@@ -1274,10 +1269,7 @@ kvm_rse_clear_invalid:
1274 ;; 1269 ;;
1275 add r24=r24,r16 1270 add r24=r24,r16
1276 ;; 1271 ;;
1277 add r16=PAL_VPS_SYNC_WRITE,r20 1272 br.sptk.many kvm_vps_sync_write // call the service
1278 ;;
1279 mov b0=r16
1280 br.cond.sptk b0 // call the service
1281 ;; 1273 ;;
1282END(ia64_leave_hypervisor) 1274END(ia64_leave_hypervisor)
1283// fall through 1275// fall through
@@ -1288,28 +1280,15 @@ GLOBAL_ENTRY(ia64_vmm_entry)
1288 * r17:cr.isr 1280 * r17:cr.isr
1289 * r18:vpd 1281 * r18:vpd
1290 * r19:vpsr 1282 * r19:vpsr
1291 * r20:__vsa_base
1292 * r22:b0 1283 * r22:b0
1293 * r23:predicate 1284 * r23:predicate
1294 */ 1285 */
1295 mov r24=r22 1286 mov r24=r22
1296 mov r25=r18 1287 mov r25=r18
1297 tbit.nz p1,p2 = r19,IA64_PSR_IC_BIT // p1=vpsr.ic 1288 tbit.nz p1,p2 = r19,IA64_PSR_IC_BIT // p1=vpsr.ic
1289 (p1) br.cond.sptk.few kvm_vps_resume_normal
1290 (p2) br.cond.sptk.many kvm_vps_resume_handler
1298 ;; 1291 ;;
1299 (p1) add r29=PAL_VPS_RESUME_NORMAL,r20
1300 (p1) br.sptk.many ia64_vmm_entry_out
1301 ;;
1302 tbit.nz p1,p2 = r17,IA64_ISR_IR_BIT //p1=cr.isr.ir
1303 ;;
1304 (p1) add r29=PAL_VPS_RESUME_NORMAL,r20
1305 (p2) add r29=PAL_VPS_RESUME_HANDLER,r20
1306 (p2) ld8 r26=[r25]
1307 ;;
1308ia64_vmm_entry_out:
1309 mov pr=r23,-2
1310 mov b0=r29
1311 ;;
1312 br.cond.sptk b0 // call pal service
1313END(ia64_vmm_entry) 1292END(ia64_vmm_entry)
1314 1293
1315 1294
@@ -1376,6 +1355,9 @@ GLOBAL_ENTRY(vmm_reset_entry)
1376 //set up ipsr, iip, vpd.vpsr, dcr 1355 //set up ipsr, iip, vpd.vpsr, dcr
1377 // For IPSR: it/dt/rt=1, i/ic=1, si=1, vm/bn=1 1356 // For IPSR: it/dt/rt=1, i/ic=1, si=1, vm/bn=1
1378 // For DCR: all bits 0 1357 // For DCR: all bits 0
1358 bsw.0
1359 ;;
1360 mov r21 =r13
1379 adds r14=-VMM_PT_REGS_SIZE, r12 1361 adds r14=-VMM_PT_REGS_SIZE, r12
1380 ;; 1362 ;;
1381 movl r6=0x501008826000 // IPSR dt/rt/it:1;i/ic:1, si:1, vm/bn:1 1363 movl r6=0x501008826000 // IPSR dt/rt/it:1;i/ic:1, si:1, vm/bn:1
@@ -1387,12 +1369,6 @@ GLOBAL_ENTRY(vmm_reset_entry)
1387 ;; 1369 ;;
1388 srlz.i 1370 srlz.i
1389 ;; 1371 ;;
1390 bsw.0
1391 ;;
1392 mov r21 =r13
1393 ;;
1394 bsw.1
1395 ;;
1396 mov ar.rsc = 0 1372 mov ar.rsc = 0
1397 ;; 1373 ;;
1398 flushrs 1374 flushrs
@@ -1406,12 +1382,9 @@ GLOBAL_ENTRY(vmm_reset_entry)
1406 ld8 r1 = [r20] 1382 ld8 r1 = [r20]
1407 ;; 1383 ;;
1408 mov cr.iip=r4 1384 mov cr.iip=r4
1409 ;;
1410 adds r16=VMM_VPD_BASE_OFFSET,r13 1385 adds r16=VMM_VPD_BASE_OFFSET,r13
1411 adds r20=VMM_VCPU_VSA_BASE_OFFSET,r13
1412 ;; 1386 ;;
1413 ld8 r18=[r16] 1387 ld8 r18=[r16]
1414 ld8 r20=[r20]
1415 ;; 1388 ;;
1416 adds r19=VMM_VPD_VPSR_OFFSET,r18 1389 adds r19=VMM_VPD_VPSR_OFFSET,r18
1417 ;; 1390 ;;
diff --git a/arch/ia64/kvm/vtlb.c b/arch/ia64/kvm/vtlb.c
index def4576d22b1..e22b93361e08 100644
--- a/arch/ia64/kvm/vtlb.c
+++ b/arch/ia64/kvm/vtlb.c
@@ -390,7 +390,7 @@ void thash_purge_entries_remote(struct kvm_vcpu *v, u64 va, u64 ps)
390 390
391u64 translate_phy_pte(u64 *pte, u64 itir, u64 va) 391u64 translate_phy_pte(u64 *pte, u64 itir, u64 va)
392{ 392{
393 u64 ps, ps_mask, paddr, maddr; 393 u64 ps, ps_mask, paddr, maddr, io_mask;
394 union pte_flags phy_pte; 394 union pte_flags phy_pte;
395 395
396 ps = itir_ps(itir); 396 ps = itir_ps(itir);
@@ -398,8 +398,9 @@ u64 translate_phy_pte(u64 *pte, u64 itir, u64 va)
398 phy_pte.val = *pte; 398 phy_pte.val = *pte;
399 paddr = *pte; 399 paddr = *pte;
400 paddr = ((paddr & _PAGE_PPN_MASK) & ps_mask) | (va & ~ps_mask); 400 paddr = ((paddr & _PAGE_PPN_MASK) & ps_mask) | (va & ~ps_mask);
401 maddr = kvm_lookup_mpa(paddr >> PAGE_SHIFT); 401 maddr = kvm_get_mpt_entry(paddr >> PAGE_SHIFT);
402 if (maddr & GPFN_IO_MASK) { 402 io_mask = maddr & GPFN_IO_MASK;
403 if (io_mask && (io_mask != GPFN_PHYS_MMIO)) {
403 *pte |= VTLB_PTE_IO; 404 *pte |= VTLB_PTE_IO;
404 return -1; 405 return -1;
405 } 406 }
@@ -418,7 +419,7 @@ int thash_purge_and_insert(struct kvm_vcpu *v, u64 pte, u64 itir,
418 u64 ifa, int type) 419 u64 ifa, int type)
419{ 420{
420 u64 ps; 421 u64 ps;
421 u64 phy_pte; 422 u64 phy_pte, io_mask, index;
422 union ia64_rr vrr, mrr; 423 union ia64_rr vrr, mrr;
423 int ret = 0; 424 int ret = 0;
424 425
@@ -426,13 +427,16 @@ int thash_purge_and_insert(struct kvm_vcpu *v, u64 pte, u64 itir,
426 vrr.val = vcpu_get_rr(v, ifa); 427 vrr.val = vcpu_get_rr(v, ifa);
427 mrr.val = ia64_get_rr(ifa); 428 mrr.val = ia64_get_rr(ifa);
428 429
430 index = (pte & _PAGE_PPN_MASK) >> PAGE_SHIFT;
431 io_mask = kvm_get_mpt_entry(index) & GPFN_IO_MASK;
429 phy_pte = translate_phy_pte(&pte, itir, ifa); 432 phy_pte = translate_phy_pte(&pte, itir, ifa);
430 433
431 /* Ensure WB attribute if pte is related to a normal mem page, 434 /* Ensure WB attribute if pte is related to a normal mem page,
432 * which is required by vga acceleration since qemu maps shared 435 * which is required by vga acceleration since qemu maps shared
433 * vram buffer with WB. 436 * vram buffer with WB.
434 */ 437 */
435 if (!(pte & VTLB_PTE_IO) && ((pte & _PAGE_MA_MASK) != _PAGE_MA_NAT)) { 438 if (!(pte & VTLB_PTE_IO) && ((pte & _PAGE_MA_MASK) != _PAGE_MA_NAT) &&
439 io_mask != GPFN_PHYS_MMIO) {
436 pte &= ~_PAGE_MA_MASK; 440 pte &= ~_PAGE_MA_MASK;
437 phy_pte &= ~_PAGE_MA_MASK; 441 phy_pte &= ~_PAGE_MA_MASK;
438 } 442 }
@@ -566,12 +570,19 @@ void thash_init(struct thash_cb *hcb, u64 sz)
566 } 570 }
567} 571}
568 572
569u64 kvm_lookup_mpa(u64 gpfn) 573u64 kvm_get_mpt_entry(u64 gpfn)
570{ 574{
571 u64 *base = (u64 *) KVM_P2M_BASE; 575 u64 *base = (u64 *) KVM_P2M_BASE;
572 return *(base + gpfn); 576 return *(base + gpfn);
573} 577}
574 578
579u64 kvm_lookup_mpa(u64 gpfn)
580{
581 u64 maddr;
582 maddr = kvm_get_mpt_entry(gpfn);
583 return maddr&_PAGE_PPN_MASK;
584}
585
575u64 kvm_gpa_to_mpa(u64 gpa) 586u64 kvm_gpa_to_mpa(u64 gpa)
576{ 587{
577 u64 pte = kvm_lookup_mpa(gpa >> PAGE_SHIFT); 588 u64 pte = kvm_lookup_mpa(gpa >> PAGE_SHIFT);
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
index 5be4faaf5b1c..7103d91e1a2f 100644
--- a/arch/m32r/kernel/process.c
+++ b/arch/m32r/kernel/process.c
@@ -11,7 +11,7 @@
11#undef DEBUG_PROCESS 11#undef DEBUG_PROCESS
12#ifdef DEBUG_PROCESS 12#ifdef DEBUG_PROCESS
13#define DPRINTK(fmt, args...) printk("%s:%d:%s: " fmt, __FILE__, __LINE__, \ 13#define DPRINTK(fmt, args...) printk("%s:%d:%s: " fmt, __FILE__, __LINE__, \
14 __FUNCTION__, ##args) 14 __func__, ##args)
15#else 15#else
16#define DPRINTK(fmt, args...) 16#define DPRINTK(fmt, args...)
17#endif 17#endif
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index cbc3c4c54566..7daf897292cf 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -111,9 +111,9 @@ unsigned long __init setup_memory(void)
111 initrd_start, INITRD_SIZE); 111 initrd_start, INITRD_SIZE);
112 } else { 112 } else {
113 printk("initrd extends beyond end of memory " 113 printk("initrd extends beyond end of memory "
114 "(0x%08lx > 0x%08lx)\ndisabling initrd\n", 114 "(0x%08lx > 0x%08llx)\ndisabling initrd\n",
115 INITRD_START + INITRD_SIZE, 115 INITRD_START + INITRD_SIZE,
116 PFN_PHYS(max_low_pfn)); 116 (unsigned long long)PFN_PHYS(max_low_pfn));
117 117
118 initrd_start = 0; 118 initrd_start = 0;
119 } 119 }
diff --git a/arch/m68knommu/include/asm/elf.h b/arch/m68knommu/include/asm/elf.h
index 27f0ec70fba8..b8046837f384 100644
--- a/arch/m68knommu/include/asm/elf.h
+++ b/arch/m68knommu/include/asm/elf.h
@@ -105,6 +105,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t;
105 105
106#define ELF_PLATFORM (NULL) 106#define ELF_PLATFORM (NULL)
107 107
108#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 108#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
109 109
110#endif 110#endif
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index f69f7acba637..a8eac1697b3d 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -247,10 +247,8 @@ extern struct mips_abi mips_abi_n32;
247 247
248#ifdef CONFIG_32BIT 248#ifdef CONFIG_32BIT
249 249
250#define SET_PERSONALITY(ex, ibcs2) \ 250#define SET_PERSONALITY(ex) \
251do { \ 251do { \
252 if (ibcs2) \
253 set_personality(PER_SVR4); \
254 set_personality(PER_LINUX); \ 252 set_personality(PER_LINUX); \
255 \ 253 \
256 current->thread.abi = &mips_abi; \ 254 current->thread.abi = &mips_abi; \
@@ -296,7 +294,7 @@ do { \
296#define __SET_PERSONALITY32(ex) do { } while (0) 294#define __SET_PERSONALITY32(ex) do { } while (0)
297#endif 295#endif
298 296
299#define SET_PERSONALITY(ex, ibcs2) \ 297#define SET_PERSONALITY(ex) \
300do { \ 298do { \
301 clear_thread_flag(TIF_32BIT_REGS); \ 299 clear_thread_flag(TIF_32BIT_REGS); \
302 clear_thread_flag(TIF_32BIT_ADDR); \ 300 clear_thread_flag(TIF_32BIT_ADDR); \
@@ -306,9 +304,7 @@ do { \
306 else \ 304 else \
307 current->thread.abi = &mips_abi; \ 305 current->thread.abi = &mips_abi; \
308 \ 306 \
309 if (ibcs2) \ 307 if (current->personality != PER_LINUX32) \
310 set_personality(PER_SVR4); \
311 else if (current->personality != PER_LINUX32) \
312 set_personality(PER_LINUX); \ 308 set_personality(PER_LINUX); \
313} while (0) 309} while (0)
314 310
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 2fefb14414b7..aa2c55e3b55f 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -63,41 +63,6 @@
63#define merge_64(r1, r2) ((((r2) & 0xffffffffUL) << 32) + ((r1) & 0xffffffffUL)) 63#define merge_64(r1, r2) ((((r2) & 0xffffffffUL) << 32) + ((r1) & 0xffffffffUL))
64#endif 64#endif
65 65
66/*
67 * Revalidate the inode. This is required for proper NFS attribute caching.
68 */
69
70int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
71{
72 struct compat_stat tmp;
73
74 if (!new_valid_dev(stat->dev) || !new_valid_dev(stat->rdev))
75 return -EOVERFLOW;
76
77 memset(&tmp, 0, sizeof(tmp));
78 tmp.st_dev = new_encode_dev(stat->dev);
79 tmp.st_ino = stat->ino;
80 if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
81 return -EOVERFLOW;
82 tmp.st_mode = stat->mode;
83 tmp.st_nlink = stat->nlink;
84 SET_UID(tmp.st_uid, stat->uid);
85 SET_GID(tmp.st_gid, stat->gid);
86 tmp.st_rdev = new_encode_dev(stat->rdev);
87 tmp.st_size = stat->size;
88 tmp.st_atime = stat->atime.tv_sec;
89 tmp.st_mtime = stat->mtime.tv_sec;
90 tmp.st_ctime = stat->ctime.tv_sec;
91#ifdef STAT_HAVE_NSEC
92 tmp.st_atime_nsec = stat->atime.tv_nsec;
93 tmp.st_mtime_nsec = stat->mtime.tv_nsec;
94 tmp.st_ctime_nsec = stat->ctime.tv_nsec;
95#endif
96 tmp.st_blocks = stat->blocks;
97 tmp.st_blksize = stat->blksize;
98 return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
99}
100
101asmlinkage unsigned long 66asmlinkage unsigned long
102sys32_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 67sys32_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
103 unsigned long flags, unsigned long fd, unsigned long pgoff) 68 unsigned long flags, unsigned long fd, unsigned long pgoff)
@@ -168,72 +133,6 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long __dummy,
168 return sys_ftruncate(fd, merge_64(a2, a3)); 133 return sys_ftruncate(fd, merge_64(a2, a3));
169} 134}
170 135
171static inline long
172get_tv32(struct timeval *o, struct compat_timeval __user *i)
173{
174 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
175 (__get_user(o->tv_sec, &i->tv_sec) |
176 __get_user(o->tv_usec, &i->tv_usec)));
177}
178
179static inline long
180put_tv32(struct compat_timeval __user *o, struct timeval *i)
181{
182 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
183 (__put_user(i->tv_sec, &o->tv_sec) |
184 __put_user(i->tv_usec, &o->tv_usec)));
185}
186
187extern struct timezone sys_tz;
188
189asmlinkage int
190sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
191{
192 if (tv) {
193 struct timeval ktv;
194 do_gettimeofday(&ktv);
195 if (put_tv32(tv, &ktv))
196 return -EFAULT;
197 }
198 if (tz) {
199 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
200 return -EFAULT;
201 }
202 return 0;
203}
204
205static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
206{
207 long usec;
208
209 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
210 return -EFAULT;
211 if (__get_user(o->tv_sec, &i->tv_sec))
212 return -EFAULT;
213 if (__get_user(usec, &i->tv_usec))
214 return -EFAULT;
215 o->tv_nsec = usec * 1000;
216 return 0;
217}
218
219asmlinkage int
220sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
221{
222 struct timespec kts;
223 struct timezone ktz;
224
225 if (tv) {
226 if (get_ts32(&kts, tv))
227 return -EFAULT;
228 }
229 if (tz) {
230 if (copy_from_user(&ktz, tz, sizeof(ktz)))
231 return -EFAULT;
232 }
233
234 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
235}
236
237asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high, 136asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high,
238 unsigned int offset_low, loff_t __user * result, 137 unsigned int offset_low, loff_t __user * result,
239 unsigned int origin) 138 unsigned int origin)
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index dfd868b68364..4ce93aa7b372 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -522,8 +522,8 @@ static int __init rtlx_module_init(void)
522 atomic_set(&channel_wqs[i].in_open, 0); 522 atomic_set(&channel_wqs[i].in_open, 0);
523 mutex_init(&channel_wqs[i].mutex); 523 mutex_init(&channel_wqs[i].mutex);
524 524
525 dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i), 525 dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
526 NULL, "%s%d", module_name, i); 526 "%s%d", module_name, i);
527 if (IS_ERR(dev)) { 527 if (IS_ERR(dev)) {
528 err = PTR_ERR(dev); 528 err = PTR_ERR(dev);
529 goto out_chrdev; 529 goto out_chrdev;
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 324c5499dec2..e266b3aa6560 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -214,7 +214,7 @@ EXPORT(sysn32_call_table)
214 PTR sys_fchown 214 PTR sys_fchown
215 PTR sys_lchown 215 PTR sys_lchown
216 PTR sys_umask 216 PTR sys_umask
217 PTR sys32_gettimeofday 217 PTR compat_sys_gettimeofday
218 PTR compat_sys_getrlimit /* 6095 */ 218 PTR compat_sys_getrlimit /* 6095 */
219 PTR compat_sys_getrusage 219 PTR compat_sys_getrusage
220 PTR compat_sys_sysinfo 220 PTR compat_sys_sysinfo
@@ -279,7 +279,7 @@ EXPORT(sysn32_call_table)
279 PTR sys_chroot 279 PTR sys_chroot
280 PTR sys_sync 280 PTR sys_sync
281 PTR sys_acct 281 PTR sys_acct
282 PTR sys32_settimeofday 282 PTR compat_sys_settimeofday
283 PTR compat_sys_mount /* 6160 */ 283 PTR compat_sys_mount /* 6160 */
284 PTR sys_umount 284 PTR sys_umount
285 PTR sys_swapon 285 PTR sys_swapon
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 85fedac99a57..6c7ef8313ebd 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -283,8 +283,8 @@ sys_call_table:
283 PTR compat_sys_setrlimit /* 4075 */ 283 PTR compat_sys_setrlimit /* 4075 */
284 PTR compat_sys_getrlimit 284 PTR compat_sys_getrlimit
285 PTR compat_sys_getrusage 285 PTR compat_sys_getrusage
286 PTR sys32_gettimeofday 286 PTR compat_sys_gettimeofday
287 PTR sys32_settimeofday 287 PTR compat_sys_settimeofday
288 PTR sys_getgroups /* 4080 */ 288 PTR sys_getgroups /* 4080 */
289 PTR sys_setgroups 289 PTR sys_setgroups
290 PTR sys_ni_syscall /* old_select */ 290 PTR sys_ni_syscall /* old_select */
diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c
index 866881ec0cf8..8f88886feb12 100644
--- a/arch/mips/lasat/sysctl.c
+++ b/arch/mips/lasat/sysctl.c
@@ -38,14 +38,13 @@
38#endif 38#endif
39 39
40/* Strategy function to write EEPROM after changing string entry */ 40/* Strategy function to write EEPROM after changing string entry */
41int sysctl_lasatstring(ctl_table *table, int *name, int nlen, 41int sysctl_lasatstring(ctl_table *table,
42 void *oldval, size_t *oldlenp, 42 void *oldval, size_t *oldlenp,
43 void *newval, size_t newlen) 43 void *newval, size_t newlen)
44{ 44{
45 int r; 45 int r;
46 46
47 r = sysctl_string(table, name, 47 r = sysctl_string(table, oldval, oldlenp, newval, newlen);
48 nlen, oldval, oldlenp, newval, newlen);
49 if (r < 0) 48 if (r < 0)
50 return r; 49 return r;
51 50
@@ -113,13 +112,13 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
113#endif 112#endif
114 113
115/* Sysctl for setting the IP addresses */ 114/* Sysctl for setting the IP addresses */
116int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen, 115int sysctl_lasat_intvec(ctl_table *table,
117 void *oldval, size_t *oldlenp, 116 void *oldval, size_t *oldlenp,
118 void *newval, size_t newlen) 117 void *newval, size_t newlen)
119{ 118{
120 int r; 119 int r;
121 120
122 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 121 r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
123 if (r < 0) 122 if (r < 0)
124 return r; 123 return r;
125 124
@@ -131,7 +130,7 @@ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen,
131 130
132#ifdef CONFIG_DS1603 131#ifdef CONFIG_DS1603
133/* Same for RTC */ 132/* Same for RTC */
134int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen, 133int sysctl_lasat_rtc(ctl_table *table,
135 void *oldval, size_t *oldlenp, 134 void *oldval, size_t *oldlenp,
136 void *newval, size_t newlen) 135 void *newval, size_t newlen)
137{ 136{
@@ -140,7 +139,7 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
140 rtctmp = read_persistent_clock(); 139 rtctmp = read_persistent_clock();
141 if (rtctmp < 0) 140 if (rtctmp < 0)
142 rtctmp = 0; 141 rtctmp = 0;
143 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 142 r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
144 if (r < 0) 143 if (r < 0)
145 return r; 144 return r;
146 if (newval && newlen) 145 if (newval && newlen)
@@ -211,13 +210,13 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
211} 210}
212#endif 211#endif
213 212
214static int sysctl_lasat_prid(ctl_table *table, int *name, int nlen, 213static int sysctl_lasat_prid(ctl_table *table,
215 void *oldval, size_t *oldlenp, 214 void *oldval, size_t *oldlenp,
216 void *newval, size_t newlen) 215 void *newval, size_t newlen)
217{ 216{
218 int r; 217 int r;
219 218
220 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 219 r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
221 if (r < 0) 220 if (r < 0)
222 return r; 221 return r;
223 if (newval && newlen) { 222 if (newval && newlen) {
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index 66e3e3fb311f..637a194e5cd5 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -576,8 +576,7 @@ static int __init sbprof_tb_init(void)
576 576
577 tb_class = tbc; 577 tb_class = tbc;
578 578
579 dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), 579 dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
580 NULL, "tb");
581 if (IS_ERR(dev)) { 580 if (IS_ERR(dev)) {
582 err = PTR_ERR(dev); 581 err = PTR_ERR(dev);
583 goto out_class; 582 goto out_class;
diff --git a/arch/parisc/kernel/binfmt_elf32.c b/arch/parisc/kernel/binfmt_elf32.c
index ecb10a4f63c6..f61692d2b557 100644
--- a/arch/parisc/kernel/binfmt_elf32.c
+++ b/arch/parisc/kernel/binfmt_elf32.c
@@ -85,7 +85,7 @@ struct elf_prpsinfo32
85 * could set a processor dependent flag in the thread_struct. 85 * could set a processor dependent flag in the thread_struct.
86 */ 86 */
87 87
88#define SET_PERSONALITY(ex, ibcs2) \ 88#define SET_PERSONALITY(ex) \
89 set_thread_flag(TIF_32BIT); \ 89 set_thread_flag(TIF_32BIT); \
90 current->thread.map_base = DEFAULT_MAP_BASE32; \ 90 current->thread.map_base = DEFAULT_MAP_BASE32; \
91 current->thread.task_size = DEFAULT_TASK_SIZE32 \ 91 current->thread.task_size = DEFAULT_TASK_SIZE32 \
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index 71efd6a28e2a..0838155b7a88 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -179,111 +179,6 @@ asmlinkage long sys32_sched_rr_get_interval(pid_t pid,
179 return ret; 179 return ret;
180} 180}
181 181
182static int
183put_compat_timeval(struct compat_timeval __user *u, struct timeval *t)
184{
185 struct compat_timeval t32;
186 t32.tv_sec = t->tv_sec;
187 t32.tv_usec = t->tv_usec;
188 return copy_to_user(u, &t32, sizeof t32);
189}
190
191static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
192{
193 long usec;
194
195 if (__get_user(o->tv_sec, &i->tv_sec))
196 return -EFAULT;
197 if (__get_user(usec, &i->tv_usec))
198 return -EFAULT;
199 o->tv_nsec = usec * 1000;
200 return 0;
201}
202
203asmlinkage int
204sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
205{
206 extern void do_gettimeofday(struct timeval *tv);
207
208 if (tv) {
209 struct timeval ktv;
210 do_gettimeofday(&ktv);
211 if (put_compat_timeval(tv, &ktv))
212 return -EFAULT;
213 }
214 if (tz) {
215 extern struct timezone sys_tz;
216 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
217 return -EFAULT;
218 }
219 return 0;
220}
221
222asmlinkage
223int sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
224{
225 struct timespec kts;
226 struct timezone ktz;
227
228 if (tv) {
229 if (get_ts32(&kts, tv))
230 return -EFAULT;
231 }
232 if (tz) {
233 if (copy_from_user(&ktz, tz, sizeof(ktz)))
234 return -EFAULT;
235 }
236
237 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
238}
239
240int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
241{
242 compat_ino_t ino;
243 int err;
244
245 if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
246 !new_valid_dev(stat->rdev))
247 return -EOVERFLOW;
248
249 ino = stat->ino;
250 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
251 return -EOVERFLOW;
252
253 err = put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
254 err |= put_user(ino, &statbuf->st_ino);
255 err |= put_user(stat->mode, &statbuf->st_mode);
256 err |= put_user(stat->nlink, &statbuf->st_nlink);
257 err |= put_user(0, &statbuf->st_reserved1);
258 err |= put_user(0, &statbuf->st_reserved2);
259 err |= put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
260 err |= put_user(stat->size, &statbuf->st_size);
261 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
262 err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
263 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
264 err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
265 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
266 err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
267 err |= put_user(stat->blksize, &statbuf->st_blksize);
268 err |= put_user(stat->blocks, &statbuf->st_blocks);
269 err |= put_user(0, &statbuf->__unused1);
270 err |= put_user(0, &statbuf->__unused2);
271 err |= put_user(0, &statbuf->__unused3);
272 err |= put_user(0, &statbuf->__unused4);
273 err |= put_user(0, &statbuf->__unused5);
274 err |= put_user(0, &statbuf->st_fstype); /* not avail */
275 err |= put_user(0, &statbuf->st_realdev); /* not avail */
276 err |= put_user(0, &statbuf->st_basemode); /* not avail */
277 err |= put_user(0, &statbuf->st_spareshort);
278 err |= put_user(stat->uid, &statbuf->st_uid);
279 err |= put_user(stat->gid, &statbuf->st_gid);
280 err |= put_user(0, &statbuf->st_spare4[0]);
281 err |= put_user(0, &statbuf->st_spare4[1]);
282 err |= put_user(0, &statbuf->st_spare4[2]);
283
284 return err;
285}
286
287/*** copied from mips64 ***/ 182/*** copied from mips64 ***/
288/* 183/*
289 * Ooo, nasty. We need here to frob 32-bit unsigned longs to 184 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 6b5ac38f5a99..c7e59f548817 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -149,8 +149,8 @@
149 ENTRY_COMP(getrlimit) 149 ENTRY_COMP(getrlimit)
150 ENTRY_COMP(getrusage) 150 ENTRY_COMP(getrusage)
151 /* struct timeval and timezone are maybe?? consistent wide and narrow */ 151 /* struct timeval and timezone are maybe?? consistent wide and narrow */
152 ENTRY_DIFF(gettimeofday) 152 ENTRY_COMP(gettimeofday)
153 ENTRY_DIFF(settimeofday) 153 ENTRY_COMP(settimeofday)
154 ENTRY_SAME(getgroups) /* 80 */ 154 ENTRY_SAME(getgroups) /* 80 */
155 ENTRY_SAME(setgroups) 155 ENTRY_SAME(setgroups)
156 /* struct socketaddr... */ 156 /* struct socketaddr... */
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c171f5bcf258..380baa1780e9 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -22,6 +22,9 @@ config WORD_SIZE
22config PPC_MERGE 22config PPC_MERGE
23 def_bool y 23 def_bool y
24 24
25config ARCH_PHYS_ADDR_T_64BIT
26 def_bool PPC64 || PHYS_64BIT
27
25config MMU 28config MMU
26 bool 29 bool
27 default y 30 default y
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index 64c6ee22eefd..d812929390e4 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -232,7 +232,7 @@ typedef elf_vrregset_t elf_fpxregset_t;
232#endif /* __powerpc64__ */ 232#endif /* __powerpc64__ */
233 233
234#ifdef __powerpc64__ 234#ifdef __powerpc64__
235# define SET_PERSONALITY(ex, ibcs2) \ 235# define SET_PERSONALITY(ex) \
236do { \ 236do { \
237 unsigned long new_flags = 0; \ 237 unsigned long new_flags = 0; \
238 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 238 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
@@ -256,7 +256,7 @@ do { \
256# define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \ 256# define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \
257 (exec_stk != EXSTACK_DISABLE_X) : 0) 257 (exec_stk != EXSTACK_DISABLE_X) : 0)
258#else 258#else
259# define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 259# define SET_PERSONALITY(ex) set_personality(PER_LINUX)
260#endif /* __powerpc64__ */ 260#endif /* __powerpc64__ */
261 261
262extern int dcache_bsize; 262extern int dcache_bsize;
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 2655e2a4831e..34b52b7180cd 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -81,11 +81,17 @@ struct kvm_vcpu_arch {
81 struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; 81 struct tlbe shadow_tlb[PPC44x_TLB_SIZE];
82 /* Pages which are referenced in the shadow TLB. */ 82 /* Pages which are referenced in the shadow TLB. */
83 struct page *shadow_pages[PPC44x_TLB_SIZE]; 83 struct page *shadow_pages[PPC44x_TLB_SIZE];
84 /* Copy of the host's TLB. */ 84
85 struct tlbe host_tlb[PPC44x_TLB_SIZE]; 85 /* Track which TLB entries we've modified in the current exit. */
86 u8 shadow_tlb_mod[PPC44x_TLB_SIZE];
86 87
87 u32 host_stack; 88 u32 host_stack;
88 u32 host_pid; 89 u32 host_pid;
90 u32 host_dbcr0;
91 u32 host_dbcr1;
92 u32 host_dbcr2;
93 u32 host_iac[4];
94 u32 host_msr;
89 95
90 u64 fpr[32]; 96 u64 fpr[32];
91 u32 gpr[32]; 97 u32 gpr[32];
@@ -123,7 +129,11 @@ struct kvm_vcpu_arch {
123 u32 ivor[16]; 129 u32 ivor[16];
124 u32 ivpr; 130 u32 ivpr;
125 u32 pir; 131 u32 pir;
132
133 u32 shadow_pid;
126 u32 pid; 134 u32 pid;
135 u32 swap_pid;
136
127 u32 pvr; 137 u32 pvr;
128 u32 ccr0; 138 u32 ccr0;
129 u32 ccr1; 139 u32 ccr1;
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index a8b068792260..8931ba729d2b 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -64,6 +64,10 @@ extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn,
64extern void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr, 64extern void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr,
65 gva_t eend, u32 asid); 65 gva_t eend, u32 asid);
66extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); 66extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode);
67extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid);
68
69/* XXX Book E specific */
70extern void kvmppc_tlbe_set_modified(struct kvm_vcpu *vcpu, unsigned int i);
67 71
68extern void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu); 72extern void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu);
69 73
@@ -92,4 +96,12 @@ static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
92 kvm_vcpu_block(vcpu); 96 kvm_vcpu_block(vcpu);
93} 97}
94 98
99static inline void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 new_pid)
100{
101 if (vcpu->arch.pid != new_pid) {
102 vcpu->arch.pid = new_pid;
103 vcpu->arch.swap_pid = 1;
104 }
105}
106
95#endif /* __POWERPC_KVM_PPC_H__ */ 107#endif /* __POWERPC_KVM_PPC_H__ */
diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h
index a9a9262e84a3..c004c13f291e 100644
--- a/arch/powerpc/include/asm/types.h
+++ b/arch/powerpc/include/asm/types.h
@@ -48,13 +48,6 @@ typedef struct {
48 48
49typedef __vector128 vector128; 49typedef __vector128 vector128;
50 50
51/* Physical address used by some IO functions */
52#if defined(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT)
53typedef u64 phys_addr_t;
54#else
55typedef u32 phys_addr_t;
56#endif
57
58#if defined(__powerpc64__) || defined(CONFIG_PHYS_64BIT) 51#if defined(__powerpc64__) || defined(CONFIG_PHYS_64BIT)
59typedef u64 dma_addr_t; 52typedef u64 dma_addr_t;
60#else 53#else
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 09febc582584..75c5dd0138fd 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -359,8 +359,8 @@ int main(void)
359 359
360 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); 360 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack));
361 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 361 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
362 DEFINE(VCPU_HOST_TLB, offsetof(struct kvm_vcpu, arch.host_tlb));
363 DEFINE(VCPU_SHADOW_TLB, offsetof(struct kvm_vcpu, arch.shadow_tlb)); 362 DEFINE(VCPU_SHADOW_TLB, offsetof(struct kvm_vcpu, arch.shadow_tlb));
363 DEFINE(VCPU_SHADOW_MOD, offsetof(struct kvm_vcpu, arch.shadow_tlb_mod));
364 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); 364 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr));
365 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); 365 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr));
366 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); 366 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr));
@@ -372,7 +372,7 @@ int main(void)
372 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5)); 372 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5));
373 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); 373 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6));
374 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7)); 374 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7));
375 DEFINE(VCPU_PID, offsetof(struct kvm_vcpu, arch.pid)); 375 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid));
376 376
377 DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); 377 DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst));
378 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear)); 378 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 550a19399bfa..ea1ba89f9c90 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -51,17 +51,6 @@ static int protect4gb = 1;
51 51
52static void __iommu_free(struct iommu_table *, dma_addr_t, unsigned int); 52static void __iommu_free(struct iommu_table *, dma_addr_t, unsigned int);
53 53
54static inline unsigned long iommu_num_pages(unsigned long vaddr,
55 unsigned long slen)
56{
57 unsigned long npages;
58
59 npages = IOMMU_PAGE_ALIGN(vaddr + slen) - (vaddr & IOMMU_PAGE_MASK);
60 npages >>= IOMMU_PAGE_SHIFT;
61
62 return npages;
63}
64
65static int __init setup_protect4gb(char *str) 54static int __init setup_protect4gb(char *str)
66{ 55{
67 if (strcmp(str, "on") == 0) 56 if (strcmp(str, "on") == 0)
@@ -325,7 +314,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
325 } 314 }
326 /* Allocate iommu entries for that segment */ 315 /* Allocate iommu entries for that segment */
327 vaddr = (unsigned long) sg_virt(s); 316 vaddr = (unsigned long) sg_virt(s);
328 npages = iommu_num_pages(vaddr, slen); 317 npages = iommu_num_pages(vaddr, slen, IOMMU_PAGE_SIZE);
329 align = 0; 318 align = 0;
330 if (IOMMU_PAGE_SHIFT < PAGE_SHIFT && slen >= PAGE_SIZE && 319 if (IOMMU_PAGE_SHIFT < PAGE_SHIFT && slen >= PAGE_SIZE &&
331 (vaddr & ~PAGE_MASK) == 0) 320 (vaddr & ~PAGE_MASK) == 0)
@@ -418,7 +407,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
418 unsigned long vaddr, npages; 407 unsigned long vaddr, npages;
419 408
420 vaddr = s->dma_address & IOMMU_PAGE_MASK; 409 vaddr = s->dma_address & IOMMU_PAGE_MASK;
421 npages = iommu_num_pages(s->dma_address, s->dma_length); 410 npages = iommu_num_pages(s->dma_address, s->dma_length,
411 IOMMU_PAGE_SIZE);
422 __iommu_free(tbl, vaddr, npages); 412 __iommu_free(tbl, vaddr, npages);
423 s->dma_address = DMA_ERROR_CODE; 413 s->dma_address = DMA_ERROR_CODE;
424 s->dma_length = 0; 414 s->dma_length = 0;
@@ -452,7 +442,8 @@ void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
452 442
453 if (sg->dma_length == 0) 443 if (sg->dma_length == 0)
454 break; 444 break;
455 npages = iommu_num_pages(dma_handle, sg->dma_length); 445 npages = iommu_num_pages(dma_handle, sg->dma_length,
446 IOMMU_PAGE_SIZE);
456 __iommu_free(tbl, dma_handle, npages); 447 __iommu_free(tbl, dma_handle, npages);
457 sg = sg_next(sg); 448 sg = sg_next(sg);
458 } 449 }
@@ -584,7 +575,7 @@ dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
584 BUG_ON(direction == DMA_NONE); 575 BUG_ON(direction == DMA_NONE);
585 576
586 uaddr = (unsigned long)vaddr; 577 uaddr = (unsigned long)vaddr;
587 npages = iommu_num_pages(uaddr, size); 578 npages = iommu_num_pages(uaddr, size, IOMMU_PAGE_SIZE);
588 579
589 if (tbl) { 580 if (tbl) {
590 align = 0; 581 align = 0;
@@ -617,7 +608,7 @@ void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
617 BUG_ON(direction == DMA_NONE); 608 BUG_ON(direction == DMA_NONE);
618 609
619 if (tbl) { 610 if (tbl) {
620 npages = iommu_num_pages(dma_handle, size); 611 npages = iommu_num_pages(dma_handle, size, IOMMU_PAGE_SIZE);
621 iommu_free(tbl, dma_handle, npages); 612 iommu_free(tbl, dma_handle, npages);
622 } 613 }
623} 614}
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index ff7de7b0797e..bb1cfcfdbbbb 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -61,42 +61,6 @@ asmlinkage long ppc32_select(u32 n, compat_ulong_t __user *inp,
61 return compat_sys_select((int)n, inp, outp, exp, compat_ptr(tvp_x)); 61 return compat_sys_select((int)n, inp, outp, exp, compat_ptr(tvp_x));
62} 62}
63 63
64int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
65{
66 compat_ino_t ino;
67 long err;
68
69 if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
70 !new_valid_dev(stat->rdev))
71 return -EOVERFLOW;
72
73 ino = stat->ino;
74 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
75 return -EOVERFLOW;
76
77 err = access_ok(VERIFY_WRITE, statbuf, sizeof(*statbuf)) ? 0 : -EFAULT;
78 err |= __put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
79 err |= __put_user(ino, &statbuf->st_ino);
80 err |= __put_user(stat->mode, &statbuf->st_mode);
81 err |= __put_user(stat->nlink, &statbuf->st_nlink);
82 err |= __put_user(stat->uid, &statbuf->st_uid);
83 err |= __put_user(stat->gid, &statbuf->st_gid);
84 err |= __put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
85 err |= __put_user(stat->size, &statbuf->st_size);
86 err |= __put_user(stat->atime.tv_sec, &statbuf->st_atime);
87 err |= __put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
88 err |= __put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
89 err |= __put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
90 err |= __put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
91 err |= __put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
92 err |= __put_user(stat->blksize, &statbuf->st_blksize);
93 err |= __put_user(stat->blocks, &statbuf->st_blocks);
94 err |= __put_user(0, &statbuf->__unused4[0]);
95 err |= __put_user(0, &statbuf->__unused4[1]);
96
97 return err;
98}
99
100/* Note: it is necessary to treat option as an unsigned int, 64/* Note: it is necessary to treat option as an unsigned int,
101 * with the corresponding cast to a signed int to insure that the 65 * with the corresponding cast to a signed int to insure that the
102 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) 66 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
@@ -107,69 +71,6 @@ asmlinkage long compat_sys_sysfs(u32 option, u32 arg1, u32 arg2)
107 return sys_sysfs((int)option, arg1, arg2); 71 return sys_sysfs((int)option, arg1, arg2);
108} 72}
109 73
110static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
111{
112 long usec;
113
114 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
115 return -EFAULT;
116 if (__get_user(o->tv_sec, &i->tv_sec))
117 return -EFAULT;
118 if (__get_user(usec, &i->tv_usec))
119 return -EFAULT;
120 o->tv_nsec = usec * 1000;
121 return 0;
122}
123
124static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
125{
126 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
127 (__put_user(i->tv_sec, &o->tv_sec) |
128 __put_user(i->tv_usec, &o->tv_usec)));
129}
130
131
132
133
134/* Translations due to time_t size differences. Which affects all
135 sorts of things, like timeval and itimerval. */
136extern struct timezone sys_tz;
137
138asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
139{
140 if (tv) {
141 struct timeval ktv;
142 do_gettimeofday(&ktv);
143 if (put_tv32(tv, &ktv))
144 return -EFAULT;
145 }
146 if (tz) {
147 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
148 return -EFAULT;
149 }
150
151 return 0;
152}
153
154
155
156asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
157{
158 struct timespec kts;
159 struct timezone ktz;
160
161 if (tv) {
162 if (get_ts32(&kts, tv))
163 return -EFAULT;
164 }
165 if (tz) {
166 if (copy_from_user(&ktz, tz, sizeof(ktz)))
167 return -EFAULT;
168 }
169
170 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
171}
172
173#ifdef CONFIG_SYSVIPC 74#ifdef CONFIG_SYSVIPC
174long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr, 75long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
175 u32 fifth) 76 u32 fifth)
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index 5a5602da5091..2e227a412bc2 100644
--- a/arch/powerpc/kvm/44x_tlb.c
+++ b/arch/powerpc/kvm/44x_tlb.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/kvm.h>
22#include <linux/kvm_host.h> 23#include <linux/kvm_host.h>
23#include <linux/highmem.h> 24#include <linux/highmem.h>
24#include <asm/mmu-44x.h> 25#include <asm/mmu-44x.h>
@@ -109,7 +110,6 @@ static int kvmppc_44x_tlbe_is_writable(struct tlbe *tlbe)
109 return tlbe->word2 & (PPC44x_TLB_SW|PPC44x_TLB_UW); 110 return tlbe->word2 & (PPC44x_TLB_SW|PPC44x_TLB_UW);
110} 111}
111 112
112/* Must be called with mmap_sem locked for writing. */
113static void kvmppc_44x_shadow_release(struct kvm_vcpu *vcpu, 113static void kvmppc_44x_shadow_release(struct kvm_vcpu *vcpu,
114 unsigned int index) 114 unsigned int index)
115{ 115{
@@ -124,6 +124,11 @@ static void kvmppc_44x_shadow_release(struct kvm_vcpu *vcpu,
124 } 124 }
125} 125}
126 126
127void kvmppc_tlbe_set_modified(struct kvm_vcpu *vcpu, unsigned int i)
128{
129 vcpu->arch.shadow_tlb_mod[i] = 1;
130}
131
127/* Caller must ensure that the specified guest TLB entry is safe to insert into 132/* Caller must ensure that the specified guest TLB entry is safe to insert into
128 * the shadow TLB. */ 133 * the shadow TLB. */
129void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, u64 asid, 134void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, u64 asid,
@@ -142,19 +147,16 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, u64 asid,
142 stlbe = &vcpu->arch.shadow_tlb[victim]; 147 stlbe = &vcpu->arch.shadow_tlb[victim];
143 148
144 /* Get reference to new page. */ 149 /* Get reference to new page. */
145 down_read(&current->mm->mmap_sem);
146 new_page = gfn_to_page(vcpu->kvm, gfn); 150 new_page = gfn_to_page(vcpu->kvm, gfn);
147 if (is_error_page(new_page)) { 151 if (is_error_page(new_page)) {
148 printk(KERN_ERR "Couldn't get guest page for gfn %lx!\n", gfn); 152 printk(KERN_ERR "Couldn't get guest page for gfn %lx!\n", gfn);
149 kvm_release_page_clean(new_page); 153 kvm_release_page_clean(new_page);
150 up_read(&current->mm->mmap_sem);
151 return; 154 return;
152 } 155 }
153 hpaddr = page_to_phys(new_page); 156 hpaddr = page_to_phys(new_page);
154 157
155 /* Drop reference to old page. */ 158 /* Drop reference to old page. */
156 kvmppc_44x_shadow_release(vcpu, victim); 159 kvmppc_44x_shadow_release(vcpu, victim);
157 up_read(&current->mm->mmap_sem);
158 160
159 vcpu->arch.shadow_pages[victim] = new_page; 161 vcpu->arch.shadow_pages[victim] = new_page;
160 162
@@ -164,27 +166,30 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, u64 asid,
164 166
165 /* XXX what about AS? */ 167 /* XXX what about AS? */
166 168
167 stlbe->tid = asid & 0xff; 169 stlbe->tid = !(asid & 0xff);
168 170
169 /* Force TS=1 for all guest mappings. */ 171 /* Force TS=1 for all guest mappings. */
170 /* For now we hardcode 4KB mappings, but it will be important to 172 /* For now we hardcode 4KB mappings, but it will be important to
171 * use host large pages in the future. */ 173 * use host large pages in the future. */
172 stlbe->word0 = (gvaddr & PAGE_MASK) | PPC44x_TLB_VALID | PPC44x_TLB_TS 174 stlbe->word0 = (gvaddr & PAGE_MASK) | PPC44x_TLB_VALID | PPC44x_TLB_TS
173 | PPC44x_TLB_4K; 175 | PPC44x_TLB_4K;
174
175 stlbe->word1 = (hpaddr & 0xfffffc00) | ((hpaddr >> 32) & 0xf); 176 stlbe->word1 = (hpaddr & 0xfffffc00) | ((hpaddr >> 32) & 0xf);
176 stlbe->word2 = kvmppc_44x_tlb_shadow_attrib(flags, 177 stlbe->word2 = kvmppc_44x_tlb_shadow_attrib(flags,
177 vcpu->arch.msr & MSR_PR); 178 vcpu->arch.msr & MSR_PR);
179 kvmppc_tlbe_set_modified(vcpu, victim);
180
181 KVMTRACE_5D(STLB_WRITE, vcpu, victim,
182 stlbe->tid, stlbe->word0, stlbe->word1, stlbe->word2,
183 handler);
178} 184}
179 185
180void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr, 186void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr,
181 gva_t eend, u32 asid) 187 gva_t eend, u32 asid)
182{ 188{
183 unsigned int pid = asid & 0xff; 189 unsigned int pid = !(asid & 0xff);
184 int i; 190 int i;
185 191
186 /* XXX Replace loop with fancy data structures. */ 192 /* XXX Replace loop with fancy data structures. */
187 down_write(&current->mm->mmap_sem);
188 for (i = 0; i <= tlb_44x_hwater; i++) { 193 for (i = 0; i <= tlb_44x_hwater; i++) {
189 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i]; 194 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i];
190 unsigned int tid; 195 unsigned int tid;
@@ -204,21 +209,35 @@ void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr,
204 209
205 kvmppc_44x_shadow_release(vcpu, i); 210 kvmppc_44x_shadow_release(vcpu, i);
206 stlbe->word0 = 0; 211 stlbe->word0 = 0;
212 kvmppc_tlbe_set_modified(vcpu, i);
213 KVMTRACE_5D(STLB_INVAL, vcpu, i,
214 stlbe->tid, stlbe->word0, stlbe->word1,
215 stlbe->word2, handler);
207 } 216 }
208 up_write(&current->mm->mmap_sem);
209} 217}
210 218
211/* Invalidate all mappings, so that when they fault back in they will get the 219/* Invalidate all mappings on the privilege switch after PID has been changed.
212 * proper permission bits. */ 220 * The guest always runs with PID=1, so we must clear the entire TLB when
221 * switching address spaces. */
213void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode) 222void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode)
214{ 223{
215 int i; 224 int i;
216 225
217 /* XXX Replace loop with fancy data structures. */ 226 if (vcpu->arch.swap_pid) {
218 down_write(&current->mm->mmap_sem); 227 /* XXX Replace loop with fancy data structures. */
219 for (i = 0; i <= tlb_44x_hwater; i++) { 228 for (i = 0; i <= tlb_44x_hwater; i++) {
220 kvmppc_44x_shadow_release(vcpu, i); 229 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i];
221 vcpu->arch.shadow_tlb[i].word0 = 0; 230
231 /* Future optimization: clear only userspace mappings. */
232 kvmppc_44x_shadow_release(vcpu, i);
233 stlbe->word0 = 0;
234 kvmppc_tlbe_set_modified(vcpu, i);
235 KVMTRACE_5D(STLB_INVAL, vcpu, i,
236 stlbe->tid, stlbe->word0, stlbe->word1,
237 stlbe->word2, handler);
238 }
239 vcpu->arch.swap_pid = 0;
222 } 240 }
223 up_write(&current->mm->mmap_sem); 241
242 vcpu->arch.shadow_pid = !usermode;
224} 243}
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index 6b076010213b..53aaa66b25e5 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -37,6 +37,17 @@ config KVM_BOOKE_HOST
37 Provides host support for KVM on Book E PowerPC processors. Currently 37 Provides host support for KVM on Book E PowerPC processors. Currently
38 this works on 440 processors only. 38 this works on 440 processors only.
39 39
40config KVM_TRACE
41 bool "KVM trace support"
42 depends on KVM && MARKERS && SYSFS
43 select RELAY
44 select DEBUG_FS
45 default n
46 ---help---
47 This option allows reading a trace of kvm-related events through
48 relayfs. Note the ABI is not considered stable and will be
49 modified in future updates.
50
40source drivers/virtio/Kconfig 51source drivers/virtio/Kconfig
41 52
42endif # VIRTUALIZATION 53endif # VIRTUALIZATION
diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
index 04e3449e1f42..2a5d4397ac4b 100644
--- a/arch/powerpc/kvm/Makefile
+++ b/arch/powerpc/kvm/Makefile
@@ -4,9 +4,11 @@
4 4
5EXTRA_CFLAGS += -Ivirt/kvm -Iarch/powerpc/kvm 5EXTRA_CFLAGS += -Ivirt/kvm -Iarch/powerpc/kvm
6 6
7common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o) 7common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o)
8 8
9kvm-objs := $(common-objs) powerpc.o emulate.o booke_guest.o 9common-objs-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o)
10
11kvm-objs := $(common-objs-y) powerpc.o emulate.o booke_guest.o
10obj-$(CONFIG_KVM) += kvm.o 12obj-$(CONFIG_KVM) += kvm.o
11 13
12AFLAGS_booke_interrupts.o := -I$(obj) 14AFLAGS_booke_interrupts.o := -I$(obj)
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
index 9c8ad850c6e3..7b2591e26bae 100644
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -410,6 +410,21 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
410 break; 410 break;
411 } 411 }
412 412
413 case BOOKE_INTERRUPT_DEBUG: {
414 u32 dbsr;
415
416 vcpu->arch.pc = mfspr(SPRN_CSRR0);
417
418 /* clear IAC events in DBSR register */
419 dbsr = mfspr(SPRN_DBSR);
420 dbsr &= DBSR_IAC1 | DBSR_IAC2 | DBSR_IAC3 | DBSR_IAC4;
421 mtspr(SPRN_DBSR, dbsr);
422
423 run->exit_reason = KVM_EXIT_DEBUG;
424 r = RESUME_HOST;
425 break;
426 }
427
413 default: 428 default:
414 printk(KERN_EMERG "exit_nr %d\n", exit_nr); 429 printk(KERN_EMERG "exit_nr %d\n", exit_nr);
415 BUG(); 430 BUG();
@@ -471,6 +486,8 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
471 vcpu->arch.msr = 0; 486 vcpu->arch.msr = 0;
472 vcpu->arch.gpr[1] = (16<<20) - 8; /* -8 for the callee-save LR slot */ 487 vcpu->arch.gpr[1] = (16<<20) - 8; /* -8 for the callee-save LR slot */
473 488
489 vcpu->arch.shadow_pid = 1;
490
474 /* Eye-catching number so we know if the guest takes an interrupt 491 /* Eye-catching number so we know if the guest takes an interrupt
475 * before it's programmed its own IVPR. */ 492 * before it's programmed its own IVPR. */
476 vcpu->arch.ivpr = 0x55550000; 493 vcpu->arch.ivpr = 0x55550000;
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 3b653b5309b8..95e165baf85f 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -42,7 +42,8 @@
42#define HOST_STACK_LR (HOST_STACK_SIZE + 4) /* In caller stack frame. */ 42#define HOST_STACK_LR (HOST_STACK_SIZE + 4) /* In caller stack frame. */
43 43
44#define NEED_INST_MASK ((1<<BOOKE_INTERRUPT_PROGRAM) | \ 44#define NEED_INST_MASK ((1<<BOOKE_INTERRUPT_PROGRAM) | \
45 (1<<BOOKE_INTERRUPT_DTLB_MISS)) 45 (1<<BOOKE_INTERRUPT_DTLB_MISS) | \
46 (1<<BOOKE_INTERRUPT_DEBUG))
46 47
47#define NEED_DEAR_MASK ((1<<BOOKE_INTERRUPT_DATA_STORAGE) | \ 48#define NEED_DEAR_MASK ((1<<BOOKE_INTERRUPT_DATA_STORAGE) | \
48 (1<<BOOKE_INTERRUPT_DTLB_MISS)) 49 (1<<BOOKE_INTERRUPT_DTLB_MISS))
@@ -331,51 +332,57 @@ lightweight_exit:
331 332
332 mfspr r3, SPRN_PID 333 mfspr r3, SPRN_PID
333 stw r3, VCPU_HOST_PID(r4) 334 stw r3, VCPU_HOST_PID(r4)
334 lwz r3, VCPU_PID(r4) 335 lwz r3, VCPU_SHADOW_PID(r4)
335 mtspr SPRN_PID, r3 336 mtspr SPRN_PID, r3
336 337
337 /* Prevent all TLB updates. */ 338 /* Prevent all asynchronous TLB updates. */
338 mfmsr r5 339 mfmsr r5
339 lis r6, (MSR_EE|MSR_CE|MSR_ME|MSR_DE)@h 340 lis r6, (MSR_EE|MSR_CE|MSR_ME|MSR_DE)@h
340 ori r6, r6, (MSR_EE|MSR_CE|MSR_ME|MSR_DE)@l 341 ori r6, r6, (MSR_EE|MSR_CE|MSR_ME|MSR_DE)@l
341 andc r6, r5, r6 342 andc r6, r5, r6
342 mtmsr r6 343 mtmsr r6
343 344
344 /* Save the host's non-pinned TLB mappings, and load the guest mappings 345 /* Load the guest mappings, leaving the host's "pinned" kernel mappings
345 * over them. Leave the host's "pinned" kernel mappings in place. */ 346 * in place. */
346 /* XXX optimization: use generation count to avoid swapping unmodified
347 * entries. */
348 mfspr r10, SPRN_MMUCR /* Save host MMUCR. */ 347 mfspr r10, SPRN_MMUCR /* Save host MMUCR. */
349 lis r8, tlb_44x_hwater@ha 348 li r5, PPC44x_TLB_SIZE
350 lwz r8, tlb_44x_hwater@l(r8) 349 lis r5, tlb_44x_hwater@ha
351 addi r3, r4, VCPU_HOST_TLB - 4 350 lwz r5, tlb_44x_hwater@l(r5)
352 addi r9, r4, VCPU_SHADOW_TLB - 4 351 mtctr r5
353 li r6, 0 352 addi r9, r4, VCPU_SHADOW_TLB
353 addi r5, r4, VCPU_SHADOW_MOD
354 li r3, 0
3541: 3551:
355 /* Save host entry. */ 356 lbzx r7, r3, r5
356 tlbre r7, r6, PPC44x_TLB_PAGEID 357 cmpwi r7, 0
357 mfspr r5, SPRN_MMUCR 358 beq 3f
358 stwu r5, 4(r3) 359
359 stwu r7, 4(r3)
360 tlbre r7, r6, PPC44x_TLB_XLAT
361 stwu r7, 4(r3)
362 tlbre r7, r6, PPC44x_TLB_ATTRIB
363 stwu r7, 4(r3)
364 /* Load guest entry. */ 360 /* Load guest entry. */
365 lwzu r7, 4(r9) 361 mulli r11, r3, TLBE_BYTES
362 add r11, r11, r9
363 lwz r7, 0(r11)
366 mtspr SPRN_MMUCR, r7 364 mtspr SPRN_MMUCR, r7
367 lwzu r7, 4(r9) 365 lwz r7, 4(r11)
368 tlbwe r7, r6, PPC44x_TLB_PAGEID 366 tlbwe r7, r3, PPC44x_TLB_PAGEID
369 lwzu r7, 4(r9) 367 lwz r7, 8(r11)
370 tlbwe r7, r6, PPC44x_TLB_XLAT 368 tlbwe r7, r3, PPC44x_TLB_XLAT
371 lwzu r7, 4(r9) 369 lwz r7, 12(r11)
372 tlbwe r7, r6, PPC44x_TLB_ATTRIB 370 tlbwe r7, r3, PPC44x_TLB_ATTRIB
373 /* Increment index. */ 3713:
374 addi r6, r6, 1 372 addi r3, r3, 1 /* Increment index. */
375 cmpw r6, r8 373 bdnz 1b
376 blt 1b 374
377 mtspr SPRN_MMUCR, r10 /* Restore host MMUCR. */ 375 mtspr SPRN_MMUCR, r10 /* Restore host MMUCR. */
378 376
377 /* Clear bitmap of modified TLB entries */
378 li r5, PPC44x_TLB_SIZE>>2
379 mtctr r5
380 addi r5, r4, VCPU_SHADOW_MOD - 4
381 li r6, 0
3821:
383 stwu r6, 4(r5)
384 bdnz 1b
385
379 iccci 0, 0 /* XXX hack */ 386 iccci 0, 0 /* XXX hack */
380 387
381 /* Load some guest volatiles. */ 388 /* Load some guest volatiles. */
@@ -431,6 +438,14 @@ lightweight_exit:
431 oris r3, r3, KVMPPC_MSR_MASK@h 438 oris r3, r3, KVMPPC_MSR_MASK@h
432 ori r3, r3, KVMPPC_MSR_MASK@l 439 ori r3, r3, KVMPPC_MSR_MASK@l
433 mtsrr1 r3 440 mtsrr1 r3
441
442 /* Clear any debug events which occurred since we disabled MSR[DE].
443 * XXX This gives us a 3-instruction window in which a breakpoint
444 * intended for guest context could fire in the host instead. */
445 lis r3, 0xffff
446 ori r3, r3, 0xffff
447 mtspr SPRN_DBSR, r3
448
434 lwz r3, VCPU_GPR(r3)(r4) 449 lwz r3, VCPU_GPR(r3)(r4)
435 lwz r4, VCPU_GPR(r4)(r4) 450 lwz r4, VCPU_GPR(r4)(r4)
436 rfi 451 rfi
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 8c605d0a5488..0fce4fbdc20d 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -170,6 +170,10 @@ static int kvmppc_emul_tlbwe(struct kvm_vcpu *vcpu, u32 inst)
170 kvmppc_mmu_map(vcpu, eaddr, raddr >> PAGE_SHIFT, asid, flags); 170 kvmppc_mmu_map(vcpu, eaddr, raddr >> PAGE_SHIFT, asid, flags);
171 } 171 }
172 172
173 KVMTRACE_5D(GTLB_WRITE, vcpu, index,
174 tlbe->tid, tlbe->word0, tlbe->word1, tlbe->word2,
175 handler);
176
173 return EMULATE_DONE; 177 return EMULATE_DONE;
174} 178}
175 179
@@ -504,7 +508,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
504 case SPRN_MMUCR: 508 case SPRN_MMUCR:
505 vcpu->arch.mmucr = vcpu->arch.gpr[rs]; break; 509 vcpu->arch.mmucr = vcpu->arch.gpr[rs]; break;
506 case SPRN_PID: 510 case SPRN_PID:
507 vcpu->arch.pid = vcpu->arch.gpr[rs]; break; 511 kvmppc_set_pid(vcpu, vcpu->arch.gpr[rs]); break;
508 case SPRN_CCR0: 512 case SPRN_CCR0:
509 vcpu->arch.ccr0 = vcpu->arch.gpr[rs]; break; 513 vcpu->arch.ccr0 = vcpu->arch.gpr[rs]; break;
510 case SPRN_CCR1: 514 case SPRN_CCR1:
@@ -765,6 +769,8 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
765 break; 769 break;
766 } 770 }
767 771
772 KVMTRACE_3D(PPC_INSTR, vcpu, inst, vcpu->arch.pc, emulated, entryexit);
773
768 if (advance) 774 if (advance)
769 vcpu->arch.pc += 4; /* Advance past emulated instruction. */ 775 vcpu->arch.pc += 4; /* Advance past emulated instruction. */
770 776
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 53826a5f6c06..90a6fc422b23 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -27,6 +27,7 @@
27#include <asm/cputable.h> 27#include <asm/cputable.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <asm/kvm_ppc.h> 29#include <asm/kvm_ppc.h>
30#include <asm/tlbflush.h>
30 31
31 32
32gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) 33gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
@@ -239,18 +240,114 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
239{ 240{
240} 241}
241 242
243/* Note: clearing MSR[DE] just means that the debug interrupt will not be
244 * delivered *immediately*. Instead, it simply sets the appropriate DBSR bits.
245 * If those DBSR bits are still set when MSR[DE] is re-enabled, the interrupt
246 * will be delivered as an "imprecise debug event" (which is indicated by
247 * DBSR[IDE].
248 */
249static void kvmppc_disable_debug_interrupts(void)
250{
251 mtmsr(mfmsr() & ~MSR_DE);
252}
253
254static void kvmppc_restore_host_debug_state(struct kvm_vcpu *vcpu)
255{
256 kvmppc_disable_debug_interrupts();
257
258 mtspr(SPRN_IAC1, vcpu->arch.host_iac[0]);
259 mtspr(SPRN_IAC2, vcpu->arch.host_iac[1]);
260 mtspr(SPRN_IAC3, vcpu->arch.host_iac[2]);
261 mtspr(SPRN_IAC4, vcpu->arch.host_iac[3]);
262 mtspr(SPRN_DBCR1, vcpu->arch.host_dbcr1);
263 mtspr(SPRN_DBCR2, vcpu->arch.host_dbcr2);
264 mtspr(SPRN_DBCR0, vcpu->arch.host_dbcr0);
265 mtmsr(vcpu->arch.host_msr);
266}
267
268static void kvmppc_load_guest_debug_registers(struct kvm_vcpu *vcpu)
269{
270 struct kvm_guest_debug *dbg = &vcpu->guest_debug;
271 u32 dbcr0 = 0;
272
273 vcpu->arch.host_msr = mfmsr();
274 kvmppc_disable_debug_interrupts();
275
276 /* Save host debug register state. */
277 vcpu->arch.host_iac[0] = mfspr(SPRN_IAC1);
278 vcpu->arch.host_iac[1] = mfspr(SPRN_IAC2);
279 vcpu->arch.host_iac[2] = mfspr(SPRN_IAC3);
280 vcpu->arch.host_iac[3] = mfspr(SPRN_IAC4);
281 vcpu->arch.host_dbcr0 = mfspr(SPRN_DBCR0);
282 vcpu->arch.host_dbcr1 = mfspr(SPRN_DBCR1);
283 vcpu->arch.host_dbcr2 = mfspr(SPRN_DBCR2);
284
285 /* set registers up for guest */
286
287 if (dbg->bp[0]) {
288 mtspr(SPRN_IAC1, dbg->bp[0]);
289 dbcr0 |= DBCR0_IAC1 | DBCR0_IDM;
290 }
291 if (dbg->bp[1]) {
292 mtspr(SPRN_IAC2, dbg->bp[1]);
293 dbcr0 |= DBCR0_IAC2 | DBCR0_IDM;
294 }
295 if (dbg->bp[2]) {
296 mtspr(SPRN_IAC3, dbg->bp[2]);
297 dbcr0 |= DBCR0_IAC3 | DBCR0_IDM;
298 }
299 if (dbg->bp[3]) {
300 mtspr(SPRN_IAC4, dbg->bp[3]);
301 dbcr0 |= DBCR0_IAC4 | DBCR0_IDM;
302 }
303
304 mtspr(SPRN_DBCR0, dbcr0);
305 mtspr(SPRN_DBCR1, 0);
306 mtspr(SPRN_DBCR2, 0);
307}
308
242void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 309void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
243{ 310{
311 int i;
312
313 if (vcpu->guest_debug.enabled)
314 kvmppc_load_guest_debug_registers(vcpu);
315
316 /* Mark every guest entry in the shadow TLB entry modified, so that they
317 * will all be reloaded on the next vcpu run (instead of being
318 * demand-faulted). */
319 for (i = 0; i <= tlb_44x_hwater; i++)
320 kvmppc_tlbe_set_modified(vcpu, i);
244} 321}
245 322
246void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 323void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
247{ 324{
325 if (vcpu->guest_debug.enabled)
326 kvmppc_restore_host_debug_state(vcpu);
327
328 /* Don't leave guest TLB entries resident when being de-scheduled. */
329 /* XXX It would be nice to differentiate between heavyweight exit and
330 * sched_out here, since we could avoid the TLB flush for heavyweight
331 * exits. */
332 _tlbia();
248} 333}
249 334
250int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, 335int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
251 struct kvm_debug_guest *dbg) 336 struct kvm_debug_guest *dbg)
252{ 337{
253 return -ENOTSUPP; 338 int i;
339
340 vcpu->guest_debug.enabled = dbg->enabled;
341 if (vcpu->guest_debug.enabled) {
342 for (i=0; i < ARRAY_SIZE(vcpu->guest_debug.bp); i++) {
343 if (dbg->breakpoints[i].enabled)
344 vcpu->guest_debug.bp[i] = dbg->breakpoints[i].address;
345 else
346 vcpu->guest_debug.bp[i] = 0;
347 }
348 }
349
350 return 0;
254} 351}
255 352
256static void kvmppc_complete_dcr_load(struct kvm_vcpu *vcpu, 353static void kvmppc_complete_dcr_load(struct kvm_vcpu *vcpu,
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 439c5ba34ecf..548efa55c8fe 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -135,7 +135,6 @@ config PTE_64BIT
135config PHYS_64BIT 135config PHYS_64BIT
136 bool 'Large physical address support' if E500 || PPC_86xx 136 bool 'Large physical address support' if E500 || PPC_86xx
137 depends on (44x || E500 || PPC_86xx) && !PPC_83xx && !PPC_82xx 137 depends on (44x || E500 || PPC_86xx) && !PPC_83xx && !PPC_82xx
138 select RESOURCES_64BIT
139 ---help--- 138 ---help---
140 This option enables kernel support for larger than 32-bit physical 139 This option enables kernel support for larger than 32-bit physical
141 addresses. This feature may not be available on all cores. 140 addresses. This feature may not be available on all cores.
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
index 9f6f73d584d6..d3e4d61030b5 100644
--- a/arch/powerpc/sysdev/ppc4xx_pci.c
+++ b/arch/powerpc/sysdev/ppc4xx_pci.c
@@ -39,13 +39,10 @@ static int dma_offset_set;
39#define U64_TO_U32_LOW(val) ((u32)((val) & 0x00000000ffffffffULL)) 39#define U64_TO_U32_LOW(val) ((u32)((val) & 0x00000000ffffffffULL))
40#define U64_TO_U32_HIGH(val) ((u32)((val) >> 32)) 40#define U64_TO_U32_HIGH(val) ((u32)((val) >> 32))
41 41
42#ifdef CONFIG_RESOURCES_64BIT 42#define RES_TO_U32_LOW(val) \
43#define RES_TO_U32_LOW(val) U64_TO_U32_LOW(val) 43 ((sizeof(resource_size_t) > sizeof(u32)) ? U64_TO_U32_LOW(val) : (val))
44#define RES_TO_U32_HIGH(val) U64_TO_U32_HIGH(val) 44#define RES_TO_U32_HIGH(val) \
45#else 45 ((sizeof(resource_size_t) > sizeof(u32)) ? U64_TO_U32_HIGH(val) : (0))
46#define RES_TO_U32_LOW(val) (val)
47#define RES_TO_U32_HIGH(val) (0)
48#endif
49 46
50static inline int ppc440spe_revA(void) 47static inline int ppc440spe_revA(void)
51{ 48{
@@ -144,12 +141,11 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
144 141
145 /* Use that */ 142 /* Use that */
146 res->start = pci_addr; 143 res->start = pci_addr;
147#ifndef CONFIG_RESOURCES_64BIT
148 /* Beware of 32 bits resources */ 144 /* Beware of 32 bits resources */
149 if ((pci_addr + size) > 0x100000000ull) 145 if (sizeof(resource_size_t) == sizeof(u32) &&
146 (pci_addr + size) > 0x100000000ull)
150 res->end = 0xffffffff; 147 res->end = 0xffffffff;
151 else 148 else
152#endif
153 res->end = res->start + size - 1; 149 res->end = res->start + size - 1;
154 break; 150 break;
155 } 151 }
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 4c03049e7db9..bc581d8a7cd9 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -565,13 +565,16 @@ config ZFCPDUMP
565 Refer to <file:Documentation/s390/zfcpdump.txt> for more details on this. 565 Refer to <file:Documentation/s390/zfcpdump.txt> for more details on this.
566 566
567config S390_GUEST 567config S390_GUEST
568bool "s390 guest support (EXPERIMENTAL)" 568bool "s390 guest support for KVM (EXPERIMENTAL)"
569 depends on 64BIT && EXPERIMENTAL 569 depends on 64BIT && EXPERIMENTAL
570 select VIRTIO 570 select VIRTIO
571 select VIRTIO_RING 571 select VIRTIO_RING
572 select VIRTIO_CONSOLE 572 select VIRTIO_CONSOLE
573 help 573 help
574 Select this option if you want to run the kernel under s390 linux 574 Select this option if you want to run the kernel as a guest under
575 the KVM hypervisor. This will add detection for KVM as well as a
576 virtio transport. If KVM is detected, the virtio console will be
577 the default console.
575endmenu 578endmenu
576 579
577source "net/Kconfig" 580source "net/Kconfig"
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index 3cad56923815..261785ab5b22 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -166,13 +166,11 @@ extern char elf_platform[];
166#define ELF_PLATFORM (elf_platform) 166#define ELF_PLATFORM (elf_platform)
167 167
168#ifndef __s390x__ 168#ifndef __s390x__
169#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 169#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
170#else /* __s390x__ */ 170#else /* __s390x__ */
171#define SET_PERSONALITY(ex, ibcs2) \ 171#define SET_PERSONALITY(ex) \
172do { \ 172do { \
173 if (ibcs2) \ 173 if (current->personality != PER_LINUX32) \
174 set_personality(PER_SVR4); \
175 else if (current->personality != PER_LINUX32) \
176 set_personality(PER_LINUX); \ 174 set_personality(PER_LINUX); \
177 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 175 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
178 set_thread_flag(TIF_31BIT); \ 176 set_thread_flag(TIF_31BIT); \
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 98e246dc0233..4646382af34f 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -279,22 +279,6 @@ asmlinkage long sys32_getegid16(void)
279 return high2lowgid(current->egid); 279 return high2lowgid(current->egid);
280} 280}
281 281
282/* 32-bit timeval and related flotsam. */
283
284static inline long get_tv32(struct timeval *o, struct compat_timeval __user *i)
285{
286 return (!access_ok(VERIFY_READ, o, sizeof(*o)) ||
287 (__get_user(o->tv_sec, &i->tv_sec) ||
288 __get_user(o->tv_usec, &i->tv_usec)));
289}
290
291static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
292{
293 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
294 (__put_user(i->tv_sec, &o->tv_sec) ||
295 __put_user(i->tv_usec, &o->tv_usec)));
296}
297
298/* 282/*
299 * sys32_ipc() is the de-multiplexer for the SysV IPC calls in 32bit emulation. 283 * sys32_ipc() is the de-multiplexer for the SysV IPC calls in 32bit emulation.
300 * 284 *
@@ -362,41 +346,6 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned
362 return sys_ftruncate(fd, (high << 32) | low); 346 return sys_ftruncate(fd, (high << 32) | low);
363} 347}
364 348
365int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
366{
367 compat_ino_t ino;
368 int err;
369
370 if (!old_valid_dev(stat->dev) || !old_valid_dev(stat->rdev))
371 return -EOVERFLOW;
372
373 ino = stat->ino;
374 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
375 return -EOVERFLOW;
376
377 err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev);
378 err |= put_user(stat->ino, &statbuf->st_ino);
379 err |= put_user(stat->mode, &statbuf->st_mode);
380 err |= put_user(stat->nlink, &statbuf->st_nlink);
381 err |= put_user(high2lowuid(stat->uid), &statbuf->st_uid);
382 err |= put_user(high2lowgid(stat->gid), &statbuf->st_gid);
383 err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev);
384 err |= put_user(stat->size, &statbuf->st_size);
385 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
386 err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
387 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
388 err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
389 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
390 err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
391 err |= put_user(stat->blksize, &statbuf->st_blksize);
392 err |= put_user(stat->blocks, &statbuf->st_blocks);
393/* fixme
394 err |= put_user(0, &statbuf->__unused4[0]);
395 err |= put_user(0, &statbuf->__unused4[1]);
396*/
397 return err;
398}
399
400asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid, 349asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
401 struct compat_timespec __user *interval) 350 struct compat_timespec __user *interval)
402{ 351{
@@ -557,57 +506,6 @@ sys32_delete_module(const char __user *name_user, unsigned int flags)
557 506
558#endif /* CONFIG_MODULES */ 507#endif /* CONFIG_MODULES */
559 508
560/* Translations due to time_t size differences. Which affects all
561 sorts of things, like timeval and itimerval. */
562
563extern struct timezone sys_tz;
564
565asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
566{
567 if (tv) {
568 struct timeval ktv;
569 do_gettimeofday(&ktv);
570 if (put_tv32(tv, &ktv))
571 return -EFAULT;
572 }
573 if (tz) {
574 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
575 return -EFAULT;
576 }
577 return 0;
578}
579
580static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
581{
582 long usec;
583
584 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
585 return -EFAULT;
586 if (__get_user(o->tv_sec, &i->tv_sec))
587 return -EFAULT;
588 if (__get_user(usec, &i->tv_usec))
589 return -EFAULT;
590 o->tv_nsec = usec * 1000;
591 return 0;
592}
593
594asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
595{
596 struct timespec kts;
597 struct timezone ktz;
598
599 if (tv) {
600 if (get_ts32(&kts, tv))
601 return -EFAULT;
602 }
603 if (tz) {
604 if (copy_from_user(&ktz, tz, sizeof(ktz)))
605 return -EFAULT;
606 }
607
608 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
609}
610
611asmlinkage long sys32_pread64(unsigned int fd, char __user *ubuf, 509asmlinkage long sys32_pread64(unsigned int fd, char __user *ubuf,
612 size_t count, u32 poshi, u32 poslo) 510 size_t count, u32 poshi, u32 poslo)
613{ 511{
diff --git a/arch/s390/kernel/compat_linux.h b/arch/s390/kernel/compat_linux.h
index 05f8516366ab..836a28842900 100644
--- a/arch/s390/kernel/compat_linux.h
+++ b/arch/s390/kernel/compat_linux.h
@@ -202,10 +202,6 @@ long sys32_execve(void);
202long sys32_init_module(void __user *umod, unsigned long len, 202long sys32_init_module(void __user *umod, unsigned long len,
203 const char __user *uargs); 203 const char __user *uargs);
204long sys32_delete_module(const char __user *name_user, unsigned int flags); 204long sys32_delete_module(const char __user *name_user, unsigned int flags);
205long sys32_gettimeofday(struct compat_timeval __user *tv,
206 struct timezone __user *tz);
207long sys32_settimeofday(struct compat_timeval __user *tv,
208 struct timezone __user *tz);
209long sys32_pread64(unsigned int fd, char __user *ubuf, size_t count, 205long sys32_pread64(unsigned int fd, char __user *ubuf, size_t count,
210 u32 poshi, u32 poslo); 206 u32 poshi, u32 poslo);
211long sys32_pwrite64(unsigned int fd, const char __user *ubuf, 207long 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 ee51ca9e23b5..fc2c97197a53 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -332,17 +332,17 @@ compat_sys_getrusage_wrapper:
332 llgtr %r3,%r3 # struct rusage_emu31 * 332 llgtr %r3,%r3 # struct rusage_emu31 *
333 jg compat_sys_getrusage # branch to system call 333 jg compat_sys_getrusage # branch to system call
334 334
335 .globl sys32_gettimeofday_wrapper 335 .globl compat_sys_gettimeofday_wrapper
336sys32_gettimeofday_wrapper: 336compat_sys_gettimeofday_wrapper:
337 llgtr %r2,%r2 # struct timeval_emu31 * 337 llgtr %r2,%r2 # struct timeval_emu31 *
338 llgtr %r3,%r3 # struct timezone * 338 llgtr %r3,%r3 # struct timezone *
339 jg sys32_gettimeofday # branch to system call 339 jg compat_sys_gettimeofday # branch to system call
340 340
341 .globl sys32_settimeofday_wrapper 341 .globl compat_sys_settimeofday_wrapper
342sys32_settimeofday_wrapper: 342compat_sys_settimeofday_wrapper:
343 llgtr %r2,%r2 # struct timeval_emu31 * 343 llgtr %r2,%r2 # struct timeval_emu31 *
344 llgtr %r3,%r3 # struct timezone * 344 llgtr %r3,%r3 # struct timezone *
345 jg sys32_settimeofday # branch to system call 345 jg compat_sys_settimeofday # branch to system call
346 346
347 .globl sys32_getgroups16_wrapper 347 .globl sys32_getgroups16_wrapper
348sys32_getgroups16_wrapper: 348sys32_getgroups16_wrapper:
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index 3ae303914b42..2d61787949d5 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -86,8 +86,8 @@ SYSCALL(sys_sethostname,sys_sethostname,sys32_sethostname_wrapper)
86SYSCALL(sys_setrlimit,sys_setrlimit,compat_sys_setrlimit_wrapper) /* 75 */ 86SYSCALL(sys_setrlimit,sys_setrlimit,compat_sys_setrlimit_wrapper) /* 75 */
87SYSCALL(sys_old_getrlimit,sys_getrlimit,compat_sys_old_getrlimit_wrapper) 87SYSCALL(sys_old_getrlimit,sys_getrlimit,compat_sys_old_getrlimit_wrapper)
88SYSCALL(sys_getrusage,sys_getrusage,compat_sys_getrusage_wrapper) 88SYSCALL(sys_getrusage,sys_getrusage,compat_sys_getrusage_wrapper)
89SYSCALL(sys_gettimeofday,sys_gettimeofday,sys32_gettimeofday_wrapper) 89SYSCALL(sys_gettimeofday,sys_gettimeofday,compat_sys_gettimeofday_wrapper)
90SYSCALL(sys_settimeofday,sys_settimeofday,sys32_settimeofday_wrapper) 90SYSCALL(sys_settimeofday,sys_settimeofday,compat_sys_settimeofday_wrapper)
91SYSCALL(sys_getgroups16,sys_ni_syscall,sys32_getgroups16_wrapper) /* 80 old getgroups16 syscall */ 91SYSCALL(sys_getgroups16,sys_ni_syscall,sys32_getgroups16_wrapper) /* 80 old getgroups16 syscall */
92SYSCALL(sys_setgroups16,sys_ni_syscall,sys32_setgroups16_wrapper) /* old setgroups16 syscall */ 92SYSCALL(sys_setgroups16,sys_ni_syscall,sys32_setgroups16_wrapper) /* old setgroups16 syscall */
93NI_SYSCALL /* old select syscall */ 93NI_SYSCALL /* old select syscall */
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index d1faf5c54405..cce40ff2913b 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -157,8 +157,8 @@ static int handle_stfl(struct kvm_vcpu *vcpu)
157 int rc; 157 int rc;
158 158
159 vcpu->stat.instruction_stfl++; 159 vcpu->stat.instruction_stfl++;
160 facility_list &= ~(1UL<<24); /* no stfle */ 160 /* only pass the facility bits, which we can handle */
161 facility_list &= ~(1UL<<23); /* no large pages */ 161 facility_list &= 0xfe00fff3;
162 162
163 rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list), 163 rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list),
164 &facility_list, sizeof(facility_list)); 164 &facility_list, sizeof(facility_list));
diff --git a/arch/sh/include/asm/elf.h b/arch/sh/include/asm/elf.h
index f01449a8d378..ee02db110f0d 100644
--- a/arch/sh/include/asm/elf.h
+++ b/arch/sh/include/asm/elf.h
@@ -189,7 +189,7 @@ do { \
189} while (0) 189} while (0)
190#endif 190#endif
191 191
192#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) 192#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
193struct task_struct; 193struct task_struct;
194extern int dump_task_regs (struct task_struct *, elf_gregset_t *); 194extern int dump_task_regs (struct task_struct *, elf_gregset_t *);
195extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); 195extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
index b7ab60547827..381a1b5256d6 100644
--- a/arch/sparc/include/asm/elf_32.h
+++ b/arch/sparc/include/asm/elf_32.h
@@ -137,6 +137,6 @@ typedef struct {
137 137
138#define ELF_PLATFORM (NULL) 138#define ELF_PLATFORM (NULL)
139 139
140#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 140#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
141 141
142#endif /* !(__ASMSPARC_ELF_H) */ 142#endif /* !(__ASMSPARC_ELF_H) */
diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
index 0818a1308f4e..425c2f9be6d5 100644
--- a/arch/sparc/include/asm/elf_64.h
+++ b/arch/sparc/include/asm/elf_64.h
@@ -195,7 +195,7 @@ static inline unsigned int sparc64_elf_hwcap(void)
195 195
196#define ELF_PLATFORM (NULL) 196#define ELF_PLATFORM (NULL)
197 197
198#define SET_PERSONALITY(ex, ibcs2) \ 198#define SET_PERSONALITY(ex) \
199do { unsigned long new_flags = current_thread_info()->flags; \ 199do { unsigned long new_flags = current_thread_info()->flags; \
200 new_flags &= _TIF_32BIT; \ 200 new_flags &= _TIF_32BIT; \
201 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 201 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
@@ -208,9 +208,7 @@ do { unsigned long new_flags = current_thread_info()->flags; \
208 else \ 208 else \
209 clear_thread_flag(TIF_ABI_PENDING); \ 209 clear_thread_flag(TIF_ABI_PENDING); \
210 /* flush_thread will update pgd cache */ \ 210 /* flush_thread will update pgd cache */ \
211 if (ibcs2) \ 211 if (current->personality != PER_LINUX32) \
212 set_personality(PER_SVR4); \
213 else if (current->personality != PER_LINUX32) \
214 set_personality(PER_LINUX); \ 212 set_personality(PER_LINUX); \
215} while (0) 213} while (0)
216 214
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index 2a37a6ca2a16..1cc1995531e2 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -575,7 +575,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
575 } 575 }
576 /* Allocate iommu entries for that segment */ 576 /* Allocate iommu entries for that segment */
577 paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s); 577 paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s);
578 npages = iommu_num_pages(paddr, slen); 578 npages = iommu_num_pages(paddr, slen, IO_PAGE_SIZE);
579 entry = iommu_range_alloc(dev, iommu, npages, &handle); 579 entry = iommu_range_alloc(dev, iommu, npages, &handle);
580 580
581 /* Handle failure */ 581 /* Handle failure */
@@ -647,7 +647,8 @@ iommu_map_failed:
647 iopte_t *base; 647 iopte_t *base;
648 648
649 vaddr = s->dma_address & IO_PAGE_MASK; 649 vaddr = s->dma_address & IO_PAGE_MASK;
650 npages = iommu_num_pages(s->dma_address, s->dma_length); 650 npages = iommu_num_pages(s->dma_address, s->dma_length,
651 IO_PAGE_SIZE);
651 iommu_range_free(iommu, vaddr, npages); 652 iommu_range_free(iommu, vaddr, npages);
652 653
653 entry = (vaddr - iommu->page_table_map_base) 654 entry = (vaddr - iommu->page_table_map_base)
@@ -715,7 +716,7 @@ static void dma_4u_unmap_sg(struct device *dev, struct scatterlist *sglist,
715 716
716 if (!len) 717 if (!len)
717 break; 718 break;
718 npages = iommu_num_pages(dma_handle, len); 719 npages = iommu_num_pages(dma_handle, len, IO_PAGE_SIZE);
719 iommu_range_free(iommu, dma_handle, npages); 720 iommu_range_free(iommu, dma_handle, npages);
720 721
721 entry = ((dma_handle - iommu->page_table_map_base) 722 entry = ((dma_handle - iommu->page_table_map_base)
diff --git a/arch/sparc64/kernel/iommu_common.h b/arch/sparc64/kernel/iommu_common.h
index 53b19c8231a9..591f5879039c 100644
--- a/arch/sparc64/kernel/iommu_common.h
+++ b/arch/sparc64/kernel/iommu_common.h
@@ -35,17 +35,6 @@
35 35
36#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG)))) 36#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))
37 37
38static inline unsigned long iommu_num_pages(unsigned long vaddr,
39 unsigned long slen)
40{
41 unsigned long npages;
42
43 npages = IO_PAGE_ALIGN(vaddr + slen) - (vaddr & IO_PAGE_MASK);
44 npages >>= IO_PAGE_SHIFT;
45
46 return npages;
47}
48
49static inline int is_span_boundary(unsigned long entry, 38static inline int is_span_boundary(unsigned long entry,
50 unsigned long shift, 39 unsigned long shift,
51 unsigned long boundary_size, 40 unsigned long boundary_size,
@@ -53,7 +42,8 @@ static inline int is_span_boundary(unsigned long entry,
53 struct scatterlist *sg) 42 struct scatterlist *sg)
54{ 43{
55 unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs); 44 unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs);
56 int nr = iommu_num_pages(paddr, outs->dma_length + sg->length); 45 int nr = iommu_num_pages(paddr, outs->dma_length + sg->length,
46 IO_PAGE_SIZE);
57 47
58 return iommu_is_span_boundary(entry, nr, shift, boundary_size); 48 return iommu_is_span_boundary(entry, nr, shift, boundary_size);
59} 49}
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index e86c73ec167b..34a1fded3941 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -384,7 +384,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
384 } 384 }
385 /* Allocate iommu entries for that segment */ 385 /* Allocate iommu entries for that segment */
386 paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s); 386 paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s);
387 npages = iommu_num_pages(paddr, slen); 387 npages = iommu_num_pages(paddr, slen, IO_PAGE_SIZE);
388 entry = iommu_range_alloc(dev, iommu, npages, &handle); 388 entry = iommu_range_alloc(dev, iommu, npages, &handle);
389 389
390 /* Handle failure */ 390 /* Handle failure */
@@ -461,7 +461,8 @@ iommu_map_failed:
461 unsigned long vaddr, npages; 461 unsigned long vaddr, npages;
462 462
463 vaddr = s->dma_address & IO_PAGE_MASK; 463 vaddr = s->dma_address & IO_PAGE_MASK;
464 npages = iommu_num_pages(s->dma_address, s->dma_length); 464 npages = iommu_num_pages(s->dma_address, s->dma_length,
465 IO_PAGE_SIZE);
465 iommu_range_free(iommu, vaddr, npages); 466 iommu_range_free(iommu, vaddr, npages);
466 /* XXX demap? XXX */ 467 /* XXX demap? XXX */
467 s->dma_address = DMA_ERROR_CODE; 468 s->dma_address = DMA_ERROR_CODE;
@@ -500,7 +501,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
500 501
501 if (!len) 502 if (!len)
502 break; 503 break;
503 npages = iommu_num_pages(dma_handle, len); 504 npages = iommu_num_pages(dma_handle, len, IO_PAGE_SIZE);
504 iommu_range_free(iommu, dma_handle, npages); 505 iommu_range_free(iommu, dma_handle, npages);
505 506
506 entry = ((dma_handle - iommu->page_table_map_base) >> IO_PAGE_SHIFT); 507 entry = ((dma_handle - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index 3320c9d0075f..e800503879e4 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -58,15 +58,6 @@
58#include <asm/mmu_context.h> 58#include <asm/mmu_context.h>
59#include <asm/compat_signal.h> 59#include <asm/compat_signal.h>
60 60
61/* 32-bit timeval and related flotsam. */
62
63static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
64{
65 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
66 (__put_user(i->tv_sec, &o->tv_sec) |
67 __put_user(i->tv_usec, &o->tv_usec)));
68}
69
70#ifdef CONFIG_SYSVIPC 61#ifdef CONFIG_SYSVIPC
71asmlinkage long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr, u32 fifth) 62asmlinkage long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr, u32 fifth)
72{ 63{
@@ -148,41 +139,6 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned
148 return sys_ftruncate(fd, (high << 32) | low); 139 return sys_ftruncate(fd, (high << 32) | low);
149} 140}
150 141
151int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
152{
153 compat_ino_t ino;
154 int err;
155
156 if (stat->size > MAX_NON_LFS || !old_valid_dev(stat->dev) ||
157 !old_valid_dev(stat->rdev))
158 return -EOVERFLOW;
159
160 ino = stat->ino;
161 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
162 return -EOVERFLOW;
163
164 err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev);
165 err |= put_user(stat->ino, &statbuf->st_ino);
166 err |= put_user(stat->mode, &statbuf->st_mode);
167 err |= put_user(stat->nlink, &statbuf->st_nlink);
168 err |= put_user(high2lowuid(stat->uid), &statbuf->st_uid);
169 err |= put_user(high2lowgid(stat->gid), &statbuf->st_gid);
170 err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev);
171 err |= put_user(stat->size, &statbuf->st_size);
172 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
173 err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
174 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
175 err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
176 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
177 err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
178 err |= put_user(stat->blksize, &statbuf->st_blksize);
179 err |= put_user(stat->blocks, &statbuf->st_blocks);
180 err |= put_user(0, &statbuf->__unused4[0]);
181 err |= put_user(0, &statbuf->__unused4[1]);
182
183 return err;
184}
185
186static int cp_compat_stat64(struct kstat *stat, 142static int cp_compat_stat64(struct kstat *stat,
187 struct compat_stat64 __user *statbuf) 143 struct compat_stat64 __user *statbuf)
188{ 144{
@@ -522,59 +478,6 @@ asmlinkage long sys32_delete_module(const char __user *name_user)
522 478
523#endif /* CONFIG_MODULES */ 479#endif /* CONFIG_MODULES */
524 480
525/* Translations due to time_t size differences. Which affects all
526 sorts of things, like timeval and itimerval. */
527
528extern struct timezone sys_tz;
529
530asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv,
531 struct timezone __user *tz)
532{
533 if (tv) {
534 struct timeval ktv;
535 do_gettimeofday(&ktv);
536 if (put_tv32(tv, &ktv))
537 return -EFAULT;
538 }
539 if (tz) {
540 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
541 return -EFAULT;
542 }
543 return 0;
544}
545
546static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
547{
548 long usec;
549
550 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
551 return -EFAULT;
552 if (__get_user(o->tv_sec, &i->tv_sec))
553 return -EFAULT;
554 if (__get_user(usec, &i->tv_usec))
555 return -EFAULT;
556 o->tv_nsec = usec * 1000;
557 return 0;
558}
559
560asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,
561 struct timezone __user *tz)
562{
563 struct timespec kts;
564 struct timezone ktz;
565
566 if (tv) {
567 if (get_ts32(&kts, tv))
568 return -EFAULT;
569 }
570 if (tz) {
571 if (copy_from_user(&ktz, tz, sizeof(ktz)))
572 return -EFAULT;
573 }
574
575 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
576}
577
578asmlinkage compat_ssize_t sys32_pread64(unsigned int fd, 481asmlinkage compat_ssize_t sys32_pread64(unsigned int fd,
579 char __user *ubuf, 482 char __user *ubuf,
580 compat_size_t count, 483 compat_size_t count,
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index 5daee4b04dd5..b2fa4c163638 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -41,8 +41,8 @@ sys_call_table32:
41/*100*/ .word sys32_getpriority, sys32_rt_sigreturn, sys32_rt_sigaction, sys32_rt_sigprocmask, sys32_rt_sigpending 41/*100*/ .word sys32_getpriority, sys32_rt_sigreturn, sys32_rt_sigaction, sys32_rt_sigprocmask, sys32_rt_sigpending
42 .word compat_sys_rt_sigtimedwait, sys32_rt_sigqueueinfo, compat_sys_rt_sigsuspend, sys_setresuid, sys_getresuid 42 .word compat_sys_rt_sigtimedwait, sys32_rt_sigqueueinfo, compat_sys_rt_sigsuspend, sys_setresuid, sys_getresuid
43/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall 43/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall
44 .word sys32_getgroups, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd 44 .word sys32_getgroups, compat_sys_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
45/*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys_fchown16, sys_fchmod 45/*120*/ .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod
46 .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate 46 .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate
47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall 47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64 48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
diff --git a/arch/sparc64/kernel/us3_cpufreq.c b/arch/sparc64/kernel/us3_cpufreq.c
index 47e3acafb5be..365b6464e2ce 100644
--- a/arch/sparc64/kernel/us3_cpufreq.c
+++ b/arch/sparc64/kernel/us3_cpufreq.c
@@ -183,7 +183,6 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
183 table[3].index = 0; 183 table[3].index = 0;
184 table[3].frequency = CPUFREQ_TABLE_END; 184 table[3].frequency = CPUFREQ_TABLE_END;
185 185
186 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
187 policy->cpuinfo.transition_latency = 0; 186 policy->cpuinfo.transition_latency = 0;
188 policy->cur = clock_tick; 187 policy->cur = clock_tick;
189 188
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index f5d7f4569ba7..598711c62c82 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -42,23 +42,11 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
42 PT_REGS_SP(regs) = esp; 42 PT_REGS_SP(regs) = esp;
43} 43}
44 44
45#ifdef CONFIG_TTY_LOG
46extern void log_exec(char **argv, void *tty);
47#endif
48
49static long execve1(char *file, char __user * __user *argv, 45static long execve1(char *file, char __user * __user *argv,
50 char __user *__user *env) 46 char __user *__user *env)
51{ 47{
52 long error; 48 long error;
53#ifdef CONFIG_TTY_LOG
54 struct tty_struct *tty;
55 49
56 mutex_lock(&tty_mutex);
57 tty = get_current_tty();
58 if (tty)
59 log_exec(argv, tty);
60 mutex_unlock(&tty_mutex);
61#endif
62 error = do_execve(file, argv, env, &current->thread.regs); 50 error = do_execve(file, argv, env, &current->thread.regs);
63 if (error == 0) { 51 if (error == 0) {
64 task_lock(current); 52 task_lock(current);
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index 8a48d6a30064..d66f0388f091 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -7,9 +7,6 @@ obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
7 registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ 7 registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \
8 umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ 8 umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/
9 9
10obj-$(CONFIG_TTY_LOG) += tty_log.o
11user-objs-$(CONFIG_TTY_LOG) += tty_log.o
12
13USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ 10USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
14 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ 11 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \
15 tty.o tls.o uaccess.o umid.o util.o 12 tty.o tls.o uaccess.o umid.o util.o
diff --git a/arch/um/os-Linux/tty_log.c b/arch/um/os-Linux/tty_log.c
deleted file mode 100644
index cc648e6fd3a2..000000000000
--- a/arch/um/os-Linux/tty_log.c
+++ /dev/null
@@ -1,217 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) and
3 * geoffrey hing <ghing@net.ohio-state.edu>
4 * Licensed under the GPL
5 */
6
7#include <errno.h>
8#include <string.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <unistd.h>
12#include <sys/time.h>
13#include "init.h"
14#include "user.h"
15#include "os.h"
16
17#define TTY_LOG_DIR "./"
18
19/* Set early in boot and then unchanged */
20static char *tty_log_dir = TTY_LOG_DIR;
21static int tty_log_fd = -1;
22
23#define TTY_LOG_OPEN 1
24#define TTY_LOG_CLOSE 2
25#define TTY_LOG_WRITE 3
26#define TTY_LOG_EXEC 4
27
28#define TTY_READ 1
29#define TTY_WRITE 2
30
31struct tty_log_buf {
32 int what;
33 unsigned long tty;
34 int len;
35 int direction;
36 unsigned long sec;
37 unsigned long usec;
38};
39
40int open_tty_log(void *tty, void *current_tty)
41{
42 struct timeval tv;
43 struct tty_log_buf data;
44 char buf[strlen(tty_log_dir) + sizeof("01234567890-01234567\0")];
45 int fd;
46
47 gettimeofday(&tv, NULL);
48 if(tty_log_fd != -1){
49 data = ((struct tty_log_buf) { .what = TTY_LOG_OPEN,
50 .tty = (unsigned long) tty,
51 .len = sizeof(current_tty),
52 .direction = 0,
53 .sec = tv.tv_sec,
54 .usec = tv.tv_usec } );
55 write(tty_log_fd, &data, sizeof(data));
56 write(tty_log_fd, &current_tty, data.len);
57 return tty_log_fd;
58 }
59
60 sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec,
61 (unsigned int) tv.tv_usec);
62
63 fd = os_open_file(buf, of_append(of_create(of_rdwr(OPENFLAGS()))),
64 0644);
65 if(fd < 0){
66 printk("open_tty_log : couldn't open '%s', errno = %d\n",
67 buf, -fd);
68 }
69 return fd;
70}
71
72void close_tty_log(int fd, void *tty)
73{
74 struct tty_log_buf data;
75 struct timeval tv;
76
77 if(tty_log_fd != -1){
78 gettimeofday(&tv, NULL);
79 data = ((struct tty_log_buf) { .what = TTY_LOG_CLOSE,
80 .tty = (unsigned long) tty,
81 .len = 0,
82 .direction = 0,
83 .sec = tv.tv_sec,
84 .usec = tv.tv_usec } );
85 write(tty_log_fd, &data, sizeof(data));
86 return;
87 }
88 os_close_file(fd);
89}
90
91static int log_chunk(int fd, const char *buf, int len)
92{
93 int total = 0, try, missed, n;
94 char chunk[64];
95
96 while(len > 0){
97 try = (len > sizeof(chunk)) ? sizeof(chunk) : len;
98 missed = copy_from_user_proc(chunk, (char *) buf, try);
99 try -= missed;
100 n = write(fd, chunk, try);
101 if(n != try) {
102 if(n < 0)
103 return -errno;
104 return -EIO;
105 }
106 if(missed != 0)
107 return -EFAULT;
108
109 len -= try;
110 total += try;
111 buf += try;
112 }
113
114 return total;
115}
116
117int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read)
118{
119 struct timeval tv;
120 struct tty_log_buf data;
121 int direction;
122
123 if(fd == tty_log_fd){
124 gettimeofday(&tv, NULL);
125 direction = is_read ? TTY_READ : TTY_WRITE;
126 data = ((struct tty_log_buf) { .what = TTY_LOG_WRITE,
127 .tty = (unsigned long) tty,
128 .len = len,
129 .direction = direction,
130 .sec = tv.tv_sec,
131 .usec = tv.tv_usec } );
132 write(tty_log_fd, &data, sizeof(data));
133 }
134
135 return log_chunk(fd, buf, len);
136}
137
138void log_exec(char **argv, void *tty)
139{
140 struct timeval tv;
141 struct tty_log_buf data;
142 char **ptr,*arg;
143 int len;
144
145 if(tty_log_fd == -1) return;
146
147 gettimeofday(&tv, NULL);
148
149 len = 0;
150 for(ptr = argv; ; ptr++){
151 if(copy_from_user_proc(&arg, ptr, sizeof(arg)))
152 return;
153 if(arg == NULL) break;
154 len += strlen_user_proc(arg);
155 }
156
157 data = ((struct tty_log_buf) { .what = TTY_LOG_EXEC,
158 .tty = (unsigned long) tty,
159 .len = len,
160 .direction = 0,
161 .sec = tv.tv_sec,
162 .usec = tv.tv_usec } );
163 write(tty_log_fd, &data, sizeof(data));
164
165 for(ptr = argv; ; ptr++){
166 if(copy_from_user_proc(&arg, ptr, sizeof(arg)))
167 return;
168 if(arg == NULL) break;
169 log_chunk(tty_log_fd, arg, strlen_user_proc(arg));
170 }
171}
172
173extern void register_tty_logger(int (*opener)(void *, void *),
174 int (*writer)(int, const char *, int,
175 void *, int),
176 void (*closer)(int, void *));
177
178static int register_logger(void)
179{
180 register_tty_logger(open_tty_log, write_tty_log, close_tty_log);
181 return 0;
182}
183
184__uml_initcall(register_logger);
185
186static int __init set_tty_log_dir(char *name, int *add)
187{
188 tty_log_dir = name;
189 return 0;
190}
191
192__uml_setup("tty_log_dir=", set_tty_log_dir,
193"tty_log_dir=<directory>\n"
194" This is used to specify the directory where the logs of all pty\n"
195" data from this UML machine will be written.\n\n"
196);
197
198static int __init set_tty_log_fd(char *name, int *add)
199{
200 char *end;
201
202 tty_log_fd = strtoul(name, &end, 0);
203 if((*end != '\0') || (end == name)){
204 printf("set_tty_log_fd - strtoul failed on '%s'\n", name);
205 tty_log_fd = -1;
206 }
207
208 *add = 0;
209 return 0;
210}
211
212__uml_setup("tty_log_fd=", set_tty_log_fd,
213"tty_log_fd=<fd>\n"
214" This is used to specify a preconfigured file descriptor to which all\n"
215" tty data will be written. Preconfigure the descriptor with something\n"
216" like '10>tty_log tty_log_fd=10'.\n\n"
217);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f65c2744d573..bd3c2c53873e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -39,10 +39,6 @@ config ARCH_DEFCONFIG
39 default "arch/x86/configs/i386_defconfig" if X86_32 39 default "arch/x86/configs/i386_defconfig" if X86_32
40 default "arch/x86/configs/x86_64_defconfig" if X86_64 40 default "arch/x86/configs/x86_64_defconfig" if X86_64
41 41
42
43config GENERIC_LOCKBREAK
44 def_bool n
45
46config GENERIC_TIME 42config GENERIC_TIME
47 def_bool y 43 def_bool y
48 44
@@ -95,7 +91,7 @@ config GENERIC_HWEIGHT
95 def_bool y 91 def_bool y
96 92
97config GENERIC_GPIO 93config GENERIC_GPIO
98 def_bool n 94 bool
99 95
100config ARCH_MAY_HAVE_PC_FDC 96config ARCH_MAY_HAVE_PC_FDC
101 def_bool y 97 def_bool y
@@ -106,12 +102,6 @@ config RWSEM_GENERIC_SPINLOCK
106config RWSEM_XCHGADD_ALGORITHM 102config RWSEM_XCHGADD_ALGORITHM
107 def_bool X86_XADD 103 def_bool X86_XADD
108 104
109config ARCH_HAS_ILOG2_U32
110 def_bool n
111
112config ARCH_HAS_ILOG2_U64
113 def_bool n
114
115config ARCH_HAS_CPU_IDLE_WAIT 105config ARCH_HAS_CPU_IDLE_WAIT
116 def_bool y 106 def_bool y
117 107
@@ -758,9 +748,8 @@ config I8K
758 Say N otherwise. 748 Say N otherwise.
759 749
760config X86_REBOOTFIXUPS 750config X86_REBOOTFIXUPS
761 def_bool n 751 bool "Enable X86 board specific fixups for reboot"
762 prompt "Enable X86 board specific fixups for reboot" 752 depends on X86_32
763 depends on X86_32 && X86
764 ---help--- 753 ---help---
765 This enables chipset and/or board specific fixups to be done 754 This enables chipset and/or board specific fixups to be done
766 in order to get reboot to work correctly. This is only needed on 755 in order to get reboot to work correctly. This is only needed on
@@ -944,16 +933,17 @@ config HIGHMEM
944 depends on X86_32 && (HIGHMEM64G || HIGHMEM4G) 933 depends on X86_32 && (HIGHMEM64G || HIGHMEM4G)
945 934
946config X86_PAE 935config X86_PAE
947 def_bool n 936 bool "PAE (Physical Address Extension) Support"
948 prompt "PAE (Physical Address Extension) Support"
949 depends on X86_32 && !HIGHMEM4G 937 depends on X86_32 && !HIGHMEM4G
950 select RESOURCES_64BIT
951 help 938 help
952 PAE is required for NX support, and furthermore enables 939 PAE is required for NX support, and furthermore enables
953 larger swapspace support for non-overcommit purposes. It 940 larger swapspace support for non-overcommit purposes. It
954 has the cost of more pagetable lookup overhead, and also 941 has the cost of more pagetable lookup overhead, and also
955 consumes more pagetable space per process. 942 consumes more pagetable space per process.
956 943
944config ARCH_PHYS_ADDR_T_64BIT
945 def_bool X86_64 || X86_PAE
946
957# Common NUMA Features 947# Common NUMA Features
958config NUMA 948config NUMA
959 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)" 949 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)"
@@ -1238,8 +1228,7 @@ config X86_PAT
1238 If unsure, say Y. 1228 If unsure, say Y.
1239 1229
1240config EFI 1230config EFI
1241 def_bool n 1231 bool "EFI runtime service support"
1242 prompt "EFI runtime service support"
1243 depends on ACPI 1232 depends on ACPI
1244 ---help--- 1233 ---help---
1245 This enables the kernel to use EFI runtime services that are 1234 This enables the kernel to use EFI runtime services that are
diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
index 1e6fe0214c85..99b3079dc6ab 100644
--- a/arch/x86/boot/video-vesa.c
+++ b/arch/x86/boot/video-vesa.c
@@ -88,14 +88,11 @@ static int vesa_probe(void)
88 (vminfo.memory_layout == 4 || 88 (vminfo.memory_layout == 4 ||
89 vminfo.memory_layout == 6) && 89 vminfo.memory_layout == 6) &&
90 vminfo.memory_planes == 1) { 90 vminfo.memory_planes == 1) {
91#ifdef CONFIG_FB 91#ifdef CONFIG_FB_BOOT_VESA_SUPPORT
92 /* Graphics mode, color, linear frame buffer 92 /* Graphics mode, color, linear frame buffer
93 supported. Only register the mode if 93 supported. Only register the mode if
94 if framebuffer is configured, however, 94 if framebuffer is configured, however,
95 otherwise the user will be left without a screen. 95 otherwise the user will be left without a screen. */
96 We don't require CONFIG_FB_VESA, however, since
97 some of the other framebuffer drivers can use
98 this mode-setting, too. */
99 mi = GET_HEAP(struct mode_info, 1); 96 mi = GET_HEAP(struct mode_info, 1);
100 mi->mode = mode + VIDEO_FIRST_VESA; 97 mi->mode = mode + VIDEO_FIRST_VESA;
101 mi->depth = vminfo.bpp; 98 mi->depth = vminfo.bpp;
@@ -133,10 +130,12 @@ static int vesa_set_mode(struct mode_info *mode)
133 if ((vminfo.mode_attr & 0x15) == 0x05) { 130 if ((vminfo.mode_attr & 0x15) == 0x05) {
134 /* It's a supported text mode */ 131 /* It's a supported text mode */
135 is_graphic = 0; 132 is_graphic = 0;
133#ifdef CONFIG_FB_BOOT_VESA_SUPPORT
136 } else if ((vminfo.mode_attr & 0x99) == 0x99) { 134 } else if ((vminfo.mode_attr & 0x99) == 0x99) {
137 /* It's a graphics mode with linear frame buffer */ 135 /* It's a graphics mode with linear frame buffer */
138 is_graphic = 1; 136 is_graphic = 1;
139 vesa_mode |= 0x4000; /* Request linear frame buffer */ 137 vesa_mode |= 0x4000; /* Request linear frame buffer */
138#endif
140 } else { 139 } else {
141 return -1; /* Invalid mode */ 140 return -1; /* Invalid mode */
142 } 141 }
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index eb4314768bf7..256b00b61892 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -571,8 +571,8 @@ ia32_sys_call_table:
571 .quad compat_sys_setrlimit /* 75 */ 571 .quad compat_sys_setrlimit /* 75 */
572 .quad compat_sys_old_getrlimit /* old_getrlimit */ 572 .quad compat_sys_old_getrlimit /* old_getrlimit */
573 .quad compat_sys_getrusage 573 .quad compat_sys_getrusage
574 .quad sys32_gettimeofday 574 .quad compat_sys_gettimeofday
575 .quad sys32_settimeofday 575 .quad compat_sys_settimeofday
576 .quad sys_getgroups16 /* 80 */ 576 .quad sys_getgroups16 /* 80 */
577 .quad sys_setgroups16 577 .quad sys_setgroups16
578 .quad sys32_old_select 578 .quad sys32_old_select
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index beda4232ce69..2e09dcd3c0a6 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -49,41 +49,6 @@
49 49
50#define AA(__x) ((unsigned long)(__x)) 50#define AA(__x) ((unsigned long)(__x))
51 51
52int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
53{
54 compat_ino_t ino;
55
56 typeof(ubuf->st_uid) uid = 0;
57 typeof(ubuf->st_gid) gid = 0;
58 SET_UID(uid, kbuf->uid);
59 SET_GID(gid, kbuf->gid);
60 if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
61 return -EOVERFLOW;
62 if (kbuf->size >= 0x7fffffff)
63 return -EOVERFLOW;
64 ino = kbuf->ino;
65 if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino)
66 return -EOVERFLOW;
67 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
68 __put_user(old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
69 __put_user(ino, &ubuf->st_ino) ||
70 __put_user(kbuf->mode, &ubuf->st_mode) ||
71 __put_user(kbuf->nlink, &ubuf->st_nlink) ||
72 __put_user(uid, &ubuf->st_uid) ||
73 __put_user(gid, &ubuf->st_gid) ||
74 __put_user(old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
75 __put_user(kbuf->size, &ubuf->st_size) ||
76 __put_user(kbuf->atime.tv_sec, &ubuf->st_atime) ||
77 __put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
78 __put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
79 __put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
80 __put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
81 __put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
82 __put_user(kbuf->blksize, &ubuf->st_blksize) ||
83 __put_user(kbuf->blocks, &ubuf->st_blocks))
84 return -EFAULT;
85 return 0;
86}
87 52
88asmlinkage long sys32_truncate64(char __user *filename, 53asmlinkage long sys32_truncate64(char __user *filename,
89 unsigned long offset_low, 54 unsigned long offset_low,
@@ -402,75 +367,11 @@ asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
402 return 0; 367 return 0;
403} 368}
404 369
405static inline long get_tv32(struct timeval *o, struct compat_timeval __user *i)
406{
407 int err = -EFAULT;
408
409 if (access_ok(VERIFY_READ, i, sizeof(*i))) {
410 err = __get_user(o->tv_sec, &i->tv_sec);
411 err |= __get_user(o->tv_usec, &i->tv_usec);
412 }
413 return err;
414}
415
416static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
417{
418 int err = -EFAULT;
419
420 if (access_ok(VERIFY_WRITE, o, sizeof(*o))) {
421 err = __put_user(i->tv_sec, &o->tv_sec);
422 err |= __put_user(i->tv_usec, &o->tv_usec);
423 }
424 return err;
425}
426
427asmlinkage long sys32_alarm(unsigned int seconds) 370asmlinkage long sys32_alarm(unsigned int seconds)
428{ 371{
429 return alarm_setitimer(seconds); 372 return alarm_setitimer(seconds);
430} 373}
431 374
432/*
433 * Translations due to time_t size differences. Which affects all
434 * sorts of things, like timeval and itimerval.
435 */
436asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv,
437 struct timezone __user *tz)
438{
439 if (tv) {
440 struct timeval ktv;
441
442 do_gettimeofday(&ktv);
443 if (put_tv32(tv, &ktv))
444 return -EFAULT;
445 }
446 if (tz) {
447 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
448 return -EFAULT;
449 }
450 return 0;
451}
452
453asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,
454 struct timezone __user *tz)
455{
456 struct timeval ktv;
457 struct timespec kts;
458 struct timezone ktz;
459
460 if (tv) {
461 if (get_tv32(&ktv, tv))
462 return -EFAULT;
463 kts.tv_sec = ktv.tv_sec;
464 kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC;
465 }
466 if (tz) {
467 if (copy_from_user(&ktz, tz, sizeof(ktz)))
468 return -EFAULT;
469 }
470
471 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
472}
473
474struct sel_arg_struct { 375struct sel_arg_struct {
475 unsigned int n; 376 unsigned int n;
476 unsigned int inp; 377 unsigned int inp;
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 34e4d112b1ef..a8fd9ebdc8e2 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -295,7 +295,7 @@ static int iommu_flush_pages(struct amd_iommu *iommu, u16 domid,
295 u64 address, size_t size) 295 u64 address, size_t size)
296{ 296{
297 int s = 0; 297 int s = 0;
298 unsigned pages = iommu_num_pages(address, size); 298 unsigned pages = iommu_num_pages(address, size, PAGE_SIZE);
299 299
300 address &= PAGE_MASK; 300 address &= PAGE_MASK;
301 301
@@ -680,7 +680,8 @@ static struct dma_ops_domain *dma_ops_domain_alloc(struct amd_iommu *iommu,
680 iommu->exclusion_start < dma_dom->aperture_size) { 680 iommu->exclusion_start < dma_dom->aperture_size) {
681 unsigned long startpage = iommu->exclusion_start >> PAGE_SHIFT; 681 unsigned long startpage = iommu->exclusion_start >> PAGE_SHIFT;
682 int pages = iommu_num_pages(iommu->exclusion_start, 682 int pages = iommu_num_pages(iommu->exclusion_start,
683 iommu->exclusion_length); 683 iommu->exclusion_length,
684 PAGE_SIZE);
684 dma_ops_reserve_addresses(dma_dom, startpage, pages); 685 dma_ops_reserve_addresses(dma_dom, startpage, pages);
685 } 686 }
686 687
@@ -935,7 +936,7 @@ static dma_addr_t __map_single(struct device *dev,
935 unsigned long align_mask = 0; 936 unsigned long align_mask = 0;
936 int i; 937 int i;
937 938
938 pages = iommu_num_pages(paddr, size); 939 pages = iommu_num_pages(paddr, size, PAGE_SIZE);
939 paddr &= PAGE_MASK; 940 paddr &= PAGE_MASK;
940 941
941 if (align) 942 if (align)
@@ -980,7 +981,7 @@ static void __unmap_single(struct amd_iommu *iommu,
980 if ((dma_addr == 0) || (dma_addr + size > dma_dom->aperture_size)) 981 if ((dma_addr == 0) || (dma_addr + size > dma_dom->aperture_size))
981 return; 982 return;
982 983
983 pages = iommu_num_pages(dma_addr, size); 984 pages = iommu_num_pages(dma_addr, size, PAGE_SIZE);
984 dma_addr &= PAGE_MASK; 985 dma_addr &= PAGE_MASK;
985 start = dma_addr; 986 start = dma_addr;
986 987
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 6a44d6465991..72cefd1e649b 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -147,8 +147,8 @@ static __cpuinit int cpuid_device_create(int cpu)
147{ 147{
148 struct device *dev; 148 struct device *dev;
149 149
150 dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), 150 dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL,
151 NULL, "cpu%d", cpu); 151 "cpu%d", cpu);
152 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 152 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
153} 153}
154 154
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 201ee359a1a9..1a78180f08d3 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -13,6 +13,7 @@
13#include <linux/kexec.h> 13#include <linux/kexec.h>
14#include <linux/bug.h> 14#include <linux/bug.h>
15#include <linux/nmi.h> 15#include <linux/nmi.h>
16#include <linux/sysfs.h>
16 17
17#include <asm/stacktrace.h> 18#include <asm/stacktrace.h>
18 19
@@ -343,6 +344,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
343 printk("DEBUG_PAGEALLOC"); 344 printk("DEBUG_PAGEALLOC");
344#endif 345#endif
345 printk("\n"); 346 printk("\n");
347 sysfs_printk_last_file();
346 if (notify_die(DIE_OOPS, str, regs, err, 348 if (notify_die(DIE_OOPS, str, regs, err,
347 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) 349 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
348 return 1; 350 return 1;
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 086cc8118e39..96a5db7da8a7 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -13,6 +13,7 @@
13#include <linux/kexec.h> 13#include <linux/kexec.h>
14#include <linux/bug.h> 14#include <linux/bug.h>
15#include <linux/nmi.h> 15#include <linux/nmi.h>
16#include <linux/sysfs.h>
16 17
17#include <asm/stacktrace.h> 18#include <asm/stacktrace.h>
18 19
@@ -489,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
489 printk("DEBUG_PAGEALLOC"); 490 printk("DEBUG_PAGEALLOC");
490#endif 491#endif
491 printk("\n"); 492 printk("\n");
493 sysfs_printk_last_file();
492 if (notify_die(DIE_OOPS, str, regs, err, 494 if (notify_die(DIE_OOPS, str, regs, err,
493 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) 495 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
494 return 1; 496 return 1;
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 78e642feac30..ce97bf3bed12 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1282,12 +1282,10 @@ void __init e820_reserve_resources(void)
1282 e820_res = res; 1282 e820_res = res;
1283 for (i = 0; i < e820.nr_map; i++) { 1283 for (i = 0; i < e820.nr_map; i++) {
1284 end = e820.map[i].addr + e820.map[i].size - 1; 1284 end = e820.map[i].addr + e820.map[i].size - 1;
1285#ifndef CONFIG_RESOURCES_64BIT 1285 if (end != (resource_size_t)end) {
1286 if (end > 0x100000000ULL) {
1287 res++; 1286 res++;
1288 continue; 1287 continue;
1289 } 1288 }
1290#endif
1291 res->name = e820_type_to_string(e820.map[i].type); 1289 res->name = e820_type_to_string(e820.map[i].type);
1292 res->start = e820.map[i].addr; 1290 res->start = e820.map[i].addr;
1293 res->end = end; 1291 res->end = end;
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d02def06ca91..774ac4991568 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -78,6 +78,34 @@ static cycle_t kvm_clock_read(void)
78 return ret; 78 return ret;
79} 79}
80 80
81/*
82 * If we don't do that, there is the possibility that the guest
83 * will calibrate under heavy load - thus, getting a lower lpj -
84 * and execute the delays themselves without load. This is wrong,
85 * because no delay loop can finish beforehand.
86 * Any heuristics is subject to fail, because ultimately, a large
87 * poll of guests can be running and trouble each other. So we preset
88 * lpj here
89 */
90static unsigned long kvm_get_tsc_khz(void)
91{
92 return preset_lpj;
93}
94
95static void kvm_get_preset_lpj(void)
96{
97 struct pvclock_vcpu_time_info *src;
98 unsigned long khz;
99 u64 lpj;
100
101 src = &per_cpu(hv_clock, 0);
102 khz = pvclock_tsc_khz(src);
103
104 lpj = ((u64)khz * 1000);
105 do_div(lpj, HZ);
106 preset_lpj = lpj;
107}
108
81static struct clocksource kvm_clock = { 109static struct clocksource kvm_clock = {
82 .name = "kvm-clock", 110 .name = "kvm-clock",
83 .read = kvm_clock_read, 111 .read = kvm_clock_read,
@@ -153,6 +181,7 @@ void __init kvmclock_init(void)
153 pv_time_ops.get_wallclock = kvm_get_wallclock; 181 pv_time_ops.get_wallclock = kvm_get_wallclock;
154 pv_time_ops.set_wallclock = kvm_set_wallclock; 182 pv_time_ops.set_wallclock = kvm_set_wallclock;
155 pv_time_ops.sched_clock = kvm_clock_read; 183 pv_time_ops.sched_clock = kvm_clock_read;
184 pv_time_ops.get_tsc_khz = kvm_get_tsc_khz;
156#ifdef CONFIG_X86_LOCAL_APIC 185#ifdef CONFIG_X86_LOCAL_APIC
157 pv_apic_ops.setup_secondary_clock = kvm_setup_secondary_clock; 186 pv_apic_ops.setup_secondary_clock = kvm_setup_secondary_clock;
158#endif 187#endif
@@ -163,6 +192,7 @@ void __init kvmclock_init(void)
163#ifdef CONFIG_KEXEC 192#ifdef CONFIG_KEXEC
164 machine_ops.crash_shutdown = kvm_crash_shutdown; 193 machine_ops.crash_shutdown = kvm_crash_shutdown;
165#endif 194#endif
195 kvm_get_preset_lpj();
166 clocksource_register(&kvm_clock); 196 clocksource_register(&kvm_clock);
167 } 197 }
168} 198}
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 2e2af5d18191..82a7c7ed6d45 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -163,8 +163,8 @@ static int __cpuinit msr_device_create(int cpu)
163{ 163{
164 struct device *dev; 164 struct device *dev;
165 165
166 dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), 166 dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL,
167 NULL, "msr%d", cpu); 167 "msr%d", cpu);
168 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 168 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
169} 169}
170 170
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 080d1d27f37a..e1e731d78f38 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -217,16 +217,6 @@ static inline unsigned long verify_bit_range(unsigned long* bitmap,
217 217
218#endif /* CONFIG_IOMMU_DEBUG */ 218#endif /* CONFIG_IOMMU_DEBUG */
219 219
220static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen)
221{
222 unsigned int npages;
223
224 npages = PAGE_ALIGN(dma + dmalen) - (dma & PAGE_MASK);
225 npages >>= PAGE_SHIFT;
226
227 return npages;
228}
229
230static inline int translation_enabled(struct iommu_table *tbl) 220static inline int translation_enabled(struct iommu_table *tbl)
231{ 221{
232 /* only PHBs with translation enabled have an IOMMU table */ 222 /* only PHBs with translation enabled have an IOMMU table */
@@ -408,7 +398,7 @@ static void calgary_unmap_sg(struct device *dev,
408 if (dmalen == 0) 398 if (dmalen == 0)
409 break; 399 break;
410 400
411 npages = num_dma_pages(dma, dmalen); 401 npages = iommu_num_pages(dma, dmalen, PAGE_SIZE);
412 iommu_free(tbl, dma, npages); 402 iommu_free(tbl, dma, npages);
413 } 403 }
414} 404}
@@ -427,7 +417,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
427 BUG_ON(!sg_page(s)); 417 BUG_ON(!sg_page(s));
428 418
429 vaddr = (unsigned long) sg_virt(s); 419 vaddr = (unsigned long) sg_virt(s);
430 npages = num_dma_pages(vaddr, s->length); 420 npages = iommu_num_pages(vaddr, s->length, PAGE_SIZE);
431 421
432 entry = iommu_range_alloc(dev, tbl, npages); 422 entry = iommu_range_alloc(dev, tbl, npages);
433 if (entry == bad_dma_address) { 423 if (entry == bad_dma_address) {
@@ -464,7 +454,7 @@ static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr,
464 struct iommu_table *tbl = find_iommu_table(dev); 454 struct iommu_table *tbl = find_iommu_table(dev);
465 455
466 uaddr = (unsigned long)vaddr; 456 uaddr = (unsigned long)vaddr;
467 npages = num_dma_pages(uaddr, size); 457 npages = iommu_num_pages(uaddr, size, PAGE_SIZE);
468 458
469 return iommu_alloc(dev, tbl, vaddr, npages, direction); 459 return iommu_alloc(dev, tbl, vaddr, npages, direction);
470} 460}
@@ -475,7 +465,7 @@ static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
475 struct iommu_table *tbl = find_iommu_table(dev); 465 struct iommu_table *tbl = find_iommu_table(dev);
476 unsigned int npages; 466 unsigned int npages;
477 467
478 npages = num_dma_pages(dma_handle, size); 468 npages = iommu_num_pages(dma_handle, size, PAGE_SIZE);
479 iommu_free(tbl, dma_handle, npages); 469 iommu_free(tbl, dma_handle, npages);
480} 470}
481 471
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 0a3824e837b4..192624820217 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -125,13 +125,13 @@ void __init pci_iommu_alloc(void)
125 pci_swiotlb_init(); 125 pci_swiotlb_init();
126} 126}
127 127
128unsigned long iommu_num_pages(unsigned long addr, unsigned long len) 128unsigned long iommu_nr_pages(unsigned long addr, unsigned long len)
129{ 129{
130 unsigned long size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE); 130 unsigned long size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE);
131 131
132 return size >> PAGE_SHIFT; 132 return size >> PAGE_SHIFT;
133} 133}
134EXPORT_SYMBOL(iommu_num_pages); 134EXPORT_SYMBOL(iommu_nr_pages);
135#endif 135#endif
136 136
137void *dma_generic_alloc_coherent(struct device *dev, size_t size, 137void *dma_generic_alloc_coherent(struct device *dev, size_t size,
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 145f1c83369f..e3f75bbcedea 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -231,7 +231,7 @@ nonforced_iommu(struct device *dev, unsigned long addr, size_t size)
231static 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,
232 size_t size, int dir, unsigned long align_mask) 232 size_t size, int dir, unsigned long align_mask)
233{ 233{
234 unsigned long npages = iommu_num_pages(phys_mem, size); 234 unsigned long npages = iommu_num_pages(phys_mem, size, PAGE_SIZE);
235 unsigned long iommu_page = alloc_iommu(dev, npages, align_mask); 235 unsigned long iommu_page = alloc_iommu(dev, npages, align_mask);
236 int i; 236 int i;
237 237
@@ -285,7 +285,7 @@ static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
285 return; 285 return;
286 286
287 iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT; 287 iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT;
288 npages = iommu_num_pages(dma_addr, size); 288 npages = iommu_num_pages(dma_addr, size, PAGE_SIZE);
289 for (i = 0; i < npages; i++) { 289 for (i = 0; i < npages; i++) {
290 iommu_gatt_base[iommu_page + i] = gart_unmapped_entry; 290 iommu_gatt_base[iommu_page + i] = gart_unmapped_entry;
291 CLEAR_LEAK(iommu_page + i); 291 CLEAR_LEAK(iommu_page + i);
@@ -368,7 +368,7 @@ static int __dma_map_cont(struct device *dev, struct scatterlist *start,
368 } 368 }
369 369
370 addr = phys_addr; 370 addr = phys_addr;
371 pages = iommu_num_pages(s->offset, s->length); 371 pages = iommu_num_pages(s->offset, s->length, PAGE_SIZE);
372 while (pages--) { 372 while (pages--) {
373 iommu_gatt_base[iommu_page] = GPTE_ENCODE(addr); 373 iommu_gatt_base[iommu_page] = GPTE_ENCODE(addr);
374 SET_LEAK(iommu_page); 374 SET_LEAK(iommu_page);
@@ -451,7 +451,7 @@ gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
451 451
452 seg_size += s->length; 452 seg_size += s->length;
453 need = nextneed; 453 need = nextneed;
454 pages += iommu_num_pages(s->offset, s->length); 454 pages += iommu_num_pages(s->offset, s->length, PAGE_SIZE);
455 ps = s; 455 ps = s;
456 } 456 }
457 if (dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0) 457 if (dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0)
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 05fbe9a0325a..4f9c55f3a7c0 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -97,6 +97,18 @@ static unsigned pvclock_get_time_values(struct pvclock_shadow_time *dst,
97 return dst->version; 97 return dst->version;
98} 98}
99 99
100unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
101{
102 u64 pv_tsc_khz = 1000000ULL << 32;
103
104 do_div(pv_tsc_khz, src->tsc_to_system_mul);
105 if (src->tsc_shift < 0)
106 pv_tsc_khz <<= -src->tsc_shift;
107 else
108 pv_tsc_khz >>= src->tsc_shift;
109 return pv_tsc_khz;
110}
111
100cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src) 112cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
101{ 113{
102 struct pvclock_shadow_time shadow; 114 struct pvclock_shadow_time shadow;
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 8c3aca7cb343..7ed9e070a6e9 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -282,6 +282,8 @@ static void __cpuinit smp_callin(void)
282 cpu_set(cpuid, cpu_callin_map); 282 cpu_set(cpuid, cpu_callin_map);
283} 283}
284 284
285static int __cpuinitdata unsafe_smp;
286
285/* 287/*
286 * Activate a secondary processor. 288 * Activate a secondary processor.
287 */ 289 */
@@ -397,7 +399,7 @@ static void __cpuinit smp_apply_quirks(struct cpuinfo_x86 *c)
397 goto valid_k7; 399 goto valid_k7;
398 400
399 /* If we get here, not a certified SMP capable AMD system. */ 401 /* If we get here, not a certified SMP capable AMD system. */
400 add_taint(TAINT_UNSAFE_SMP); 402 unsafe_smp = 1;
401 } 403 }
402 404
403valid_k7: 405valid_k7:
@@ -414,12 +416,10 @@ static void __cpuinit smp_checks(void)
414 * Don't taint if we are running SMP kernel on a single non-MP 416 * Don't taint if we are running SMP kernel on a single non-MP
415 * approved Athlon 417 * approved Athlon
416 */ 418 */
417 if (tainted & TAINT_UNSAFE_SMP) { 419 if (unsafe_smp && num_online_cpus() > 1) {
418 if (num_online_cpus()) 420 printk(KERN_INFO "WARNING: This combination of AMD"
419 printk(KERN_INFO "WARNING: This combination of AMD" 421 "processors is not suitable for SMP.\n");
420 "processors is not suitable for SMP.\n"); 422 add_taint(TAINT_UNSAFE_SMP);
421 else
422 tainted &= ~TAINT_UNSAFE_SMP;
423 } 423 }
424} 424}
425 425
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index d0e940bb6f40..c02343594b4d 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -3,10 +3,13 @@
3# 3#
4 4
5common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ 5common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
6 coalesced_mmio.o) 6 coalesced_mmio.o irq_comm.o)
7ifeq ($(CONFIG_KVM_TRACE),y) 7ifeq ($(CONFIG_KVM_TRACE),y)
8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) 8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o)
9endif 9endif
10ifeq ($(CONFIG_DMAR),y)
11common-objs += $(addprefix ../../../virt/kvm/, vtd.o)
12endif
10 13
11EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm 14EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm
12 15
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index c0f7872a9124..634132a9a512 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -200,13 +200,14 @@ static int __pit_timer_fn(struct kvm_kpit_state *ps)
200 200
201 if (!atomic_inc_and_test(&pt->pending)) 201 if (!atomic_inc_and_test(&pt->pending))
202 set_bit(KVM_REQ_PENDING_TIMER, &vcpu0->requests); 202 set_bit(KVM_REQ_PENDING_TIMER, &vcpu0->requests);
203 if (vcpu0 && waitqueue_active(&vcpu0->wq)) { 203
204 vcpu0->arch.mp_state = KVM_MP_STATE_RUNNABLE; 204 if (vcpu0 && waitqueue_active(&vcpu0->wq))
205 wake_up_interruptible(&vcpu0->wq); 205 wake_up_interruptible(&vcpu0->wq);
206 }
207 206
208 pt->timer.expires = ktime_add_ns(pt->timer.expires, pt->period); 207 pt->timer.expires = ktime_add_ns(pt->timer.expires, pt->period);
209 pt->scheduled = ktime_to_ns(pt->timer.expires); 208 pt->scheduled = ktime_to_ns(pt->timer.expires);
209 if (pt->period)
210 ps->channels[0].count_load_time = pt->timer.expires;
210 211
211 return (pt->period == 0 ? 0 : 1); 212 return (pt->period == 0 ? 0 : 1);
212} 213}
@@ -215,12 +216,22 @@ int pit_has_pending_timer(struct kvm_vcpu *vcpu)
215{ 216{
216 struct kvm_pit *pit = vcpu->kvm->arch.vpit; 217 struct kvm_pit *pit = vcpu->kvm->arch.vpit;
217 218
218 if (pit && vcpu->vcpu_id == 0 && pit->pit_state.inject_pending) 219 if (pit && vcpu->vcpu_id == 0 && pit->pit_state.irq_ack)
219 return atomic_read(&pit->pit_state.pit_timer.pending); 220 return atomic_read(&pit->pit_state.pit_timer.pending);
220
221 return 0; 221 return 0;
222} 222}
223 223
224static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian)
225{
226 struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state,
227 irq_ack_notifier);
228 spin_lock(&ps->inject_lock);
229 if (atomic_dec_return(&ps->pit_timer.pending) < 0)
230 atomic_inc(&ps->pit_timer.pending);
231 ps->irq_ack = 1;
232 spin_unlock(&ps->inject_lock);
233}
234
224static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) 235static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
225{ 236{
226 struct kvm_kpit_state *ps; 237 struct kvm_kpit_state *ps;
@@ -255,8 +266,9 @@ static void destroy_pit_timer(struct kvm_kpit_timer *pt)
255 hrtimer_cancel(&pt->timer); 266 hrtimer_cancel(&pt->timer);
256} 267}
257 268
258static void create_pit_timer(struct kvm_kpit_timer *pt, u32 val, int is_period) 269static void create_pit_timer(struct kvm_kpit_state *ps, u32 val, int is_period)
259{ 270{
271 struct kvm_kpit_timer *pt = &ps->pit_timer;
260 s64 interval; 272 s64 interval;
261 273
262 interval = muldiv64(val, NSEC_PER_SEC, KVM_PIT_FREQ); 274 interval = muldiv64(val, NSEC_PER_SEC, KVM_PIT_FREQ);
@@ -268,6 +280,7 @@ static void create_pit_timer(struct kvm_kpit_timer *pt, u32 val, int is_period)
268 pt->period = (is_period == 0) ? 0 : interval; 280 pt->period = (is_period == 0) ? 0 : interval;
269 pt->timer.function = pit_timer_fn; 281 pt->timer.function = pit_timer_fn;
270 atomic_set(&pt->pending, 0); 282 atomic_set(&pt->pending, 0);
283 ps->irq_ack = 1;
271 284
272 hrtimer_start(&pt->timer, ktime_add_ns(ktime_get(), interval), 285 hrtimer_start(&pt->timer, ktime_add_ns(ktime_get(), interval),
273 HRTIMER_MODE_ABS); 286 HRTIMER_MODE_ABS);
@@ -302,11 +315,11 @@ static void pit_load_count(struct kvm *kvm, int channel, u32 val)
302 case 1: 315 case 1:
303 /* FIXME: enhance mode 4 precision */ 316 /* FIXME: enhance mode 4 precision */
304 case 4: 317 case 4:
305 create_pit_timer(&ps->pit_timer, val, 0); 318 create_pit_timer(ps, val, 0);
306 break; 319 break;
307 case 2: 320 case 2:
308 case 3: 321 case 3:
309 create_pit_timer(&ps->pit_timer, val, 1); 322 create_pit_timer(ps, val, 1);
310 break; 323 break;
311 default: 324 default:
312 destroy_pit_timer(&ps->pit_timer); 325 destroy_pit_timer(&ps->pit_timer);
@@ -520,7 +533,7 @@ void kvm_pit_reset(struct kvm_pit *pit)
520 mutex_unlock(&pit->pit_state.lock); 533 mutex_unlock(&pit->pit_state.lock);
521 534
522 atomic_set(&pit->pit_state.pit_timer.pending, 0); 535 atomic_set(&pit->pit_state.pit_timer.pending, 0);
523 pit->pit_state.inject_pending = 1; 536 pit->pit_state.irq_ack = 1;
524} 537}
525 538
526struct kvm_pit *kvm_create_pit(struct kvm *kvm) 539struct kvm_pit *kvm_create_pit(struct kvm *kvm)
@@ -534,6 +547,7 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm)
534 547
535 mutex_init(&pit->pit_state.lock); 548 mutex_init(&pit->pit_state.lock);
536 mutex_lock(&pit->pit_state.lock); 549 mutex_lock(&pit->pit_state.lock);
550 spin_lock_init(&pit->pit_state.inject_lock);
537 551
538 /* Initialize PIO device */ 552 /* Initialize PIO device */
539 pit->dev.read = pit_ioport_read; 553 pit->dev.read = pit_ioport_read;
@@ -555,6 +569,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm)
555 pit_state->pit = pit; 569 pit_state->pit = pit;
556 hrtimer_init(&pit_state->pit_timer.timer, 570 hrtimer_init(&pit_state->pit_timer.timer,
557 CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 571 CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
572 pit_state->irq_ack_notifier.gsi = 0;
573 pit_state->irq_ack_notifier.irq_acked = kvm_pit_ack_irq;
574 kvm_register_irq_ack_notifier(kvm, &pit_state->irq_ack_notifier);
558 mutex_unlock(&pit->pit_state.lock); 575 mutex_unlock(&pit->pit_state.lock);
559 576
560 kvm_pit_reset(pit); 577 kvm_pit_reset(pit);
@@ -578,10 +595,8 @@ void kvm_free_pit(struct kvm *kvm)
578static void __inject_pit_timer_intr(struct kvm *kvm) 595static void __inject_pit_timer_intr(struct kvm *kvm)
579{ 596{
580 mutex_lock(&kvm->lock); 597 mutex_lock(&kvm->lock);
581 kvm_ioapic_set_irq(kvm->arch.vioapic, 0, 1); 598 kvm_set_irq(kvm, 0, 1);
582 kvm_ioapic_set_irq(kvm->arch.vioapic, 0, 0); 599 kvm_set_irq(kvm, 0, 0);
583 kvm_pic_set_irq(pic_irqchip(kvm), 0, 1);
584 kvm_pic_set_irq(pic_irqchip(kvm), 0, 0);
585 mutex_unlock(&kvm->lock); 600 mutex_unlock(&kvm->lock);
586} 601}
587 602
@@ -592,37 +607,19 @@ void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu)
592 struct kvm_kpit_state *ps; 607 struct kvm_kpit_state *ps;
593 608
594 if (vcpu && pit) { 609 if (vcpu && pit) {
610 int inject = 0;
595 ps = &pit->pit_state; 611 ps = &pit->pit_state;
596 612
597 /* Try to inject pending interrupts when: 613 /* Try to inject pending interrupts when
598 * 1. Pending exists 614 * last one has been acked.
599 * 2. Last interrupt was accepted or waited for too long time*/ 615 */
600 if (atomic_read(&ps->pit_timer.pending) && 616 spin_lock(&ps->inject_lock);
601 (ps->inject_pending || 617 if (atomic_read(&ps->pit_timer.pending) && ps->irq_ack) {
602 (jiffies - ps->last_injected_time 618 ps->irq_ack = 0;
603 >= KVM_MAX_PIT_INTR_INTERVAL))) { 619 inject = 1;
604 ps->inject_pending = 0;
605 __inject_pit_timer_intr(kvm);
606 ps->last_injected_time = jiffies;
607 }
608 }
609}
610
611void kvm_pit_timer_intr_post(struct kvm_vcpu *vcpu, int vec)
612{
613 struct kvm_arch *arch = &vcpu->kvm->arch;
614 struct kvm_kpit_state *ps;
615
616 if (vcpu && arch->vpit) {
617 ps = &arch->vpit->pit_state;
618 if (atomic_read(&ps->pit_timer.pending) &&
619 (((arch->vpic->pics[0].imr & 1) == 0 &&
620 arch->vpic->pics[0].irq_base == vec) ||
621 (arch->vioapic->redirtbl[0].fields.vector == vec &&
622 arch->vioapic->redirtbl[0].fields.mask != 1))) {
623 ps->inject_pending = 1;
624 atomic_dec(&ps->pit_timer.pending);
625 ps->channels[0].count_load_time = ktime_get();
626 } 620 }
621 spin_unlock(&ps->inject_lock);
622 if (inject)
623 __inject_pit_timer_intr(kvm);
627 } 624 }
628} 625}
diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h
index db25c2a6c8c4..e436d4983aa1 100644
--- a/arch/x86/kvm/i8254.h
+++ b/arch/x86/kvm/i8254.h
@@ -8,7 +8,6 @@ struct kvm_kpit_timer {
8 int irq; 8 int irq;
9 s64 period; /* unit: ns */ 9 s64 period; /* unit: ns */
10 s64 scheduled; 10 s64 scheduled;
11 ktime_t last_update;
12 atomic_t pending; 11 atomic_t pending;
13}; 12};
14 13
@@ -34,8 +33,9 @@ struct kvm_kpit_state {
34 u32 speaker_data_on; 33 u32 speaker_data_on;
35 struct mutex lock; 34 struct mutex lock;
36 struct kvm_pit *pit; 35 struct kvm_pit *pit;
37 bool inject_pending; /* if inject pending interrupts */ 36 spinlock_t inject_lock;
38 unsigned long last_injected_time; 37 unsigned long irq_ack;
38 struct kvm_irq_ack_notifier irq_ack_notifier;
39}; 39};
40 40
41struct kvm_pit { 41struct kvm_pit {
@@ -54,7 +54,6 @@ struct kvm_pit {
54#define KVM_PIT_CHANNEL_MASK 0x3 54#define KVM_PIT_CHANNEL_MASK 0x3
55 55
56void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu); 56void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu);
57void kvm_pit_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
58void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val); 57void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val);
59struct kvm_pit *kvm_create_pit(struct kvm *kvm); 58struct kvm_pit *kvm_create_pit(struct kvm *kvm);
60void kvm_free_pit(struct kvm *kvm); 59void kvm_free_pit(struct kvm *kvm);
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index c31164e8aa46..17e41e165f1a 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -30,6 +30,19 @@
30 30
31#include <linux/kvm_host.h> 31#include <linux/kvm_host.h>
32 32
33static void pic_clear_isr(struct kvm_kpic_state *s, int irq)
34{
35 s->isr &= ~(1 << irq);
36 s->isr_ack |= (1 << irq);
37}
38
39void kvm_pic_clear_isr_ack(struct kvm *kvm)
40{
41 struct kvm_pic *s = pic_irqchip(kvm);
42 s->pics[0].isr_ack = 0xff;
43 s->pics[1].isr_ack = 0xff;
44}
45
33/* 46/*
34 * set irq level. If an edge is detected, then the IRR is set to 1 47 * set irq level. If an edge is detected, then the IRR is set to 1
35 */ 48 */
@@ -141,11 +154,12 @@ void kvm_pic_set_irq(void *opaque, int irq, int level)
141 */ 154 */
142static inline void pic_intack(struct kvm_kpic_state *s, int irq) 155static inline void pic_intack(struct kvm_kpic_state *s, int irq)
143{ 156{
157 s->isr |= 1 << irq;
144 if (s->auto_eoi) { 158 if (s->auto_eoi) {
145 if (s->rotate_on_auto_eoi) 159 if (s->rotate_on_auto_eoi)
146 s->priority_add = (irq + 1) & 7; 160 s->priority_add = (irq + 1) & 7;
147 } else 161 pic_clear_isr(s, irq);
148 s->isr |= (1 << irq); 162 }
149 /* 163 /*
150 * We don't clear a level sensitive interrupt here 164 * We don't clear a level sensitive interrupt here
151 */ 165 */
@@ -153,9 +167,10 @@ static inline void pic_intack(struct kvm_kpic_state *s, int irq)
153 s->irr &= ~(1 << irq); 167 s->irr &= ~(1 << irq);
154} 168}
155 169
156int kvm_pic_read_irq(struct kvm_pic *s) 170int kvm_pic_read_irq(struct kvm *kvm)
157{ 171{
158 int irq, irq2, intno; 172 int irq, irq2, intno;
173 struct kvm_pic *s = pic_irqchip(kvm);
159 174
160 irq = pic_get_irq(&s->pics[0]); 175 irq = pic_get_irq(&s->pics[0]);
161 if (irq >= 0) { 176 if (irq >= 0) {
@@ -181,16 +196,32 @@ int kvm_pic_read_irq(struct kvm_pic *s)
181 intno = s->pics[0].irq_base + irq; 196 intno = s->pics[0].irq_base + irq;
182 } 197 }
183 pic_update_irq(s); 198 pic_update_irq(s);
199 kvm_notify_acked_irq(kvm, irq);
184 200
185 return intno; 201 return intno;
186} 202}
187 203
188void kvm_pic_reset(struct kvm_kpic_state *s) 204void kvm_pic_reset(struct kvm_kpic_state *s)
189{ 205{
206 int irq, irqbase;
207 struct kvm *kvm = s->pics_state->irq_request_opaque;
208 struct kvm_vcpu *vcpu0 = kvm->vcpus[0];
209
210 if (s == &s->pics_state->pics[0])
211 irqbase = 0;
212 else
213 irqbase = 8;
214
215 for (irq = 0; irq < PIC_NUM_PINS/2; irq++) {
216 if (vcpu0 && kvm_apic_accept_pic_intr(vcpu0))
217 if (s->irr & (1 << irq) || s->isr & (1 << irq))
218 kvm_notify_acked_irq(kvm, irq+irqbase);
219 }
190 s->last_irr = 0; 220 s->last_irr = 0;
191 s->irr = 0; 221 s->irr = 0;
192 s->imr = 0; 222 s->imr = 0;
193 s->isr = 0; 223 s->isr = 0;
224 s->isr_ack = 0xff;
194 s->priority_add = 0; 225 s->priority_add = 0;
195 s->irq_base = 0; 226 s->irq_base = 0;
196 s->read_reg_select = 0; 227 s->read_reg_select = 0;
@@ -243,7 +274,7 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
243 priority = get_priority(s, s->isr); 274 priority = get_priority(s, s->isr);
244 if (priority != 8) { 275 if (priority != 8) {
245 irq = (priority + s->priority_add) & 7; 276 irq = (priority + s->priority_add) & 7;
246 s->isr &= ~(1 << irq); 277 pic_clear_isr(s, irq);
247 if (cmd == 5) 278 if (cmd == 5)
248 s->priority_add = (irq + 1) & 7; 279 s->priority_add = (irq + 1) & 7;
249 pic_update_irq(s->pics_state); 280 pic_update_irq(s->pics_state);
@@ -251,7 +282,7 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
251 break; 282 break;
252 case 3: 283 case 3:
253 irq = val & 7; 284 irq = val & 7;
254 s->isr &= ~(1 << irq); 285 pic_clear_isr(s, irq);
255 pic_update_irq(s->pics_state); 286 pic_update_irq(s->pics_state);
256 break; 287 break;
257 case 6: 288 case 6:
@@ -260,8 +291,8 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
260 break; 291 break;
261 case 7: 292 case 7:
262 irq = val & 7; 293 irq = val & 7;
263 s->isr &= ~(1 << irq);
264 s->priority_add = (irq + 1) & 7; 294 s->priority_add = (irq + 1) & 7;
295 pic_clear_isr(s, irq);
265 pic_update_irq(s->pics_state); 296 pic_update_irq(s->pics_state);
266 break; 297 break;
267 default: 298 default:
@@ -303,7 +334,7 @@ static u32 pic_poll_read(struct kvm_kpic_state *s, u32 addr1)
303 s->pics_state->pics[0].irr &= ~(1 << 2); 334 s->pics_state->pics[0].irr &= ~(1 << 2);
304 } 335 }
305 s->irr &= ~(1 << ret); 336 s->irr &= ~(1 << ret);
306 s->isr &= ~(1 << ret); 337 pic_clear_isr(s, ret);
307 if (addr1 >> 7 || ret != 2) 338 if (addr1 >> 7 || ret != 2)
308 pic_update_irq(s->pics_state); 339 pic_update_irq(s->pics_state);
309 } else { 340 } else {
@@ -422,10 +453,14 @@ static void pic_irq_request(void *opaque, int level)
422{ 453{
423 struct kvm *kvm = opaque; 454 struct kvm *kvm = opaque;
424 struct kvm_vcpu *vcpu = kvm->vcpus[0]; 455 struct kvm_vcpu *vcpu = kvm->vcpus[0];
456 struct kvm_pic *s = pic_irqchip(kvm);
457 int irq = pic_get_irq(&s->pics[0]);
425 458
426 pic_irqchip(kvm)->output = level; 459 s->output = level;
427 if (vcpu) 460 if (vcpu && level && (s->pics[0].isr_ack & (1 << irq))) {
461 s->pics[0].isr_ack &= ~(1 << irq);
428 kvm_vcpu_kick(vcpu); 462 kvm_vcpu_kick(vcpu);
463 }
429} 464}
430 465
431struct kvm_pic *kvm_create_pic(struct kvm *kvm) 466struct kvm_pic *kvm_create_pic(struct kvm *kvm)
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 76d736b5f664..c019b8edcdb7 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -72,7 +72,7 @@ int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
72 if (kvm_apic_accept_pic_intr(v)) { 72 if (kvm_apic_accept_pic_intr(v)) {
73 s = pic_irqchip(v->kvm); 73 s = pic_irqchip(v->kvm);
74 s->output = 0; /* PIC */ 74 s->output = 0; /* PIC */
75 vector = kvm_pic_read_irq(s); 75 vector = kvm_pic_read_irq(v->kvm);
76 } 76 }
77 } 77 }
78 return vector; 78 return vector;
@@ -90,7 +90,6 @@ EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs);
90void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec) 90void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec)
91{ 91{
92 kvm_apic_timer_intr_post(vcpu, vec); 92 kvm_apic_timer_intr_post(vcpu, vec);
93 kvm_pit_timer_intr_post(vcpu, vec);
94 /* TODO: PIT, RTC etc. */ 93 /* TODO: PIT, RTC etc. */
95} 94}
96EXPORT_SYMBOL_GPL(kvm_timer_intr_post); 95EXPORT_SYMBOL_GPL(kvm_timer_intr_post);
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 7ca47cbb48bb..f17c8f5bbf31 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -42,6 +42,7 @@ struct kvm_kpic_state {
42 u8 irr; /* interrupt request register */ 42 u8 irr; /* interrupt request register */
43 u8 imr; /* interrupt mask register */ 43 u8 imr; /* interrupt mask register */
44 u8 isr; /* interrupt service register */ 44 u8 isr; /* interrupt service register */
45 u8 isr_ack; /* interrupt ack detection */
45 u8 priority_add; /* highest irq priority */ 46 u8 priority_add; /* highest irq priority */
46 u8 irq_base; 47 u8 irq_base;
47 u8 read_reg_select; 48 u8 read_reg_select;
@@ -63,12 +64,13 @@ struct kvm_pic {
63 void *irq_request_opaque; 64 void *irq_request_opaque;
64 int output; /* intr from master PIC */ 65 int output; /* intr from master PIC */
65 struct kvm_io_device dev; 66 struct kvm_io_device dev;
67 void (*ack_notifier)(void *opaque, int irq);
66}; 68};
67 69
68struct kvm_pic *kvm_create_pic(struct kvm *kvm); 70struct kvm_pic *kvm_create_pic(struct kvm *kvm);
69void kvm_pic_set_irq(void *opaque, int irq, int level); 71int kvm_pic_read_irq(struct kvm *kvm);
70int kvm_pic_read_irq(struct kvm_pic *s);
71void kvm_pic_update_irq(struct kvm_pic *s); 72void kvm_pic_update_irq(struct kvm_pic *s);
73void kvm_pic_clear_isr_ack(struct kvm *kvm);
72 74
73static inline struct kvm_pic *pic_irqchip(struct kvm *kvm) 75static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
74{ 76{
diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h
new file mode 100644
index 000000000000..1ff819dce7d3
--- /dev/null
+++ b/arch/x86/kvm/kvm_cache_regs.h
@@ -0,0 +1,32 @@
1#ifndef ASM_KVM_CACHE_REGS_H
2#define ASM_KVM_CACHE_REGS_H
3
4static inline unsigned long kvm_register_read(struct kvm_vcpu *vcpu,
5 enum kvm_reg reg)
6{
7 if (!test_bit(reg, (unsigned long *)&vcpu->arch.regs_avail))
8 kvm_x86_ops->cache_reg(vcpu, reg);
9
10 return vcpu->arch.regs[reg];
11}
12
13static inline void kvm_register_write(struct kvm_vcpu *vcpu,
14 enum kvm_reg reg,
15 unsigned long val)
16{
17 vcpu->arch.regs[reg] = val;
18 __set_bit(reg, (unsigned long *)&vcpu->arch.regs_dirty);
19 __set_bit(reg, (unsigned long *)&vcpu->arch.regs_avail);
20}
21
22static inline unsigned long kvm_rip_read(struct kvm_vcpu *vcpu)
23{
24 return kvm_register_read(vcpu, VCPU_REGS_RIP);
25}
26
27static inline void kvm_rip_write(struct kvm_vcpu *vcpu, unsigned long val)
28{
29 kvm_register_write(vcpu, VCPU_REGS_RIP, val);
30}
31
32#endif
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 73f43de69f67..6571926bfd33 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -32,6 +32,7 @@
32#include <asm/current.h> 32#include <asm/current.h>
33#include <asm/apicdef.h> 33#include <asm/apicdef.h>
34#include <asm/atomic.h> 34#include <asm/atomic.h>
35#include "kvm_cache_regs.h"
35#include "irq.h" 36#include "irq.h"
36 37
37#define PRId64 "d" 38#define PRId64 "d"
@@ -338,13 +339,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
338 } else 339 } else
339 apic_clear_vector(vector, apic->regs + APIC_TMR); 340 apic_clear_vector(vector, apic->regs + APIC_TMR);
340 341
341 if (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE) 342 kvm_vcpu_kick(vcpu);
342 kvm_vcpu_kick(vcpu);
343 else if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) {
344 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
345 if (waitqueue_active(&vcpu->wq))
346 wake_up_interruptible(&vcpu->wq);
347 }
348 343
349 result = (orig_irr == 0); 344 result = (orig_irr == 0);
350 break; 345 break;
@@ -370,21 +365,18 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
370 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; 365 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
371 kvm_vcpu_kick(vcpu); 366 kvm_vcpu_kick(vcpu);
372 } else { 367 } else {
373 printk(KERN_DEBUG 368 apic_debug("Ignoring de-assert INIT to vcpu %d\n",
374 "Ignoring de-assert INIT to vcpu %d\n", 369 vcpu->vcpu_id);
375 vcpu->vcpu_id);
376 } 370 }
377
378 break; 371 break;
379 372
380 case APIC_DM_STARTUP: 373 case APIC_DM_STARTUP:
381 printk(KERN_DEBUG "SIPI to vcpu %d vector 0x%02x\n", 374 apic_debug("SIPI to vcpu %d vector 0x%02x\n",
382 vcpu->vcpu_id, vector); 375 vcpu->vcpu_id, vector);
383 if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) { 376 if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
384 vcpu->arch.sipi_vector = vector; 377 vcpu->arch.sipi_vector = vector;
385 vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED; 378 vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED;
386 if (waitqueue_active(&vcpu->wq)) 379 kvm_vcpu_kick(vcpu);
387 wake_up_interruptible(&vcpu->wq);
388 } 380 }
389 break; 381 break;
390 382
@@ -438,7 +430,7 @@ struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
438static void apic_set_eoi(struct kvm_lapic *apic) 430static void apic_set_eoi(struct kvm_lapic *apic)
439{ 431{
440 int vector = apic_find_highest_isr(apic); 432 int vector = apic_find_highest_isr(apic);
441 433 int trigger_mode;
442 /* 434 /*
443 * Not every write EOI will has corresponding ISR, 435 * Not every write EOI will has corresponding ISR,
444 * one example is when Kernel check timer on setup_IO_APIC 436 * one example is when Kernel check timer on setup_IO_APIC
@@ -450,7 +442,10 @@ static void apic_set_eoi(struct kvm_lapic *apic)
450 apic_update_ppr(apic); 442 apic_update_ppr(apic);
451 443
452 if (apic_test_and_clear_vector(vector, apic->regs + APIC_TMR)) 444 if (apic_test_and_clear_vector(vector, apic->regs + APIC_TMR))
453 kvm_ioapic_update_eoi(apic->vcpu->kvm, vector); 445 trigger_mode = IOAPIC_LEVEL_TRIG;
446 else
447 trigger_mode = IOAPIC_EDGE_TRIG;
448 kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode);
454} 449}
455 450
456static void apic_send_ipi(struct kvm_lapic *apic) 451static void apic_send_ipi(struct kvm_lapic *apic)
@@ -558,8 +553,7 @@ static void __report_tpr_access(struct kvm_lapic *apic, bool write)
558 struct kvm_run *run = vcpu->run; 553 struct kvm_run *run = vcpu->run;
559 554
560 set_bit(KVM_REQ_REPORT_TPR_ACCESS, &vcpu->requests); 555 set_bit(KVM_REQ_REPORT_TPR_ACCESS, &vcpu->requests);
561 kvm_x86_ops->cache_regs(vcpu); 556 run->tpr_access.rip = kvm_rip_read(vcpu);
562 run->tpr_access.rip = vcpu->arch.rip;
563 run->tpr_access.is_write = write; 557 run->tpr_access.is_write = write;
564} 558}
565 559
@@ -683,9 +677,9 @@ static void apic_mmio_write(struct kvm_io_device *this,
683 * Refer SDM 8.4.1 677 * Refer SDM 8.4.1
684 */ 678 */
685 if (len != 4 || alignment) { 679 if (len != 4 || alignment) {
686 if (printk_ratelimit()) 680 /* Don't shout loud, $infamous_os would cause only noise. */
687 printk(KERN_ERR "apic write: bad size=%d %lx\n", 681 apic_debug("apic write: bad size=%d %lx\n",
688 len, (long)address); 682 len, (long)address);
689 return; 683 return;
690 } 684 }
691 685
@@ -947,10 +941,9 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
947 941
948 if(!atomic_inc_and_test(&apic->timer.pending)) 942 if(!atomic_inc_and_test(&apic->timer.pending))
949 set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests); 943 set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests);
950 if (waitqueue_active(q)) { 944 if (waitqueue_active(q))
951 apic->vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
952 wake_up_interruptible(q); 945 wake_up_interruptible(q);
953 } 946
954 if (apic_lvtt_period(apic)) { 947 if (apic_lvtt_period(apic)) {
955 result = 1; 948 result = 1;
956 apic->timer.dev.expires = ktime_add_ns( 949 apic->timer.dev.expires = ktime_add_ns(
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 3da2508eb22a..99c239c5c0ac 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -70,6 +70,9 @@ static int dbg = 0;
70module_param(dbg, bool, 0644); 70module_param(dbg, bool, 0644);
71#endif 71#endif
72 72
73static int oos_shadow = 1;
74module_param(oos_shadow, bool, 0644);
75
73#ifndef MMU_DEBUG 76#ifndef MMU_DEBUG
74#define ASSERT(x) do { } while (0) 77#define ASSERT(x) do { } while (0)
75#else 78#else
@@ -135,18 +138,24 @@ module_param(dbg, bool, 0644);
135#define ACC_USER_MASK PT_USER_MASK 138#define ACC_USER_MASK PT_USER_MASK
136#define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK) 139#define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK)
137 140
138struct kvm_pv_mmu_op_buffer { 141#define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
139 void *ptr;
140 unsigned len;
141 unsigned processed;
142 char buf[512] __aligned(sizeof(long));
143};
144 142
145struct kvm_rmap_desc { 143struct kvm_rmap_desc {
146 u64 *shadow_ptes[RMAP_EXT]; 144 u64 *shadow_ptes[RMAP_EXT];
147 struct kvm_rmap_desc *more; 145 struct kvm_rmap_desc *more;
148}; 146};
149 147
148struct kvm_shadow_walk {
149 int (*entry)(struct kvm_shadow_walk *walk, struct kvm_vcpu *vcpu,
150 u64 addr, u64 *spte, int level);
151};
152
153struct kvm_unsync_walk {
154 int (*entry) (struct kvm_mmu_page *sp, struct kvm_unsync_walk *walk);
155};
156
157typedef int (*mmu_parent_walk_fn) (struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp);
158
150static struct kmem_cache *pte_chain_cache; 159static struct kmem_cache *pte_chain_cache;
151static struct kmem_cache *rmap_desc_cache; 160static struct kmem_cache *rmap_desc_cache;
152static struct kmem_cache *mmu_page_header_cache; 161static struct kmem_cache *mmu_page_header_cache;
@@ -405,16 +414,19 @@ static int host_largepage_backed(struct kvm *kvm, gfn_t gfn)
405{ 414{
406 struct vm_area_struct *vma; 415 struct vm_area_struct *vma;
407 unsigned long addr; 416 unsigned long addr;
417 int ret = 0;
408 418
409 addr = gfn_to_hva(kvm, gfn); 419 addr = gfn_to_hva(kvm, gfn);
410 if (kvm_is_error_hva(addr)) 420 if (kvm_is_error_hva(addr))
411 return 0; 421 return ret;
412 422
423 down_read(&current->mm->mmap_sem);
413 vma = find_vma(current->mm, addr); 424 vma = find_vma(current->mm, addr);
414 if (vma && is_vm_hugetlb_page(vma)) 425 if (vma && is_vm_hugetlb_page(vma))
415 return 1; 426 ret = 1;
427 up_read(&current->mm->mmap_sem);
416 428
417 return 0; 429 return ret;
418} 430}
419 431
420static int is_largepage_backed(struct kvm_vcpu *vcpu, gfn_t large_gfn) 432static int is_largepage_backed(struct kvm_vcpu *vcpu, gfn_t large_gfn)
@@ -649,8 +661,6 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
649 661
650 if (write_protected) 662 if (write_protected)
651 kvm_flush_remote_tlbs(kvm); 663 kvm_flush_remote_tlbs(kvm);
652
653 account_shadowed(kvm, gfn);
654} 664}
655 665
656static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp) 666static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp)
@@ -859,6 +869,77 @@ static void mmu_page_remove_parent_pte(struct kvm_mmu_page *sp,
859 BUG(); 869 BUG();
860} 870}
861 871
872
873static void mmu_parent_walk(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
874 mmu_parent_walk_fn fn)
875{
876 struct kvm_pte_chain *pte_chain;
877 struct hlist_node *node;
878 struct kvm_mmu_page *parent_sp;
879 int i;
880
881 if (!sp->multimapped && sp->parent_pte) {
882 parent_sp = page_header(__pa(sp->parent_pte));
883 fn(vcpu, parent_sp);
884 mmu_parent_walk(vcpu, parent_sp, fn);
885 return;
886 }
887 hlist_for_each_entry(pte_chain, node, &sp->parent_ptes, link)
888 for (i = 0; i < NR_PTE_CHAIN_ENTRIES; ++i) {
889 if (!pte_chain->parent_ptes[i])
890 break;
891 parent_sp = page_header(__pa(pte_chain->parent_ptes[i]));
892 fn(vcpu, parent_sp);
893 mmu_parent_walk(vcpu, parent_sp, fn);
894 }
895}
896
897static void kvm_mmu_update_unsync_bitmap(u64 *spte)
898{
899 unsigned int index;
900 struct kvm_mmu_page *sp = page_header(__pa(spte));
901
902 index = spte - sp->spt;
903 __set_bit(index, sp->unsync_child_bitmap);
904 sp->unsync_children = 1;
905}
906
907static void kvm_mmu_update_parents_unsync(struct kvm_mmu_page *sp)
908{
909 struct kvm_pte_chain *pte_chain;
910 struct hlist_node *node;
911 int i;
912
913 if (!sp->parent_pte)
914 return;
915
916 if (!sp->multimapped) {
917 kvm_mmu_update_unsync_bitmap(sp->parent_pte);
918 return;
919 }
920
921 hlist_for_each_entry(pte_chain, node, &sp->parent_ptes, link)
922 for (i = 0; i < NR_PTE_CHAIN_ENTRIES; ++i) {
923 if (!pte_chain->parent_ptes[i])
924 break;
925 kvm_mmu_update_unsync_bitmap(pte_chain->parent_ptes[i]);
926 }
927}
928
929static int unsync_walk_fn(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
930{
931 sp->unsync_children = 1;
932 kvm_mmu_update_parents_unsync(sp);
933 return 1;
934}
935
936static void kvm_mmu_mark_parents_unsync(struct kvm_vcpu *vcpu,
937 struct kvm_mmu_page *sp)
938{
939 mmu_parent_walk(vcpu, sp, unsync_walk_fn);
940 kvm_mmu_update_parents_unsync(sp);
941}
942
862static void nonpaging_prefetch_page(struct kvm_vcpu *vcpu, 943static void nonpaging_prefetch_page(struct kvm_vcpu *vcpu,
863 struct kvm_mmu_page *sp) 944 struct kvm_mmu_page *sp)
864{ 945{
@@ -868,6 +949,58 @@ static void nonpaging_prefetch_page(struct kvm_vcpu *vcpu,
868 sp->spt[i] = shadow_trap_nonpresent_pte; 949 sp->spt[i] = shadow_trap_nonpresent_pte;
869} 950}
870 951
952static int nonpaging_sync_page(struct kvm_vcpu *vcpu,
953 struct kvm_mmu_page *sp)
954{
955 return 1;
956}
957
958static void nonpaging_invlpg(struct kvm_vcpu *vcpu, gva_t gva)
959{
960}
961
962#define for_each_unsync_children(bitmap, idx) \
963 for (idx = find_first_bit(bitmap, 512); \
964 idx < 512; \
965 idx = find_next_bit(bitmap, 512, idx+1))
966
967static int mmu_unsync_walk(struct kvm_mmu_page *sp,
968 struct kvm_unsync_walk *walker)
969{
970 int i, ret;
971
972 if (!sp->unsync_children)
973 return 0;
974
975 for_each_unsync_children(sp->unsync_child_bitmap, i) {
976 u64 ent = sp->spt[i];
977
978 if (is_shadow_present_pte(ent)) {
979 struct kvm_mmu_page *child;
980 child = page_header(ent & PT64_BASE_ADDR_MASK);
981
982 if (child->unsync_children) {
983 ret = mmu_unsync_walk(child, walker);
984 if (ret)
985 return ret;
986 __clear_bit(i, sp->unsync_child_bitmap);
987 }
988
989 if (child->unsync) {
990 ret = walker->entry(child, walker);
991 __clear_bit(i, sp->unsync_child_bitmap);
992 if (ret)
993 return ret;
994 }
995 }
996 }
997
998 if (find_first_bit(sp->unsync_child_bitmap, 512) == 512)
999 sp->unsync_children = 0;
1000
1001 return 0;
1002}
1003
871static struct kvm_mmu_page *kvm_mmu_lookup_page(struct kvm *kvm, gfn_t gfn) 1004static struct kvm_mmu_page *kvm_mmu_lookup_page(struct kvm *kvm, gfn_t gfn)
872{ 1005{
873 unsigned index; 1006 unsigned index;
@@ -888,6 +1021,59 @@ static struct kvm_mmu_page *kvm_mmu_lookup_page(struct kvm *kvm, gfn_t gfn)
888 return NULL; 1021 return NULL;
889} 1022}
890 1023
1024static void kvm_unlink_unsync_page(struct kvm *kvm, struct kvm_mmu_page *sp)
1025{
1026 WARN_ON(!sp->unsync);
1027 sp->unsync = 0;
1028 --kvm->stat.mmu_unsync;
1029}
1030
1031static int kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp);
1032
1033static int kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
1034{
1035 if (sp->role.glevels != vcpu->arch.mmu.root_level) {
1036 kvm_mmu_zap_page(vcpu->kvm, sp);
1037 return 1;
1038 }
1039
1040 rmap_write_protect(vcpu->kvm, sp->gfn);
1041 if (vcpu->arch.mmu.sync_page(vcpu, sp)) {
1042 kvm_mmu_zap_page(vcpu->kvm, sp);
1043 return 1;
1044 }
1045
1046 kvm_mmu_flush_tlb(vcpu);
1047 kvm_unlink_unsync_page(vcpu->kvm, sp);
1048 return 0;
1049}
1050
1051struct sync_walker {
1052 struct kvm_vcpu *vcpu;
1053 struct kvm_unsync_walk walker;
1054};
1055
1056static int mmu_sync_fn(struct kvm_mmu_page *sp, struct kvm_unsync_walk *walk)
1057{
1058 struct sync_walker *sync_walk = container_of(walk, struct sync_walker,
1059 walker);
1060 struct kvm_vcpu *vcpu = sync_walk->vcpu;
1061
1062 kvm_sync_page(vcpu, sp);
1063 return (need_resched() || spin_needbreak(&vcpu->kvm->mmu_lock));
1064}
1065
1066static void mmu_sync_children(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
1067{
1068 struct sync_walker walker = {
1069 .walker = { .entry = mmu_sync_fn, },
1070 .vcpu = vcpu,
1071 };
1072
1073 while (mmu_unsync_walk(sp, &walker.walker))
1074 cond_resched_lock(&vcpu->kvm->mmu_lock);
1075}
1076
891static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, 1077static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
892 gfn_t gfn, 1078 gfn_t gfn,
893 gva_t gaddr, 1079 gva_t gaddr,
@@ -901,7 +1087,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
901 unsigned quadrant; 1087 unsigned quadrant;
902 struct hlist_head *bucket; 1088 struct hlist_head *bucket;
903 struct kvm_mmu_page *sp; 1089 struct kvm_mmu_page *sp;
904 struct hlist_node *node; 1090 struct hlist_node *node, *tmp;
905 1091
906 role.word = 0; 1092 role.word = 0;
907 role.glevels = vcpu->arch.mmu.root_level; 1093 role.glevels = vcpu->arch.mmu.root_level;
@@ -917,9 +1103,20 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
917 gfn, role.word); 1103 gfn, role.word);
918 index = kvm_page_table_hashfn(gfn); 1104 index = kvm_page_table_hashfn(gfn);
919 bucket = &vcpu->kvm->arch.mmu_page_hash[index]; 1105 bucket = &vcpu->kvm->arch.mmu_page_hash[index];
920 hlist_for_each_entry(sp, node, bucket, hash_link) 1106 hlist_for_each_entry_safe(sp, node, tmp, bucket, hash_link)
921 if (sp->gfn == gfn && sp->role.word == role.word) { 1107 if (sp->gfn == gfn) {
1108 if (sp->unsync)
1109 if (kvm_sync_page(vcpu, sp))
1110 continue;
1111
1112 if (sp->role.word != role.word)
1113 continue;
1114
922 mmu_page_add_parent_pte(vcpu, sp, parent_pte); 1115 mmu_page_add_parent_pte(vcpu, sp, parent_pte);
1116 if (sp->unsync_children) {
1117 set_bit(KVM_REQ_MMU_SYNC, &vcpu->requests);
1118 kvm_mmu_mark_parents_unsync(vcpu, sp);
1119 }
923 pgprintk("%s: found\n", __func__); 1120 pgprintk("%s: found\n", __func__);
924 return sp; 1121 return sp;
925 } 1122 }
@@ -931,8 +1128,10 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
931 sp->gfn = gfn; 1128 sp->gfn = gfn;
932 sp->role = role; 1129 sp->role = role;
933 hlist_add_head(&sp->hash_link, bucket); 1130 hlist_add_head(&sp->hash_link, bucket);
934 if (!metaphysical) 1131 if (!metaphysical) {
935 rmap_write_protect(vcpu->kvm, gfn); 1132 rmap_write_protect(vcpu->kvm, gfn);
1133 account_shadowed(vcpu->kvm, gfn);
1134 }
936 if (shadow_trap_nonpresent_pte != shadow_notrap_nonpresent_pte) 1135 if (shadow_trap_nonpresent_pte != shadow_notrap_nonpresent_pte)
937 vcpu->arch.mmu.prefetch_page(vcpu, sp); 1136 vcpu->arch.mmu.prefetch_page(vcpu, sp);
938 else 1137 else
@@ -940,6 +1139,35 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
940 return sp; 1139 return sp;
941} 1140}
942 1141
1142static int walk_shadow(struct kvm_shadow_walk *walker,
1143 struct kvm_vcpu *vcpu, u64 addr)
1144{
1145 hpa_t shadow_addr;
1146 int level;
1147 int r;
1148 u64 *sptep;
1149 unsigned index;
1150
1151 shadow_addr = vcpu->arch.mmu.root_hpa;
1152 level = vcpu->arch.mmu.shadow_root_level;
1153 if (level == PT32E_ROOT_LEVEL) {
1154 shadow_addr = vcpu->arch.mmu.pae_root[(addr >> 30) & 3];
1155 shadow_addr &= PT64_BASE_ADDR_MASK;
1156 --level;
1157 }
1158
1159 while (level >= PT_PAGE_TABLE_LEVEL) {
1160 index = SHADOW_PT_INDEX(addr, level);
1161 sptep = ((u64 *)__va(shadow_addr)) + index;
1162 r = walker->entry(walker, vcpu, addr, sptep, level);
1163 if (r)
1164 return r;
1165 shadow_addr = *sptep & PT64_BASE_ADDR_MASK;
1166 --level;
1167 }
1168 return 0;
1169}
1170
943static void kvm_mmu_page_unlink_children(struct kvm *kvm, 1171static void kvm_mmu_page_unlink_children(struct kvm *kvm,
944 struct kvm_mmu_page *sp) 1172 struct kvm_mmu_page *sp)
945{ 1173{
@@ -955,7 +1183,6 @@ static void kvm_mmu_page_unlink_children(struct kvm *kvm,
955 rmap_remove(kvm, &pt[i]); 1183 rmap_remove(kvm, &pt[i]);
956 pt[i] = shadow_trap_nonpresent_pte; 1184 pt[i] = shadow_trap_nonpresent_pte;
957 } 1185 }
958 kvm_flush_remote_tlbs(kvm);
959 return; 1186 return;
960 } 1187 }
961 1188
@@ -974,7 +1201,6 @@ static void kvm_mmu_page_unlink_children(struct kvm *kvm,
974 } 1201 }
975 pt[i] = shadow_trap_nonpresent_pte; 1202 pt[i] = shadow_trap_nonpresent_pte;
976 } 1203 }
977 kvm_flush_remote_tlbs(kvm);
978} 1204}
979 1205
980static void kvm_mmu_put_page(struct kvm_mmu_page *sp, u64 *parent_pte) 1206static void kvm_mmu_put_page(struct kvm_mmu_page *sp, u64 *parent_pte)
@@ -991,11 +1217,10 @@ static void kvm_mmu_reset_last_pte_updated(struct kvm *kvm)
991 kvm->vcpus[i]->arch.last_pte_updated = NULL; 1217 kvm->vcpus[i]->arch.last_pte_updated = NULL;
992} 1218}
993 1219
994static void kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp) 1220static void kvm_mmu_unlink_parents(struct kvm *kvm, struct kvm_mmu_page *sp)
995{ 1221{
996 u64 *parent_pte; 1222 u64 *parent_pte;
997 1223
998 ++kvm->stat.mmu_shadow_zapped;
999 while (sp->multimapped || sp->parent_pte) { 1224 while (sp->multimapped || sp->parent_pte) {
1000 if (!sp->multimapped) 1225 if (!sp->multimapped)
1001 parent_pte = sp->parent_pte; 1226 parent_pte = sp->parent_pte;
@@ -1010,21 +1235,59 @@ static void kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp)
1010 kvm_mmu_put_page(sp, parent_pte); 1235 kvm_mmu_put_page(sp, parent_pte);
1011 set_shadow_pte(parent_pte, shadow_trap_nonpresent_pte); 1236 set_shadow_pte(parent_pte, shadow_trap_nonpresent_pte);
1012 } 1237 }
1238}
1239
1240struct zap_walker {
1241 struct kvm_unsync_walk walker;
1242 struct kvm *kvm;
1243 int zapped;
1244};
1245
1246static int mmu_zap_fn(struct kvm_mmu_page *sp, struct kvm_unsync_walk *walk)
1247{
1248 struct zap_walker *zap_walk = container_of(walk, struct zap_walker,
1249 walker);
1250 kvm_mmu_zap_page(zap_walk->kvm, sp);
1251 zap_walk->zapped = 1;
1252 return 0;
1253}
1254
1255static int mmu_zap_unsync_children(struct kvm *kvm, struct kvm_mmu_page *sp)
1256{
1257 struct zap_walker walker = {
1258 .walker = { .entry = mmu_zap_fn, },
1259 .kvm = kvm,
1260 .zapped = 0,
1261 };
1262
1263 if (sp->role.level == PT_PAGE_TABLE_LEVEL)
1264 return 0;
1265 mmu_unsync_walk(sp, &walker.walker);
1266 return walker.zapped;
1267}
1268
1269static int kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp)
1270{
1271 int ret;
1272 ++kvm->stat.mmu_shadow_zapped;
1273 ret = mmu_zap_unsync_children(kvm, sp);
1013 kvm_mmu_page_unlink_children(kvm, sp); 1274 kvm_mmu_page_unlink_children(kvm, sp);
1275 kvm_mmu_unlink_parents(kvm, sp);
1276 kvm_flush_remote_tlbs(kvm);
1277 if (!sp->role.invalid && !sp->role.metaphysical)
1278 unaccount_shadowed(kvm, sp->gfn);
1279 if (sp->unsync)
1280 kvm_unlink_unsync_page(kvm, sp);
1014 if (!sp->root_count) { 1281 if (!sp->root_count) {
1015 if (!sp->role.metaphysical && !sp->role.invalid)
1016 unaccount_shadowed(kvm, sp->gfn);
1017 hlist_del(&sp->hash_link); 1282 hlist_del(&sp->hash_link);
1018 kvm_mmu_free_page(kvm, sp); 1283 kvm_mmu_free_page(kvm, sp);
1019 } else { 1284 } else {
1020 int invalid = sp->role.invalid;
1021 list_move(&sp->link, &kvm->arch.active_mmu_pages);
1022 sp->role.invalid = 1; 1285 sp->role.invalid = 1;
1286 list_move(&sp->link, &kvm->arch.active_mmu_pages);
1023 kvm_reload_remote_mmus(kvm); 1287 kvm_reload_remote_mmus(kvm);
1024 if (!sp->role.metaphysical && !invalid)
1025 unaccount_shadowed(kvm, sp->gfn);
1026 } 1288 }
1027 kvm_mmu_reset_last_pte_updated(kvm); 1289 kvm_mmu_reset_last_pte_updated(kvm);
1290 return ret;
1028} 1291}
1029 1292
1030/* 1293/*
@@ -1077,8 +1340,9 @@ static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn)
1077 if (sp->gfn == gfn && !sp->role.metaphysical) { 1340 if (sp->gfn == gfn && !sp->role.metaphysical) {
1078 pgprintk("%s: gfn %lx role %x\n", __func__, gfn, 1341 pgprintk("%s: gfn %lx role %x\n", __func__, gfn,
1079 sp->role.word); 1342 sp->role.word);
1080 kvm_mmu_zap_page(kvm, sp);
1081 r = 1; 1343 r = 1;
1344 if (kvm_mmu_zap_page(kvm, sp))
1345 n = bucket->first;
1082 } 1346 }
1083 return r; 1347 return r;
1084} 1348}
@@ -1101,6 +1365,20 @@ static void page_header_update_slot(struct kvm *kvm, void *pte, gfn_t gfn)
1101 __set_bit(slot, &sp->slot_bitmap); 1365 __set_bit(slot, &sp->slot_bitmap);
1102} 1366}
1103 1367
1368static void mmu_convert_notrap(struct kvm_mmu_page *sp)
1369{
1370 int i;
1371 u64 *pt = sp->spt;
1372
1373 if (shadow_trap_nonpresent_pte == shadow_notrap_nonpresent_pte)
1374 return;
1375
1376 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
1377 if (pt[i] == shadow_notrap_nonpresent_pte)
1378 set_shadow_pte(&pt[i], shadow_trap_nonpresent_pte);
1379 }
1380}
1381
1104struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva) 1382struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva)
1105{ 1383{
1106 struct page *page; 1384 struct page *page;
@@ -1110,51 +1388,60 @@ struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva)
1110 if (gpa == UNMAPPED_GVA) 1388 if (gpa == UNMAPPED_GVA)
1111 return NULL; 1389 return NULL;
1112 1390
1113 down_read(&current->mm->mmap_sem);
1114 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); 1391 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
1115 up_read(&current->mm->mmap_sem);
1116 1392
1117 return page; 1393 return page;
1118} 1394}
1119 1395
1120static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, 1396static int kvm_unsync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
1121 unsigned pt_access, unsigned pte_access,
1122 int user_fault, int write_fault, int dirty,
1123 int *ptwrite, int largepage, gfn_t gfn,
1124 pfn_t pfn, bool speculative)
1125{ 1397{
1126 u64 spte; 1398 unsigned index;
1127 int was_rmapped = 0; 1399 struct hlist_head *bucket;
1128 int was_writeble = is_writeble_pte(*shadow_pte); 1400 struct kvm_mmu_page *s;
1401 struct hlist_node *node, *n;
1129 1402
1130 pgprintk("%s: spte %llx access %x write_fault %d" 1403 index = kvm_page_table_hashfn(sp->gfn);
1131 " user_fault %d gfn %lx\n", 1404 bucket = &vcpu->kvm->arch.mmu_page_hash[index];
1132 __func__, *shadow_pte, pt_access, 1405 /* don't unsync if pagetable is shadowed with multiple roles */
1133 write_fault, user_fault, gfn); 1406 hlist_for_each_entry_safe(s, node, n, bucket, hash_link) {
1407 if (s->gfn != sp->gfn || s->role.metaphysical)
1408 continue;
1409 if (s->role.word != sp->role.word)
1410 return 1;
1411 }
1412 kvm_mmu_mark_parents_unsync(vcpu, sp);
1413 ++vcpu->kvm->stat.mmu_unsync;
1414 sp->unsync = 1;
1415 mmu_convert_notrap(sp);
1416 return 0;
1417}
1134 1418
1135 if (is_rmap_pte(*shadow_pte)) { 1419static int mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,
1136 /* 1420 bool can_unsync)
1137 * If we overwrite a PTE page pointer with a 2MB PMD, unlink 1421{
1138 * the parent of the now unreachable PTE. 1422 struct kvm_mmu_page *shadow;
1139 */
1140 if (largepage && !is_large_pte(*shadow_pte)) {
1141 struct kvm_mmu_page *child;
1142 u64 pte = *shadow_pte;
1143 1423
1144 child = page_header(pte & PT64_BASE_ADDR_MASK); 1424 shadow = kvm_mmu_lookup_page(vcpu->kvm, gfn);
1145 mmu_page_remove_parent_pte(child, shadow_pte); 1425 if (shadow) {
1146 } else if (pfn != spte_to_pfn(*shadow_pte)) { 1426 if (shadow->role.level != PT_PAGE_TABLE_LEVEL)
1147 pgprintk("hfn old %lx new %lx\n", 1427 return 1;
1148 spte_to_pfn(*shadow_pte), pfn); 1428 if (shadow->unsync)
1149 rmap_remove(vcpu->kvm, shadow_pte); 1429 return 0;
1150 } else { 1430 if (can_unsync && oos_shadow)
1151 if (largepage) 1431 return kvm_unsync_page(vcpu, shadow);
1152 was_rmapped = is_large_pte(*shadow_pte); 1432 return 1;
1153 else
1154 was_rmapped = 1;
1155 }
1156 } 1433 }
1434 return 0;
1435}
1157 1436
1437static int set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1438 unsigned pte_access, int user_fault,
1439 int write_fault, int dirty, int largepage,
1440 gfn_t gfn, pfn_t pfn, bool speculative,
1441 bool can_unsync)
1442{
1443 u64 spte;
1444 int ret = 0;
1158 /* 1445 /*
1159 * We don't set the accessed bit, since we sometimes want to see 1446 * We don't set the accessed bit, since we sometimes want to see
1160 * whether the guest actually used the pte (in order to detect 1447 * whether the guest actually used the pte (in order to detect
@@ -1162,7 +1449,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1162 */ 1449 */
1163 spte = shadow_base_present_pte | shadow_dirty_mask; 1450 spte = shadow_base_present_pte | shadow_dirty_mask;
1164 if (!speculative) 1451 if (!speculative)
1165 pte_access |= PT_ACCESSED_MASK; 1452 spte |= shadow_accessed_mask;
1166 if (!dirty) 1453 if (!dirty)
1167 pte_access &= ~ACC_WRITE_MASK; 1454 pte_access &= ~ACC_WRITE_MASK;
1168 if (pte_access & ACC_EXEC_MASK) 1455 if (pte_access & ACC_EXEC_MASK)
@@ -1178,35 +1465,82 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1178 1465
1179 if ((pte_access & ACC_WRITE_MASK) 1466 if ((pte_access & ACC_WRITE_MASK)
1180 || (write_fault && !is_write_protection(vcpu) && !user_fault)) { 1467 || (write_fault && !is_write_protection(vcpu) && !user_fault)) {
1181 struct kvm_mmu_page *shadow; 1468
1469 if (largepage && has_wrprotected_page(vcpu->kvm, gfn)) {
1470 ret = 1;
1471 spte = shadow_trap_nonpresent_pte;
1472 goto set_pte;
1473 }
1182 1474
1183 spte |= PT_WRITABLE_MASK; 1475 spte |= PT_WRITABLE_MASK;
1184 1476
1185 shadow = kvm_mmu_lookup_page(vcpu->kvm, gfn); 1477 if (mmu_need_write_protect(vcpu, gfn, can_unsync)) {
1186 if (shadow ||
1187 (largepage && has_wrprotected_page(vcpu->kvm, gfn))) {
1188 pgprintk("%s: found shadow page for %lx, marking ro\n", 1478 pgprintk("%s: found shadow page for %lx, marking ro\n",
1189 __func__, gfn); 1479 __func__, gfn);
1480 ret = 1;
1190 pte_access &= ~ACC_WRITE_MASK; 1481 pte_access &= ~ACC_WRITE_MASK;
1191 if (is_writeble_pte(spte)) { 1482 if (is_writeble_pte(spte))
1192 spte &= ~PT_WRITABLE_MASK; 1483 spte &= ~PT_WRITABLE_MASK;
1193 kvm_x86_ops->tlb_flush(vcpu);
1194 }
1195 if (write_fault)
1196 *ptwrite = 1;
1197 } 1484 }
1198 } 1485 }
1199 1486
1200 if (pte_access & ACC_WRITE_MASK) 1487 if (pte_access & ACC_WRITE_MASK)
1201 mark_page_dirty(vcpu->kvm, gfn); 1488 mark_page_dirty(vcpu->kvm, gfn);
1202 1489
1203 pgprintk("%s: setting spte %llx\n", __func__, spte); 1490set_pte:
1204 pgprintk("instantiating %s PTE (%s) at %ld (%llx) addr %p\n",
1205 (spte&PT_PAGE_SIZE_MASK)? "2MB" : "4kB",
1206 (spte&PT_WRITABLE_MASK)?"RW":"R", gfn, spte, shadow_pte);
1207 set_shadow_pte(shadow_pte, spte); 1491 set_shadow_pte(shadow_pte, spte);
1208 if (!was_rmapped && (spte & PT_PAGE_SIZE_MASK) 1492 return ret;
1209 && (spte & PT_PRESENT_MASK)) 1493}
1494
1495static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1496 unsigned pt_access, unsigned pte_access,
1497 int user_fault, int write_fault, int dirty,
1498 int *ptwrite, int largepage, gfn_t gfn,
1499 pfn_t pfn, bool speculative)
1500{
1501 int was_rmapped = 0;
1502 int was_writeble = is_writeble_pte(*shadow_pte);
1503
1504 pgprintk("%s: spte %llx access %x write_fault %d"
1505 " user_fault %d gfn %lx\n",
1506 __func__, *shadow_pte, pt_access,
1507 write_fault, user_fault, gfn);
1508
1509 if (is_rmap_pte(*shadow_pte)) {
1510 /*
1511 * If we overwrite a PTE page pointer with a 2MB PMD, unlink
1512 * the parent of the now unreachable PTE.
1513 */
1514 if (largepage && !is_large_pte(*shadow_pte)) {
1515 struct kvm_mmu_page *child;
1516 u64 pte = *shadow_pte;
1517
1518 child = page_header(pte & PT64_BASE_ADDR_MASK);
1519 mmu_page_remove_parent_pte(child, shadow_pte);
1520 } else if (pfn != spte_to_pfn(*shadow_pte)) {
1521 pgprintk("hfn old %lx new %lx\n",
1522 spte_to_pfn(*shadow_pte), pfn);
1523 rmap_remove(vcpu->kvm, shadow_pte);
1524 } else {
1525 if (largepage)
1526 was_rmapped = is_large_pte(*shadow_pte);
1527 else
1528 was_rmapped = 1;
1529 }
1530 }
1531 if (set_spte(vcpu, shadow_pte, pte_access, user_fault, write_fault,
1532 dirty, largepage, gfn, pfn, speculative, true)) {
1533 if (write_fault)
1534 *ptwrite = 1;
1535 kvm_x86_ops->tlb_flush(vcpu);
1536 }
1537
1538 pgprintk("%s: setting spte %llx\n", __func__, *shadow_pte);
1539 pgprintk("instantiating %s PTE (%s) at %ld (%llx) addr %p\n",
1540 is_large_pte(*shadow_pte)? "2MB" : "4kB",
1541 is_present_pte(*shadow_pte)?"RW":"R", gfn,
1542 *shadow_pte, shadow_pte);
1543 if (!was_rmapped && is_large_pte(*shadow_pte))
1210 ++vcpu->kvm->stat.lpages; 1544 ++vcpu->kvm->stat.lpages;
1211 1545
1212 page_header_update_slot(vcpu->kvm, shadow_pte, gfn); 1546 page_header_update_slot(vcpu->kvm, shadow_pte, gfn);
@@ -1230,54 +1564,67 @@ static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
1230{ 1564{
1231} 1565}
1232 1566
1233static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, 1567struct direct_shadow_walk {
1234 int largepage, gfn_t gfn, pfn_t pfn, 1568 struct kvm_shadow_walk walker;
1235 int level) 1569 pfn_t pfn;
1236{ 1570 int write;
1237 hpa_t table_addr = vcpu->arch.mmu.root_hpa; 1571 int largepage;
1238 int pt_write = 0; 1572 int pt_write;
1239 1573};
1240 for (; ; level--) {
1241 u32 index = PT64_INDEX(v, level);
1242 u64 *table;
1243
1244 ASSERT(VALID_PAGE(table_addr));
1245 table = __va(table_addr);
1246 1574
1247 if (level == 1) { 1575static int direct_map_entry(struct kvm_shadow_walk *_walk,
1248 mmu_set_spte(vcpu, &table[index], ACC_ALL, ACC_ALL, 1576 struct kvm_vcpu *vcpu,
1249 0, write, 1, &pt_write, 0, gfn, pfn, false); 1577 u64 addr, u64 *sptep, int level)
1250 return pt_write; 1578{
1251 } 1579 struct direct_shadow_walk *walk =
1580 container_of(_walk, struct direct_shadow_walk, walker);
1581 struct kvm_mmu_page *sp;
1582 gfn_t pseudo_gfn;
1583 gfn_t gfn = addr >> PAGE_SHIFT;
1584
1585 if (level == PT_PAGE_TABLE_LEVEL
1586 || (walk->largepage && level == PT_DIRECTORY_LEVEL)) {
1587 mmu_set_spte(vcpu, sptep, ACC_ALL, ACC_ALL,
1588 0, walk->write, 1, &walk->pt_write,
1589 walk->largepage, gfn, walk->pfn, false);
1590 ++vcpu->stat.pf_fixed;
1591 return 1;
1592 }
1252 1593
1253 if (largepage && level == 2) { 1594 if (*sptep == shadow_trap_nonpresent_pte) {
1254 mmu_set_spte(vcpu, &table[index], ACC_ALL, ACC_ALL, 1595 pseudo_gfn = (addr & PT64_DIR_BASE_ADDR_MASK) >> PAGE_SHIFT;
1255 0, write, 1, &pt_write, 1, gfn, pfn, false); 1596 sp = kvm_mmu_get_page(vcpu, pseudo_gfn, (gva_t)addr, level - 1,
1256 return pt_write; 1597 1, ACC_ALL, sptep);
1598 if (!sp) {
1599 pgprintk("nonpaging_map: ENOMEM\n");
1600 kvm_release_pfn_clean(walk->pfn);
1601 return -ENOMEM;
1257 } 1602 }
1258 1603
1259 if (table[index] == shadow_trap_nonpresent_pte) { 1604 set_shadow_pte(sptep,
1260 struct kvm_mmu_page *new_table; 1605 __pa(sp->spt)
1261 gfn_t pseudo_gfn; 1606 | PT_PRESENT_MASK | PT_WRITABLE_MASK
1262 1607 | shadow_user_mask | shadow_x_mask);
1263 pseudo_gfn = (v & PT64_DIR_BASE_ADDR_MASK)
1264 >> PAGE_SHIFT;
1265 new_table = kvm_mmu_get_page(vcpu, pseudo_gfn,
1266 v, level - 1,
1267 1, ACC_ALL, &table[index]);
1268 if (!new_table) {
1269 pgprintk("nonpaging_map: ENOMEM\n");
1270 kvm_release_pfn_clean(pfn);
1271 return -ENOMEM;
1272 }
1273
1274 set_shadow_pte(&table[index],
1275 __pa(new_table->spt)
1276 | PT_PRESENT_MASK | PT_WRITABLE_MASK
1277 | shadow_user_mask | shadow_x_mask);
1278 }
1279 table_addr = table[index] & PT64_BASE_ADDR_MASK;
1280 } 1608 }
1609 return 0;
1610}
1611
1612static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
1613 int largepage, gfn_t gfn, pfn_t pfn)
1614{
1615 int r;
1616 struct direct_shadow_walk walker = {
1617 .walker = { .entry = direct_map_entry, },
1618 .pfn = pfn,
1619 .largepage = largepage,
1620 .write = write,
1621 .pt_write = 0,
1622 };
1623
1624 r = walk_shadow(&walker.walker, vcpu, gfn << PAGE_SHIFT);
1625 if (r < 0)
1626 return r;
1627 return walker.pt_write;
1281} 1628}
1282 1629
1283static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn) 1630static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn)
@@ -1287,16 +1634,14 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn)
1287 pfn_t pfn; 1634 pfn_t pfn;
1288 unsigned long mmu_seq; 1635 unsigned long mmu_seq;
1289 1636
1290 down_read(&current->mm->mmap_sem);
1291 if (is_largepage_backed(vcpu, gfn & ~(KVM_PAGES_PER_HPAGE-1))) { 1637 if (is_largepage_backed(vcpu, gfn & ~(KVM_PAGES_PER_HPAGE-1))) {
1292 gfn &= ~(KVM_PAGES_PER_HPAGE-1); 1638 gfn &= ~(KVM_PAGES_PER_HPAGE-1);
1293 largepage = 1; 1639 largepage = 1;
1294 } 1640 }
1295 1641
1296 mmu_seq = vcpu->kvm->mmu_notifier_seq; 1642 mmu_seq = vcpu->kvm->mmu_notifier_seq;
1297 /* implicit mb(), we'll read before PT lock is unlocked */ 1643 smp_rmb();
1298 pfn = gfn_to_pfn(vcpu->kvm, gfn); 1644 pfn = gfn_to_pfn(vcpu->kvm, gfn);
1299 up_read(&current->mm->mmap_sem);
1300 1645
1301 /* mmio */ 1646 /* mmio */
1302 if (is_error_pfn(pfn)) { 1647 if (is_error_pfn(pfn)) {
@@ -1308,8 +1653,7 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn)
1308 if (mmu_notifier_retry(vcpu, mmu_seq)) 1653 if (mmu_notifier_retry(vcpu, mmu_seq))
1309 goto out_unlock; 1654 goto out_unlock;
1310 kvm_mmu_free_some_pages(vcpu); 1655 kvm_mmu_free_some_pages(vcpu);
1311 r = __direct_map(vcpu, v, write, largepage, gfn, pfn, 1656 r = __direct_map(vcpu, v, write, largepage, gfn, pfn);
1312 PT32E_ROOT_LEVEL);
1313 spin_unlock(&vcpu->kvm->mmu_lock); 1657 spin_unlock(&vcpu->kvm->mmu_lock);
1314 1658
1315 1659
@@ -1405,6 +1749,37 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
1405 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root); 1749 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root);
1406} 1750}
1407 1751
1752static void mmu_sync_roots(struct kvm_vcpu *vcpu)
1753{
1754 int i;
1755 struct kvm_mmu_page *sp;
1756
1757 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
1758 return;
1759 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
1760 hpa_t root = vcpu->arch.mmu.root_hpa;
1761 sp = page_header(root);
1762 mmu_sync_children(vcpu, sp);
1763 return;
1764 }
1765 for (i = 0; i < 4; ++i) {
1766 hpa_t root = vcpu->arch.mmu.pae_root[i];
1767
1768 if (root) {
1769 root &= PT64_BASE_ADDR_MASK;
1770 sp = page_header(root);
1771 mmu_sync_children(vcpu, sp);
1772 }
1773 }
1774}
1775
1776void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu)
1777{
1778 spin_lock(&vcpu->kvm->mmu_lock);
1779 mmu_sync_roots(vcpu);
1780 spin_unlock(&vcpu->kvm->mmu_lock);
1781}
1782
1408static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr) 1783static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr)
1409{ 1784{
1410 return vaddr; 1785 return vaddr;
@@ -1446,15 +1821,13 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa,
1446 if (r) 1821 if (r)
1447 return r; 1822 return r;
1448 1823
1449 down_read(&current->mm->mmap_sem);
1450 if (is_largepage_backed(vcpu, gfn & ~(KVM_PAGES_PER_HPAGE-1))) { 1824 if (is_largepage_backed(vcpu, gfn & ~(KVM_PAGES_PER_HPAGE-1))) {
1451 gfn &= ~(KVM_PAGES_PER_HPAGE-1); 1825 gfn &= ~(KVM_PAGES_PER_HPAGE-1);
1452 largepage = 1; 1826 largepage = 1;
1453 } 1827 }
1454 mmu_seq = vcpu->kvm->mmu_notifier_seq; 1828 mmu_seq = vcpu->kvm->mmu_notifier_seq;
1455 /* implicit mb(), we'll read before PT lock is unlocked */ 1829 smp_rmb();
1456 pfn = gfn_to_pfn(vcpu->kvm, gfn); 1830 pfn = gfn_to_pfn(vcpu->kvm, gfn);
1457 up_read(&current->mm->mmap_sem);
1458 if (is_error_pfn(pfn)) { 1831 if (is_error_pfn(pfn)) {
1459 kvm_release_pfn_clean(pfn); 1832 kvm_release_pfn_clean(pfn);
1460 return 1; 1833 return 1;
@@ -1464,7 +1837,7 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa,
1464 goto out_unlock; 1837 goto out_unlock;
1465 kvm_mmu_free_some_pages(vcpu); 1838 kvm_mmu_free_some_pages(vcpu);
1466 r = __direct_map(vcpu, gpa, error_code & PFERR_WRITE_MASK, 1839 r = __direct_map(vcpu, gpa, error_code & PFERR_WRITE_MASK,
1467 largepage, gfn, pfn, kvm_x86_ops->get_tdp_level()); 1840 largepage, gfn, pfn);
1468 spin_unlock(&vcpu->kvm->mmu_lock); 1841 spin_unlock(&vcpu->kvm->mmu_lock);
1469 1842
1470 return r; 1843 return r;
@@ -1489,6 +1862,8 @@ static int nonpaging_init_context(struct kvm_vcpu *vcpu)
1489 context->gva_to_gpa = nonpaging_gva_to_gpa; 1862 context->gva_to_gpa = nonpaging_gva_to_gpa;
1490 context->free = nonpaging_free; 1863 context->free = nonpaging_free;
1491 context->prefetch_page = nonpaging_prefetch_page; 1864 context->prefetch_page = nonpaging_prefetch_page;
1865 context->sync_page = nonpaging_sync_page;
1866 context->invlpg = nonpaging_invlpg;
1492 context->root_level = 0; 1867 context->root_level = 0;
1493 context->shadow_root_level = PT32E_ROOT_LEVEL; 1868 context->shadow_root_level = PT32E_ROOT_LEVEL;
1494 context->root_hpa = INVALID_PAGE; 1869 context->root_hpa = INVALID_PAGE;
@@ -1536,6 +1911,8 @@ static int paging64_init_context_common(struct kvm_vcpu *vcpu, int level)
1536 context->page_fault = paging64_page_fault; 1911 context->page_fault = paging64_page_fault;
1537 context->gva_to_gpa = paging64_gva_to_gpa; 1912 context->gva_to_gpa = paging64_gva_to_gpa;
1538 context->prefetch_page = paging64_prefetch_page; 1913 context->prefetch_page = paging64_prefetch_page;
1914 context->sync_page = paging64_sync_page;
1915 context->invlpg = paging64_invlpg;
1539 context->free = paging_free; 1916 context->free = paging_free;
1540 context->root_level = level; 1917 context->root_level = level;
1541 context->shadow_root_level = level; 1918 context->shadow_root_level = level;
@@ -1557,6 +1934,8 @@ static int paging32_init_context(struct kvm_vcpu *vcpu)
1557 context->gva_to_gpa = paging32_gva_to_gpa; 1934 context->gva_to_gpa = paging32_gva_to_gpa;
1558 context->free = paging_free; 1935 context->free = paging_free;
1559 context->prefetch_page = paging32_prefetch_page; 1936 context->prefetch_page = paging32_prefetch_page;
1937 context->sync_page = paging32_sync_page;
1938 context->invlpg = paging32_invlpg;
1560 context->root_level = PT32_ROOT_LEVEL; 1939 context->root_level = PT32_ROOT_LEVEL;
1561 context->shadow_root_level = PT32E_ROOT_LEVEL; 1940 context->shadow_root_level = PT32E_ROOT_LEVEL;
1562 context->root_hpa = INVALID_PAGE; 1941 context->root_hpa = INVALID_PAGE;
@@ -1576,6 +1955,8 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
1576 context->page_fault = tdp_page_fault; 1955 context->page_fault = tdp_page_fault;
1577 context->free = nonpaging_free; 1956 context->free = nonpaging_free;
1578 context->prefetch_page = nonpaging_prefetch_page; 1957 context->prefetch_page = nonpaging_prefetch_page;
1958 context->sync_page = nonpaging_sync_page;
1959 context->invlpg = nonpaging_invlpg;
1579 context->shadow_root_level = kvm_x86_ops->get_tdp_level(); 1960 context->shadow_root_level = kvm_x86_ops->get_tdp_level();
1580 context->root_hpa = INVALID_PAGE; 1961 context->root_hpa = INVALID_PAGE;
1581 1962
@@ -1647,6 +2028,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
1647 spin_lock(&vcpu->kvm->mmu_lock); 2028 spin_lock(&vcpu->kvm->mmu_lock);
1648 kvm_mmu_free_some_pages(vcpu); 2029 kvm_mmu_free_some_pages(vcpu);
1649 mmu_alloc_roots(vcpu); 2030 mmu_alloc_roots(vcpu);
2031 mmu_sync_roots(vcpu);
1650 spin_unlock(&vcpu->kvm->mmu_lock); 2032 spin_unlock(&vcpu->kvm->mmu_lock);
1651 kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa); 2033 kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
1652 kvm_mmu_flush_tlb(vcpu); 2034 kvm_mmu_flush_tlb(vcpu);
@@ -1767,15 +2149,13 @@ static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1767 return; 2149 return;
1768 gfn = (gpte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT; 2150 gfn = (gpte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
1769 2151
1770 down_read(&current->mm->mmap_sem);
1771 if (is_large_pte(gpte) && is_largepage_backed(vcpu, gfn)) { 2152 if (is_large_pte(gpte) && is_largepage_backed(vcpu, gfn)) {
1772 gfn &= ~(KVM_PAGES_PER_HPAGE-1); 2153 gfn &= ~(KVM_PAGES_PER_HPAGE-1);
1773 vcpu->arch.update_pte.largepage = 1; 2154 vcpu->arch.update_pte.largepage = 1;
1774 } 2155 }
1775 vcpu->arch.update_pte.mmu_seq = vcpu->kvm->mmu_notifier_seq; 2156 vcpu->arch.update_pte.mmu_seq = vcpu->kvm->mmu_notifier_seq;
1776 /* implicit mb(), we'll read before PT lock is unlocked */ 2157 smp_rmb();
1777 pfn = gfn_to_pfn(vcpu->kvm, gfn); 2158 pfn = gfn_to_pfn(vcpu->kvm, gfn);
1778 up_read(&current->mm->mmap_sem);
1779 2159
1780 if (is_error_pfn(pfn)) { 2160 if (is_error_pfn(pfn)) {
1781 kvm_release_pfn_clean(pfn); 2161 kvm_release_pfn_clean(pfn);
@@ -1837,7 +2217,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1837 index = kvm_page_table_hashfn(gfn); 2217 index = kvm_page_table_hashfn(gfn);
1838 bucket = &vcpu->kvm->arch.mmu_page_hash[index]; 2218 bucket = &vcpu->kvm->arch.mmu_page_hash[index];
1839 hlist_for_each_entry_safe(sp, node, n, bucket, hash_link) { 2219 hlist_for_each_entry_safe(sp, node, n, bucket, hash_link) {
1840 if (sp->gfn != gfn || sp->role.metaphysical) 2220 if (sp->gfn != gfn || sp->role.metaphysical || sp->role.invalid)
1841 continue; 2221 continue;
1842 pte_size = sp->role.glevels == PT32_ROOT_LEVEL ? 4 : 8; 2222 pte_size = sp->role.glevels == PT32_ROOT_LEVEL ? 4 : 8;
1843 misaligned = (offset ^ (offset + bytes - 1)) & ~(pte_size - 1); 2223 misaligned = (offset ^ (offset + bytes - 1)) & ~(pte_size - 1);
@@ -1855,7 +2235,8 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1855 */ 2235 */
1856 pgprintk("misaligned: gpa %llx bytes %d role %x\n", 2236 pgprintk("misaligned: gpa %llx bytes %d role %x\n",
1857 gpa, bytes, sp->role.word); 2237 gpa, bytes, sp->role.word);
1858 kvm_mmu_zap_page(vcpu->kvm, sp); 2238 if (kvm_mmu_zap_page(vcpu->kvm, sp))
2239 n = bucket->first;
1859 ++vcpu->kvm->stat.mmu_flooded; 2240 ++vcpu->kvm->stat.mmu_flooded;
1860 continue; 2241 continue;
1861 } 2242 }
@@ -1969,6 +2350,16 @@ out:
1969} 2350}
1970EXPORT_SYMBOL_GPL(kvm_mmu_page_fault); 2351EXPORT_SYMBOL_GPL(kvm_mmu_page_fault);
1971 2352
2353void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva)
2354{
2355 spin_lock(&vcpu->kvm->mmu_lock);
2356 vcpu->arch.mmu.invlpg(vcpu, gva);
2357 spin_unlock(&vcpu->kvm->mmu_lock);
2358 kvm_mmu_flush_tlb(vcpu);
2359 ++vcpu->stat.invlpg;
2360}
2361EXPORT_SYMBOL_GPL(kvm_mmu_invlpg);
2362
1972void kvm_enable_tdp(void) 2363void kvm_enable_tdp(void)
1973{ 2364{
1974 tdp_enabled = true; 2365 tdp_enabled = true;
@@ -2055,6 +2446,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
2055{ 2446{
2056 struct kvm_mmu_page *sp; 2447 struct kvm_mmu_page *sp;
2057 2448
2449 spin_lock(&kvm->mmu_lock);
2058 list_for_each_entry(sp, &kvm->arch.active_mmu_pages, link) { 2450 list_for_each_entry(sp, &kvm->arch.active_mmu_pages, link) {
2059 int i; 2451 int i;
2060 u64 *pt; 2452 u64 *pt;
@@ -2068,6 +2460,8 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
2068 if (pt[i] & PT_WRITABLE_MASK) 2460 if (pt[i] & PT_WRITABLE_MASK)
2069 pt[i] &= ~PT_WRITABLE_MASK; 2461 pt[i] &= ~PT_WRITABLE_MASK;
2070 } 2462 }
2463 kvm_flush_remote_tlbs(kvm);
2464 spin_unlock(&kvm->mmu_lock);
2071} 2465}
2072 2466
2073void kvm_mmu_zap_all(struct kvm *kvm) 2467void kvm_mmu_zap_all(struct kvm *kvm)
@@ -2076,7 +2470,9 @@ void kvm_mmu_zap_all(struct kvm *kvm)
2076 2470
2077 spin_lock(&kvm->mmu_lock); 2471 spin_lock(&kvm->mmu_lock);
2078 list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) 2472 list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link)
2079 kvm_mmu_zap_page(kvm, sp); 2473 if (kvm_mmu_zap_page(kvm, sp))
2474 node = container_of(kvm->arch.active_mmu_pages.next,
2475 struct kvm_mmu_page, link);
2080 spin_unlock(&kvm->mmu_lock); 2476 spin_unlock(&kvm->mmu_lock);
2081 2477
2082 kvm_flush_remote_tlbs(kvm); 2478 kvm_flush_remote_tlbs(kvm);
@@ -2291,18 +2687,18 @@ int kvm_pv_mmu_op(struct kvm_vcpu *vcpu, unsigned long bytes,
2291 gpa_t addr, unsigned long *ret) 2687 gpa_t addr, unsigned long *ret)
2292{ 2688{
2293 int r; 2689 int r;
2294 struct kvm_pv_mmu_op_buffer buffer; 2690 struct kvm_pv_mmu_op_buffer *buffer = &vcpu->arch.mmu_op_buffer;
2295 2691
2296 buffer.ptr = buffer.buf; 2692 buffer->ptr = buffer->buf;
2297 buffer.len = min_t(unsigned long, bytes, sizeof buffer.buf); 2693 buffer->len = min_t(unsigned long, bytes, sizeof buffer->buf);
2298 buffer.processed = 0; 2694 buffer->processed = 0;
2299 2695
2300 r = kvm_read_guest(vcpu->kvm, addr, buffer.buf, buffer.len); 2696 r = kvm_read_guest(vcpu->kvm, addr, buffer->buf, buffer->len);
2301 if (r) 2697 if (r)
2302 goto out; 2698 goto out;
2303 2699
2304 while (buffer.len) { 2700 while (buffer->len) {
2305 r = kvm_pv_mmu_op_one(vcpu, &buffer); 2701 r = kvm_pv_mmu_op_one(vcpu, buffer);
2306 if (r < 0) 2702 if (r < 0)
2307 goto out; 2703 goto out;
2308 if (r == 0) 2704 if (r == 0)
@@ -2311,7 +2707,7 @@ int kvm_pv_mmu_op(struct kvm_vcpu *vcpu, unsigned long bytes,
2311 2707
2312 r = 1; 2708 r = 1;
2313out: 2709out:
2314 *ret = buffer.processed; 2710 *ret = buffer->processed;
2315 return r; 2711 return r;
2316} 2712}
2317 2713
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 4a814bff21f2..613ec9aa674a 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -25,11 +25,11 @@
25#if PTTYPE == 64 25#if PTTYPE == 64
26 #define pt_element_t u64 26 #define pt_element_t u64
27 #define guest_walker guest_walker64 27 #define guest_walker guest_walker64
28 #define shadow_walker shadow_walker64
28 #define FNAME(name) paging##64_##name 29 #define FNAME(name) paging##64_##name
29 #define PT_BASE_ADDR_MASK PT64_BASE_ADDR_MASK 30 #define PT_BASE_ADDR_MASK PT64_BASE_ADDR_MASK
30 #define PT_DIR_BASE_ADDR_MASK PT64_DIR_BASE_ADDR_MASK 31 #define PT_DIR_BASE_ADDR_MASK PT64_DIR_BASE_ADDR_MASK
31 #define PT_INDEX(addr, level) PT64_INDEX(addr, level) 32 #define PT_INDEX(addr, level) PT64_INDEX(addr, level)
32 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
33 #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level) 33 #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level)
34 #define PT_LEVEL_BITS PT64_LEVEL_BITS 34 #define PT_LEVEL_BITS PT64_LEVEL_BITS
35 #ifdef CONFIG_X86_64 35 #ifdef CONFIG_X86_64
@@ -42,11 +42,11 @@
42#elif PTTYPE == 32 42#elif PTTYPE == 32
43 #define pt_element_t u32 43 #define pt_element_t u32
44 #define guest_walker guest_walker32 44 #define guest_walker guest_walker32
45 #define shadow_walker shadow_walker32
45 #define FNAME(name) paging##32_##name 46 #define FNAME(name) paging##32_##name
46 #define PT_BASE_ADDR_MASK PT32_BASE_ADDR_MASK 47 #define PT_BASE_ADDR_MASK PT32_BASE_ADDR_MASK
47 #define PT_DIR_BASE_ADDR_MASK PT32_DIR_BASE_ADDR_MASK 48 #define PT_DIR_BASE_ADDR_MASK PT32_DIR_BASE_ADDR_MASK
48 #define PT_INDEX(addr, level) PT32_INDEX(addr, level) 49 #define PT_INDEX(addr, level) PT32_INDEX(addr, level)
49 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
50 #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level) 50 #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level)
51 #define PT_LEVEL_BITS PT32_LEVEL_BITS 51 #define PT_LEVEL_BITS PT32_LEVEL_BITS
52 #define PT_MAX_FULL_LEVELS 2 52 #define PT_MAX_FULL_LEVELS 2
@@ -73,6 +73,17 @@ struct guest_walker {
73 u32 error_code; 73 u32 error_code;
74}; 74};
75 75
76struct shadow_walker {
77 struct kvm_shadow_walk walker;
78 struct guest_walker *guest_walker;
79 int user_fault;
80 int write_fault;
81 int largepage;
82 int *ptwrite;
83 pfn_t pfn;
84 u64 *sptep;
85};
86
76static gfn_t gpte_to_gfn(pt_element_t gpte) 87static gfn_t gpte_to_gfn(pt_element_t gpte)
77{ 88{
78 return (gpte & PT_BASE_ADDR_MASK) >> PAGE_SHIFT; 89 return (gpte & PT_BASE_ADDR_MASK) >> PAGE_SHIFT;
@@ -91,14 +102,10 @@ static bool FNAME(cmpxchg_gpte)(struct kvm *kvm,
91 pt_element_t *table; 102 pt_element_t *table;
92 struct page *page; 103 struct page *page;
93 104
94 down_read(&current->mm->mmap_sem);
95 page = gfn_to_page(kvm, table_gfn); 105 page = gfn_to_page(kvm, table_gfn);
96 up_read(&current->mm->mmap_sem);
97 106
98 table = kmap_atomic(page, KM_USER0); 107 table = kmap_atomic(page, KM_USER0);
99
100 ret = CMPXCHG(&table[index], orig_pte, new_pte); 108 ret = CMPXCHG(&table[index], orig_pte, new_pte);
101
102 kunmap_atomic(table, KM_USER0); 109 kunmap_atomic(table, KM_USER0);
103 110
104 kvm_release_page_dirty(page); 111 kvm_release_page_dirty(page);
@@ -274,86 +281,89 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *page,
274/* 281/*
275 * Fetch a shadow pte for a specific level in the paging hierarchy. 282 * Fetch a shadow pte for a specific level in the paging hierarchy.
276 */ 283 */
277static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, 284static int FNAME(shadow_walk_entry)(struct kvm_shadow_walk *_sw,
278 struct guest_walker *walker, 285 struct kvm_vcpu *vcpu, u64 addr,
279 int user_fault, int write_fault, int largepage, 286 u64 *sptep, int level)
280 int *ptwrite, pfn_t pfn)
281{ 287{
282 hpa_t shadow_addr; 288 struct shadow_walker *sw =
283 int level; 289 container_of(_sw, struct shadow_walker, walker);
284 u64 *shadow_ent; 290 struct guest_walker *gw = sw->guest_walker;
285 unsigned access = walker->pt_access; 291 unsigned access = gw->pt_access;
286 292 struct kvm_mmu_page *shadow_page;
287 if (!is_present_pte(walker->ptes[walker->level - 1])) 293 u64 spte;
288 return NULL; 294 int metaphysical;
289 295 gfn_t table_gfn;
290 shadow_addr = vcpu->arch.mmu.root_hpa; 296 int r;
291 level = vcpu->arch.mmu.shadow_root_level; 297 pt_element_t curr_pte;
292 if (level == PT32E_ROOT_LEVEL) { 298
293 shadow_addr = vcpu->arch.mmu.pae_root[(addr >> 30) & 3]; 299 if (level == PT_PAGE_TABLE_LEVEL
294 shadow_addr &= PT64_BASE_ADDR_MASK; 300 || (sw->largepage && level == PT_DIRECTORY_LEVEL)) {
295 --level; 301 mmu_set_spte(vcpu, sptep, access, gw->pte_access & access,
302 sw->user_fault, sw->write_fault,
303 gw->ptes[gw->level-1] & PT_DIRTY_MASK,
304 sw->ptwrite, sw->largepage, gw->gfn, sw->pfn,
305 false);
306 sw->sptep = sptep;
307 return 1;
296 } 308 }
297 309
298 for (; ; level--) { 310 if (is_shadow_present_pte(*sptep) && !is_large_pte(*sptep))
299 u32 index = SHADOW_PT_INDEX(addr, level); 311 return 0;
300 struct kvm_mmu_page *shadow_page;
301 u64 shadow_pte;
302 int metaphysical;
303 gfn_t table_gfn;
304
305 shadow_ent = ((u64 *)__va(shadow_addr)) + index;
306 if (level == PT_PAGE_TABLE_LEVEL)
307 break;
308
309 if (largepage && level == PT_DIRECTORY_LEVEL)
310 break;
311 312
312 if (is_shadow_present_pte(*shadow_ent) 313 if (is_large_pte(*sptep)) {
313 && !is_large_pte(*shadow_ent)) { 314 set_shadow_pte(sptep, shadow_trap_nonpresent_pte);
314 shadow_addr = *shadow_ent & PT64_BASE_ADDR_MASK; 315 kvm_flush_remote_tlbs(vcpu->kvm);
315 continue; 316 rmap_remove(vcpu->kvm, sptep);
316 } 317 }
317 318
318 if (is_large_pte(*shadow_ent)) 319 if (level == PT_DIRECTORY_LEVEL && gw->level == PT_DIRECTORY_LEVEL) {
319 rmap_remove(vcpu->kvm, shadow_ent); 320 metaphysical = 1;
320 321 if (!is_dirty_pte(gw->ptes[level - 1]))
321 if (level - 1 == PT_PAGE_TABLE_LEVEL 322 access &= ~ACC_WRITE_MASK;
322 && walker->level == PT_DIRECTORY_LEVEL) { 323 table_gfn = gpte_to_gfn(gw->ptes[level - 1]);
323 metaphysical = 1; 324 } else {
324 if (!is_dirty_pte(walker->ptes[level - 1])) 325 metaphysical = 0;
325 access &= ~ACC_WRITE_MASK; 326 table_gfn = gw->table_gfn[level - 2];
326 table_gfn = gpte_to_gfn(walker->ptes[level - 1]); 327 }
327 } else { 328 shadow_page = kvm_mmu_get_page(vcpu, table_gfn, (gva_t)addr, level-1,
328 metaphysical = 0; 329 metaphysical, access, sptep);
329 table_gfn = walker->table_gfn[level - 2]; 330 if (!metaphysical) {
330 } 331 r = kvm_read_guest_atomic(vcpu->kvm, gw->pte_gpa[level - 2],
331 shadow_page = kvm_mmu_get_page(vcpu, table_gfn, addr, level-1, 332 &curr_pte, sizeof(curr_pte));
332 metaphysical, access, 333 if (r || curr_pte != gw->ptes[level - 2]) {
333 shadow_ent); 334 kvm_release_pfn_clean(sw->pfn);
334 if (!metaphysical) { 335 sw->sptep = NULL;
335 int r; 336 return 1;
336 pt_element_t curr_pte;
337 r = kvm_read_guest_atomic(vcpu->kvm,
338 walker->pte_gpa[level - 2],
339 &curr_pte, sizeof(curr_pte));
340 if (r || curr_pte != walker->ptes[level - 2]) {
341 kvm_release_pfn_clean(pfn);
342 return NULL;
343 }
344 } 337 }
345 shadow_addr = __pa(shadow_page->spt);
346 shadow_pte = shadow_addr | PT_PRESENT_MASK | PT_ACCESSED_MASK
347 | PT_WRITABLE_MASK | PT_USER_MASK;
348 set_shadow_pte(shadow_ent, shadow_pte);
349 } 338 }
350 339
351 mmu_set_spte(vcpu, shadow_ent, access, walker->pte_access & access, 340 spte = __pa(shadow_page->spt) | PT_PRESENT_MASK | PT_ACCESSED_MASK
352 user_fault, write_fault, 341 | PT_WRITABLE_MASK | PT_USER_MASK;
353 walker->ptes[walker->level-1] & PT_DIRTY_MASK, 342 *sptep = spte;
354 ptwrite, largepage, walker->gfn, pfn, false); 343 return 0;
344}
345
346static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
347 struct guest_walker *guest_walker,
348 int user_fault, int write_fault, int largepage,
349 int *ptwrite, pfn_t pfn)
350{
351 struct shadow_walker walker = {
352 .walker = { .entry = FNAME(shadow_walk_entry), },
353 .guest_walker = guest_walker,
354 .user_fault = user_fault,
355 .write_fault = write_fault,
356 .largepage = largepage,
357 .ptwrite = ptwrite,
358 .pfn = pfn,
359 };
360
361 if (!is_present_pte(guest_walker->ptes[guest_walker->level - 1]))
362 return NULL;
363
364 walk_shadow(&walker.walker, vcpu, addr);
355 365
356 return shadow_ent; 366 return walker.sptep;
357} 367}
358 368
359/* 369/*
@@ -407,7 +417,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
407 return 0; 417 return 0;
408 } 418 }
409 419
410 down_read(&current->mm->mmap_sem);
411 if (walker.level == PT_DIRECTORY_LEVEL) { 420 if (walker.level == PT_DIRECTORY_LEVEL) {
412 gfn_t large_gfn; 421 gfn_t large_gfn;
413 large_gfn = walker.gfn & ~(KVM_PAGES_PER_HPAGE-1); 422 large_gfn = walker.gfn & ~(KVM_PAGES_PER_HPAGE-1);
@@ -417,9 +426,8 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
417 } 426 }
418 } 427 }
419 mmu_seq = vcpu->kvm->mmu_notifier_seq; 428 mmu_seq = vcpu->kvm->mmu_notifier_seq;
420 /* implicit mb(), we'll read before PT lock is unlocked */ 429 smp_rmb();
421 pfn = gfn_to_pfn(vcpu->kvm, walker.gfn); 430 pfn = gfn_to_pfn(vcpu->kvm, walker.gfn);
422 up_read(&current->mm->mmap_sem);
423 431
424 /* mmio */ 432 /* mmio */
425 if (is_error_pfn(pfn)) { 433 if (is_error_pfn(pfn)) {
@@ -453,6 +461,31 @@ out_unlock:
453 return 0; 461 return 0;
454} 462}
455 463
464static int FNAME(shadow_invlpg_entry)(struct kvm_shadow_walk *_sw,
465 struct kvm_vcpu *vcpu, u64 addr,
466 u64 *sptep, int level)
467{
468
469 if (level == PT_PAGE_TABLE_LEVEL) {
470 if (is_shadow_present_pte(*sptep))
471 rmap_remove(vcpu->kvm, sptep);
472 set_shadow_pte(sptep, shadow_trap_nonpresent_pte);
473 return 1;
474 }
475 if (!is_shadow_present_pte(*sptep))
476 return 1;
477 return 0;
478}
479
480static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
481{
482 struct shadow_walker walker = {
483 .walker = { .entry = FNAME(shadow_invlpg_entry), },
484 };
485
486 walk_shadow(&walker.walker, vcpu, gva);
487}
488
456static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr) 489static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
457{ 490{
458 struct guest_walker walker; 491 struct guest_walker walker;
@@ -499,12 +532,66 @@ static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu,
499 } 532 }
500} 533}
501 534
535/*
536 * Using the cached information from sp->gfns is safe because:
537 * - The spte has a reference to the struct page, so the pfn for a given gfn
538 * can't change unless all sptes pointing to it are nuked first.
539 * - Alias changes zap the entire shadow cache.
540 */
541static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
542{
543 int i, offset, nr_present;
544
545 offset = nr_present = 0;
546
547 if (PTTYPE == 32)
548 offset = sp->role.quadrant << PT64_LEVEL_BITS;
549
550 for (i = 0; i < PT64_ENT_PER_PAGE; i++) {
551 unsigned pte_access;
552 pt_element_t gpte;
553 gpa_t pte_gpa;
554 gfn_t gfn = sp->gfns[i];
555
556 if (!is_shadow_present_pte(sp->spt[i]))
557 continue;
558
559 pte_gpa = gfn_to_gpa(sp->gfn);
560 pte_gpa += (i+offset) * sizeof(pt_element_t);
561
562 if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte,
563 sizeof(pt_element_t)))
564 return -EINVAL;
565
566 if (gpte_to_gfn(gpte) != gfn || !is_present_pte(gpte) ||
567 !(gpte & PT_ACCESSED_MASK)) {
568 u64 nonpresent;
569
570 rmap_remove(vcpu->kvm, &sp->spt[i]);
571 if (is_present_pte(gpte))
572 nonpresent = shadow_trap_nonpresent_pte;
573 else
574 nonpresent = shadow_notrap_nonpresent_pte;
575 set_shadow_pte(&sp->spt[i], nonpresent);
576 continue;
577 }
578
579 nr_present++;
580 pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte);
581 set_spte(vcpu, &sp->spt[i], pte_access, 0, 0,
582 is_dirty_pte(gpte), 0, gfn,
583 spte_to_pfn(sp->spt[i]), true, false);
584 }
585
586 return !nr_present;
587}
588
502#undef pt_element_t 589#undef pt_element_t
503#undef guest_walker 590#undef guest_walker
591#undef shadow_walker
504#undef FNAME 592#undef FNAME
505#undef PT_BASE_ADDR_MASK 593#undef PT_BASE_ADDR_MASK
506#undef PT_INDEX 594#undef PT_INDEX
507#undef SHADOW_PT_INDEX
508#undef PT_LEVEL_MASK 595#undef PT_LEVEL_MASK
509#undef PT_DIR_BASE_ADDR_MASK 596#undef PT_DIR_BASE_ADDR_MASK
510#undef PT_LEVEL_BITS 597#undef PT_LEVEL_BITS
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 8233b86c778c..9c4ce657d963 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -18,6 +18,7 @@
18#include "kvm_svm.h" 18#include "kvm_svm.h"
19#include "irq.h" 19#include "irq.h"
20#include "mmu.h" 20#include "mmu.h"
21#include "kvm_cache_regs.h"
21 22
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -35,10 +36,6 @@ MODULE_LICENSE("GPL");
35#define IOPM_ALLOC_ORDER 2 36#define IOPM_ALLOC_ORDER 2
36#define MSRPM_ALLOC_ORDER 1 37#define MSRPM_ALLOC_ORDER 1
37 38
38#define DB_VECTOR 1
39#define UD_VECTOR 6
40#define GP_VECTOR 13
41
42#define DR7_GD_MASK (1 << 13) 39#define DR7_GD_MASK (1 << 13)
43#define DR6_BD_MASK (1 << 13) 40#define DR6_BD_MASK (1 << 13)
44 41
@@ -47,7 +44,7 @@ MODULE_LICENSE("GPL");
47 44
48#define SVM_FEATURE_NPT (1 << 0) 45#define SVM_FEATURE_NPT (1 << 0)
49#define SVM_FEATURE_LBRV (1 << 1) 46#define SVM_FEATURE_LBRV (1 << 1)
50#define SVM_DEATURE_SVML (1 << 2) 47#define SVM_FEATURE_SVML (1 << 2)
51 48
52#define DEBUGCTL_RESERVED_BITS (~(0x3fULL)) 49#define DEBUGCTL_RESERVED_BITS (~(0x3fULL))
53 50
@@ -236,13 +233,11 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
236 printk(KERN_DEBUG "%s: NOP\n", __func__); 233 printk(KERN_DEBUG "%s: NOP\n", __func__);
237 return; 234 return;
238 } 235 }
239 if (svm->next_rip - svm->vmcb->save.rip > MAX_INST_SIZE) 236 if (svm->next_rip - kvm_rip_read(vcpu) > MAX_INST_SIZE)
240 printk(KERN_ERR "%s: ip 0x%llx next 0x%llx\n", 237 printk(KERN_ERR "%s: ip 0x%lx next 0x%llx\n",
241 __func__, 238 __func__, kvm_rip_read(vcpu), svm->next_rip);
242 svm->vmcb->save.rip,
243 svm->next_rip);
244 239
245 vcpu->arch.rip = svm->vmcb->save.rip = svm->next_rip; 240 kvm_rip_write(vcpu, svm->next_rip);
246 svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK; 241 svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK;
247 242
248 vcpu->arch.interrupt_window_open = 1; 243 vcpu->arch.interrupt_window_open = 1;
@@ -530,6 +525,7 @@ static void init_vmcb(struct vcpu_svm *svm)
530 (1ULL << INTERCEPT_CPUID) | 525 (1ULL << INTERCEPT_CPUID) |
531 (1ULL << INTERCEPT_INVD) | 526 (1ULL << INTERCEPT_INVD) |
532 (1ULL << INTERCEPT_HLT) | 527 (1ULL << INTERCEPT_HLT) |
528 (1ULL << INTERCEPT_INVLPG) |
533 (1ULL << INTERCEPT_INVLPGA) | 529 (1ULL << INTERCEPT_INVLPGA) |
534 (1ULL << INTERCEPT_IOIO_PROT) | 530 (1ULL << INTERCEPT_IOIO_PROT) |
535 (1ULL << INTERCEPT_MSR_PROT) | 531 (1ULL << INTERCEPT_MSR_PROT) |
@@ -581,6 +577,7 @@ static void init_vmcb(struct vcpu_svm *svm)
581 save->dr7 = 0x400; 577 save->dr7 = 0x400;
582 save->rflags = 2; 578 save->rflags = 2;
583 save->rip = 0x0000fff0; 579 save->rip = 0x0000fff0;
580 svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip;
584 581
585 /* 582 /*
586 * cr0 val on cpu init should be 0x60000010, we enable cpu 583 * cr0 val on cpu init should be 0x60000010, we enable cpu
@@ -593,7 +590,8 @@ static void init_vmcb(struct vcpu_svm *svm)
593 if (npt_enabled) { 590 if (npt_enabled) {
594 /* Setup VMCB for Nested Paging */ 591 /* Setup VMCB for Nested Paging */
595 control->nested_ctl = 1; 592 control->nested_ctl = 1;
596 control->intercept &= ~(1ULL << INTERCEPT_TASK_SWITCH); 593 control->intercept &= ~((1ULL << INTERCEPT_TASK_SWITCH) |
594 (1ULL << INTERCEPT_INVLPG));
597 control->intercept_exceptions &= ~(1 << PF_VECTOR); 595 control->intercept_exceptions &= ~(1 << PF_VECTOR);
598 control->intercept_cr_read &= ~(INTERCEPT_CR0_MASK| 596 control->intercept_cr_read &= ~(INTERCEPT_CR0_MASK|
599 INTERCEPT_CR3_MASK); 597 INTERCEPT_CR3_MASK);
@@ -615,10 +613,12 @@ static int svm_vcpu_reset(struct kvm_vcpu *vcpu)
615 init_vmcb(svm); 613 init_vmcb(svm);
616 614
617 if (vcpu->vcpu_id != 0) { 615 if (vcpu->vcpu_id != 0) {
618 svm->vmcb->save.rip = 0; 616 kvm_rip_write(vcpu, 0);
619 svm->vmcb->save.cs.base = svm->vcpu.arch.sipi_vector << 12; 617 svm->vmcb->save.cs.base = svm->vcpu.arch.sipi_vector << 12;
620 svm->vmcb->save.cs.selector = svm->vcpu.arch.sipi_vector << 8; 618 svm->vmcb->save.cs.selector = svm->vcpu.arch.sipi_vector << 8;
621 } 619 }
620 vcpu->arch.regs_avail = ~0;
621 vcpu->arch.regs_dirty = ~0;
622 622
623 return 0; 623 return 0;
624} 624}
@@ -721,23 +721,6 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
721 rdtscll(vcpu->arch.host_tsc); 721 rdtscll(vcpu->arch.host_tsc);
722} 722}
723 723
724static void svm_cache_regs(struct kvm_vcpu *vcpu)
725{
726 struct vcpu_svm *svm = to_svm(vcpu);
727
728 vcpu->arch.regs[VCPU_REGS_RAX] = svm->vmcb->save.rax;
729 vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp;
730 vcpu->arch.rip = svm->vmcb->save.rip;
731}
732
733static void svm_decache_regs(struct kvm_vcpu *vcpu)
734{
735 struct vcpu_svm *svm = to_svm(vcpu);
736 svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX];
737 svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP];
738 svm->vmcb->save.rip = vcpu->arch.rip;
739}
740
741static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu) 724static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu)
742{ 725{
743 return to_svm(vcpu)->vmcb->save.rflags; 726 return to_svm(vcpu)->vmcb->save.rflags;
@@ -1040,7 +1023,7 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1040 if (npt_enabled) 1023 if (npt_enabled)
1041 svm_flush_tlb(&svm->vcpu); 1024 svm_flush_tlb(&svm->vcpu);
1042 1025
1043 if (event_injection) 1026 if (!npt_enabled && event_injection)
1044 kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address); 1027 kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address);
1045 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code); 1028 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
1046} 1029}
@@ -1139,14 +1122,14 @@ static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1139 1122
1140static int halt_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 1123static int halt_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1141{ 1124{
1142 svm->next_rip = svm->vmcb->save.rip + 1; 1125 svm->next_rip = kvm_rip_read(&svm->vcpu) + 1;
1143 skip_emulated_instruction(&svm->vcpu); 1126 skip_emulated_instruction(&svm->vcpu);
1144 return kvm_emulate_halt(&svm->vcpu); 1127 return kvm_emulate_halt(&svm->vcpu);
1145} 1128}
1146 1129
1147static int vmmcall_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 1130static int vmmcall_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1148{ 1131{
1149 svm->next_rip = svm->vmcb->save.rip + 3; 1132 svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
1150 skip_emulated_instruction(&svm->vcpu); 1133 skip_emulated_instruction(&svm->vcpu);
1151 kvm_emulate_hypercall(&svm->vcpu); 1134 kvm_emulate_hypercall(&svm->vcpu);
1152 return 1; 1135 return 1;
@@ -1178,11 +1161,18 @@ static int task_switch_interception(struct vcpu_svm *svm,
1178 1161
1179static int cpuid_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 1162static int cpuid_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1180{ 1163{
1181 svm->next_rip = svm->vmcb->save.rip + 2; 1164 svm->next_rip = kvm_rip_read(&svm->vcpu) + 2;
1182 kvm_emulate_cpuid(&svm->vcpu); 1165 kvm_emulate_cpuid(&svm->vcpu);
1183 return 1; 1166 return 1;
1184} 1167}
1185 1168
1169static int invlpg_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1170{
1171 if (emulate_instruction(&svm->vcpu, kvm_run, 0, 0, 0) != EMULATE_DONE)
1172 pr_unimpl(&svm->vcpu, "%s: failed\n", __func__);
1173 return 1;
1174}
1175
1186static int emulate_on_interception(struct vcpu_svm *svm, 1176static int emulate_on_interception(struct vcpu_svm *svm,
1187 struct kvm_run *kvm_run) 1177 struct kvm_run *kvm_run)
1188{ 1178{
@@ -1273,9 +1263,9 @@ static int rdmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1273 KVMTRACE_3D(MSR_READ, &svm->vcpu, ecx, (u32)data, 1263 KVMTRACE_3D(MSR_READ, &svm->vcpu, ecx, (u32)data,
1274 (u32)(data >> 32), handler); 1264 (u32)(data >> 32), handler);
1275 1265
1276 svm->vmcb->save.rax = data & 0xffffffff; 1266 svm->vcpu.arch.regs[VCPU_REGS_RAX] = data & 0xffffffff;
1277 svm->vcpu.arch.regs[VCPU_REGS_RDX] = data >> 32; 1267 svm->vcpu.arch.regs[VCPU_REGS_RDX] = data >> 32;
1278 svm->next_rip = svm->vmcb->save.rip + 2; 1268 svm->next_rip = kvm_rip_read(&svm->vcpu) + 2;
1279 skip_emulated_instruction(&svm->vcpu); 1269 skip_emulated_instruction(&svm->vcpu);
1280 } 1270 }
1281 return 1; 1271 return 1;
@@ -1359,13 +1349,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
1359static int wrmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 1349static int wrmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1360{ 1350{
1361 u32 ecx = svm->vcpu.arch.regs[VCPU_REGS_RCX]; 1351 u32 ecx = svm->vcpu.arch.regs[VCPU_REGS_RCX];
1362 u64 data = (svm->vmcb->save.rax & -1u) 1352 u64 data = (svm->vcpu.arch.regs[VCPU_REGS_RAX] & -1u)
1363 | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX] & -1u) << 32); 1353 | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX] & -1u) << 32);
1364 1354
1365 KVMTRACE_3D(MSR_WRITE, &svm->vcpu, ecx, (u32)data, (u32)(data >> 32), 1355 KVMTRACE_3D(MSR_WRITE, &svm->vcpu, ecx, (u32)data, (u32)(data >> 32),
1366 handler); 1356 handler);
1367 1357
1368 svm->next_rip = svm->vmcb->save.rip + 2; 1358 svm->next_rip = kvm_rip_read(&svm->vcpu) + 2;
1369 if (svm_set_msr(&svm->vcpu, ecx, data)) 1359 if (svm_set_msr(&svm->vcpu, ecx, data))
1370 kvm_inject_gp(&svm->vcpu, 0); 1360 kvm_inject_gp(&svm->vcpu, 0);
1371 else 1361 else
@@ -1436,7 +1426,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm,
1436 [SVM_EXIT_CPUID] = cpuid_interception, 1426 [SVM_EXIT_CPUID] = cpuid_interception,
1437 [SVM_EXIT_INVD] = emulate_on_interception, 1427 [SVM_EXIT_INVD] = emulate_on_interception,
1438 [SVM_EXIT_HLT] = halt_interception, 1428 [SVM_EXIT_HLT] = halt_interception,
1439 [SVM_EXIT_INVLPG] = emulate_on_interception, 1429 [SVM_EXIT_INVLPG] = invlpg_interception,
1440 [SVM_EXIT_INVLPGA] = invalid_op_interception, 1430 [SVM_EXIT_INVLPGA] = invalid_op_interception,
1441 [SVM_EXIT_IOIO] = io_interception, 1431 [SVM_EXIT_IOIO] = io_interception,
1442 [SVM_EXIT_MSR] = msr_interception, 1432 [SVM_EXIT_MSR] = msr_interception,
@@ -1538,6 +1528,7 @@ static inline void svm_inject_irq(struct vcpu_svm *svm, int irq)
1538 1528
1539 KVMTRACE_1D(INJ_VIRQ, &svm->vcpu, (u32)irq, handler); 1529 KVMTRACE_1D(INJ_VIRQ, &svm->vcpu, (u32)irq, handler);
1540 1530
1531 ++svm->vcpu.stat.irq_injections;
1541 control = &svm->vmcb->control; 1532 control = &svm->vmcb->control;
1542 control->int_vector = irq; 1533 control->int_vector = irq;
1543 control->int_ctl &= ~V_INTR_PRIO_MASK; 1534 control->int_ctl &= ~V_INTR_PRIO_MASK;
@@ -1716,6 +1707,12 @@ static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu)
1716 svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK; 1707 svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK;
1717} 1708}
1718 1709
1710#ifdef CONFIG_X86_64
1711#define R "r"
1712#else
1713#define R "e"
1714#endif
1715
1719static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1716static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1720{ 1717{
1721 struct vcpu_svm *svm = to_svm(vcpu); 1718 struct vcpu_svm *svm = to_svm(vcpu);
@@ -1723,6 +1720,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1723 u16 gs_selector; 1720 u16 gs_selector;
1724 u16 ldt_selector; 1721 u16 ldt_selector;
1725 1722
1723 svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX];
1724 svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP];
1725 svm->vmcb->save.rip = vcpu->arch.regs[VCPU_REGS_RIP];
1726
1726 pre_svm_run(svm); 1727 pre_svm_run(svm);
1727 1728
1728 sync_lapic_to_cr8(vcpu); 1729 sync_lapic_to_cr8(vcpu);
@@ -1750,19 +1751,14 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1750 local_irq_enable(); 1751 local_irq_enable();
1751 1752
1752 asm volatile ( 1753 asm volatile (
1754 "push %%"R"bp; \n\t"
1755 "mov %c[rbx](%[svm]), %%"R"bx \n\t"
1756 "mov %c[rcx](%[svm]), %%"R"cx \n\t"
1757 "mov %c[rdx](%[svm]), %%"R"dx \n\t"
1758 "mov %c[rsi](%[svm]), %%"R"si \n\t"
1759 "mov %c[rdi](%[svm]), %%"R"di \n\t"
1760 "mov %c[rbp](%[svm]), %%"R"bp \n\t"
1753#ifdef CONFIG_X86_64 1761#ifdef CONFIG_X86_64
1754 "push %%rbp; \n\t"
1755#else
1756 "push %%ebp; \n\t"
1757#endif
1758
1759#ifdef CONFIG_X86_64
1760 "mov %c[rbx](%[svm]), %%rbx \n\t"
1761 "mov %c[rcx](%[svm]), %%rcx \n\t"
1762 "mov %c[rdx](%[svm]), %%rdx \n\t"
1763 "mov %c[rsi](%[svm]), %%rsi \n\t"
1764 "mov %c[rdi](%[svm]), %%rdi \n\t"
1765 "mov %c[rbp](%[svm]), %%rbp \n\t"
1766 "mov %c[r8](%[svm]), %%r8 \n\t" 1762 "mov %c[r8](%[svm]), %%r8 \n\t"
1767 "mov %c[r9](%[svm]), %%r9 \n\t" 1763 "mov %c[r9](%[svm]), %%r9 \n\t"
1768 "mov %c[r10](%[svm]), %%r10 \n\t" 1764 "mov %c[r10](%[svm]), %%r10 \n\t"
@@ -1771,41 +1767,24 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1771 "mov %c[r13](%[svm]), %%r13 \n\t" 1767 "mov %c[r13](%[svm]), %%r13 \n\t"
1772 "mov %c[r14](%[svm]), %%r14 \n\t" 1768 "mov %c[r14](%[svm]), %%r14 \n\t"
1773 "mov %c[r15](%[svm]), %%r15 \n\t" 1769 "mov %c[r15](%[svm]), %%r15 \n\t"
1774#else
1775 "mov %c[rbx](%[svm]), %%ebx \n\t"
1776 "mov %c[rcx](%[svm]), %%ecx \n\t"
1777 "mov %c[rdx](%[svm]), %%edx \n\t"
1778 "mov %c[rsi](%[svm]), %%esi \n\t"
1779 "mov %c[rdi](%[svm]), %%edi \n\t"
1780 "mov %c[rbp](%[svm]), %%ebp \n\t"
1781#endif 1770#endif
1782 1771
1783#ifdef CONFIG_X86_64
1784 /* Enter guest mode */
1785 "push %%rax \n\t"
1786 "mov %c[vmcb](%[svm]), %%rax \n\t"
1787 __ex(SVM_VMLOAD) "\n\t"
1788 __ex(SVM_VMRUN) "\n\t"
1789 __ex(SVM_VMSAVE) "\n\t"
1790 "pop %%rax \n\t"
1791#else
1792 /* Enter guest mode */ 1772 /* Enter guest mode */
1793 "push %%eax \n\t" 1773 "push %%"R"ax \n\t"
1794 "mov %c[vmcb](%[svm]), %%eax \n\t" 1774 "mov %c[vmcb](%[svm]), %%"R"ax \n\t"
1795 __ex(SVM_VMLOAD) "\n\t" 1775 __ex(SVM_VMLOAD) "\n\t"
1796 __ex(SVM_VMRUN) "\n\t" 1776 __ex(SVM_VMRUN) "\n\t"
1797 __ex(SVM_VMSAVE) "\n\t" 1777 __ex(SVM_VMSAVE) "\n\t"
1798 "pop %%eax \n\t" 1778 "pop %%"R"ax \n\t"
1799#endif
1800 1779
1801 /* Save guest registers, load host registers */ 1780 /* Save guest registers, load host registers */
1781 "mov %%"R"bx, %c[rbx](%[svm]) \n\t"
1782 "mov %%"R"cx, %c[rcx](%[svm]) \n\t"
1783 "mov %%"R"dx, %c[rdx](%[svm]) \n\t"
1784 "mov %%"R"si, %c[rsi](%[svm]) \n\t"
1785 "mov %%"R"di, %c[rdi](%[svm]) \n\t"
1786 "mov %%"R"bp, %c[rbp](%[svm]) \n\t"
1802#ifdef CONFIG_X86_64 1787#ifdef CONFIG_X86_64
1803 "mov %%rbx, %c[rbx](%[svm]) \n\t"
1804 "mov %%rcx, %c[rcx](%[svm]) \n\t"
1805 "mov %%rdx, %c[rdx](%[svm]) \n\t"
1806 "mov %%rsi, %c[rsi](%[svm]) \n\t"
1807 "mov %%rdi, %c[rdi](%[svm]) \n\t"
1808 "mov %%rbp, %c[rbp](%[svm]) \n\t"
1809 "mov %%r8, %c[r8](%[svm]) \n\t" 1788 "mov %%r8, %c[r8](%[svm]) \n\t"
1810 "mov %%r9, %c[r9](%[svm]) \n\t" 1789 "mov %%r9, %c[r9](%[svm]) \n\t"
1811 "mov %%r10, %c[r10](%[svm]) \n\t" 1790 "mov %%r10, %c[r10](%[svm]) \n\t"
@@ -1814,18 +1793,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1814 "mov %%r13, %c[r13](%[svm]) \n\t" 1793 "mov %%r13, %c[r13](%[svm]) \n\t"
1815 "mov %%r14, %c[r14](%[svm]) \n\t" 1794 "mov %%r14, %c[r14](%[svm]) \n\t"
1816 "mov %%r15, %c[r15](%[svm]) \n\t" 1795 "mov %%r15, %c[r15](%[svm]) \n\t"
1817
1818 "pop %%rbp; \n\t"
1819#else
1820 "mov %%ebx, %c[rbx](%[svm]) \n\t"
1821 "mov %%ecx, %c[rcx](%[svm]) \n\t"
1822 "mov %%edx, %c[rdx](%[svm]) \n\t"
1823 "mov %%esi, %c[rsi](%[svm]) \n\t"
1824 "mov %%edi, %c[rdi](%[svm]) \n\t"
1825 "mov %%ebp, %c[rbp](%[svm]) \n\t"
1826
1827 "pop %%ebp; \n\t"
1828#endif 1796#endif
1797 "pop %%"R"bp"
1829 : 1798 :
1830 : [svm]"a"(svm), 1799 : [svm]"a"(svm),
1831 [vmcb]"i"(offsetof(struct vcpu_svm, vmcb_pa)), 1800 [vmcb]"i"(offsetof(struct vcpu_svm, vmcb_pa)),
@@ -1846,11 +1815,9 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1846 [r15]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_R15])) 1815 [r15]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_R15]))
1847#endif 1816#endif
1848 : "cc", "memory" 1817 : "cc", "memory"
1818 , R"bx", R"cx", R"dx", R"si", R"di"
1849#ifdef CONFIG_X86_64 1819#ifdef CONFIG_X86_64
1850 , "rbx", "rcx", "rdx", "rsi", "rdi"
1851 , "r8", "r9", "r10", "r11" , "r12", "r13", "r14", "r15" 1820 , "r8", "r9", "r10", "r11" , "r12", "r13", "r14", "r15"
1852#else
1853 , "ebx", "ecx", "edx" , "esi", "edi"
1854#endif 1821#endif
1855 ); 1822 );
1856 1823
@@ -1858,6 +1825,9 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1858 load_db_regs(svm->host_db_regs); 1825 load_db_regs(svm->host_db_regs);
1859 1826
1860 vcpu->arch.cr2 = svm->vmcb->save.cr2; 1827 vcpu->arch.cr2 = svm->vmcb->save.cr2;
1828 vcpu->arch.regs[VCPU_REGS_RAX] = svm->vmcb->save.rax;
1829 vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp;
1830 vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip;
1861 1831
1862 write_dr6(svm->host_dr6); 1832 write_dr6(svm->host_dr6);
1863 write_dr7(svm->host_dr7); 1833 write_dr7(svm->host_dr7);
@@ -1879,6 +1849,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1879 svm->next_rip = 0; 1849 svm->next_rip = 0;
1880} 1850}
1881 1851
1852#undef R
1853
1882static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) 1854static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root)
1883{ 1855{
1884 struct vcpu_svm *svm = to_svm(vcpu); 1856 struct vcpu_svm *svm = to_svm(vcpu);
@@ -1977,8 +1949,6 @@ static struct kvm_x86_ops svm_x86_ops = {
1977 .set_gdt = svm_set_gdt, 1949 .set_gdt = svm_set_gdt,
1978 .get_dr = svm_get_dr, 1950 .get_dr = svm_get_dr,
1979 .set_dr = svm_set_dr, 1951 .set_dr = svm_set_dr,
1980 .cache_regs = svm_cache_regs,
1981 .decache_regs = svm_decache_regs,
1982 .get_rflags = svm_get_rflags, 1952 .get_rflags = svm_get_rflags,
1983 .set_rflags = svm_set_rflags, 1953 .set_rflags = svm_set_rflags,
1984 1954
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 7041cc52b562..2643b430d83a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -26,6 +26,8 @@
26#include <linux/highmem.h> 26#include <linux/highmem.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include "kvm_cache_regs.h"
30#include "x86.h"
29 31
30#include <asm/io.h> 32#include <asm/io.h>
31#include <asm/desc.h> 33#include <asm/desc.h>
@@ -47,6 +49,9 @@ module_param(flexpriority_enabled, bool, 0);
47static int enable_ept = 1; 49static int enable_ept = 1;
48module_param(enable_ept, bool, 0); 50module_param(enable_ept, bool, 0);
49 51
52static int emulate_invalid_guest_state = 0;
53module_param(emulate_invalid_guest_state, bool, 0);
54
50struct vmcs { 55struct vmcs {
51 u32 revision_id; 56 u32 revision_id;
52 u32 abort; 57 u32 abort;
@@ -56,6 +61,7 @@ struct vmcs {
56struct vcpu_vmx { 61struct vcpu_vmx {
57 struct kvm_vcpu vcpu; 62 struct kvm_vcpu vcpu;
58 struct list_head local_vcpus_link; 63 struct list_head local_vcpus_link;
64 unsigned long host_rsp;
59 int launched; 65 int launched;
60 u8 fail; 66 u8 fail;
61 u32 idt_vectoring_info; 67 u32 idt_vectoring_info;
@@ -83,6 +89,7 @@ struct vcpu_vmx {
83 } irq; 89 } irq;
84 } rmode; 90 } rmode;
85 int vpid; 91 int vpid;
92 bool emulation_required;
86}; 93};
87 94
88static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu) 95static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu)
@@ -468,7 +475,7 @@ static void update_exception_bitmap(struct kvm_vcpu *vcpu)
468 if (!vcpu->fpu_active) 475 if (!vcpu->fpu_active)
469 eb |= 1u << NM_VECTOR; 476 eb |= 1u << NM_VECTOR;
470 if (vcpu->guest_debug.enabled) 477 if (vcpu->guest_debug.enabled)
471 eb |= 1u << 1; 478 eb |= 1u << DB_VECTOR;
472 if (vcpu->arch.rmode.active) 479 if (vcpu->arch.rmode.active)
473 eb = ~0; 480 eb = ~0;
474 if (vm_need_ept()) 481 if (vm_need_ept())
@@ -715,9 +722,9 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
715 unsigned long rip; 722 unsigned long rip;
716 u32 interruptibility; 723 u32 interruptibility;
717 724
718 rip = vmcs_readl(GUEST_RIP); 725 rip = kvm_rip_read(vcpu);
719 rip += vmcs_read32(VM_EXIT_INSTRUCTION_LEN); 726 rip += vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
720 vmcs_writel(GUEST_RIP, rip); 727 kvm_rip_write(vcpu, rip);
721 728
722 /* 729 /*
723 * We emulated an instruction, so temporary interrupt blocking 730 * We emulated an instruction, so temporary interrupt blocking
@@ -733,19 +740,35 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
733static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, 740static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
734 bool has_error_code, u32 error_code) 741 bool has_error_code, u32 error_code)
735{ 742{
743 struct vcpu_vmx *vmx = to_vmx(vcpu);
744
745 if (has_error_code)
746 vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
747
748 if (vcpu->arch.rmode.active) {
749 vmx->rmode.irq.pending = true;
750 vmx->rmode.irq.vector = nr;
751 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
752 if (nr == BP_VECTOR)
753 vmx->rmode.irq.rip++;
754 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
755 nr | INTR_TYPE_SOFT_INTR
756 | (has_error_code ? INTR_INFO_DELIVER_CODE_MASK : 0)
757 | INTR_INFO_VALID_MASK);
758 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
759 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
760 return;
761 }
762
736 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 763 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
737 nr | INTR_TYPE_EXCEPTION 764 nr | INTR_TYPE_EXCEPTION
738 | (has_error_code ? INTR_INFO_DELIVER_CODE_MASK : 0) 765 | (has_error_code ? INTR_INFO_DELIVER_CODE_MASK : 0)
739 | INTR_INFO_VALID_MASK); 766 | INTR_INFO_VALID_MASK);
740 if (has_error_code)
741 vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
742} 767}
743 768
744static bool vmx_exception_injected(struct kvm_vcpu *vcpu) 769static bool vmx_exception_injected(struct kvm_vcpu *vcpu)
745{ 770{
746 struct vcpu_vmx *vmx = to_vmx(vcpu); 771 return false;
747
748 return !(vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK);
749} 772}
750 773
751/* 774/*
@@ -947,24 +970,19 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
947 return ret; 970 return ret;
948} 971}
949 972
950/* 973static void vmx_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
951 * Sync the rsp and rip registers into the vcpu structure. This allows
952 * registers to be accessed by indexing vcpu->arch.regs.
953 */
954static void vcpu_load_rsp_rip(struct kvm_vcpu *vcpu)
955{
956 vcpu->arch.regs[VCPU_REGS_RSP] = vmcs_readl(GUEST_RSP);
957 vcpu->arch.rip = vmcs_readl(GUEST_RIP);
958}
959
960/*
961 * Syncs rsp and rip back into the vmcs. Should be called after possible
962 * modification.
963 */
964static void vcpu_put_rsp_rip(struct kvm_vcpu *vcpu)
965{ 974{
966 vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]); 975 __set_bit(reg, (unsigned long *)&vcpu->arch.regs_avail);
967 vmcs_writel(GUEST_RIP, vcpu->arch.rip); 976 switch (reg) {
977 case VCPU_REGS_RSP:
978 vcpu->arch.regs[VCPU_REGS_RSP] = vmcs_readl(GUEST_RSP);
979 break;
980 case VCPU_REGS_RIP:
981 vcpu->arch.regs[VCPU_REGS_RIP] = vmcs_readl(GUEST_RIP);
982 break;
983 default:
984 break;
985 }
968} 986}
969 987
970static int set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_debug_guest *dbg) 988static int set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_debug_guest *dbg)
@@ -1007,17 +1025,9 @@ static int set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_debug_guest *dbg)
1007 1025
1008static int vmx_get_irq(struct kvm_vcpu *vcpu) 1026static int vmx_get_irq(struct kvm_vcpu *vcpu)
1009{ 1027{
1010 struct vcpu_vmx *vmx = to_vmx(vcpu); 1028 if (!vcpu->arch.interrupt.pending)
1011 u32 idtv_info_field; 1029 return -1;
1012 1030 return vcpu->arch.interrupt.nr;
1013 idtv_info_field = vmx->idt_vectoring_info;
1014 if (idtv_info_field & INTR_INFO_VALID_MASK) {
1015 if (is_external_interrupt(idtv_info_field))
1016 return idtv_info_field & VECTORING_INFO_VECTOR_MASK;
1017 else
1018 printk(KERN_DEBUG "pending exception: not handled yet\n");
1019 }
1020 return -1;
1021} 1031}
1022 1032
1023static __init int cpu_has_kvm_support(void) 1033static __init int cpu_has_kvm_support(void)
@@ -1031,9 +1041,9 @@ static __init int vmx_disabled_by_bios(void)
1031 u64 msr; 1041 u64 msr;
1032 1042
1033 rdmsrl(MSR_IA32_FEATURE_CONTROL, msr); 1043 rdmsrl(MSR_IA32_FEATURE_CONTROL, msr);
1034 return (msr & (MSR_IA32_FEATURE_CONTROL_LOCKED | 1044 return (msr & (FEATURE_CONTROL_LOCKED |
1035 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED)) 1045 FEATURE_CONTROL_VMXON_ENABLED))
1036 == MSR_IA32_FEATURE_CONTROL_LOCKED; 1046 == FEATURE_CONTROL_LOCKED;
1037 /* locked but not enabled */ 1047 /* locked but not enabled */
1038} 1048}
1039 1049
@@ -1045,14 +1055,14 @@ static void hardware_enable(void *garbage)
1045 1055
1046 INIT_LIST_HEAD(&per_cpu(vcpus_on_cpu, cpu)); 1056 INIT_LIST_HEAD(&per_cpu(vcpus_on_cpu, cpu));
1047 rdmsrl(MSR_IA32_FEATURE_CONTROL, old); 1057 rdmsrl(MSR_IA32_FEATURE_CONTROL, old);
1048 if ((old & (MSR_IA32_FEATURE_CONTROL_LOCKED | 1058 if ((old & (FEATURE_CONTROL_LOCKED |
1049 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED)) 1059 FEATURE_CONTROL_VMXON_ENABLED))
1050 != (MSR_IA32_FEATURE_CONTROL_LOCKED | 1060 != (FEATURE_CONTROL_LOCKED |
1051 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED)) 1061 FEATURE_CONTROL_VMXON_ENABLED))
1052 /* enable and lock */ 1062 /* enable and lock */
1053 wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 1063 wrmsrl(MSR_IA32_FEATURE_CONTROL, old |
1054 MSR_IA32_FEATURE_CONTROL_LOCKED | 1064 FEATURE_CONTROL_LOCKED |
1055 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED); 1065 FEATURE_CONTROL_VMXON_ENABLED);
1056 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */ 1066 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */
1057 asm volatile (ASM_VMX_VMXON_RAX 1067 asm volatile (ASM_VMX_VMXON_RAX
1058 : : "a"(&phys_addr), "m"(phys_addr) 1068 : : "a"(&phys_addr), "m"(phys_addr)
@@ -1120,7 +1130,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
1120 CPU_BASED_CR3_STORE_EXITING | 1130 CPU_BASED_CR3_STORE_EXITING |
1121 CPU_BASED_USE_IO_BITMAPS | 1131 CPU_BASED_USE_IO_BITMAPS |
1122 CPU_BASED_MOV_DR_EXITING | 1132 CPU_BASED_MOV_DR_EXITING |
1123 CPU_BASED_USE_TSC_OFFSETING; 1133 CPU_BASED_USE_TSC_OFFSETING |
1134 CPU_BASED_INVLPG_EXITING;
1124 opt = CPU_BASED_TPR_SHADOW | 1135 opt = CPU_BASED_TPR_SHADOW |
1125 CPU_BASED_USE_MSR_BITMAPS | 1136 CPU_BASED_USE_MSR_BITMAPS |
1126 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS; 1137 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
@@ -1149,9 +1160,11 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
1149 _cpu_based_exec_control &= ~CPU_BASED_TPR_SHADOW; 1160 _cpu_based_exec_control &= ~CPU_BASED_TPR_SHADOW;
1150#endif 1161#endif
1151 if (_cpu_based_2nd_exec_control & SECONDARY_EXEC_ENABLE_EPT) { 1162 if (_cpu_based_2nd_exec_control & SECONDARY_EXEC_ENABLE_EPT) {
1152 /* CR3 accesses don't need to cause VM Exits when EPT enabled */ 1163 /* CR3 accesses and invlpg don't need to cause VM Exits when EPT
1164 enabled */
1153 min &= ~(CPU_BASED_CR3_LOAD_EXITING | 1165 min &= ~(CPU_BASED_CR3_LOAD_EXITING |
1154 CPU_BASED_CR3_STORE_EXITING); 1166 CPU_BASED_CR3_STORE_EXITING |
1167 CPU_BASED_INVLPG_EXITING);
1155 if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PROCBASED_CTLS, 1168 if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PROCBASED_CTLS,
1156 &_cpu_based_exec_control) < 0) 1169 &_cpu_based_exec_control) < 0)
1157 return -EIO; 1170 return -EIO;
@@ -1288,7 +1301,9 @@ static void fix_pmode_dataseg(int seg, struct kvm_save_segment *save)
1288static void enter_pmode(struct kvm_vcpu *vcpu) 1301static void enter_pmode(struct kvm_vcpu *vcpu)
1289{ 1302{
1290 unsigned long flags; 1303 unsigned long flags;
1304 struct vcpu_vmx *vmx = to_vmx(vcpu);
1291 1305
1306 vmx->emulation_required = 1;
1292 vcpu->arch.rmode.active = 0; 1307 vcpu->arch.rmode.active = 0;
1293 1308
1294 vmcs_writel(GUEST_TR_BASE, vcpu->arch.rmode.tr.base); 1309 vmcs_writel(GUEST_TR_BASE, vcpu->arch.rmode.tr.base);
@@ -1305,6 +1320,9 @@ static void enter_pmode(struct kvm_vcpu *vcpu)
1305 1320
1306 update_exception_bitmap(vcpu); 1321 update_exception_bitmap(vcpu);
1307 1322
1323 if (emulate_invalid_guest_state)
1324 return;
1325
1308 fix_pmode_dataseg(VCPU_SREG_ES, &vcpu->arch.rmode.es); 1326 fix_pmode_dataseg(VCPU_SREG_ES, &vcpu->arch.rmode.es);
1309 fix_pmode_dataseg(VCPU_SREG_DS, &vcpu->arch.rmode.ds); 1327 fix_pmode_dataseg(VCPU_SREG_DS, &vcpu->arch.rmode.ds);
1310 fix_pmode_dataseg(VCPU_SREG_GS, &vcpu->arch.rmode.gs); 1328 fix_pmode_dataseg(VCPU_SREG_GS, &vcpu->arch.rmode.gs);
@@ -1345,7 +1363,9 @@ static void fix_rmode_seg(int seg, struct kvm_save_segment *save)
1345static void enter_rmode(struct kvm_vcpu *vcpu) 1363static void enter_rmode(struct kvm_vcpu *vcpu)
1346{ 1364{
1347 unsigned long flags; 1365 unsigned long flags;
1366 struct vcpu_vmx *vmx = to_vmx(vcpu);
1348 1367
1368 vmx->emulation_required = 1;
1349 vcpu->arch.rmode.active = 1; 1369 vcpu->arch.rmode.active = 1;
1350 1370
1351 vcpu->arch.rmode.tr.base = vmcs_readl(GUEST_TR_BASE); 1371 vcpu->arch.rmode.tr.base = vmcs_readl(GUEST_TR_BASE);
@@ -1367,6 +1387,9 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
1367 vmcs_writel(GUEST_CR4, vmcs_readl(GUEST_CR4) | X86_CR4_VME); 1387 vmcs_writel(GUEST_CR4, vmcs_readl(GUEST_CR4) | X86_CR4_VME);
1368 update_exception_bitmap(vcpu); 1388 update_exception_bitmap(vcpu);
1369 1389
1390 if (emulate_invalid_guest_state)
1391 goto continue_rmode;
1392
1370 vmcs_write16(GUEST_SS_SELECTOR, vmcs_readl(GUEST_SS_BASE) >> 4); 1393 vmcs_write16(GUEST_SS_SELECTOR, vmcs_readl(GUEST_SS_BASE) >> 4);
1371 vmcs_write32(GUEST_SS_LIMIT, 0xffff); 1394 vmcs_write32(GUEST_SS_LIMIT, 0xffff);
1372 vmcs_write32(GUEST_SS_AR_BYTES, 0xf3); 1395 vmcs_write32(GUEST_SS_AR_BYTES, 0xf3);
@@ -1382,6 +1405,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
1382 fix_rmode_seg(VCPU_SREG_GS, &vcpu->arch.rmode.gs); 1405 fix_rmode_seg(VCPU_SREG_GS, &vcpu->arch.rmode.gs);
1383 fix_rmode_seg(VCPU_SREG_FS, &vcpu->arch.rmode.fs); 1406 fix_rmode_seg(VCPU_SREG_FS, &vcpu->arch.rmode.fs);
1384 1407
1408continue_rmode:
1385 kvm_mmu_reset_context(vcpu); 1409 kvm_mmu_reset_context(vcpu);
1386 init_rmode(vcpu->kvm); 1410 init_rmode(vcpu->kvm);
1387} 1411}
@@ -1715,6 +1739,186 @@ static void vmx_set_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
1715 vmcs_writel(GUEST_GDTR_BASE, dt->base); 1739 vmcs_writel(GUEST_GDTR_BASE, dt->base);
1716} 1740}
1717 1741
1742static bool rmode_segment_valid(struct kvm_vcpu *vcpu, int seg)
1743{
1744 struct kvm_segment var;
1745 u32 ar;
1746
1747 vmx_get_segment(vcpu, &var, seg);
1748 ar = vmx_segment_access_rights(&var);
1749
1750 if (var.base != (var.selector << 4))
1751 return false;
1752 if (var.limit != 0xffff)
1753 return false;
1754 if (ar != 0xf3)
1755 return false;
1756
1757 return true;
1758}
1759
1760static bool code_segment_valid(struct kvm_vcpu *vcpu)
1761{
1762 struct kvm_segment cs;
1763 unsigned int cs_rpl;
1764
1765 vmx_get_segment(vcpu, &cs, VCPU_SREG_CS);
1766 cs_rpl = cs.selector & SELECTOR_RPL_MASK;
1767
1768 if (~cs.type & (AR_TYPE_CODE_MASK|AR_TYPE_ACCESSES_MASK))
1769 return false;
1770 if (!cs.s)
1771 return false;
1772 if (!(~cs.type & (AR_TYPE_CODE_MASK|AR_TYPE_WRITEABLE_MASK))) {
1773 if (cs.dpl > cs_rpl)
1774 return false;
1775 } else if (cs.type & AR_TYPE_CODE_MASK) {
1776 if (cs.dpl != cs_rpl)
1777 return false;
1778 }
1779 if (!cs.present)
1780 return false;
1781
1782 /* TODO: Add Reserved field check, this'll require a new member in the kvm_segment_field structure */
1783 return true;
1784}
1785
1786static bool stack_segment_valid(struct kvm_vcpu *vcpu)
1787{
1788 struct kvm_segment ss;
1789 unsigned int ss_rpl;
1790
1791 vmx_get_segment(vcpu, &ss, VCPU_SREG_SS);
1792 ss_rpl = ss.selector & SELECTOR_RPL_MASK;
1793
1794 if ((ss.type != 3) || (ss.type != 7))
1795 return false;
1796 if (!ss.s)
1797 return false;
1798 if (ss.dpl != ss_rpl) /* DPL != RPL */
1799 return false;
1800 if (!ss.present)
1801 return false;
1802
1803 return true;
1804}
1805
1806static bool data_segment_valid(struct kvm_vcpu *vcpu, int seg)
1807{
1808 struct kvm_segment var;
1809 unsigned int rpl;
1810
1811 vmx_get_segment(vcpu, &var, seg);
1812 rpl = var.selector & SELECTOR_RPL_MASK;
1813
1814 if (!var.s)
1815 return false;
1816 if (!var.present)
1817 return false;
1818 if (~var.type & (AR_TYPE_CODE_MASK|AR_TYPE_WRITEABLE_MASK)) {
1819 if (var.dpl < rpl) /* DPL < RPL */
1820 return false;
1821 }
1822
1823 /* TODO: Add other members to kvm_segment_field to allow checking for other access
1824 * rights flags
1825 */
1826 return true;
1827}
1828
1829static bool tr_valid(struct kvm_vcpu *vcpu)
1830{
1831 struct kvm_segment tr;
1832
1833 vmx_get_segment(vcpu, &tr, VCPU_SREG_TR);
1834
1835 if (tr.selector & SELECTOR_TI_MASK) /* TI = 1 */
1836 return false;
1837 if ((tr.type != 3) || (tr.type != 11)) /* TODO: Check if guest is in IA32e mode */
1838 return false;
1839 if (!tr.present)
1840 return false;
1841
1842 return true;
1843}
1844
1845static bool ldtr_valid(struct kvm_vcpu *vcpu)
1846{
1847 struct kvm_segment ldtr;
1848
1849 vmx_get_segment(vcpu, &ldtr, VCPU_SREG_LDTR);
1850
1851 if (ldtr.selector & SELECTOR_TI_MASK) /* TI = 1 */
1852 return false;
1853 if (ldtr.type != 2)
1854 return false;
1855 if (!ldtr.present)
1856 return false;
1857
1858 return true;
1859}
1860
1861static bool cs_ss_rpl_check(struct kvm_vcpu *vcpu)
1862{
1863 struct kvm_segment cs, ss;
1864
1865 vmx_get_segment(vcpu, &cs, VCPU_SREG_CS);
1866 vmx_get_segment(vcpu, &ss, VCPU_SREG_SS);
1867
1868 return ((cs.selector & SELECTOR_RPL_MASK) ==
1869 (ss.selector & SELECTOR_RPL_MASK));
1870}
1871
1872/*
1873 * Check if guest state is valid. Returns true if valid, false if
1874 * not.
1875 * We assume that registers are always usable
1876 */
1877static bool guest_state_valid(struct kvm_vcpu *vcpu)
1878{
1879 /* real mode guest state checks */
1880 if (!(vcpu->arch.cr0 & X86_CR0_PE)) {
1881 if (!rmode_segment_valid(vcpu, VCPU_SREG_CS))
1882 return false;
1883 if (!rmode_segment_valid(vcpu, VCPU_SREG_SS))
1884 return false;
1885 if (!rmode_segment_valid(vcpu, VCPU_SREG_DS))
1886 return false;
1887 if (!rmode_segment_valid(vcpu, VCPU_SREG_ES))
1888 return false;
1889 if (!rmode_segment_valid(vcpu, VCPU_SREG_FS))
1890 return false;
1891 if (!rmode_segment_valid(vcpu, VCPU_SREG_GS))
1892 return false;
1893 } else {
1894 /* protected mode guest state checks */
1895 if (!cs_ss_rpl_check(vcpu))
1896 return false;
1897 if (!code_segment_valid(vcpu))
1898 return false;
1899 if (!stack_segment_valid(vcpu))
1900 return false;
1901 if (!data_segment_valid(vcpu, VCPU_SREG_DS))
1902 return false;
1903 if (!data_segment_valid(vcpu, VCPU_SREG_ES))
1904 return false;
1905 if (!data_segment_valid(vcpu, VCPU_SREG_FS))
1906 return false;
1907 if (!data_segment_valid(vcpu, VCPU_SREG_GS))
1908 return false;
1909 if (!tr_valid(vcpu))
1910 return false;
1911 if (!ldtr_valid(vcpu))
1912 return false;
1913 }
1914 /* TODO:
1915 * - Add checks on RIP
1916 * - Add checks on RFLAGS
1917 */
1918
1919 return true;
1920}
1921
1718static int init_rmode_tss(struct kvm *kvm) 1922static int init_rmode_tss(struct kvm *kvm)
1719{ 1923{
1720 gfn_t fn = rmode_tss_base(kvm) >> PAGE_SHIFT; 1924 gfn_t fn = rmode_tss_base(kvm) >> PAGE_SHIFT;
@@ -1726,7 +1930,8 @@ static int init_rmode_tss(struct kvm *kvm)
1726 if (r < 0) 1930 if (r < 0)
1727 goto out; 1931 goto out;
1728 data = TSS_BASE_SIZE + TSS_REDIRECTION_SIZE; 1932 data = TSS_BASE_SIZE + TSS_REDIRECTION_SIZE;
1729 r = kvm_write_guest_page(kvm, fn++, &data, 0x66, sizeof(u16)); 1933 r = kvm_write_guest_page(kvm, fn++, &data,
1934 TSS_IOPB_BASE_OFFSET, sizeof(u16));
1730 if (r < 0) 1935 if (r < 0)
1731 goto out; 1936 goto out;
1732 r = kvm_clear_guest_page(kvm, fn++, 0, PAGE_SIZE); 1937 r = kvm_clear_guest_page(kvm, fn++, 0, PAGE_SIZE);
@@ -1789,7 +1994,7 @@ static void seg_setup(int seg)
1789 vmcs_write16(sf->selector, 0); 1994 vmcs_write16(sf->selector, 0);
1790 vmcs_writel(sf->base, 0); 1995 vmcs_writel(sf->base, 0);
1791 vmcs_write32(sf->limit, 0xffff); 1996 vmcs_write32(sf->limit, 0xffff);
1792 vmcs_write32(sf->ar_bytes, 0x93); 1997 vmcs_write32(sf->ar_bytes, 0xf3);
1793} 1998}
1794 1999
1795static int alloc_apic_access_page(struct kvm *kvm) 2000static int alloc_apic_access_page(struct kvm *kvm)
@@ -1808,9 +2013,7 @@ static int alloc_apic_access_page(struct kvm *kvm)
1808 if (r) 2013 if (r)
1809 goto out; 2014 goto out;
1810 2015
1811 down_read(&current->mm->mmap_sem);
1812 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00); 2016 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00);
1813 up_read(&current->mm->mmap_sem);
1814out: 2017out:
1815 up_write(&kvm->slots_lock); 2018 up_write(&kvm->slots_lock);
1816 return r; 2019 return r;
@@ -1832,10 +2035,8 @@ static int alloc_identity_pagetable(struct kvm *kvm)
1832 if (r) 2035 if (r)
1833 goto out; 2036 goto out;
1834 2037
1835 down_read(&current->mm->mmap_sem);
1836 kvm->arch.ept_identity_pagetable = gfn_to_page(kvm, 2038 kvm->arch.ept_identity_pagetable = gfn_to_page(kvm,
1837 VMX_EPT_IDENTITY_PAGETABLE_ADDR >> PAGE_SHIFT); 2039 VMX_EPT_IDENTITY_PAGETABLE_ADDR >> PAGE_SHIFT);
1838 up_read(&current->mm->mmap_sem);
1839out: 2040out:
1840 up_write(&kvm->slots_lock); 2041 up_write(&kvm->slots_lock);
1841 return r; 2042 return r;
@@ -1917,7 +2118,8 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
1917 } 2118 }
1918 if (!vm_need_ept()) 2119 if (!vm_need_ept())
1919 exec_control |= CPU_BASED_CR3_STORE_EXITING | 2120 exec_control |= CPU_BASED_CR3_STORE_EXITING |
1920 CPU_BASED_CR3_LOAD_EXITING; 2121 CPU_BASED_CR3_LOAD_EXITING |
2122 CPU_BASED_INVLPG_EXITING;
1921 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control); 2123 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control);
1922 2124
1923 if (cpu_has_secondary_exec_ctrls()) { 2125 if (cpu_has_secondary_exec_ctrls()) {
@@ -2019,6 +2221,7 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2019 u64 msr; 2221 u64 msr;
2020 int ret; 2222 int ret;
2021 2223
2224 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP));
2022 down_read(&vcpu->kvm->slots_lock); 2225 down_read(&vcpu->kvm->slots_lock);
2023 if (!init_rmode(vmx->vcpu.kvm)) { 2226 if (!init_rmode(vmx->vcpu.kvm)) {
2024 ret = -ENOMEM; 2227 ret = -ENOMEM;
@@ -2036,6 +2239,7 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2036 2239
2037 fx_init(&vmx->vcpu); 2240 fx_init(&vmx->vcpu);
2038 2241
2242 seg_setup(VCPU_SREG_CS);
2039 /* 2243 /*
2040 * GUEST_CS_BASE should really be 0xffff0000, but VT vm86 mode 2244 * GUEST_CS_BASE should really be 0xffff0000, but VT vm86 mode
2041 * insists on having GUEST_CS_BASE == GUEST_CS_SELECTOR << 4. Sigh. 2245 * insists on having GUEST_CS_BASE == GUEST_CS_SELECTOR << 4. Sigh.
@@ -2047,8 +2251,6 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2047 vmcs_write16(GUEST_CS_SELECTOR, vmx->vcpu.arch.sipi_vector << 8); 2251 vmcs_write16(GUEST_CS_SELECTOR, vmx->vcpu.arch.sipi_vector << 8);
2048 vmcs_writel(GUEST_CS_BASE, vmx->vcpu.arch.sipi_vector << 12); 2252 vmcs_writel(GUEST_CS_BASE, vmx->vcpu.arch.sipi_vector << 12);
2049 } 2253 }
2050 vmcs_write32(GUEST_CS_LIMIT, 0xffff);
2051 vmcs_write32(GUEST_CS_AR_BYTES, 0x9b);
2052 2254
2053 seg_setup(VCPU_SREG_DS); 2255 seg_setup(VCPU_SREG_DS);
2054 seg_setup(VCPU_SREG_ES); 2256 seg_setup(VCPU_SREG_ES);
@@ -2072,10 +2274,10 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2072 2274
2073 vmcs_writel(GUEST_RFLAGS, 0x02); 2275 vmcs_writel(GUEST_RFLAGS, 0x02);
2074 if (vmx->vcpu.vcpu_id == 0) 2276 if (vmx->vcpu.vcpu_id == 0)
2075 vmcs_writel(GUEST_RIP, 0xfff0); 2277 kvm_rip_write(vcpu, 0xfff0);
2076 else 2278 else
2077 vmcs_writel(GUEST_RIP, 0); 2279 kvm_rip_write(vcpu, 0);
2078 vmcs_writel(GUEST_RSP, 0); 2280 kvm_register_write(vcpu, VCPU_REGS_RSP, 0);
2079 2281
2080 /* todo: dr0 = dr1 = dr2 = dr3 = 0; dr6 = 0xffff0ff0 */ 2282 /* todo: dr0 = dr1 = dr2 = dr3 = 0; dr6 = 0xffff0ff0 */
2081 vmcs_writel(GUEST_DR7, 0x400); 2283 vmcs_writel(GUEST_DR7, 0x400);
@@ -2125,6 +2327,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2125 2327
2126 ret = 0; 2328 ret = 0;
2127 2329
2330 /* HACK: Don't enable emulation on guest boot/reset */
2331 vmx->emulation_required = 0;
2332
2128out: 2333out:
2129 up_read(&vcpu->kvm->slots_lock); 2334 up_read(&vcpu->kvm->slots_lock);
2130 return ret; 2335 return ret;
@@ -2136,14 +2341,15 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
2136 2341
2137 KVMTRACE_1D(INJ_VIRQ, vcpu, (u32)irq, handler); 2342 KVMTRACE_1D(INJ_VIRQ, vcpu, (u32)irq, handler);
2138 2343
2344 ++vcpu->stat.irq_injections;
2139 if (vcpu->arch.rmode.active) { 2345 if (vcpu->arch.rmode.active) {
2140 vmx->rmode.irq.pending = true; 2346 vmx->rmode.irq.pending = true;
2141 vmx->rmode.irq.vector = irq; 2347 vmx->rmode.irq.vector = irq;
2142 vmx->rmode.irq.rip = vmcs_readl(GUEST_RIP); 2348 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
2143 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 2349 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2144 irq | INTR_TYPE_SOFT_INTR | INTR_INFO_VALID_MASK); 2350 irq | INTR_TYPE_SOFT_INTR | INTR_INFO_VALID_MASK);
2145 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1); 2351 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
2146 vmcs_writel(GUEST_RIP, vmx->rmode.irq.rip - 1); 2352 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
2147 return; 2353 return;
2148 } 2354 }
2149 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 2355 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
@@ -2154,7 +2360,6 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
2154{ 2360{
2155 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 2361 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2156 INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR); 2362 INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR);
2157 vcpu->arch.nmi_pending = 0;
2158} 2363}
2159 2364
2160static void kvm_do_inject_irq(struct kvm_vcpu *vcpu) 2365static void kvm_do_inject_irq(struct kvm_vcpu *vcpu)
@@ -2166,7 +2371,7 @@ static void kvm_do_inject_irq(struct kvm_vcpu *vcpu)
2166 clear_bit(bit_index, &vcpu->arch.irq_pending[word_index]); 2371 clear_bit(bit_index, &vcpu->arch.irq_pending[word_index]);
2167 if (!vcpu->arch.irq_pending[word_index]) 2372 if (!vcpu->arch.irq_pending[word_index])
2168 clear_bit(word_index, &vcpu->arch.irq_summary); 2373 clear_bit(word_index, &vcpu->arch.irq_summary);
2169 vmx_inject_irq(vcpu, irq); 2374 kvm_queue_interrupt(vcpu, irq);
2170} 2375}
2171 2376
2172 2377
@@ -2180,13 +2385,12 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
2180 (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0); 2385 (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0);
2181 2386
2182 if (vcpu->arch.interrupt_window_open && 2387 if (vcpu->arch.interrupt_window_open &&
2183 vcpu->arch.irq_summary && 2388 vcpu->arch.irq_summary && !vcpu->arch.interrupt.pending)
2184 !(vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) & INTR_INFO_VALID_MASK))
2185 /*
2186 * If interrupts enabled, and not blocked by sti or mov ss. Good.
2187 */
2188 kvm_do_inject_irq(vcpu); 2389 kvm_do_inject_irq(vcpu);
2189 2390
2391 if (vcpu->arch.interrupt_window_open && vcpu->arch.interrupt.pending)
2392 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
2393
2190 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); 2394 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
2191 if (!vcpu->arch.interrupt_window_open && 2395 if (!vcpu->arch.interrupt_window_open &&
2192 (vcpu->arch.irq_summary || kvm_run->request_interrupt_window)) 2396 (vcpu->arch.irq_summary || kvm_run->request_interrupt_window))
@@ -2237,9 +2441,6 @@ static void kvm_guest_debug_pre(struct kvm_vcpu *vcpu)
2237static int handle_rmode_exception(struct kvm_vcpu *vcpu, 2441static int handle_rmode_exception(struct kvm_vcpu *vcpu,
2238 int vec, u32 err_code) 2442 int vec, u32 err_code)
2239{ 2443{
2240 if (!vcpu->arch.rmode.active)
2241 return 0;
2242
2243 /* 2444 /*
2244 * Instruction with address size override prefix opcode 0x67 2445 * Instruction with address size override prefix opcode 0x67
2245 * Cause the #SS fault with 0 error code in VM86 mode. 2446 * Cause the #SS fault with 0 error code in VM86 mode.
@@ -2247,6 +2448,25 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu,
2247 if (((vec == GP_VECTOR) || (vec == SS_VECTOR)) && err_code == 0) 2448 if (((vec == GP_VECTOR) || (vec == SS_VECTOR)) && err_code == 0)
2248 if (emulate_instruction(vcpu, NULL, 0, 0, 0) == EMULATE_DONE) 2449 if (emulate_instruction(vcpu, NULL, 0, 0, 0) == EMULATE_DONE)
2249 return 1; 2450 return 1;
2451 /*
2452 * Forward all other exceptions that are valid in real mode.
2453 * FIXME: Breaks guest debugging in real mode, needs to be fixed with
2454 * the required debugging infrastructure rework.
2455 */
2456 switch (vec) {
2457 case DE_VECTOR:
2458 case DB_VECTOR:
2459 case BP_VECTOR:
2460 case OF_VECTOR:
2461 case BR_VECTOR:
2462 case UD_VECTOR:
2463 case DF_VECTOR:
2464 case SS_VECTOR:
2465 case GP_VECTOR:
2466 case MF_VECTOR:
2467 kvm_queue_exception(vcpu, vec);
2468 return 1;
2469 }
2250 return 0; 2470 return 0;
2251} 2471}
2252 2472
@@ -2288,7 +2508,7 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2288 } 2508 }
2289 2509
2290 error_code = 0; 2510 error_code = 0;
2291 rip = vmcs_readl(GUEST_RIP); 2511 rip = kvm_rip_read(vcpu);
2292 if (intr_info & INTR_INFO_DELIVER_CODE_MASK) 2512 if (intr_info & INTR_INFO_DELIVER_CODE_MASK)
2293 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); 2513 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
2294 if (is_page_fault(intr_info)) { 2514 if (is_page_fault(intr_info)) {
@@ -2298,7 +2518,7 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2298 cr2 = vmcs_readl(EXIT_QUALIFICATION); 2518 cr2 = vmcs_readl(EXIT_QUALIFICATION);
2299 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, 2519 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2,
2300 (u32)((u64)cr2 >> 32), handler); 2520 (u32)((u64)cr2 >> 32), handler);
2301 if (vect_info & VECTORING_INFO_VALID_MASK) 2521 if (vcpu->arch.interrupt.pending || vcpu->arch.exception.pending)
2302 kvm_mmu_unprotect_page_virt(vcpu, cr2); 2522 kvm_mmu_unprotect_page_virt(vcpu, cr2);
2303 return kvm_mmu_page_fault(vcpu, cr2, error_code); 2523 return kvm_mmu_page_fault(vcpu, cr2, error_code);
2304 } 2524 }
@@ -2386,27 +2606,25 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2386 reg = (exit_qualification >> 8) & 15; 2606 reg = (exit_qualification >> 8) & 15;
2387 switch ((exit_qualification >> 4) & 3) { 2607 switch ((exit_qualification >> 4) & 3) {
2388 case 0: /* mov to cr */ 2608 case 0: /* mov to cr */
2389 KVMTRACE_3D(CR_WRITE, vcpu, (u32)cr, (u32)vcpu->arch.regs[reg], 2609 KVMTRACE_3D(CR_WRITE, vcpu, (u32)cr,
2390 (u32)((u64)vcpu->arch.regs[reg] >> 32), handler); 2610 (u32)kvm_register_read(vcpu, reg),
2611 (u32)((u64)kvm_register_read(vcpu, reg) >> 32),
2612 handler);
2391 switch (cr) { 2613 switch (cr) {
2392 case 0: 2614 case 0:
2393 vcpu_load_rsp_rip(vcpu); 2615 kvm_set_cr0(vcpu, kvm_register_read(vcpu, reg));
2394 kvm_set_cr0(vcpu, vcpu->arch.regs[reg]);
2395 skip_emulated_instruction(vcpu); 2616 skip_emulated_instruction(vcpu);
2396 return 1; 2617 return 1;
2397 case 3: 2618 case 3:
2398 vcpu_load_rsp_rip(vcpu); 2619 kvm_set_cr3(vcpu, kvm_register_read(vcpu, reg));
2399 kvm_set_cr3(vcpu, vcpu->arch.regs[reg]);
2400 skip_emulated_instruction(vcpu); 2620 skip_emulated_instruction(vcpu);
2401 return 1; 2621 return 1;
2402 case 4: 2622 case 4:
2403 vcpu_load_rsp_rip(vcpu); 2623 kvm_set_cr4(vcpu, kvm_register_read(vcpu, reg));
2404 kvm_set_cr4(vcpu, vcpu->arch.regs[reg]);
2405 skip_emulated_instruction(vcpu); 2624 skip_emulated_instruction(vcpu);
2406 return 1; 2625 return 1;
2407 case 8: 2626 case 8:
2408 vcpu_load_rsp_rip(vcpu); 2627 kvm_set_cr8(vcpu, kvm_register_read(vcpu, reg));
2409 kvm_set_cr8(vcpu, vcpu->arch.regs[reg]);
2410 skip_emulated_instruction(vcpu); 2628 skip_emulated_instruction(vcpu);
2411 if (irqchip_in_kernel(vcpu->kvm)) 2629 if (irqchip_in_kernel(vcpu->kvm))
2412 return 1; 2630 return 1;
@@ -2415,7 +2633,6 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2415 }; 2633 };
2416 break; 2634 break;
2417 case 2: /* clts */ 2635 case 2: /* clts */
2418 vcpu_load_rsp_rip(vcpu);
2419 vmx_fpu_deactivate(vcpu); 2636 vmx_fpu_deactivate(vcpu);
2420 vcpu->arch.cr0 &= ~X86_CR0_TS; 2637 vcpu->arch.cr0 &= ~X86_CR0_TS;
2421 vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0); 2638 vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0);
@@ -2426,21 +2643,17 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2426 case 1: /*mov from cr*/ 2643 case 1: /*mov from cr*/
2427 switch (cr) { 2644 switch (cr) {
2428 case 3: 2645 case 3:
2429 vcpu_load_rsp_rip(vcpu); 2646 kvm_register_write(vcpu, reg, vcpu->arch.cr3);
2430 vcpu->arch.regs[reg] = vcpu->arch.cr3;
2431 vcpu_put_rsp_rip(vcpu);
2432 KVMTRACE_3D(CR_READ, vcpu, (u32)cr, 2647 KVMTRACE_3D(CR_READ, vcpu, (u32)cr,
2433 (u32)vcpu->arch.regs[reg], 2648 (u32)kvm_register_read(vcpu, reg),
2434 (u32)((u64)vcpu->arch.regs[reg] >> 32), 2649 (u32)((u64)kvm_register_read(vcpu, reg) >> 32),
2435 handler); 2650 handler);
2436 skip_emulated_instruction(vcpu); 2651 skip_emulated_instruction(vcpu);
2437 return 1; 2652 return 1;
2438 case 8: 2653 case 8:
2439 vcpu_load_rsp_rip(vcpu); 2654 kvm_register_write(vcpu, reg, kvm_get_cr8(vcpu));
2440 vcpu->arch.regs[reg] = kvm_get_cr8(vcpu);
2441 vcpu_put_rsp_rip(vcpu);
2442 KVMTRACE_2D(CR_READ, vcpu, (u32)cr, 2655 KVMTRACE_2D(CR_READ, vcpu, (u32)cr,
2443 (u32)vcpu->arch.regs[reg], handler); 2656 (u32)kvm_register_read(vcpu, reg), handler);
2444 skip_emulated_instruction(vcpu); 2657 skip_emulated_instruction(vcpu);
2445 return 1; 2658 return 1;
2446 } 2659 }
@@ -2472,7 +2685,6 @@ static int handle_dr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2472 exit_qualification = vmcs_readl(EXIT_QUALIFICATION); 2685 exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
2473 dr = exit_qualification & 7; 2686 dr = exit_qualification & 7;
2474 reg = (exit_qualification >> 8) & 15; 2687 reg = (exit_qualification >> 8) & 15;
2475 vcpu_load_rsp_rip(vcpu);
2476 if (exit_qualification & 16) { 2688 if (exit_qualification & 16) {
2477 /* mov from dr */ 2689 /* mov from dr */
2478 switch (dr) { 2690 switch (dr) {
@@ -2485,12 +2697,11 @@ static int handle_dr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2485 default: 2697 default:
2486 val = 0; 2698 val = 0;
2487 } 2699 }
2488 vcpu->arch.regs[reg] = val; 2700 kvm_register_write(vcpu, reg, val);
2489 KVMTRACE_2D(DR_READ, vcpu, (u32)dr, (u32)val, handler); 2701 KVMTRACE_2D(DR_READ, vcpu, (u32)dr, (u32)val, handler);
2490 } else { 2702 } else {
2491 /* mov to dr */ 2703 /* mov to dr */
2492 } 2704 }
2493 vcpu_put_rsp_rip(vcpu);
2494 skip_emulated_instruction(vcpu); 2705 skip_emulated_instruction(vcpu);
2495 return 1; 2706 return 1;
2496} 2707}
@@ -2583,6 +2794,15 @@ static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2583 return 1; 2794 return 1;
2584} 2795}
2585 2796
2797static int handle_invlpg(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2798{
2799 u64 exit_qualification = vmcs_read64(EXIT_QUALIFICATION);
2800
2801 kvm_mmu_invlpg(vcpu, exit_qualification);
2802 skip_emulated_instruction(vcpu);
2803 return 1;
2804}
2805
2586static int handle_wbinvd(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2806static int handle_wbinvd(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2587{ 2807{
2588 skip_emulated_instruction(vcpu); 2808 skip_emulated_instruction(vcpu);
@@ -2695,6 +2915,43 @@ static int handle_nmi_window(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2695 return 1; 2915 return 1;
2696} 2916}
2697 2917
2918static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
2919 struct kvm_run *kvm_run)
2920{
2921 struct vcpu_vmx *vmx = to_vmx(vcpu);
2922 int err;
2923
2924 preempt_enable();
2925 local_irq_enable();
2926
2927 while (!guest_state_valid(vcpu)) {
2928 err = emulate_instruction(vcpu, kvm_run, 0, 0, 0);
2929
2930 switch (err) {
2931 case EMULATE_DONE:
2932 break;
2933 case EMULATE_DO_MMIO:
2934 kvm_report_emulation_failure(vcpu, "mmio");
2935 /* TODO: Handle MMIO */
2936 return;
2937 default:
2938 kvm_report_emulation_failure(vcpu, "emulation failure");
2939 return;
2940 }
2941
2942 if (signal_pending(current))
2943 break;
2944 if (need_resched())
2945 schedule();
2946 }
2947
2948 local_irq_disable();
2949 preempt_disable();
2950
2951 /* Guest state should be valid now, no more emulation should be needed */
2952 vmx->emulation_required = 0;
2953}
2954
2698/* 2955/*
2699 * The exit handlers return 1 if the exit was handled fully and guest execution 2956 * The exit handlers return 1 if the exit was handled fully and guest execution
2700 * may resume. Otherwise they set the kvm_run parameter to indicate what needs 2957 * may resume. Otherwise they set the kvm_run parameter to indicate what needs
@@ -2714,6 +2971,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu,
2714 [EXIT_REASON_MSR_WRITE] = handle_wrmsr, 2971 [EXIT_REASON_MSR_WRITE] = handle_wrmsr,
2715 [EXIT_REASON_PENDING_INTERRUPT] = handle_interrupt_window, 2972 [EXIT_REASON_PENDING_INTERRUPT] = handle_interrupt_window,
2716 [EXIT_REASON_HLT] = handle_halt, 2973 [EXIT_REASON_HLT] = handle_halt,
2974 [EXIT_REASON_INVLPG] = handle_invlpg,
2717 [EXIT_REASON_VMCALL] = handle_vmcall, 2975 [EXIT_REASON_VMCALL] = handle_vmcall,
2718 [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold, 2976 [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold,
2719 [EXIT_REASON_APIC_ACCESS] = handle_apic_access, 2977 [EXIT_REASON_APIC_ACCESS] = handle_apic_access,
@@ -2735,8 +2993,8 @@ static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
2735 struct vcpu_vmx *vmx = to_vmx(vcpu); 2993 struct vcpu_vmx *vmx = to_vmx(vcpu);
2736 u32 vectoring_info = vmx->idt_vectoring_info; 2994 u32 vectoring_info = vmx->idt_vectoring_info;
2737 2995
2738 KVMTRACE_3D(VMEXIT, vcpu, exit_reason, (u32)vmcs_readl(GUEST_RIP), 2996 KVMTRACE_3D(VMEXIT, vcpu, exit_reason, (u32)kvm_rip_read(vcpu),
2739 (u32)((u64)vmcs_readl(GUEST_RIP) >> 32), entryexit); 2997 (u32)((u64)kvm_rip_read(vcpu) >> 32), entryexit);
2740 2998
2741 /* Access CR3 don't cause VMExit in paging mode, so we need 2999 /* Access CR3 don't cause VMExit in paging mode, so we need
2742 * to sync with guest real CR3. */ 3000 * to sync with guest real CR3. */
@@ -2829,88 +3087,92 @@ static void enable_intr_window(struct kvm_vcpu *vcpu)
2829 enable_irq_window(vcpu); 3087 enable_irq_window(vcpu);
2830} 3088}
2831 3089
2832static void vmx_intr_assist(struct kvm_vcpu *vcpu) 3090static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
2833{ 3091{
2834 struct vcpu_vmx *vmx = to_vmx(vcpu); 3092 u32 exit_intr_info;
2835 u32 idtv_info_field, intr_info_field, exit_intr_info_field; 3093 u32 idt_vectoring_info;
2836 int vector; 3094 bool unblock_nmi;
3095 u8 vector;
3096 int type;
3097 bool idtv_info_valid;
3098 u32 error;
2837 3099
2838 update_tpr_threshold(vcpu); 3100 exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
2839 3101 if (cpu_has_virtual_nmis()) {
2840 intr_info_field = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD); 3102 unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0;
2841 exit_intr_info_field = vmcs_read32(VM_EXIT_INTR_INFO); 3103 vector = exit_intr_info & INTR_INFO_VECTOR_MASK;
2842 idtv_info_field = vmx->idt_vectoring_info; 3104 /*
2843 if (intr_info_field & INTR_INFO_VALID_MASK) { 3105 * SDM 3: 25.7.1.2
2844 if (idtv_info_field & INTR_INFO_VALID_MASK) { 3106 * Re-set bit "block by NMI" before VM entry if vmexit caused by
2845 /* TODO: fault when IDT_Vectoring */ 3107 * a guest IRET fault.
2846 if (printk_ratelimit()) 3108 */
2847 printk(KERN_ERR "Fault when IDT_Vectoring\n"); 3109 if (unblock_nmi && vector != DF_VECTOR)
2848 } 3110 vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO,
2849 enable_intr_window(vcpu); 3111 GUEST_INTR_STATE_NMI);
2850 return;
2851 } 3112 }
2852 if (unlikely(idtv_info_field & INTR_INFO_VALID_MASK)) {
2853 if ((idtv_info_field & VECTORING_INFO_TYPE_MASK)
2854 == INTR_TYPE_EXT_INTR
2855 && vcpu->arch.rmode.active) {
2856 u8 vect = idtv_info_field & VECTORING_INFO_VECTOR_MASK;
2857
2858 vmx_inject_irq(vcpu, vect);
2859 enable_intr_window(vcpu);
2860 return;
2861 }
2862
2863 KVMTRACE_1D(REDELIVER_EVT, vcpu, idtv_info_field, handler);
2864 3113
3114 idt_vectoring_info = vmx->idt_vectoring_info;
3115 idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK;
3116 vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK;
3117 type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK;
3118 if (vmx->vcpu.arch.nmi_injected) {
2865 /* 3119 /*
2866 * SDM 3: 25.7.1.2 3120 * SDM 3: 25.7.1.2
2867 * Clear bit "block by NMI" before VM entry if a NMI delivery 3121 * Clear bit "block by NMI" before VM entry if a NMI delivery
2868 * faulted. 3122 * faulted.
2869 */ 3123 */
2870 if ((idtv_info_field & VECTORING_INFO_TYPE_MASK) 3124 if (idtv_info_valid && type == INTR_TYPE_NMI_INTR)
2871 == INTR_TYPE_NMI_INTR && cpu_has_virtual_nmis()) 3125 vmcs_clear_bits(GUEST_INTERRUPTIBILITY_INFO,
2872 vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, 3126 GUEST_INTR_STATE_NMI);
2873 vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3127 else
2874 ~GUEST_INTR_STATE_NMI); 3128 vmx->vcpu.arch.nmi_injected = false;
2875 3129 }
2876 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field 3130 kvm_clear_exception_queue(&vmx->vcpu);
2877 & ~INTR_INFO_RESVD_BITS_MASK); 3131 if (idtv_info_valid && type == INTR_TYPE_EXCEPTION) {
2878 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 3132 if (idt_vectoring_info & VECTORING_INFO_DELIVER_CODE_MASK) {
2879 vmcs_read32(VM_EXIT_INSTRUCTION_LEN)); 3133 error = vmcs_read32(IDT_VECTORING_ERROR_CODE);
2880 3134 kvm_queue_exception_e(&vmx->vcpu, vector, error);
2881 if (unlikely(idtv_info_field & INTR_INFO_DELIVER_CODE_MASK)) 3135 } else
2882 vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, 3136 kvm_queue_exception(&vmx->vcpu, vector);
2883 vmcs_read32(IDT_VECTORING_ERROR_CODE)); 3137 vmx->idt_vectoring_info = 0;
2884 enable_intr_window(vcpu);
2885 return;
2886 } 3138 }
3139 kvm_clear_interrupt_queue(&vmx->vcpu);
3140 if (idtv_info_valid && type == INTR_TYPE_EXT_INTR) {
3141 kvm_queue_interrupt(&vmx->vcpu, vector);
3142 vmx->idt_vectoring_info = 0;
3143 }
3144}
3145
3146static void vmx_intr_assist(struct kvm_vcpu *vcpu)
3147{
3148 update_tpr_threshold(vcpu);
3149
2887 if (cpu_has_virtual_nmis()) { 3150 if (cpu_has_virtual_nmis()) {
2888 /* 3151 if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) {
2889 * SDM 3: 25.7.1.2 3152 if (vmx_nmi_enabled(vcpu)) {
2890 * Re-set bit "block by NMI" before VM entry if vmexit caused by 3153 vcpu->arch.nmi_pending = false;
2891 * a guest IRET fault. 3154 vcpu->arch.nmi_injected = true;
2892 */ 3155 } else {
2893 if ((exit_intr_info_field & INTR_INFO_UNBLOCK_NMI) && 3156 enable_intr_window(vcpu);
2894 (exit_intr_info_field & INTR_INFO_VECTOR_MASK) != 8) 3157 return;
2895 vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, 3158 }
2896 vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) | 3159 }
2897 GUEST_INTR_STATE_NMI); 3160 if (vcpu->arch.nmi_injected) {
2898 else if (vcpu->arch.nmi_pending) { 3161 vmx_inject_nmi(vcpu);
2899 if (vmx_nmi_enabled(vcpu))
2900 vmx_inject_nmi(vcpu);
2901 enable_intr_window(vcpu); 3162 enable_intr_window(vcpu);
2902 return; 3163 return;
2903 } 3164 }
2904
2905 } 3165 }
2906 if (!kvm_cpu_has_interrupt(vcpu)) 3166 if (!vcpu->arch.interrupt.pending && kvm_cpu_has_interrupt(vcpu)) {
2907 return; 3167 if (vmx_irq_enabled(vcpu))
2908 if (vmx_irq_enabled(vcpu)) { 3168 kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
2909 vector = kvm_cpu_get_interrupt(vcpu); 3169 else
2910 vmx_inject_irq(vcpu, vector); 3170 enable_irq_window(vcpu);
2911 kvm_timer_intr_post(vcpu, vector); 3171 }
2912 } else 3172 if (vcpu->arch.interrupt.pending) {
2913 enable_irq_window(vcpu); 3173 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
3174 kvm_timer_intr_post(vcpu, vcpu->arch.interrupt.nr);
3175 }
2914} 3176}
2915 3177
2916/* 3178/*
@@ -2922,9 +3184,9 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
2922static void fixup_rmode_irq(struct vcpu_vmx *vmx) 3184static void fixup_rmode_irq(struct vcpu_vmx *vmx)
2923{ 3185{
2924 vmx->rmode.irq.pending = 0; 3186 vmx->rmode.irq.pending = 0;
2925 if (vmcs_readl(GUEST_RIP) + 1 != vmx->rmode.irq.rip) 3187 if (kvm_rip_read(&vmx->vcpu) + 1 != vmx->rmode.irq.rip)
2926 return; 3188 return;
2927 vmcs_writel(GUEST_RIP, vmx->rmode.irq.rip); 3189 kvm_rip_write(&vmx->vcpu, vmx->rmode.irq.rip);
2928 if (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) { 3190 if (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) {
2929 vmx->idt_vectoring_info &= ~VECTORING_INFO_TYPE_MASK; 3191 vmx->idt_vectoring_info &= ~VECTORING_INFO_TYPE_MASK;
2930 vmx->idt_vectoring_info |= INTR_TYPE_EXT_INTR; 3192 vmx->idt_vectoring_info |= INTR_TYPE_EXT_INTR;
@@ -2936,11 +3198,30 @@ static void fixup_rmode_irq(struct vcpu_vmx *vmx)
2936 | vmx->rmode.irq.vector; 3198 | vmx->rmode.irq.vector;
2937} 3199}
2938 3200
3201#ifdef CONFIG_X86_64
3202#define R "r"
3203#define Q "q"
3204#else
3205#define R "e"
3206#define Q "l"
3207#endif
3208
2939static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3209static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2940{ 3210{
2941 struct vcpu_vmx *vmx = to_vmx(vcpu); 3211 struct vcpu_vmx *vmx = to_vmx(vcpu);
2942 u32 intr_info; 3212 u32 intr_info;
2943 3213
3214 /* Handle invalid guest state instead of entering VMX */
3215 if (vmx->emulation_required && emulate_invalid_guest_state) {
3216 handle_invalid_guest_state(vcpu, kvm_run);
3217 return;
3218 }
3219
3220 if (test_bit(VCPU_REGS_RSP, (unsigned long *)&vcpu->arch.regs_dirty))
3221 vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]);
3222 if (test_bit(VCPU_REGS_RIP, (unsigned long *)&vcpu->arch.regs_dirty))
3223 vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]);
3224
2944 /* 3225 /*
2945 * Loading guest fpu may have cleared host cr0.ts 3226 * Loading guest fpu may have cleared host cr0.ts
2946 */ 3227 */
@@ -2948,26 +3229,25 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2948 3229
2949 asm( 3230 asm(
2950 /* Store host registers */ 3231 /* Store host registers */
2951#ifdef CONFIG_X86_64 3232 "push %%"R"dx; push %%"R"bp;"
2952 "push %%rdx; push %%rbp;" 3233 "push %%"R"cx \n\t"
2953 "push %%rcx \n\t" 3234 "cmp %%"R"sp, %c[host_rsp](%0) \n\t"
2954#else 3235 "je 1f \n\t"
2955 "push %%edx; push %%ebp;" 3236 "mov %%"R"sp, %c[host_rsp](%0) \n\t"
2956 "push %%ecx \n\t"
2957#endif
2958 __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t" 3237 __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
3238 "1: \n\t"
2959 /* Check if vmlaunch of vmresume is needed */ 3239 /* Check if vmlaunch of vmresume is needed */
2960 "cmpl $0, %c[launched](%0) \n\t" 3240 "cmpl $0, %c[launched](%0) \n\t"
2961 /* Load guest registers. Don't clobber flags. */ 3241 /* Load guest registers. Don't clobber flags. */
3242 "mov %c[cr2](%0), %%"R"ax \n\t"
3243 "mov %%"R"ax, %%cr2 \n\t"
3244 "mov %c[rax](%0), %%"R"ax \n\t"
3245 "mov %c[rbx](%0), %%"R"bx \n\t"
3246 "mov %c[rdx](%0), %%"R"dx \n\t"
3247 "mov %c[rsi](%0), %%"R"si \n\t"
3248 "mov %c[rdi](%0), %%"R"di \n\t"
3249 "mov %c[rbp](%0), %%"R"bp \n\t"
2962#ifdef CONFIG_X86_64 3250#ifdef CONFIG_X86_64
2963 "mov %c[cr2](%0), %%rax \n\t"
2964 "mov %%rax, %%cr2 \n\t"
2965 "mov %c[rax](%0), %%rax \n\t"
2966 "mov %c[rbx](%0), %%rbx \n\t"
2967 "mov %c[rdx](%0), %%rdx \n\t"
2968 "mov %c[rsi](%0), %%rsi \n\t"
2969 "mov %c[rdi](%0), %%rdi \n\t"
2970 "mov %c[rbp](%0), %%rbp \n\t"
2971 "mov %c[r8](%0), %%r8 \n\t" 3251 "mov %c[r8](%0), %%r8 \n\t"
2972 "mov %c[r9](%0), %%r9 \n\t" 3252 "mov %c[r9](%0), %%r9 \n\t"
2973 "mov %c[r10](%0), %%r10 \n\t" 3253 "mov %c[r10](%0), %%r10 \n\t"
@@ -2976,18 +3256,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2976 "mov %c[r13](%0), %%r13 \n\t" 3256 "mov %c[r13](%0), %%r13 \n\t"
2977 "mov %c[r14](%0), %%r14 \n\t" 3257 "mov %c[r14](%0), %%r14 \n\t"
2978 "mov %c[r15](%0), %%r15 \n\t" 3258 "mov %c[r15](%0), %%r15 \n\t"
2979 "mov %c[rcx](%0), %%rcx \n\t" /* kills %0 (rcx) */
2980#else
2981 "mov %c[cr2](%0), %%eax \n\t"
2982 "mov %%eax, %%cr2 \n\t"
2983 "mov %c[rax](%0), %%eax \n\t"
2984 "mov %c[rbx](%0), %%ebx \n\t"
2985 "mov %c[rdx](%0), %%edx \n\t"
2986 "mov %c[rsi](%0), %%esi \n\t"
2987 "mov %c[rdi](%0), %%edi \n\t"
2988 "mov %c[rbp](%0), %%ebp \n\t"
2989 "mov %c[rcx](%0), %%ecx \n\t" /* kills %0 (ecx) */
2990#endif 3259#endif
3260 "mov %c[rcx](%0), %%"R"cx \n\t" /* kills %0 (ecx) */
3261
2991 /* Enter guest mode */ 3262 /* Enter guest mode */
2992 "jne .Llaunched \n\t" 3263 "jne .Llaunched \n\t"
2993 __ex(ASM_VMX_VMLAUNCH) "\n\t" 3264 __ex(ASM_VMX_VMLAUNCH) "\n\t"
@@ -2995,15 +3266,15 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2995 ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t" 3266 ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
2996 ".Lkvm_vmx_return: " 3267 ".Lkvm_vmx_return: "
2997 /* Save guest registers, load host registers, keep flags */ 3268 /* Save guest registers, load host registers, keep flags */
3269 "xchg %0, (%%"R"sp) \n\t"
3270 "mov %%"R"ax, %c[rax](%0) \n\t"
3271 "mov %%"R"bx, %c[rbx](%0) \n\t"
3272 "push"Q" (%%"R"sp); pop"Q" %c[rcx](%0) \n\t"
3273 "mov %%"R"dx, %c[rdx](%0) \n\t"
3274 "mov %%"R"si, %c[rsi](%0) \n\t"
3275 "mov %%"R"di, %c[rdi](%0) \n\t"
3276 "mov %%"R"bp, %c[rbp](%0) \n\t"
2998#ifdef CONFIG_X86_64 3277#ifdef CONFIG_X86_64
2999 "xchg %0, (%%rsp) \n\t"
3000 "mov %%rax, %c[rax](%0) \n\t"
3001 "mov %%rbx, %c[rbx](%0) \n\t"
3002 "pushq (%%rsp); popq %c[rcx](%0) \n\t"
3003 "mov %%rdx, %c[rdx](%0) \n\t"
3004 "mov %%rsi, %c[rsi](%0) \n\t"
3005 "mov %%rdi, %c[rdi](%0) \n\t"
3006 "mov %%rbp, %c[rbp](%0) \n\t"
3007 "mov %%r8, %c[r8](%0) \n\t" 3278 "mov %%r8, %c[r8](%0) \n\t"
3008 "mov %%r9, %c[r9](%0) \n\t" 3279 "mov %%r9, %c[r9](%0) \n\t"
3009 "mov %%r10, %c[r10](%0) \n\t" 3280 "mov %%r10, %c[r10](%0) \n\t"
@@ -3012,28 +3283,16 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3012 "mov %%r13, %c[r13](%0) \n\t" 3283 "mov %%r13, %c[r13](%0) \n\t"
3013 "mov %%r14, %c[r14](%0) \n\t" 3284 "mov %%r14, %c[r14](%0) \n\t"
3014 "mov %%r15, %c[r15](%0) \n\t" 3285 "mov %%r15, %c[r15](%0) \n\t"
3015 "mov %%cr2, %%rax \n\t"
3016 "mov %%rax, %c[cr2](%0) \n\t"
3017
3018 "pop %%rbp; pop %%rbp; pop %%rdx \n\t"
3019#else
3020 "xchg %0, (%%esp) \n\t"
3021 "mov %%eax, %c[rax](%0) \n\t"
3022 "mov %%ebx, %c[rbx](%0) \n\t"
3023 "pushl (%%esp); popl %c[rcx](%0) \n\t"
3024 "mov %%edx, %c[rdx](%0) \n\t"
3025 "mov %%esi, %c[rsi](%0) \n\t"
3026 "mov %%edi, %c[rdi](%0) \n\t"
3027 "mov %%ebp, %c[rbp](%0) \n\t"
3028 "mov %%cr2, %%eax \n\t"
3029 "mov %%eax, %c[cr2](%0) \n\t"
3030
3031 "pop %%ebp; pop %%ebp; pop %%edx \n\t"
3032#endif 3286#endif
3287 "mov %%cr2, %%"R"ax \n\t"
3288 "mov %%"R"ax, %c[cr2](%0) \n\t"
3289
3290 "pop %%"R"bp; pop %%"R"bp; pop %%"R"dx \n\t"
3033 "setbe %c[fail](%0) \n\t" 3291 "setbe %c[fail](%0) \n\t"
3034 : : "c"(vmx), "d"((unsigned long)HOST_RSP), 3292 : : "c"(vmx), "d"((unsigned long)HOST_RSP),
3035 [launched]"i"(offsetof(struct vcpu_vmx, launched)), 3293 [launched]"i"(offsetof(struct vcpu_vmx, launched)),
3036 [fail]"i"(offsetof(struct vcpu_vmx, fail)), 3294 [fail]"i"(offsetof(struct vcpu_vmx, fail)),
3295 [host_rsp]"i"(offsetof(struct vcpu_vmx, host_rsp)),
3037 [rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])), 3296 [rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])),
3038 [rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])), 3297 [rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])),
3039 [rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])), 3298 [rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])),
@@ -3053,14 +3312,15 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3053#endif 3312#endif
3054 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)) 3313 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2))
3055 : "cc", "memory" 3314 : "cc", "memory"
3315 , R"bx", R"di", R"si"
3056#ifdef CONFIG_X86_64 3316#ifdef CONFIG_X86_64
3057 , "rbx", "rdi", "rsi"
3058 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" 3317 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
3059#else
3060 , "ebx", "edi", "rsi"
3061#endif 3318#endif
3062 ); 3319 );
3063 3320
3321 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP));
3322 vcpu->arch.regs_dirty = 0;
3323
3064 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); 3324 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
3065 if (vmx->rmode.irq.pending) 3325 if (vmx->rmode.irq.pending)
3066 fixup_rmode_irq(vmx); 3326 fixup_rmode_irq(vmx);
@@ -3080,8 +3340,13 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3080 KVMTRACE_0D(NMI, vcpu, handler); 3340 KVMTRACE_0D(NMI, vcpu, handler);
3081 asm("int $2"); 3341 asm("int $2");
3082 } 3342 }
3343
3344 vmx_complete_interrupts(vmx);
3083} 3345}
3084 3346
3347#undef R
3348#undef Q
3349
3085static void vmx_free_vmcs(struct kvm_vcpu *vcpu) 3350static void vmx_free_vmcs(struct kvm_vcpu *vcpu)
3086{ 3351{
3087 struct vcpu_vmx *vmx = to_vmx(vcpu); 3352 struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -3224,8 +3489,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
3224 .set_idt = vmx_set_idt, 3489 .set_idt = vmx_set_idt,
3225 .get_gdt = vmx_get_gdt, 3490 .get_gdt = vmx_get_gdt,
3226 .set_gdt = vmx_set_gdt, 3491 .set_gdt = vmx_set_gdt,
3227 .cache_regs = vcpu_load_rsp_rip, 3492 .cache_reg = vmx_cache_reg,
3228 .decache_regs = vcpu_put_rsp_rip,
3229 .get_rflags = vmx_get_rflags, 3493 .get_rflags = vmx_get_rflags,
3230 .set_rflags = vmx_set_rflags, 3494 .set_rflags = vmx_set_rflags,
3231 3495
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h
index 17e25995b65b..3e010d21fdd7 100644
--- a/arch/x86/kvm/vmx.h
+++ b/arch/x86/kvm/vmx.h
@@ -331,9 +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_FEATURE_CONTROL_LOCKED 0x1
335#define MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED 0x4
336
337#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9 334#define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9
338#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT 10 335#define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT 10
339 336
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0d682fc6aeb3..4f0677d1eae8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4,10 +4,14 @@
4 * derived from drivers/kvm/kvm_main.c 4 * derived from drivers/kvm/kvm_main.c
5 * 5 *
6 * Copyright (C) 2006 Qumranet, Inc. 6 * Copyright (C) 2006 Qumranet, Inc.
7 * Copyright (C) 2008 Qumranet, Inc.
8 * Copyright IBM Corporation, 2008
7 * 9 *
8 * Authors: 10 * Authors:
9 * Avi Kivity <avi@qumranet.com> 11 * Avi Kivity <avi@qumranet.com>
10 * Yaniv Kamay <yaniv@qumranet.com> 12 * Yaniv Kamay <yaniv@qumranet.com>
13 * Amit Shah <amit.shah@qumranet.com>
14 * Ben-Ami Yassour <benami@il.ibm.com>
11 * 15 *
12 * This work is licensed under the terms of the GNU GPL, version 2. See 16 * This work is licensed under the terms of the GNU GPL, version 2. See
13 * the COPYING file in the top-level directory. 17 * the COPYING file in the top-level directory.
@@ -19,14 +23,18 @@
19#include "mmu.h" 23#include "mmu.h"
20#include "i8254.h" 24#include "i8254.h"
21#include "tss.h" 25#include "tss.h"
26#include "kvm_cache_regs.h"
27#include "x86.h"
22 28
23#include <linux/clocksource.h> 29#include <linux/clocksource.h>
30#include <linux/interrupt.h>
24#include <linux/kvm.h> 31#include <linux/kvm.h>
25#include <linux/fs.h> 32#include <linux/fs.h>
26#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
27#include <linux/module.h> 34#include <linux/module.h>
28#include <linux/mman.h> 35#include <linux/mman.h>
29#include <linux/highmem.h> 36#include <linux/highmem.h>
37#include <linux/intel-iommu.h>
30 38
31#include <asm/uaccess.h> 39#include <asm/uaccess.h>
32#include <asm/msr.h> 40#include <asm/msr.h>
@@ -61,6 +69,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
61 struct kvm_cpuid_entry2 __user *entries); 69 struct kvm_cpuid_entry2 __user *entries);
62 70
63struct kvm_x86_ops *kvm_x86_ops; 71struct kvm_x86_ops *kvm_x86_ops;
72EXPORT_SYMBOL_GPL(kvm_x86_ops);
64 73
65struct kvm_stats_debugfs_item debugfs_entries[] = { 74struct kvm_stats_debugfs_item debugfs_entries[] = {
66 { "pf_fixed", VCPU_STAT(pf_fixed) }, 75 { "pf_fixed", VCPU_STAT(pf_fixed) },
@@ -83,6 +92,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
83 { "fpu_reload", VCPU_STAT(fpu_reload) }, 92 { "fpu_reload", VCPU_STAT(fpu_reload) },
84 { "insn_emulation", VCPU_STAT(insn_emulation) }, 93 { "insn_emulation", VCPU_STAT(insn_emulation) },
85 { "insn_emulation_fail", VCPU_STAT(insn_emulation_fail) }, 94 { "insn_emulation_fail", VCPU_STAT(insn_emulation_fail) },
95 { "irq_injections", VCPU_STAT(irq_injections) },
86 { "mmu_shadow_zapped", VM_STAT(mmu_shadow_zapped) }, 96 { "mmu_shadow_zapped", VM_STAT(mmu_shadow_zapped) },
87 { "mmu_pte_write", VM_STAT(mmu_pte_write) }, 97 { "mmu_pte_write", VM_STAT(mmu_pte_write) },
88 { "mmu_pte_updated", VM_STAT(mmu_pte_updated) }, 98 { "mmu_pte_updated", VM_STAT(mmu_pte_updated) },
@@ -90,12 +100,12 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
90 { "mmu_flooded", VM_STAT(mmu_flooded) }, 100 { "mmu_flooded", VM_STAT(mmu_flooded) },
91 { "mmu_recycled", VM_STAT(mmu_recycled) }, 101 { "mmu_recycled", VM_STAT(mmu_recycled) },
92 { "mmu_cache_miss", VM_STAT(mmu_cache_miss) }, 102 { "mmu_cache_miss", VM_STAT(mmu_cache_miss) },
103 { "mmu_unsync", VM_STAT(mmu_unsync) },
93 { "remote_tlb_flush", VM_STAT(remote_tlb_flush) }, 104 { "remote_tlb_flush", VM_STAT(remote_tlb_flush) },
94 { "largepages", VM_STAT(lpages) }, 105 { "largepages", VM_STAT(lpages) },
95 { NULL } 106 { NULL }
96}; 107};
97 108
98
99unsigned long segment_base(u16 selector) 109unsigned long segment_base(u16 selector)
100{ 110{
101 struct descriptor_table gdt; 111 struct descriptor_table gdt;
@@ -352,6 +362,7 @@ EXPORT_SYMBOL_GPL(kvm_set_cr4);
352void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) 362void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
353{ 363{
354 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) { 364 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) {
365 kvm_mmu_sync_roots(vcpu);
355 kvm_mmu_flush_tlb(vcpu); 366 kvm_mmu_flush_tlb(vcpu);
356 return; 367 return;
357 } 368 }
@@ -564,7 +575,7 @@ static void kvm_set_time_scale(uint32_t tsc_khz, struct pvclock_vcpu_time_info *
564 hv_clock->tsc_to_system_mul = div_frac(nsecs, tps32); 575 hv_clock->tsc_to_system_mul = div_frac(nsecs, tps32);
565 576
566 pr_debug("%s: tsc_khz %u, tsc_shift %d, tsc_mul %u\n", 577 pr_debug("%s: tsc_khz %u, tsc_shift %d, tsc_mul %u\n",
567 __FUNCTION__, tsc_khz, hv_clock->tsc_shift, 578 __func__, tsc_khz, hv_clock->tsc_shift,
568 hv_clock->tsc_to_system_mul); 579 hv_clock->tsc_to_system_mul);
569} 580}
570 581
@@ -662,6 +673,18 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
662 pr_unimpl(vcpu, "%s: MSR_IA32_MCG_CTL 0x%llx, nop\n", 673 pr_unimpl(vcpu, "%s: MSR_IA32_MCG_CTL 0x%llx, nop\n",
663 __func__, data); 674 __func__, data);
664 break; 675 break;
676 case MSR_IA32_DEBUGCTLMSR:
677 if (!data) {
678 /* We support the non-activated case already */
679 break;
680 } else if (data & ~(DEBUGCTLMSR_LBR | DEBUGCTLMSR_BTF)) {
681 /* Values other than LBR and BTF are vendor-specific,
682 thus reserved and should throw a #GP */
683 return 1;
684 }
685 pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
686 __func__, data);
687 break;
665 case MSR_IA32_UCODE_REV: 688 case MSR_IA32_UCODE_REV:
666 case MSR_IA32_UCODE_WRITE: 689 case MSR_IA32_UCODE_WRITE:
667 break; 690 break;
@@ -692,10 +715,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
692 /* ...but clean it before doing the actual write */ 715 /* ...but clean it before doing the actual write */
693 vcpu->arch.time_offset = data & ~(PAGE_MASK | 1); 716 vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
694 717
695 down_read(&current->mm->mmap_sem);
696 vcpu->arch.time_page = 718 vcpu->arch.time_page =
697 gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT); 719 gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
698 up_read(&current->mm->mmap_sem);
699 720
700 if (is_error_page(vcpu->arch.time_page)) { 721 if (is_error_page(vcpu->arch.time_page)) {
701 kvm_release_page_clean(vcpu->arch.time_page); 722 kvm_release_page_clean(vcpu->arch.time_page);
@@ -752,8 +773,14 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
752 case MSR_IA32_MC0_MISC+8: 773 case MSR_IA32_MC0_MISC+8:
753 case MSR_IA32_MC0_MISC+12: 774 case MSR_IA32_MC0_MISC+12:
754 case MSR_IA32_MC0_MISC+16: 775 case MSR_IA32_MC0_MISC+16:
776 case MSR_IA32_MC0_MISC+20:
755 case MSR_IA32_UCODE_REV: 777 case MSR_IA32_UCODE_REV:
756 case MSR_IA32_EBL_CR_POWERON: 778 case MSR_IA32_EBL_CR_POWERON:
779 case MSR_IA32_DEBUGCTLMSR:
780 case MSR_IA32_LASTBRANCHFROMIP:
781 case MSR_IA32_LASTBRANCHTOIP:
782 case MSR_IA32_LASTINTFROMIP:
783 case MSR_IA32_LASTINTTOIP:
757 data = 0; 784 data = 0;
758 break; 785 break;
759 case MSR_MTRRcap: 786 case MSR_MTRRcap:
@@ -901,6 +928,9 @@ int kvm_dev_ioctl_check_extension(long ext)
901 case KVM_CAP_PV_MMU: 928 case KVM_CAP_PV_MMU:
902 r = !tdp_enabled; 929 r = !tdp_enabled;
903 break; 930 break;
931 case KVM_CAP_IOMMU:
932 r = intel_iommu_found();
933 break;
904 default: 934 default:
905 r = 0; 935 r = 0;
906 break; 936 break;
@@ -1303,28 +1333,33 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1303 struct kvm_vcpu *vcpu = filp->private_data; 1333 struct kvm_vcpu *vcpu = filp->private_data;
1304 void __user *argp = (void __user *)arg; 1334 void __user *argp = (void __user *)arg;
1305 int r; 1335 int r;
1336 struct kvm_lapic_state *lapic = NULL;
1306 1337
1307 switch (ioctl) { 1338 switch (ioctl) {
1308 case KVM_GET_LAPIC: { 1339 case KVM_GET_LAPIC: {
1309 struct kvm_lapic_state lapic; 1340 lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
1310 1341
1311 memset(&lapic, 0, sizeof lapic); 1342 r = -ENOMEM;
1312 r = kvm_vcpu_ioctl_get_lapic(vcpu, &lapic); 1343 if (!lapic)
1344 goto out;
1345 r = kvm_vcpu_ioctl_get_lapic(vcpu, lapic);
1313 if (r) 1346 if (r)
1314 goto out; 1347 goto out;
1315 r = -EFAULT; 1348 r = -EFAULT;
1316 if (copy_to_user(argp, &lapic, sizeof lapic)) 1349 if (copy_to_user(argp, lapic, sizeof(struct kvm_lapic_state)))
1317 goto out; 1350 goto out;
1318 r = 0; 1351 r = 0;
1319 break; 1352 break;
1320 } 1353 }
1321 case KVM_SET_LAPIC: { 1354 case KVM_SET_LAPIC: {
1322 struct kvm_lapic_state lapic; 1355 lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
1323 1356 r = -ENOMEM;
1357 if (!lapic)
1358 goto out;
1324 r = -EFAULT; 1359 r = -EFAULT;
1325 if (copy_from_user(&lapic, argp, sizeof lapic)) 1360 if (copy_from_user(lapic, argp, sizeof(struct kvm_lapic_state)))
1326 goto out; 1361 goto out;
1327 r = kvm_vcpu_ioctl_set_lapic(vcpu, &lapic);; 1362 r = kvm_vcpu_ioctl_set_lapic(vcpu, lapic);
1328 if (r) 1363 if (r)
1329 goto out; 1364 goto out;
1330 r = 0; 1365 r = 0;
@@ -1422,6 +1457,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1422 r = -EINVAL; 1457 r = -EINVAL;
1423 } 1458 }
1424out: 1459out:
1460 if (lapic)
1461 kfree(lapic);
1425 return r; 1462 return r;
1426} 1463}
1427 1464
@@ -1630,6 +1667,15 @@ long kvm_arch_vm_ioctl(struct file *filp,
1630 struct kvm *kvm = filp->private_data; 1667 struct kvm *kvm = filp->private_data;
1631 void __user *argp = (void __user *)arg; 1668 void __user *argp = (void __user *)arg;
1632 int r = -EINVAL; 1669 int r = -EINVAL;
1670 /*
1671 * This union makes it completely explicit to gcc-3.x
1672 * that these two variables' stack usage should be
1673 * combined, not added together.
1674 */
1675 union {
1676 struct kvm_pit_state ps;
1677 struct kvm_memory_alias alias;
1678 } u;
1633 1679
1634 switch (ioctl) { 1680 switch (ioctl) {
1635 case KVM_SET_TSS_ADDR: 1681 case KVM_SET_TSS_ADDR:
@@ -1661,17 +1707,14 @@ long kvm_arch_vm_ioctl(struct file *filp,
1661 case KVM_GET_NR_MMU_PAGES: 1707 case KVM_GET_NR_MMU_PAGES:
1662 r = kvm_vm_ioctl_get_nr_mmu_pages(kvm); 1708 r = kvm_vm_ioctl_get_nr_mmu_pages(kvm);
1663 break; 1709 break;
1664 case KVM_SET_MEMORY_ALIAS: { 1710 case KVM_SET_MEMORY_ALIAS:
1665 struct kvm_memory_alias alias;
1666
1667 r = -EFAULT; 1711 r = -EFAULT;
1668 if (copy_from_user(&alias, argp, sizeof alias)) 1712 if (copy_from_user(&u.alias, argp, sizeof(struct kvm_memory_alias)))
1669 goto out; 1713 goto out;
1670 r = kvm_vm_ioctl_set_memory_alias(kvm, &alias); 1714 r = kvm_vm_ioctl_set_memory_alias(kvm, &u.alias);
1671 if (r) 1715 if (r)
1672 goto out; 1716 goto out;
1673 break; 1717 break;
1674 }
1675 case KVM_CREATE_IRQCHIP: 1718 case KVM_CREATE_IRQCHIP:
1676 r = -ENOMEM; 1719 r = -ENOMEM;
1677 kvm->arch.vpic = kvm_create_pic(kvm); 1720 kvm->arch.vpic = kvm_create_pic(kvm);
@@ -1699,13 +1742,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
1699 goto out; 1742 goto out;
1700 if (irqchip_in_kernel(kvm)) { 1743 if (irqchip_in_kernel(kvm)) {
1701 mutex_lock(&kvm->lock); 1744 mutex_lock(&kvm->lock);
1702 if (irq_event.irq < 16) 1745 kvm_set_irq(kvm, irq_event.irq, irq_event.level);
1703 kvm_pic_set_irq(pic_irqchip(kvm),
1704 irq_event.irq,
1705 irq_event.level);
1706 kvm_ioapic_set_irq(kvm->arch.vioapic,
1707 irq_event.irq,
1708 irq_event.level);
1709 mutex_unlock(&kvm->lock); 1746 mutex_unlock(&kvm->lock);
1710 r = 0; 1747 r = 0;
1711 } 1748 }
@@ -1713,65 +1750,77 @@ long kvm_arch_vm_ioctl(struct file *filp,
1713 } 1750 }
1714 case KVM_GET_IRQCHIP: { 1751 case KVM_GET_IRQCHIP: {
1715 /* 0: PIC master, 1: PIC slave, 2: IOAPIC */ 1752 /* 0: PIC master, 1: PIC slave, 2: IOAPIC */
1716 struct kvm_irqchip chip; 1753 struct kvm_irqchip *chip = kmalloc(sizeof(*chip), GFP_KERNEL);
1717 1754
1718 r = -EFAULT; 1755 r = -ENOMEM;
1719 if (copy_from_user(&chip, argp, sizeof chip)) 1756 if (!chip)
1720 goto out; 1757 goto out;
1758 r = -EFAULT;
1759 if (copy_from_user(chip, argp, sizeof *chip))
1760 goto get_irqchip_out;
1721 r = -ENXIO; 1761 r = -ENXIO;
1722 if (!irqchip_in_kernel(kvm)) 1762 if (!irqchip_in_kernel(kvm))
1723 goto out; 1763 goto get_irqchip_out;
1724 r = kvm_vm_ioctl_get_irqchip(kvm, &chip); 1764 r = kvm_vm_ioctl_get_irqchip(kvm, chip);
1725 if (r) 1765 if (r)
1726 goto out; 1766 goto get_irqchip_out;
1727 r = -EFAULT; 1767 r = -EFAULT;
1728 if (copy_to_user(argp, &chip, sizeof chip)) 1768 if (copy_to_user(argp, chip, sizeof *chip))
1729 goto out; 1769 goto get_irqchip_out;
1730 r = 0; 1770 r = 0;
1771 get_irqchip_out:
1772 kfree(chip);
1773 if (r)
1774 goto out;
1731 break; 1775 break;
1732 } 1776 }
1733 case KVM_SET_IRQCHIP: { 1777 case KVM_SET_IRQCHIP: {
1734 /* 0: PIC master, 1: PIC slave, 2: IOAPIC */ 1778 /* 0: PIC master, 1: PIC slave, 2: IOAPIC */
1735 struct kvm_irqchip chip; 1779 struct kvm_irqchip *chip = kmalloc(sizeof(*chip), GFP_KERNEL);
1736 1780
1737 r = -EFAULT; 1781 r = -ENOMEM;
1738 if (copy_from_user(&chip, argp, sizeof chip)) 1782 if (!chip)
1739 goto out; 1783 goto out;
1784 r = -EFAULT;
1785 if (copy_from_user(chip, argp, sizeof *chip))
1786 goto set_irqchip_out;
1740 r = -ENXIO; 1787 r = -ENXIO;
1741 if (!irqchip_in_kernel(kvm)) 1788 if (!irqchip_in_kernel(kvm))
1742 goto out; 1789 goto set_irqchip_out;
1743 r = kvm_vm_ioctl_set_irqchip(kvm, &chip); 1790 r = kvm_vm_ioctl_set_irqchip(kvm, chip);
1744 if (r) 1791 if (r)
1745 goto out; 1792 goto set_irqchip_out;
1746 r = 0; 1793 r = 0;
1794 set_irqchip_out:
1795 kfree(chip);
1796 if (r)
1797 goto out;
1747 break; 1798 break;
1748 } 1799 }
1749 case KVM_GET_PIT: { 1800 case KVM_GET_PIT: {
1750 struct kvm_pit_state ps;
1751 r = -EFAULT; 1801 r = -EFAULT;
1752 if (copy_from_user(&ps, argp, sizeof ps)) 1802 if (copy_from_user(&u.ps, argp, sizeof(struct kvm_pit_state)))
1753 goto out; 1803 goto out;
1754 r = -ENXIO; 1804 r = -ENXIO;
1755 if (!kvm->arch.vpit) 1805 if (!kvm->arch.vpit)
1756 goto out; 1806 goto out;
1757 r = kvm_vm_ioctl_get_pit(kvm, &ps); 1807 r = kvm_vm_ioctl_get_pit(kvm, &u.ps);
1758 if (r) 1808 if (r)
1759 goto out; 1809 goto out;
1760 r = -EFAULT; 1810 r = -EFAULT;
1761 if (copy_to_user(argp, &ps, sizeof ps)) 1811 if (copy_to_user(argp, &u.ps, sizeof(struct kvm_pit_state)))
1762 goto out; 1812 goto out;
1763 r = 0; 1813 r = 0;
1764 break; 1814 break;
1765 } 1815 }
1766 case KVM_SET_PIT: { 1816 case KVM_SET_PIT: {
1767 struct kvm_pit_state ps;
1768 r = -EFAULT; 1817 r = -EFAULT;
1769 if (copy_from_user(&ps, argp, sizeof ps)) 1818 if (copy_from_user(&u.ps, argp, sizeof u.ps))
1770 goto out; 1819 goto out;
1771 r = -ENXIO; 1820 r = -ENXIO;
1772 if (!kvm->arch.vpit) 1821 if (!kvm->arch.vpit)
1773 goto out; 1822 goto out;
1774 r = kvm_vm_ioctl_set_pit(kvm, &ps); 1823 r = kvm_vm_ioctl_set_pit(kvm, &u.ps);
1775 if (r) 1824 if (r)
1776 goto out; 1825 goto out;
1777 r = 0; 1826 r = 0;
@@ -2018,9 +2067,7 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
2018 2067
2019 val = *(u64 *)new; 2068 val = *(u64 *)new;
2020 2069
2021 down_read(&current->mm->mmap_sem);
2022 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); 2070 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
2023 up_read(&current->mm->mmap_sem);
2024 2071
2025 kaddr = kmap_atomic(page, KM_USER0); 2072 kaddr = kmap_atomic(page, KM_USER0);
2026 set_64bit((u64 *)(kaddr + offset_in_page(gpa)), val); 2073 set_64bit((u64 *)(kaddr + offset_in_page(gpa)), val);
@@ -2040,6 +2087,7 @@ static unsigned long get_segment_base(struct kvm_vcpu *vcpu, int seg)
2040 2087
2041int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address) 2088int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address)
2042{ 2089{
2090 kvm_mmu_invlpg(vcpu, address);
2043 return X86EMUL_CONTINUE; 2091 return X86EMUL_CONTINUE;
2044} 2092}
2045 2093
@@ -2080,7 +2128,7 @@ int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value)
2080void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context) 2128void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context)
2081{ 2129{
2082 u8 opcodes[4]; 2130 u8 opcodes[4];
2083 unsigned long rip = vcpu->arch.rip; 2131 unsigned long rip = kvm_rip_read(vcpu);
2084 unsigned long rip_linear; 2132 unsigned long rip_linear;
2085 2133
2086 if (!printk_ratelimit()) 2134 if (!printk_ratelimit())
@@ -2102,6 +2150,14 @@ static struct x86_emulate_ops emulate_ops = {
2102 .cmpxchg_emulated = emulator_cmpxchg_emulated, 2150 .cmpxchg_emulated = emulator_cmpxchg_emulated,
2103}; 2151};
2104 2152
2153static void cache_all_regs(struct kvm_vcpu *vcpu)
2154{
2155 kvm_register_read(vcpu, VCPU_REGS_RAX);
2156 kvm_register_read(vcpu, VCPU_REGS_RSP);
2157 kvm_register_read(vcpu, VCPU_REGS_RIP);
2158 vcpu->arch.regs_dirty = ~0;
2159}
2160
2105int emulate_instruction(struct kvm_vcpu *vcpu, 2161int emulate_instruction(struct kvm_vcpu *vcpu,
2106 struct kvm_run *run, 2162 struct kvm_run *run,
2107 unsigned long cr2, 2163 unsigned long cr2,
@@ -2111,8 +2167,15 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
2111 int r; 2167 int r;
2112 struct decode_cache *c; 2168 struct decode_cache *c;
2113 2169
2170 kvm_clear_exception_queue(vcpu);
2114 vcpu->arch.mmio_fault_cr2 = cr2; 2171 vcpu->arch.mmio_fault_cr2 = cr2;
2115 kvm_x86_ops->cache_regs(vcpu); 2172 /*
2173 * TODO: fix x86_emulate.c to use guest_read/write_register
2174 * instead of direct ->regs accesses, can save hundred cycles
2175 * on Intel for instructions that don't read/change RSP, for
2176 * for example.
2177 */
2178 cache_all_regs(vcpu);
2116 2179
2117 vcpu->mmio_is_write = 0; 2180 vcpu->mmio_is_write = 0;
2118 vcpu->arch.pio.string = 0; 2181 vcpu->arch.pio.string = 0;
@@ -2172,7 +2235,6 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
2172 return EMULATE_DO_MMIO; 2235 return EMULATE_DO_MMIO;
2173 } 2236 }
2174 2237
2175 kvm_x86_ops->decache_regs(vcpu);
2176 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); 2238 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
2177 2239
2178 if (vcpu->mmio_is_write) { 2240 if (vcpu->mmio_is_write) {
@@ -2225,20 +2287,19 @@ int complete_pio(struct kvm_vcpu *vcpu)
2225 struct kvm_pio_request *io = &vcpu->arch.pio; 2287 struct kvm_pio_request *io = &vcpu->arch.pio;
2226 long delta; 2288 long delta;
2227 int r; 2289 int r;
2228 2290 unsigned long val;
2229 kvm_x86_ops->cache_regs(vcpu);
2230 2291
2231 if (!io->string) { 2292 if (!io->string) {
2232 if (io->in) 2293 if (io->in) {
2233 memcpy(&vcpu->arch.regs[VCPU_REGS_RAX], vcpu->arch.pio_data, 2294 val = kvm_register_read(vcpu, VCPU_REGS_RAX);
2234 io->size); 2295 memcpy(&val, vcpu->arch.pio_data, io->size);
2296 kvm_register_write(vcpu, VCPU_REGS_RAX, val);
2297 }
2235 } else { 2298 } else {
2236 if (io->in) { 2299 if (io->in) {
2237 r = pio_copy_data(vcpu); 2300 r = pio_copy_data(vcpu);
2238 if (r) { 2301 if (r)
2239 kvm_x86_ops->cache_regs(vcpu);
2240 return r; 2302 return r;
2241 }
2242 } 2303 }
2243 2304
2244 delta = 1; 2305 delta = 1;
@@ -2248,19 +2309,24 @@ int complete_pio(struct kvm_vcpu *vcpu)
2248 * The size of the register should really depend on 2309 * The size of the register should really depend on
2249 * current address size. 2310 * current address size.
2250 */ 2311 */
2251 vcpu->arch.regs[VCPU_REGS_RCX] -= delta; 2312 val = kvm_register_read(vcpu, VCPU_REGS_RCX);
2313 val -= delta;
2314 kvm_register_write(vcpu, VCPU_REGS_RCX, val);
2252 } 2315 }
2253 if (io->down) 2316 if (io->down)
2254 delta = -delta; 2317 delta = -delta;
2255 delta *= io->size; 2318 delta *= io->size;
2256 if (io->in) 2319 if (io->in) {
2257 vcpu->arch.regs[VCPU_REGS_RDI] += delta; 2320 val = kvm_register_read(vcpu, VCPU_REGS_RDI);
2258 else 2321 val += delta;
2259 vcpu->arch.regs[VCPU_REGS_RSI] += delta; 2322 kvm_register_write(vcpu, VCPU_REGS_RDI, val);
2323 } else {
2324 val = kvm_register_read(vcpu, VCPU_REGS_RSI);
2325 val += delta;
2326 kvm_register_write(vcpu, VCPU_REGS_RSI, val);
2327 }
2260 } 2328 }
2261 2329
2262 kvm_x86_ops->decache_regs(vcpu);
2263
2264 io->count -= io->cur_count; 2330 io->count -= io->cur_count;
2265 io->cur_count = 0; 2331 io->cur_count = 0;
2266 2332
@@ -2313,6 +2379,7 @@ int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
2313 int size, unsigned port) 2379 int size, unsigned port)
2314{ 2380{
2315 struct kvm_io_device *pio_dev; 2381 struct kvm_io_device *pio_dev;
2382 unsigned long val;
2316 2383
2317 vcpu->run->exit_reason = KVM_EXIT_IO; 2384 vcpu->run->exit_reason = KVM_EXIT_IO;
2318 vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT; 2385 vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT;
@@ -2333,8 +2400,8 @@ int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
2333 KVMTRACE_2D(IO_WRITE, vcpu, vcpu->run->io.port, (u32)size, 2400 KVMTRACE_2D(IO_WRITE, vcpu, vcpu->run->io.port, (u32)size,
2334 handler); 2401 handler);
2335 2402
2336 kvm_x86_ops->cache_regs(vcpu); 2403 val = kvm_register_read(vcpu, VCPU_REGS_RAX);
2337 memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4); 2404 memcpy(vcpu->arch.pio_data, &val, 4);
2338 2405
2339 kvm_x86_ops->skip_emulated_instruction(vcpu); 2406 kvm_x86_ops->skip_emulated_instruction(vcpu);
2340 2407
@@ -2492,11 +2559,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
2492 KVMTRACE_0D(HLT, vcpu, handler); 2559 KVMTRACE_0D(HLT, vcpu, handler);
2493 if (irqchip_in_kernel(vcpu->kvm)) { 2560 if (irqchip_in_kernel(vcpu->kvm)) {
2494 vcpu->arch.mp_state = KVM_MP_STATE_HALTED; 2561 vcpu->arch.mp_state = KVM_MP_STATE_HALTED;
2495 up_read(&vcpu->kvm->slots_lock);
2496 kvm_vcpu_block(vcpu);
2497 down_read(&vcpu->kvm->slots_lock);
2498 if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE)
2499 return -EINTR;
2500 return 1; 2562 return 1;
2501 } else { 2563 } else {
2502 vcpu->run->exit_reason = KVM_EXIT_HLT; 2564 vcpu->run->exit_reason = KVM_EXIT_HLT;
@@ -2519,13 +2581,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
2519 unsigned long nr, a0, a1, a2, a3, ret; 2581 unsigned long nr, a0, a1, a2, a3, ret;
2520 int r = 1; 2582 int r = 1;
2521 2583
2522 kvm_x86_ops->cache_regs(vcpu); 2584 nr = kvm_register_read(vcpu, VCPU_REGS_RAX);
2523 2585 a0 = kvm_register_read(vcpu, VCPU_REGS_RBX);
2524 nr = vcpu->arch.regs[VCPU_REGS_RAX]; 2586 a1 = kvm_register_read(vcpu, VCPU_REGS_RCX);
2525 a0 = vcpu->arch.regs[VCPU_REGS_RBX]; 2587 a2 = kvm_register_read(vcpu, VCPU_REGS_RDX);
2526 a1 = vcpu->arch.regs[VCPU_REGS_RCX]; 2588 a3 = kvm_register_read(vcpu, VCPU_REGS_RSI);
2527 a2 = vcpu->arch.regs[VCPU_REGS_RDX];
2528 a3 = vcpu->arch.regs[VCPU_REGS_RSI];
2529 2589
2530 KVMTRACE_1D(VMMCALL, vcpu, (u32)nr, handler); 2590 KVMTRACE_1D(VMMCALL, vcpu, (u32)nr, handler);
2531 2591
@@ -2548,8 +2608,7 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
2548 ret = -KVM_ENOSYS; 2608 ret = -KVM_ENOSYS;
2549 break; 2609 break;
2550 } 2610 }
2551 vcpu->arch.regs[VCPU_REGS_RAX] = ret; 2611 kvm_register_write(vcpu, VCPU_REGS_RAX, ret);
2552 kvm_x86_ops->decache_regs(vcpu);
2553 ++vcpu->stat.hypercalls; 2612 ++vcpu->stat.hypercalls;
2554 return r; 2613 return r;
2555} 2614}
@@ -2559,6 +2618,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu)
2559{ 2618{
2560 char instruction[3]; 2619 char instruction[3];
2561 int ret = 0; 2620 int ret = 0;
2621 unsigned long rip = kvm_rip_read(vcpu);
2562 2622
2563 2623
2564 /* 2624 /*
@@ -2568,9 +2628,8 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu)
2568 */ 2628 */
2569 kvm_mmu_zap_all(vcpu->kvm); 2629 kvm_mmu_zap_all(vcpu->kvm);
2570 2630
2571 kvm_x86_ops->cache_regs(vcpu);
2572 kvm_x86_ops->patch_hypercall(vcpu, instruction); 2631 kvm_x86_ops->patch_hypercall(vcpu, instruction);
2573 if (emulator_write_emulated(vcpu->arch.rip, instruction, 3, vcpu) 2632 if (emulator_write_emulated(rip, instruction, 3, vcpu)
2574 != X86EMUL_CONTINUE) 2633 != X86EMUL_CONTINUE)
2575 ret = -EFAULT; 2634 ret = -EFAULT;
2576 2635
@@ -2700,13 +2759,12 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
2700 u32 function, index; 2759 u32 function, index;
2701 struct kvm_cpuid_entry2 *e, *best; 2760 struct kvm_cpuid_entry2 *e, *best;
2702 2761
2703 kvm_x86_ops->cache_regs(vcpu); 2762 function = kvm_register_read(vcpu, VCPU_REGS_RAX);
2704 function = vcpu->arch.regs[VCPU_REGS_RAX]; 2763 index = kvm_register_read(vcpu, VCPU_REGS_RCX);
2705 index = vcpu->arch.regs[VCPU_REGS_RCX]; 2764 kvm_register_write(vcpu, VCPU_REGS_RAX, 0);
2706 vcpu->arch.regs[VCPU_REGS_RAX] = 0; 2765 kvm_register_write(vcpu, VCPU_REGS_RBX, 0);
2707 vcpu->arch.regs[VCPU_REGS_RBX] = 0; 2766 kvm_register_write(vcpu, VCPU_REGS_RCX, 0);
2708 vcpu->arch.regs[VCPU_REGS_RCX] = 0; 2767 kvm_register_write(vcpu, VCPU_REGS_RDX, 0);
2709 vcpu->arch.regs[VCPU_REGS_RDX] = 0;
2710 best = NULL; 2768 best = NULL;
2711 for (i = 0; i < vcpu->arch.cpuid_nent; ++i) { 2769 for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
2712 e = &vcpu->arch.cpuid_entries[i]; 2770 e = &vcpu->arch.cpuid_entries[i];
@@ -2724,18 +2782,17 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
2724 best = e; 2782 best = e;
2725 } 2783 }
2726 if (best) { 2784 if (best) {
2727 vcpu->arch.regs[VCPU_REGS_RAX] = best->eax; 2785 kvm_register_write(vcpu, VCPU_REGS_RAX, best->eax);
2728 vcpu->arch.regs[VCPU_REGS_RBX] = best->ebx; 2786 kvm_register_write(vcpu, VCPU_REGS_RBX, best->ebx);
2729 vcpu->arch.regs[VCPU_REGS_RCX] = best->ecx; 2787 kvm_register_write(vcpu, VCPU_REGS_RCX, best->ecx);
2730 vcpu->arch.regs[VCPU_REGS_RDX] = best->edx; 2788 kvm_register_write(vcpu, VCPU_REGS_RDX, best->edx);
2731 } 2789 }
2732 kvm_x86_ops->decache_regs(vcpu);
2733 kvm_x86_ops->skip_emulated_instruction(vcpu); 2790 kvm_x86_ops->skip_emulated_instruction(vcpu);
2734 KVMTRACE_5D(CPUID, vcpu, function, 2791 KVMTRACE_5D(CPUID, vcpu, function,
2735 (u32)vcpu->arch.regs[VCPU_REGS_RAX], 2792 (u32)kvm_register_read(vcpu, VCPU_REGS_RAX),
2736 (u32)vcpu->arch.regs[VCPU_REGS_RBX], 2793 (u32)kvm_register_read(vcpu, VCPU_REGS_RBX),
2737 (u32)vcpu->arch.regs[VCPU_REGS_RCX], 2794 (u32)kvm_register_read(vcpu, VCPU_REGS_RCX),
2738 (u32)vcpu->arch.regs[VCPU_REGS_RDX], handler); 2795 (u32)kvm_register_read(vcpu, VCPU_REGS_RDX), handler);
2739} 2796}
2740EXPORT_SYMBOL_GPL(kvm_emulate_cpuid); 2797EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);
2741 2798
@@ -2776,9 +2833,7 @@ static void vapic_enter(struct kvm_vcpu *vcpu)
2776 if (!apic || !apic->vapic_addr) 2833 if (!apic || !apic->vapic_addr)
2777 return; 2834 return;
2778 2835
2779 down_read(&current->mm->mmap_sem);
2780 page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT); 2836 page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
2781 up_read(&current->mm->mmap_sem);
2782 2837
2783 vcpu->arch.apic->vapic_page = page; 2838 vcpu->arch.apic->vapic_page = page;
2784} 2839}
@@ -2796,28 +2851,10 @@ static void vapic_exit(struct kvm_vcpu *vcpu)
2796 up_read(&vcpu->kvm->slots_lock); 2851 up_read(&vcpu->kvm->slots_lock);
2797} 2852}
2798 2853
2799static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2854static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2800{ 2855{
2801 int r; 2856 int r;
2802 2857
2803 if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED)) {
2804 pr_debug("vcpu %d received sipi with vector # %x\n",
2805 vcpu->vcpu_id, vcpu->arch.sipi_vector);
2806 kvm_lapic_reset(vcpu);
2807 r = kvm_x86_ops->vcpu_reset(vcpu);
2808 if (r)
2809 return r;
2810 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
2811 }
2812
2813 down_read(&vcpu->kvm->slots_lock);
2814 vapic_enter(vcpu);
2815
2816preempted:
2817 if (vcpu->guest_debug.enabled)
2818 kvm_x86_ops->guest_debug_pre(vcpu);
2819
2820again:
2821 if (vcpu->requests) 2858 if (vcpu->requests)
2822 if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) 2859 if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests))
2823 kvm_mmu_unload(vcpu); 2860 kvm_mmu_unload(vcpu);
@@ -2829,6 +2866,8 @@ again:
2829 if (vcpu->requests) { 2866 if (vcpu->requests) {
2830 if (test_and_clear_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests)) 2867 if (test_and_clear_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests))
2831 __kvm_migrate_timers(vcpu); 2868 __kvm_migrate_timers(vcpu);
2869 if (test_and_clear_bit(KVM_REQ_MMU_SYNC, &vcpu->requests))
2870 kvm_mmu_sync_roots(vcpu);
2832 if (test_and_clear_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests)) 2871 if (test_and_clear_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests))
2833 kvm_x86_ops->tlb_flush(vcpu); 2872 kvm_x86_ops->tlb_flush(vcpu);
2834 if (test_and_clear_bit(KVM_REQ_REPORT_TPR_ACCESS, 2873 if (test_and_clear_bit(KVM_REQ_REPORT_TPR_ACCESS,
@@ -2854,21 +2893,15 @@ again:
2854 2893
2855 local_irq_disable(); 2894 local_irq_disable();
2856 2895
2857 if (vcpu->requests || need_resched()) { 2896 if (vcpu->requests || need_resched() || signal_pending(current)) {
2858 local_irq_enable(); 2897 local_irq_enable();
2859 preempt_enable(); 2898 preempt_enable();
2860 r = 1; 2899 r = 1;
2861 goto out; 2900 goto out;
2862 } 2901 }
2863 2902
2864 if (signal_pending(current)) { 2903 if (vcpu->guest_debug.enabled)
2865 local_irq_enable(); 2904 kvm_x86_ops->guest_debug_pre(vcpu);
2866 preempt_enable();
2867 r = -EINTR;
2868 kvm_run->exit_reason = KVM_EXIT_INTR;
2869 ++vcpu->stat.signal_exits;
2870 goto out;
2871 }
2872 2905
2873 vcpu->guest_mode = 1; 2906 vcpu->guest_mode = 1;
2874 /* 2907 /*
@@ -2917,8 +2950,8 @@ again:
2917 * Profile KVM exit RIPs: 2950 * Profile KVM exit RIPs:
2918 */ 2951 */
2919 if (unlikely(prof_on == KVM_PROFILING)) { 2952 if (unlikely(prof_on == KVM_PROFILING)) {
2920 kvm_x86_ops->cache_regs(vcpu); 2953 unsigned long rip = kvm_rip_read(vcpu);
2921 profile_hit(KVM_PROFILING, (void *)vcpu->arch.rip); 2954 profile_hit(KVM_PROFILING, (void *)rip);
2922 } 2955 }
2923 2956
2924 if (vcpu->arch.exception.pending && kvm_x86_ops->exception_injected(vcpu)) 2957 if (vcpu->arch.exception.pending && kvm_x86_ops->exception_injected(vcpu))
@@ -2927,26 +2960,63 @@ again:
2927 kvm_lapic_sync_from_vapic(vcpu); 2960 kvm_lapic_sync_from_vapic(vcpu);
2928 2961
2929 r = kvm_x86_ops->handle_exit(kvm_run, vcpu); 2962 r = kvm_x86_ops->handle_exit(kvm_run, vcpu);
2963out:
2964 return r;
2965}
2930 2966
2931 if (r > 0) { 2967static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2932 if (dm_request_for_irq_injection(vcpu, kvm_run)) { 2968{
2933 r = -EINTR; 2969 int r;
2934 kvm_run->exit_reason = KVM_EXIT_INTR; 2970
2935 ++vcpu->stat.request_irq_exits; 2971 if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED)) {
2936 goto out; 2972 pr_debug("vcpu %d received sipi with vector # %x\n",
2937 } 2973 vcpu->vcpu_id, vcpu->arch.sipi_vector);
2938 if (!need_resched()) 2974 kvm_lapic_reset(vcpu);
2939 goto again; 2975 r = kvm_x86_ops->vcpu_reset(vcpu);
2976 if (r)
2977 return r;
2978 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
2940 } 2979 }
2941 2980
2942out: 2981 down_read(&vcpu->kvm->slots_lock);
2943 up_read(&vcpu->kvm->slots_lock); 2982 vapic_enter(vcpu);
2944 if (r > 0) { 2983
2945 kvm_resched(vcpu); 2984 r = 1;
2946 down_read(&vcpu->kvm->slots_lock); 2985 while (r > 0) {
2947 goto preempted; 2986 if (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE)
2987 r = vcpu_enter_guest(vcpu, kvm_run);
2988 else {
2989 up_read(&vcpu->kvm->slots_lock);
2990 kvm_vcpu_block(vcpu);
2991 down_read(&vcpu->kvm->slots_lock);
2992 if (test_and_clear_bit(KVM_REQ_UNHALT, &vcpu->requests))
2993 if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED)
2994 vcpu->arch.mp_state =
2995 KVM_MP_STATE_RUNNABLE;
2996 if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE)
2997 r = -EINTR;
2998 }
2999
3000 if (r > 0) {
3001 if (dm_request_for_irq_injection(vcpu, kvm_run)) {
3002 r = -EINTR;
3003 kvm_run->exit_reason = KVM_EXIT_INTR;
3004 ++vcpu->stat.request_irq_exits;
3005 }
3006 if (signal_pending(current)) {
3007 r = -EINTR;
3008 kvm_run->exit_reason = KVM_EXIT_INTR;
3009 ++vcpu->stat.signal_exits;
3010 }
3011 if (need_resched()) {
3012 up_read(&vcpu->kvm->slots_lock);
3013 kvm_resched(vcpu);
3014 down_read(&vcpu->kvm->slots_lock);
3015 }
3016 }
2948 } 3017 }
2949 3018
3019 up_read(&vcpu->kvm->slots_lock);
2950 post_kvm_run_save(vcpu, kvm_run); 3020 post_kvm_run_save(vcpu, kvm_run);
2951 3021
2952 vapic_exit(vcpu); 3022 vapic_exit(vcpu);
@@ -2966,6 +3036,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2966 3036
2967 if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { 3037 if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {
2968 kvm_vcpu_block(vcpu); 3038 kvm_vcpu_block(vcpu);
3039 clear_bit(KVM_REQ_UNHALT, &vcpu->requests);
2969 r = -EAGAIN; 3040 r = -EAGAIN;
2970 goto out; 3041 goto out;
2971 } 3042 }
@@ -2999,11 +3070,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2999 } 3070 }
3000 } 3071 }
3001#endif 3072#endif
3002 if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL) { 3073 if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL)
3003 kvm_x86_ops->cache_regs(vcpu); 3074 kvm_register_write(vcpu, VCPU_REGS_RAX,
3004 vcpu->arch.regs[VCPU_REGS_RAX] = kvm_run->hypercall.ret; 3075 kvm_run->hypercall.ret);
3005 kvm_x86_ops->decache_regs(vcpu);
3006 }
3007 3076
3008 r = __vcpu_run(vcpu, kvm_run); 3077 r = __vcpu_run(vcpu, kvm_run);
3009 3078
@@ -3019,28 +3088,26 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
3019{ 3088{
3020 vcpu_load(vcpu); 3089 vcpu_load(vcpu);
3021 3090
3022 kvm_x86_ops->cache_regs(vcpu); 3091 regs->rax = kvm_register_read(vcpu, VCPU_REGS_RAX);
3023 3092 regs->rbx = kvm_register_read(vcpu, VCPU_REGS_RBX);
3024 regs->rax = vcpu->arch.regs[VCPU_REGS_RAX]; 3093 regs->rcx = kvm_register_read(vcpu, VCPU_REGS_RCX);
3025 regs->rbx = vcpu->arch.regs[VCPU_REGS_RBX]; 3094 regs->rdx = kvm_register_read(vcpu, VCPU_REGS_RDX);
3026 regs->rcx = vcpu->arch.regs[VCPU_REGS_RCX]; 3095 regs->rsi = kvm_register_read(vcpu, VCPU_REGS_RSI);
3027 regs->rdx = vcpu->arch.regs[VCPU_REGS_RDX]; 3096 regs->rdi = kvm_register_read(vcpu, VCPU_REGS_RDI);
3028 regs->rsi = vcpu->arch.regs[VCPU_REGS_RSI]; 3097 regs->rsp = kvm_register_read(vcpu, VCPU_REGS_RSP);
3029 regs->rdi = vcpu->arch.regs[VCPU_REGS_RDI]; 3098 regs->rbp = kvm_register_read(vcpu, VCPU_REGS_RBP);
3030 regs->rsp = vcpu->arch.regs[VCPU_REGS_RSP];
3031 regs->rbp = vcpu->arch.regs[VCPU_REGS_RBP];
3032#ifdef CONFIG_X86_64 3099#ifdef CONFIG_X86_64
3033 regs->r8 = vcpu->arch.regs[VCPU_REGS_R8]; 3100 regs->r8 = kvm_register_read(vcpu, VCPU_REGS_R8);
3034 regs->r9 = vcpu->arch.regs[VCPU_REGS_R9]; 3101 regs->r9 = kvm_register_read(vcpu, VCPU_REGS_R9);
3035 regs->r10 = vcpu->arch.regs[VCPU_REGS_R10]; 3102 regs->r10 = kvm_register_read(vcpu, VCPU_REGS_R10);
3036 regs->r11 = vcpu->arch.regs[VCPU_REGS_R11]; 3103 regs->r11 = kvm_register_read(vcpu, VCPU_REGS_R11);
3037 regs->r12 = vcpu->arch.regs[VCPU_REGS_R12]; 3104 regs->r12 = kvm_register_read(vcpu, VCPU_REGS_R12);
3038 regs->r13 = vcpu->arch.regs[VCPU_REGS_R13]; 3105 regs->r13 = kvm_register_read(vcpu, VCPU_REGS_R13);
3039 regs->r14 = vcpu->arch.regs[VCPU_REGS_R14]; 3106 regs->r14 = kvm_register_read(vcpu, VCPU_REGS_R14);
3040 regs->r15 = vcpu->arch.regs[VCPU_REGS_R15]; 3107 regs->r15 = kvm_register_read(vcpu, VCPU_REGS_R15);
3041#endif 3108#endif
3042 3109
3043 regs->rip = vcpu->arch.rip; 3110 regs->rip = kvm_rip_read(vcpu);
3044 regs->rflags = kvm_x86_ops->get_rflags(vcpu); 3111 regs->rflags = kvm_x86_ops->get_rflags(vcpu);
3045 3112
3046 /* 3113 /*
@@ -3058,29 +3125,29 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
3058{ 3125{
3059 vcpu_load(vcpu); 3126 vcpu_load(vcpu);
3060 3127
3061 vcpu->arch.regs[VCPU_REGS_RAX] = regs->rax; 3128 kvm_register_write(vcpu, VCPU_REGS_RAX, regs->rax);
3062 vcpu->arch.regs[VCPU_REGS_RBX] = regs->rbx; 3129 kvm_register_write(vcpu, VCPU_REGS_RBX, regs->rbx);
3063 vcpu->arch.regs[VCPU_REGS_RCX] = regs->rcx; 3130 kvm_register_write(vcpu, VCPU_REGS_RCX, regs->rcx);
3064 vcpu->arch.regs[VCPU_REGS_RDX] = regs->rdx; 3131 kvm_register_write(vcpu, VCPU_REGS_RDX, regs->rdx);
3065 vcpu->arch.regs[VCPU_REGS_RSI] = regs->rsi; 3132 kvm_register_write(vcpu, VCPU_REGS_RSI, regs->rsi);
3066 vcpu->arch.regs[VCPU_REGS_RDI] = regs->rdi; 3133 kvm_register_write(vcpu, VCPU_REGS_RDI, regs->rdi);
3067 vcpu->arch.regs[VCPU_REGS_RSP] = regs->rsp; 3134 kvm_register_write(vcpu, VCPU_REGS_RSP, regs->rsp);
3068 vcpu->arch.regs[VCPU_REGS_RBP] = regs->rbp; 3135 kvm_register_write(vcpu, VCPU_REGS_RBP, regs->rbp);
3069#ifdef CONFIG_X86_64 3136#ifdef CONFIG_X86_64
3070 vcpu->arch.regs[VCPU_REGS_R8] = regs->r8; 3137 kvm_register_write(vcpu, VCPU_REGS_R8, regs->r8);
3071 vcpu->arch.regs[VCPU_REGS_R9] = regs->r9; 3138 kvm_register_write(vcpu, VCPU_REGS_R9, regs->r9);
3072 vcpu->arch.regs[VCPU_REGS_R10] = regs->r10; 3139 kvm_register_write(vcpu, VCPU_REGS_R10, regs->r10);
3073 vcpu->arch.regs[VCPU_REGS_R11] = regs->r11; 3140 kvm_register_write(vcpu, VCPU_REGS_R11, regs->r11);
3074 vcpu->arch.regs[VCPU_REGS_R12] = regs->r12; 3141 kvm_register_write(vcpu, VCPU_REGS_R12, regs->r12);
3075 vcpu->arch.regs[VCPU_REGS_R13] = regs->r13; 3142 kvm_register_write(vcpu, VCPU_REGS_R13, regs->r13);
3076 vcpu->arch.regs[VCPU_REGS_R14] = regs->r14; 3143 kvm_register_write(vcpu, VCPU_REGS_R14, regs->r14);
3077 vcpu->arch.regs[VCPU_REGS_R15] = regs->r15; 3144 kvm_register_write(vcpu, VCPU_REGS_R15, regs->r15);
3145
3078#endif 3146#endif
3079 3147
3080 vcpu->arch.rip = regs->rip; 3148 kvm_rip_write(vcpu, regs->rip);
3081 kvm_x86_ops->set_rflags(vcpu, regs->rflags); 3149 kvm_x86_ops->set_rflags(vcpu, regs->rflags);
3082 3150
3083 kvm_x86_ops->decache_regs(vcpu);
3084 3151
3085 vcpu->arch.exception.pending = false; 3152 vcpu->arch.exception.pending = false;
3086 3153
@@ -3294,11 +3361,33 @@ static int load_segment_descriptor_to_kvm_desct(struct kvm_vcpu *vcpu,
3294 return 0; 3361 return 0;
3295} 3362}
3296 3363
3364static int kvm_load_realmode_segment(struct kvm_vcpu *vcpu, u16 selector, int seg)
3365{
3366 struct kvm_segment segvar = {
3367 .base = selector << 4,
3368 .limit = 0xffff,
3369 .selector = selector,
3370 .type = 3,
3371 .present = 1,
3372 .dpl = 3,
3373 .db = 0,
3374 .s = 1,
3375 .l = 0,
3376 .g = 0,
3377 .avl = 0,
3378 .unusable = 0,
3379 };
3380 kvm_x86_ops->set_segment(vcpu, &segvar, seg);
3381 return 0;
3382}
3383
3297int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, 3384int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3298 int type_bits, int seg) 3385 int type_bits, int seg)
3299{ 3386{
3300 struct kvm_segment kvm_seg; 3387 struct kvm_segment kvm_seg;
3301 3388
3389 if (!(vcpu->arch.cr0 & X86_CR0_PE))
3390 return kvm_load_realmode_segment(vcpu, selector, seg);
3302 if (load_segment_descriptor_to_kvm_desct(vcpu, selector, &kvm_seg)) 3391 if (load_segment_descriptor_to_kvm_desct(vcpu, selector, &kvm_seg))
3303 return 1; 3392 return 1;
3304 kvm_seg.type |= type_bits; 3393 kvm_seg.type |= type_bits;
@@ -3316,17 +3405,16 @@ static void save_state_to_tss32(struct kvm_vcpu *vcpu,
3316 struct tss_segment_32 *tss) 3405 struct tss_segment_32 *tss)
3317{ 3406{
3318 tss->cr3 = vcpu->arch.cr3; 3407 tss->cr3 = vcpu->arch.cr3;
3319 tss->eip = vcpu->arch.rip; 3408 tss->eip = kvm_rip_read(vcpu);
3320 tss->eflags = kvm_x86_ops->get_rflags(vcpu); 3409 tss->eflags = kvm_x86_ops->get_rflags(vcpu);
3321 tss->eax = vcpu->arch.regs[VCPU_REGS_RAX]; 3410 tss->eax = kvm_register_read(vcpu, VCPU_REGS_RAX);
3322 tss->ecx = vcpu->arch.regs[VCPU_REGS_RCX]; 3411 tss->ecx = kvm_register_read(vcpu, VCPU_REGS_RCX);
3323 tss->edx = vcpu->arch.regs[VCPU_REGS_RDX]; 3412 tss->edx = kvm_register_read(vcpu, VCPU_REGS_RDX);
3324 tss->ebx = vcpu->arch.regs[VCPU_REGS_RBX]; 3413 tss->ebx = kvm_register_read(vcpu, VCPU_REGS_RBX);
3325 tss->esp = vcpu->arch.regs[VCPU_REGS_RSP]; 3414 tss->esp = kvm_register_read(vcpu, VCPU_REGS_RSP);
3326 tss->ebp = vcpu->arch.regs[VCPU_REGS_RBP]; 3415 tss->ebp = kvm_register_read(vcpu, VCPU_REGS_RBP);
3327 tss->esi = vcpu->arch.regs[VCPU_REGS_RSI]; 3416 tss->esi = kvm_register_read(vcpu, VCPU_REGS_RSI);
3328 tss->edi = vcpu->arch.regs[VCPU_REGS_RDI]; 3417 tss->edi = kvm_register_read(vcpu, VCPU_REGS_RDI);
3329
3330 tss->es = get_segment_selector(vcpu, VCPU_SREG_ES); 3418 tss->es = get_segment_selector(vcpu, VCPU_SREG_ES);
3331 tss->cs = get_segment_selector(vcpu, VCPU_SREG_CS); 3419 tss->cs = get_segment_selector(vcpu, VCPU_SREG_CS);
3332 tss->ss = get_segment_selector(vcpu, VCPU_SREG_SS); 3420 tss->ss = get_segment_selector(vcpu, VCPU_SREG_SS);
@@ -3342,17 +3430,17 @@ static int load_state_from_tss32(struct kvm_vcpu *vcpu,
3342{ 3430{
3343 kvm_set_cr3(vcpu, tss->cr3); 3431 kvm_set_cr3(vcpu, tss->cr3);
3344 3432
3345 vcpu->arch.rip = tss->eip; 3433 kvm_rip_write(vcpu, tss->eip);
3346 kvm_x86_ops->set_rflags(vcpu, tss->eflags | 2); 3434 kvm_x86_ops->set_rflags(vcpu, tss->eflags | 2);
3347 3435
3348 vcpu->arch.regs[VCPU_REGS_RAX] = tss->eax; 3436 kvm_register_write(vcpu, VCPU_REGS_RAX, tss->eax);
3349 vcpu->arch.regs[VCPU_REGS_RCX] = tss->ecx; 3437 kvm_register_write(vcpu, VCPU_REGS_RCX, tss->ecx);
3350 vcpu->arch.regs[VCPU_REGS_RDX] = tss->edx; 3438 kvm_register_write(vcpu, VCPU_REGS_RDX, tss->edx);
3351 vcpu->arch.regs[VCPU_REGS_RBX] = tss->ebx; 3439 kvm_register_write(vcpu, VCPU_REGS_RBX, tss->ebx);
3352 vcpu->arch.regs[VCPU_REGS_RSP] = tss->esp; 3440 kvm_register_write(vcpu, VCPU_REGS_RSP, tss->esp);
3353 vcpu->arch.regs[VCPU_REGS_RBP] = tss->ebp; 3441 kvm_register_write(vcpu, VCPU_REGS_RBP, tss->ebp);
3354 vcpu->arch.regs[VCPU_REGS_RSI] = tss->esi; 3442 kvm_register_write(vcpu, VCPU_REGS_RSI, tss->esi);
3355 vcpu->arch.regs[VCPU_REGS_RDI] = tss->edi; 3443 kvm_register_write(vcpu, VCPU_REGS_RDI, tss->edi);
3356 3444
3357 if (kvm_load_segment_descriptor(vcpu, tss->ldt_selector, 0, VCPU_SREG_LDTR)) 3445 if (kvm_load_segment_descriptor(vcpu, tss->ldt_selector, 0, VCPU_SREG_LDTR))
3358 return 1; 3446 return 1;
@@ -3380,16 +3468,16 @@ static int load_state_from_tss32(struct kvm_vcpu *vcpu,
3380static void save_state_to_tss16(struct kvm_vcpu *vcpu, 3468static void save_state_to_tss16(struct kvm_vcpu *vcpu,
3381 struct tss_segment_16 *tss) 3469 struct tss_segment_16 *tss)
3382{ 3470{
3383 tss->ip = vcpu->arch.rip; 3471 tss->ip = kvm_rip_read(vcpu);
3384 tss->flag = kvm_x86_ops->get_rflags(vcpu); 3472 tss->flag = kvm_x86_ops->get_rflags(vcpu);
3385 tss->ax = vcpu->arch.regs[VCPU_REGS_RAX]; 3473 tss->ax = kvm_register_read(vcpu, VCPU_REGS_RAX);
3386 tss->cx = vcpu->arch.regs[VCPU_REGS_RCX]; 3474 tss->cx = kvm_register_read(vcpu, VCPU_REGS_RCX);
3387 tss->dx = vcpu->arch.regs[VCPU_REGS_RDX]; 3475 tss->dx = kvm_register_read(vcpu, VCPU_REGS_RDX);
3388 tss->bx = vcpu->arch.regs[VCPU_REGS_RBX]; 3476 tss->bx = kvm_register_read(vcpu, VCPU_REGS_RBX);
3389 tss->sp = vcpu->arch.regs[VCPU_REGS_RSP]; 3477 tss->sp = kvm_register_read(vcpu, VCPU_REGS_RSP);
3390 tss->bp = vcpu->arch.regs[VCPU_REGS_RBP]; 3478 tss->bp = kvm_register_read(vcpu, VCPU_REGS_RBP);
3391 tss->si = vcpu->arch.regs[VCPU_REGS_RSI]; 3479 tss->si = kvm_register_read(vcpu, VCPU_REGS_RSI);
3392 tss->di = vcpu->arch.regs[VCPU_REGS_RDI]; 3480 tss->di = kvm_register_read(vcpu, VCPU_REGS_RDI);
3393 3481
3394 tss->es = get_segment_selector(vcpu, VCPU_SREG_ES); 3482 tss->es = get_segment_selector(vcpu, VCPU_SREG_ES);
3395 tss->cs = get_segment_selector(vcpu, VCPU_SREG_CS); 3483 tss->cs = get_segment_selector(vcpu, VCPU_SREG_CS);
@@ -3402,16 +3490,16 @@ static void save_state_to_tss16(struct kvm_vcpu *vcpu,
3402static int load_state_from_tss16(struct kvm_vcpu *vcpu, 3490static int load_state_from_tss16(struct kvm_vcpu *vcpu,
3403 struct tss_segment_16 *tss) 3491 struct tss_segment_16 *tss)
3404{ 3492{
3405 vcpu->arch.rip = tss->ip; 3493 kvm_rip_write(vcpu, tss->ip);
3406 kvm_x86_ops->set_rflags(vcpu, tss->flag | 2); 3494 kvm_x86_ops->set_rflags(vcpu, tss->flag | 2);
3407 vcpu->arch.regs[VCPU_REGS_RAX] = tss->ax; 3495 kvm_register_write(vcpu, VCPU_REGS_RAX, tss->ax);
3408 vcpu->arch.regs[VCPU_REGS_RCX] = tss->cx; 3496 kvm_register_write(vcpu, VCPU_REGS_RCX, tss->cx);
3409 vcpu->arch.regs[VCPU_REGS_RDX] = tss->dx; 3497 kvm_register_write(vcpu, VCPU_REGS_RDX, tss->dx);
3410 vcpu->arch.regs[VCPU_REGS_RBX] = tss->bx; 3498 kvm_register_write(vcpu, VCPU_REGS_RBX, tss->bx);
3411 vcpu->arch.regs[VCPU_REGS_RSP] = tss->sp; 3499 kvm_register_write(vcpu, VCPU_REGS_RSP, tss->sp);
3412 vcpu->arch.regs[VCPU_REGS_RBP] = tss->bp; 3500 kvm_register_write(vcpu, VCPU_REGS_RBP, tss->bp);
3413 vcpu->arch.regs[VCPU_REGS_RSI] = tss->si; 3501 kvm_register_write(vcpu, VCPU_REGS_RSI, tss->si);
3414 vcpu->arch.regs[VCPU_REGS_RDI] = tss->di; 3502 kvm_register_write(vcpu, VCPU_REGS_RDI, tss->di);
3415 3503
3416 if (kvm_load_segment_descriptor(vcpu, tss->ldt, 0, VCPU_SREG_LDTR)) 3504 if (kvm_load_segment_descriptor(vcpu, tss->ldt, 0, VCPU_SREG_LDTR))
3417 return 1; 3505 return 1;
@@ -3534,7 +3622,6 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3534 } 3622 }
3535 3623
3536 kvm_x86_ops->skip_emulated_instruction(vcpu); 3624 kvm_x86_ops->skip_emulated_instruction(vcpu);
3537 kvm_x86_ops->cache_regs(vcpu);
3538 3625
3539 if (nseg_desc.type & 8) 3626 if (nseg_desc.type & 8)
3540 ret = kvm_task_switch_32(vcpu, tss_selector, old_tss_base, 3627 ret = kvm_task_switch_32(vcpu, tss_selector, old_tss_base,
@@ -3559,7 +3646,6 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3559 tr_seg.type = 11; 3646 tr_seg.type = 11;
3560 kvm_set_segment(vcpu, &tr_seg, VCPU_SREG_TR); 3647 kvm_set_segment(vcpu, &tr_seg, VCPU_SREG_TR);
3561out: 3648out:
3562 kvm_x86_ops->decache_regs(vcpu);
3563 return ret; 3649 return ret;
3564} 3650}
3565EXPORT_SYMBOL_GPL(kvm_task_switch); 3651EXPORT_SYMBOL_GPL(kvm_task_switch);
@@ -3622,6 +3708,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
3622 pr_debug("Set back pending irq %d\n", 3708 pr_debug("Set back pending irq %d\n",
3623 pending_vec); 3709 pending_vec);
3624 } 3710 }
3711 kvm_pic_clear_isr_ack(vcpu->kvm);
3625 } 3712 }
3626 3713
3627 kvm_set_segment(vcpu, &sregs->cs, VCPU_SREG_CS); 3714 kvm_set_segment(vcpu, &sregs->cs, VCPU_SREG_CS);
@@ -3634,6 +3721,12 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
3634 kvm_set_segment(vcpu, &sregs->tr, VCPU_SREG_TR); 3721 kvm_set_segment(vcpu, &sregs->tr, VCPU_SREG_TR);
3635 kvm_set_segment(vcpu, &sregs->ldt, VCPU_SREG_LDTR); 3722 kvm_set_segment(vcpu, &sregs->ldt, VCPU_SREG_LDTR);
3636 3723
3724 /* Older userspace won't unhalt the vcpu on reset. */
3725 if (vcpu->vcpu_id == 0 && kvm_rip_read(vcpu) == 0xfff0 &&
3726 sregs->cs.selector == 0xf000 && sregs->cs.base == 0xffff0000 &&
3727 !(vcpu->arch.cr0 & X86_CR0_PE))
3728 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
3729
3637 vcpu_put(vcpu); 3730 vcpu_put(vcpu);
3638 3731
3639 return 0; 3732 return 0;
@@ -3918,6 +4011,7 @@ struct kvm *kvm_arch_create_vm(void)
3918 return ERR_PTR(-ENOMEM); 4011 return ERR_PTR(-ENOMEM);
3919 4012
3920 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); 4013 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages);
4014 INIT_LIST_HEAD(&kvm->arch.assigned_dev_head);
3921 4015
3922 return kvm; 4016 return kvm;
3923} 4017}
@@ -3950,6 +4044,8 @@ static void kvm_free_vcpus(struct kvm *kvm)
3950 4044
3951void kvm_arch_destroy_vm(struct kvm *kvm) 4045void kvm_arch_destroy_vm(struct kvm *kvm)
3952{ 4046{
4047 kvm_iommu_unmap_guest(kvm);
4048 kvm_free_all_assigned_devices(kvm);
3953 kvm_free_pit(kvm); 4049 kvm_free_pit(kvm);
3954 kfree(kvm->arch.vpic); 4050 kfree(kvm->arch.vpic);
3955 kfree(kvm->arch.vioapic); 4051 kfree(kvm->arch.vioapic);
@@ -3981,7 +4077,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
3981 userspace_addr = do_mmap(NULL, 0, 4077 userspace_addr = do_mmap(NULL, 0,
3982 npages * PAGE_SIZE, 4078 npages * PAGE_SIZE,
3983 PROT_READ | PROT_WRITE, 4079 PROT_READ | PROT_WRITE,
3984 MAP_SHARED | MAP_ANONYMOUS, 4080 MAP_PRIVATE | MAP_ANONYMOUS,
3985 0); 4081 0);
3986 up_write(&current->mm->mmap_sem); 4082 up_write(&current->mm->mmap_sem);
3987 4083
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
new file mode 100644
index 000000000000..6a4be78a7384
--- /dev/null
+++ b/arch/x86/kvm/x86.h
@@ -0,0 +1,22 @@
1#ifndef ARCH_X86_KVM_X86_H
2#define ARCH_X86_KVM_X86_H
3
4#include <linux/kvm_host.h>
5
6static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)
7{
8 vcpu->arch.exception.pending = false;
9}
10
11static inline void kvm_queue_interrupt(struct kvm_vcpu *vcpu, u8 vector)
12{
13 vcpu->arch.interrupt.pending = true;
14 vcpu->arch.interrupt.nr = vector;
15}
16
17static inline void kvm_clear_interrupt_queue(struct kvm_vcpu *vcpu)
18{
19 vcpu->arch.interrupt.pending = false;
20}
21
22#endif
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index f2f90468f8b1..ea051173b0da 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -26,6 +26,7 @@
26#define DPRINTF(_f, _a ...) printf(_f , ## _a) 26#define DPRINTF(_f, _a ...) printf(_f , ## _a)
27#else 27#else
28#include <linux/kvm_host.h> 28#include <linux/kvm_host.h>
29#include "kvm_cache_regs.h"
29#define DPRINTF(x...) do {} while (0) 30#define DPRINTF(x...) do {} while (0)
30#endif 31#endif
31#include <linux/module.h> 32#include <linux/module.h>
@@ -46,25 +47,26 @@
46#define ImplicitOps (1<<1) /* Implicit in opcode. No generic decode. */ 47#define ImplicitOps (1<<1) /* Implicit in opcode. No generic decode. */
47#define DstReg (2<<1) /* Register operand. */ 48#define DstReg (2<<1) /* Register operand. */
48#define DstMem (3<<1) /* Memory operand. */ 49#define DstMem (3<<1) /* Memory operand. */
49#define DstMask (3<<1) 50#define DstAcc (4<<1) /* Destination Accumulator */
51#define DstMask (7<<1)
50/* Source operand type. */ 52/* Source operand type. */
51#define SrcNone (0<<3) /* No source operand. */ 53#define SrcNone (0<<4) /* No source operand. */
52#define SrcImplicit (0<<3) /* Source operand is implicit in the opcode. */ 54#define SrcImplicit (0<<4) /* Source operand is implicit in the opcode. */
53#define SrcReg (1<<3) /* Register operand. */ 55#define SrcReg (1<<4) /* Register operand. */
54#define SrcMem (2<<3) /* Memory operand. */ 56#define SrcMem (2<<4) /* Memory operand. */
55#define SrcMem16 (3<<3) /* Memory operand (16-bit). */ 57#define SrcMem16 (3<<4) /* Memory operand (16-bit). */
56#define SrcMem32 (4<<3) /* Memory operand (32-bit). */ 58#define SrcMem32 (4<<4) /* Memory operand (32-bit). */
57#define SrcImm (5<<3) /* Immediate operand. */ 59#define SrcImm (5<<4) /* Immediate operand. */
58#define SrcImmByte (6<<3) /* 8-bit sign-extended immediate operand. */ 60#define SrcImmByte (6<<4) /* 8-bit sign-extended immediate operand. */
59#define SrcMask (7<<3) 61#define SrcMask (7<<4)
60/* Generic ModRM decode. */ 62/* Generic ModRM decode. */
61#define ModRM (1<<6) 63#define ModRM (1<<7)
62/* Destination is only written; never read. */ 64/* Destination is only written; never read. */
63#define Mov (1<<7) 65#define Mov (1<<8)
64#define BitOp (1<<8) 66#define BitOp (1<<9)
65#define MemAbs (1<<9) /* Memory operand is absolute displacement */ 67#define MemAbs (1<<10) /* Memory operand is absolute displacement */
66#define String (1<<10) /* String instruction (rep capable) */ 68#define String (1<<12) /* String instruction (rep capable) */
67#define Stack (1<<11) /* Stack instruction (push/pop) */ 69#define Stack (1<<13) /* Stack instruction (push/pop) */
68#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */ 70#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */
69#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */ 71#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */
70#define GroupMask 0xff /* Group number stored in bits 0:7 */ 72#define GroupMask 0xff /* Group number stored in bits 0:7 */
@@ -94,7 +96,7 @@ static u16 opcode_table[256] = {
94 /* 0x20 - 0x27 */ 96 /* 0x20 - 0x27 */
95 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM, 97 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
96 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM, 98 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
97 SrcImmByte, SrcImm, 0, 0, 99 DstAcc | SrcImmByte, DstAcc | SrcImm, 0, 0,
98 /* 0x28 - 0x2F */ 100 /* 0x28 - 0x2F */
99 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM, 101 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
100 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM, 102 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
@@ -106,7 +108,8 @@ static u16 opcode_table[256] = {
106 /* 0x38 - 0x3F */ 108 /* 0x38 - 0x3F */
107 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM, 109 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
108 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM, 110 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
109 0, 0, 0, 0, 111 ByteOp | DstAcc | SrcImm, DstAcc | SrcImm,
112 0, 0,
110 /* 0x40 - 0x47 */ 113 /* 0x40 - 0x47 */
111 DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, 114 DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg,
112 /* 0x48 - 0x4F */ 115 /* 0x48 - 0x4F */
@@ -153,9 +156,16 @@ static u16 opcode_table[256] = {
153 0, 0, ByteOp | ImplicitOps | Mov | String, ImplicitOps | Mov | String, 156 0, 0, ByteOp | ImplicitOps | Mov | String, ImplicitOps | Mov | String,
154 ByteOp | ImplicitOps | Mov | String, ImplicitOps | Mov | String, 157 ByteOp | ImplicitOps | Mov | String, ImplicitOps | Mov | String,
155 ByteOp | ImplicitOps | String, ImplicitOps | String, 158 ByteOp | ImplicitOps | String, ImplicitOps | String,
156 /* 0xB0 - 0xBF */ 159 /* 0xB0 - 0xB7 */
157 0, 0, 0, 0, 0, 0, 0, 0, 160 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
158 DstReg | SrcImm | Mov, 0, 0, 0, 0, 0, 0, 0, 161 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
162 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
163 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
164 /* 0xB8 - 0xBF */
165 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
166 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
167 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
168 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
159 /* 0xC0 - 0xC7 */ 169 /* 0xC0 - 0xC7 */
160 ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM, 170 ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM,
161 0, ImplicitOps | Stack, 0, 0, 171 0, ImplicitOps | Stack, 0, 0,
@@ -169,17 +179,20 @@ static u16 opcode_table[256] = {
169 /* 0xD8 - 0xDF */ 179 /* 0xD8 - 0xDF */
170 0, 0, 0, 0, 0, 0, 0, 0, 180 0, 0, 0, 0, 0, 0, 0, 0,
171 /* 0xE0 - 0xE7 */ 181 /* 0xE0 - 0xE7 */
172 0, 0, 0, 0, 0, 0, 0, 0, 182 0, 0, 0, 0,
183 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps,
184 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps,
173 /* 0xE8 - 0xEF */ 185 /* 0xE8 - 0xEF */
174 ImplicitOps | Stack, SrcImm | ImplicitOps, 186 ImplicitOps | Stack, SrcImm | ImplicitOps,
175 ImplicitOps, SrcImmByte | ImplicitOps, 187 ImplicitOps, SrcImmByte | ImplicitOps,
176 0, 0, 0, 0, 188 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps,
189 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps,
177 /* 0xF0 - 0xF7 */ 190 /* 0xF0 - 0xF7 */
178 0, 0, 0, 0, 191 0, 0, 0, 0,
179 ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3, 192 ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3,
180 /* 0xF8 - 0xFF */ 193 /* 0xF8 - 0xFF */
181 ImplicitOps, 0, ImplicitOps, ImplicitOps, 194 ImplicitOps, 0, ImplicitOps, ImplicitOps,
182 0, 0, Group | Group4, Group | Group5, 195 ImplicitOps, ImplicitOps, Group | Group4, Group | Group5,
183}; 196};
184 197
185static u16 twobyte_table[256] = { 198static u16 twobyte_table[256] = {
@@ -268,15 +281,16 @@ static u16 group_table[] = {
268 ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM, 281 ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
269 0, 0, 0, 0, 282 0, 0, 0, 0,
270 [Group3*8] = 283 [Group3*8] =
271 DstMem | SrcImm | ModRM | SrcImm, 0, 284 DstMem | SrcImm | ModRM, 0,
272 DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM, 285 DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM,
273 0, 0, 0, 0, 286 0, 0, 0, 0,
274 [Group4*8] = 287 [Group4*8] =
275 ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM, 288 ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
276 0, 0, 0, 0, 0, 0, 289 0, 0, 0, 0, 0, 0,
277 [Group5*8] = 290 [Group5*8] =
278 DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM, 0, 0, 291 DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM,
279 SrcMem | ModRM, 0, SrcMem | ModRM | Stack, 0, 292 SrcMem | ModRM | Stack, 0,
293 SrcMem | ModRM | Stack, 0, SrcMem | ModRM | Stack, 0,
280 [Group7*8] = 294 [Group7*8] =
281 0, 0, ModRM | SrcMem, ModRM | SrcMem, 295 0, 0, ModRM | SrcMem, ModRM | SrcMem,
282 SrcNone | ModRM | DstMem | Mov, 0, 296 SrcNone | ModRM | DstMem | Mov, 0,
@@ -839,7 +853,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
839 /* Shadow copy of register state. Committed on successful emulation. */ 853 /* Shadow copy of register state. Committed on successful emulation. */
840 854
841 memset(c, 0, sizeof(struct decode_cache)); 855 memset(c, 0, sizeof(struct decode_cache));
842 c->eip = ctxt->vcpu->arch.rip; 856 c->eip = kvm_rip_read(ctxt->vcpu);
843 ctxt->cs_base = seg_base(ctxt, VCPU_SREG_CS); 857 ctxt->cs_base = seg_base(ctxt, VCPU_SREG_CS);
844 memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs); 858 memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs);
845 859
@@ -1048,6 +1062,23 @@ done_prefixes:
1048 } 1062 }
1049 c->dst.type = OP_MEM; 1063 c->dst.type = OP_MEM;
1050 break; 1064 break;
1065 case DstAcc:
1066 c->dst.type = OP_REG;
1067 c->dst.bytes = c->op_bytes;
1068 c->dst.ptr = &c->regs[VCPU_REGS_RAX];
1069 switch (c->op_bytes) {
1070 case 1:
1071 c->dst.val = *(u8 *)c->dst.ptr;
1072 break;
1073 case 2:
1074 c->dst.val = *(u16 *)c->dst.ptr;
1075 break;
1076 case 4:
1077 c->dst.val = *(u32 *)c->dst.ptr;
1078 break;
1079 }
1080 c->dst.orig_val = c->dst.val;
1081 break;
1051 } 1082 }
1052 1083
1053 if (c->rip_relative) 1084 if (c->rip_relative)
@@ -1151,6 +1182,14 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
1151 case 1: /* dec */ 1182 case 1: /* dec */
1152 emulate_1op("dec", c->dst, ctxt->eflags); 1183 emulate_1op("dec", c->dst, ctxt->eflags);
1153 break; 1184 break;
1185 case 2: /* call near abs */ {
1186 long int old_eip;
1187 old_eip = c->eip;
1188 c->eip = c->src.val;
1189 c->src.val = old_eip;
1190 emulate_push(ctxt);
1191 break;
1192 }
1154 case 4: /* jmp abs */ 1193 case 4: /* jmp abs */
1155 c->eip = c->src.val; 1194 c->eip = c->src.val;
1156 break; 1195 break;
@@ -1251,6 +1290,8 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
1251 u64 msr_data; 1290 u64 msr_data;
1252 unsigned long saved_eip = 0; 1291 unsigned long saved_eip = 0;
1253 struct decode_cache *c = &ctxt->decode; 1292 struct decode_cache *c = &ctxt->decode;
1293 unsigned int port;
1294 int io_dir_in;
1254 int rc = 0; 1295 int rc = 0;
1255 1296
1256 /* Shadow copy of register state. Committed on successful emulation. 1297 /* Shadow copy of register state. Committed on successful emulation.
@@ -1267,7 +1308,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
1267 if (c->rep_prefix && (c->d & String)) { 1308 if (c->rep_prefix && (c->d & String)) {
1268 /* All REP prefixes have the same first termination condition */ 1309 /* All REP prefixes have the same first termination condition */
1269 if (c->regs[VCPU_REGS_RCX] == 0) { 1310 if (c->regs[VCPU_REGS_RCX] == 0) {
1270 ctxt->vcpu->arch.rip = c->eip; 1311 kvm_rip_write(ctxt->vcpu, c->eip);
1271 goto done; 1312 goto done;
1272 } 1313 }
1273 /* The second termination condition only applies for REPE 1314 /* The second termination condition only applies for REPE
@@ -1281,17 +1322,17 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
1281 (c->b == 0xae) || (c->b == 0xaf)) { 1322 (c->b == 0xae) || (c->b == 0xaf)) {
1282 if ((c->rep_prefix == REPE_PREFIX) && 1323 if ((c->rep_prefix == REPE_PREFIX) &&
1283 ((ctxt->eflags & EFLG_ZF) == 0)) { 1324 ((ctxt->eflags & EFLG_ZF) == 0)) {
1284 ctxt->vcpu->arch.rip = c->eip; 1325 kvm_rip_write(ctxt->vcpu, c->eip);
1285 goto done; 1326 goto done;
1286 } 1327 }
1287 if ((c->rep_prefix == REPNE_PREFIX) && 1328 if ((c->rep_prefix == REPNE_PREFIX) &&
1288 ((ctxt->eflags & EFLG_ZF) == EFLG_ZF)) { 1329 ((ctxt->eflags & EFLG_ZF) == EFLG_ZF)) {
1289 ctxt->vcpu->arch.rip = c->eip; 1330 kvm_rip_write(ctxt->vcpu, c->eip);
1290 goto done; 1331 goto done;
1291 } 1332 }
1292 } 1333 }
1293 c->regs[VCPU_REGS_RCX]--; 1334 c->regs[VCPU_REGS_RCX]--;
1294 c->eip = ctxt->vcpu->arch.rip; 1335 c->eip = kvm_rip_read(ctxt->vcpu);
1295 } 1336 }
1296 1337
1297 if (c->src.type == OP_MEM) { 1338 if (c->src.type == OP_MEM) {
@@ -1351,27 +1392,10 @@ special_insn:
1351 sbb: /* sbb */ 1392 sbb: /* sbb */
1352 emulate_2op_SrcV("sbb", c->src, c->dst, ctxt->eflags); 1393 emulate_2op_SrcV("sbb", c->src, c->dst, ctxt->eflags);
1353 break; 1394 break;
1354 case 0x20 ... 0x23: 1395 case 0x20 ... 0x25:
1355 and: /* and */ 1396 and: /* and */
1356 emulate_2op_SrcV("and", c->src, c->dst, ctxt->eflags); 1397 emulate_2op_SrcV("and", c->src, c->dst, ctxt->eflags);
1357 break; 1398 break;
1358 case 0x24: /* and al imm8 */
1359 c->dst.type = OP_REG;
1360 c->dst.ptr = &c->regs[VCPU_REGS_RAX];
1361 c->dst.val = *(u8 *)c->dst.ptr;
1362 c->dst.bytes = 1;
1363 c->dst.orig_val = c->dst.val;
1364 goto and;
1365 case 0x25: /* and ax imm16, or eax imm32 */
1366 c->dst.type = OP_REG;
1367 c->dst.bytes = c->op_bytes;
1368 c->dst.ptr = &c->regs[VCPU_REGS_RAX];
1369 if (c->op_bytes == 2)
1370 c->dst.val = *(u16 *)c->dst.ptr;
1371 else
1372 c->dst.val = *(u32 *)c->dst.ptr;
1373 c->dst.orig_val = c->dst.val;
1374 goto and;
1375 case 0x28 ... 0x2d: 1399 case 0x28 ... 0x2d:
1376 sub: /* sub */ 1400 sub: /* sub */
1377 emulate_2op_SrcV("sub", c->src, c->dst, ctxt->eflags); 1401 emulate_2op_SrcV("sub", c->src, c->dst, ctxt->eflags);
@@ -1659,7 +1683,7 @@ special_insn:
1659 case 0xae ... 0xaf: /* scas */ 1683 case 0xae ... 0xaf: /* scas */
1660 DPRINTF("Urk! I don't handle SCAS.\n"); 1684 DPRINTF("Urk! I don't handle SCAS.\n");
1661 goto cannot_emulate; 1685 goto cannot_emulate;
1662 case 0xb8: /* mov r, imm */ 1686 case 0xb0 ... 0xbf: /* mov r, imm */
1663 goto mov; 1687 goto mov;
1664 case 0xc0 ... 0xc1: 1688 case 0xc0 ... 0xc1:
1665 emulate_grp2(ctxt); 1689 emulate_grp2(ctxt);
@@ -1679,6 +1703,16 @@ special_insn:
1679 c->src.val = c->regs[VCPU_REGS_RCX]; 1703 c->src.val = c->regs[VCPU_REGS_RCX];
1680 emulate_grp2(ctxt); 1704 emulate_grp2(ctxt);
1681 break; 1705 break;
1706 case 0xe4: /* inb */
1707 case 0xe5: /* in */
1708 port = insn_fetch(u8, 1, c->eip);
1709 io_dir_in = 1;
1710 goto do_io;
1711 case 0xe6: /* outb */
1712 case 0xe7: /* out */
1713 port = insn_fetch(u8, 1, c->eip);
1714 io_dir_in = 0;
1715 goto do_io;
1682 case 0xe8: /* call (near) */ { 1716 case 0xe8: /* call (near) */ {
1683 long int rel; 1717 long int rel;
1684 switch (c->op_bytes) { 1718 switch (c->op_bytes) {
@@ -1729,6 +1763,22 @@ special_insn:
1729 jmp_rel(c, c->src.val); 1763 jmp_rel(c, c->src.val);
1730 c->dst.type = OP_NONE; /* Disable writeback. */ 1764 c->dst.type = OP_NONE; /* Disable writeback. */
1731 break; 1765 break;
1766 case 0xec: /* in al,dx */
1767 case 0xed: /* in (e/r)ax,dx */
1768 port = c->regs[VCPU_REGS_RDX];
1769 io_dir_in = 1;
1770 goto do_io;
1771 case 0xee: /* out al,dx */
1772 case 0xef: /* out (e/r)ax,dx */
1773 port = c->regs[VCPU_REGS_RDX];
1774 io_dir_in = 0;
1775 do_io: if (kvm_emulate_pio(ctxt->vcpu, NULL, io_dir_in,
1776 (c->d & ByteOp) ? 1 : c->op_bytes,
1777 port) != 0) {
1778 c->eip = saved_eip;
1779 goto cannot_emulate;
1780 }
1781 return 0;
1732 case 0xf4: /* hlt */ 1782 case 0xf4: /* hlt */
1733 ctxt->vcpu->arch.halt_request = 1; 1783 ctxt->vcpu->arch.halt_request = 1;
1734 break; 1784 break;
@@ -1754,6 +1804,14 @@ special_insn:
1754 ctxt->eflags |= X86_EFLAGS_IF; 1804 ctxt->eflags |= X86_EFLAGS_IF;
1755 c->dst.type = OP_NONE; /* Disable writeback. */ 1805 c->dst.type = OP_NONE; /* Disable writeback. */
1756 break; 1806 break;
1807 case 0xfc: /* cld */
1808 ctxt->eflags &= ~EFLG_DF;
1809 c->dst.type = OP_NONE; /* Disable writeback. */
1810 break;
1811 case 0xfd: /* std */
1812 ctxt->eflags |= EFLG_DF;
1813 c->dst.type = OP_NONE; /* Disable writeback. */
1814 break;
1757 case 0xfe ... 0xff: /* Grp4/Grp5 */ 1815 case 0xfe ... 0xff: /* Grp4/Grp5 */
1758 rc = emulate_grp45(ctxt, ops); 1816 rc = emulate_grp45(ctxt, ops);
1759 if (rc != 0) 1817 if (rc != 0)
@@ -1768,7 +1826,7 @@ writeback:
1768 1826
1769 /* Commit shadow register state. */ 1827 /* Commit shadow register state. */
1770 memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs); 1828 memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs);
1771 ctxt->vcpu->arch.rip = c->eip; 1829 kvm_rip_write(ctxt->vcpu, c->eip);
1772 1830
1773done: 1831done:
1774 if (rc == X86EMUL_UNHANDLEABLE) { 1832 if (rc == X86EMUL_UNHANDLEABLE) {
@@ -1793,7 +1851,7 @@ twobyte_insn:
1793 goto done; 1851 goto done;
1794 1852
1795 /* Let the processor re-execute the fixed hypercall */ 1853 /* Let the processor re-execute the fixed hypercall */
1796 c->eip = ctxt->vcpu->arch.rip; 1854 c->eip = kvm_rip_read(ctxt->vcpu);
1797 /* Disable writeback. */ 1855 /* Disable writeback. */
1798 c->dst.type = OP_NONE; 1856 c->dst.type = OP_NONE;
1799 break; 1857 break;
@@ -1889,7 +1947,7 @@ twobyte_insn:
1889 rc = kvm_set_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], msr_data); 1947 rc = kvm_set_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], msr_data);
1890 if (rc) { 1948 if (rc) {
1891 kvm_inject_gp(ctxt->vcpu, 0); 1949 kvm_inject_gp(ctxt->vcpu, 0);
1892 c->eip = ctxt->vcpu->arch.rip; 1950 c->eip = kvm_rip_read(ctxt->vcpu);
1893 } 1951 }
1894 rc = X86EMUL_CONTINUE; 1952 rc = X86EMUL_CONTINUE;
1895 c->dst.type = OP_NONE; 1953 c->dst.type = OP_NONE;
@@ -1899,7 +1957,7 @@ twobyte_insn:
1899 rc = kvm_get_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], &msr_data); 1957 rc = kvm_get_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], &msr_data);
1900 if (rc) { 1958 if (rc) {
1901 kvm_inject_gp(ctxt->vcpu, 0); 1959 kvm_inject_gp(ctxt->vcpu, 0);
1902 c->eip = ctxt->vcpu->arch.rip; 1960 c->eip = kvm_rip_read(ctxt->vcpu);
1903 } else { 1961 } else {
1904 c->regs[VCPU_REGS_RAX] = (u32)msr_data; 1962 c->regs[VCPU_REGS_RAX] = (u32)msr_data;
1905 c->regs[VCPU_REGS_RDX] = msr_data >> 32; 1963 c->regs[VCPU_REGS_RDX] = msr_data >> 32;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 3f2b8962cbd0..31e8730fa246 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -640,24 +640,23 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
640 } 640 }
641 641
642 642
643#ifdef CONFIG_X86_32
644 /* It's safe to allow irq's after cr2 has been saved and the vmalloc
645 fault has been handled. */
646 if (regs->flags & (X86_EFLAGS_IF | X86_VM_MASK))
647 local_irq_enable();
648
649 /* 643 /*
650 * If we're in an interrupt, have no user context or are running in an 644 * It's safe to allow irq's after cr2 has been saved and the
651 * atomic region then we must not take the fault. 645 * vmalloc fault has been handled.
646 *
647 * User-mode registers count as a user access even for any
648 * potential system fault or CPU buglet.
652 */ 649 */
653 if (in_atomic() || !mm) 650 if (user_mode_vm(regs)) {
654 goto bad_area_nosemaphore; 651 local_irq_enable();
655#else /* CONFIG_X86_64 */ 652 error_code |= PF_USER;
656 if (likely(regs->flags & X86_EFLAGS_IF)) 653 } else if (regs->flags & X86_EFLAGS_IF)
657 local_irq_enable(); 654 local_irq_enable();
658 655
656#ifdef CONFIG_X86_64
659 if (unlikely(error_code & PF_RSVD)) 657 if (unlikely(error_code & PF_RSVD))
660 pgtable_bad(address, regs, error_code); 658 pgtable_bad(address, regs, error_code);
659#endif
661 660
662 /* 661 /*
663 * If we're in an interrupt, have no user context or are running in an 662 * If we're in an interrupt, have no user context or are running in an
@@ -666,15 +665,9 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
666 if (unlikely(in_atomic() || !mm)) 665 if (unlikely(in_atomic() || !mm))
667 goto bad_area_nosemaphore; 666 goto bad_area_nosemaphore;
668 667
669 /*
670 * User-mode registers count as a user access even for any
671 * potential system fault or CPU buglet.
672 */
673 if (user_mode_vm(regs))
674 error_code |= PF_USER;
675again: 668again:
676#endif 669 /*
677 /* When running in the kernel we expect faults to occur only to 670 * When running in the kernel we expect faults to occur only to
678 * addresses in user space. All other faults represent errors in the 671 * addresses in user space. All other faults represent errors in the
679 * kernel and should generate an OOPS. Unfortunately, in the case of an 672 * kernel and should generate an OOPS. Unfortunately, in the case of an
680 * erroneous fault occurring in a code path which already holds mmap_sem 673 * erroneous fault occurring in a code path which already holds mmap_sem
@@ -737,9 +730,6 @@ good_area:
737 goto bad_area; 730 goto bad_area;
738 } 731 }
739 732
740#ifdef CONFIG_X86_32
741survive:
742#endif
743 /* 733 /*
744 * If for any reason at all we couldn't handle the fault, 734 * If for any reason at all we couldn't handle the fault,
745 * make sure we exit gracefully rather than endlessly redo 735 * make sure we exit gracefully rather than endlessly redo
@@ -874,12 +864,11 @@ out_of_memory:
874 up_read(&mm->mmap_sem); 864 up_read(&mm->mmap_sem);
875 if (is_global_init(tsk)) { 865 if (is_global_init(tsk)) {
876 yield(); 866 yield();
877#ifdef CONFIG_X86_32 867 /*
878 down_read(&mm->mmap_sem); 868 * Re-lookup the vma - in theory the vma tree might
879 goto survive; 869 * have changed:
880#else 870 */
881 goto again; 871 goto again;
882#endif
883 } 872 }
884 873
885 printk("VM: killing process %s\n", tsk->comm); 874 printk("VM: killing process %s\n", tsk->comm);
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index e4c43ec71b29..ae71e11eb3e5 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -220,6 +220,12 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
220 return (__force void __iomem *)phys_to_virt(phys_addr); 220 return (__force void __iomem *)phys_to_virt(phys_addr);
221 221
222 /* 222 /*
223 * Check if the request spans more than any BAR in the iomem resource
224 * tree.
225 */
226 WARN_ON(iomem_map_sanity_check(phys_addr, size));
227
228 /*
223 * Don't allow anybody to remap normal RAM that we're using.. 229 * Don't allow anybody to remap normal RAM that we're using..
224 */ 230 */
225 for (pfn = phys_addr >> PAGE_SHIFT; 231 for (pfn = phys_addr >> PAGE_SHIFT;
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 004ba86326ae..c9f7cda48ed7 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -198,17 +198,10 @@ unsigned long long xen_sched_clock(void)
198/* Get the TSC speed from Xen */ 198/* Get the TSC speed from Xen */
199unsigned long xen_tsc_khz(void) 199unsigned long xen_tsc_khz(void)
200{ 200{
201 u64 xen_khz = 1000000ULL << 32; 201 struct pvclock_vcpu_time_info *info =
202 const struct pvclock_vcpu_time_info *info =
203 &HYPERVISOR_shared_info->vcpu_info[0].time; 202 &HYPERVISOR_shared_info->vcpu_info[0].time;
204 203
205 do_div(xen_khz, info->tsc_to_system_mul); 204 return pvclock_tsc_khz(info);
206 if (info->tsc_shift < 0)
207 xen_khz <<= -info->tsc_shift;
208 else
209 xen_khz >>= info->tsc_shift;
210
211 return xen_khz;
212} 205}
213 206
214cycle_t xen_clocksource_read(void) 207cycle_t xen_clocksource_read(void)
diff --git a/block/bsg.c b/block/bsg.c
index 56cb343c76d8..034112bfe1f3 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -1024,8 +1024,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
1024 bcd->release = release; 1024 bcd->release = release;
1025 kref_init(&bcd->ref); 1025 kref_init(&bcd->ref);
1026 dev = MKDEV(bsg_major, bcd->minor); 1026 dev = MKDEV(bsg_major, bcd->minor);
1027 class_dev = device_create_drvdata(bsg_class, parent, dev, NULL, 1027 class_dev = device_create(bsg_class, parent, dev, NULL, "%s", devname);
1028 "%s", devname);
1029 if (IS_ERR(class_dev)) { 1028 if (IS_ERR(class_dev)) {
1030 ret = PTR_ERR(class_dev); 1029 ret = PTR_ERR(class_dev);
1031 goto put_dev; 1030 goto put_dev;
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 6318f6b57360..d8e8c49c0cbd 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -54,7 +54,7 @@ config FIRMWARE_IN_KERNEL
54 such firmware, and do not wish to use an initrd. 54 such firmware, and do not wish to use an initrd.
55 55
56 This single option controls the inclusion of firmware for 56 This single option controls the inclusion of firmware for
57 every driver which usees request_firmare() and ships its 57 every driver which uses request_firmare() and ships its
58 firmware in the kernel source tree, to avoid a proliferation 58 firmware in the kernel source tree, to avoid a proliferation
59 of 'Include firmware for xxx device' options. 59 of 'Include firmware for xxx device' options.
60 60
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index ef522ae55480..5aee1c0169ea 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -333,9 +333,7 @@ static int match_name(struct device *dev, void *data)
333{ 333{
334 const char *name = data; 334 const char *name = data;
335 335
336 if (strcmp(name, dev->bus_id) == 0) 336 return sysfs_streq(name, dev->bus_id);
337 return 1;
338 return 0;
339} 337}
340 338
341/** 339/**
@@ -982,6 +980,56 @@ struct klist *bus_get_device_klist(struct bus_type *bus)
982} 980}
983EXPORT_SYMBOL_GPL(bus_get_device_klist); 981EXPORT_SYMBOL_GPL(bus_get_device_klist);
984 982
983/*
984 * Yes, this forcably breaks the klist abstraction temporarily. It
985 * just wants to sort the klist, not change reference counts and
986 * take/drop locks rapidly in the process. It does all this while
987 * holding the lock for the list, so objects can't otherwise be
988 * added/removed while we're swizzling.
989 */
990static void device_insertion_sort_klist(struct device *a, struct list_head *list,
991 int (*compare)(const struct device *a,
992 const struct device *b))
993{
994 struct list_head *pos;
995 struct klist_node *n;
996 struct device *b;
997
998 list_for_each(pos, list) {
999 n = container_of(pos, struct klist_node, n_node);
1000 b = container_of(n, struct device, knode_bus);
1001 if (compare(a, b) <= 0) {
1002 list_move_tail(&a->knode_bus.n_node,
1003 &b->knode_bus.n_node);
1004 return;
1005 }
1006 }
1007 list_move_tail(&a->knode_bus.n_node, list);
1008}
1009
1010void bus_sort_breadthfirst(struct bus_type *bus,
1011 int (*compare)(const struct device *a,
1012 const struct device *b))
1013{
1014 LIST_HEAD(sorted_devices);
1015 struct list_head *pos, *tmp;
1016 struct klist_node *n;
1017 struct device *dev;
1018 struct klist *device_klist;
1019
1020 device_klist = bus_get_device_klist(bus);
1021
1022 spin_lock(&device_klist->k_lock);
1023 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1024 n = container_of(pos, struct klist_node, n_node);
1025 dev = container_of(n, struct device, knode_bus);
1026 device_insertion_sort_klist(dev, &sorted_devices, compare);
1027 }
1028 list_splice(&sorted_devices, &device_klist->k_list);
1029 spin_unlock(&device_klist->k_lock);
1030}
1031EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
1032
985int __init buses_init(void) 1033int __init buses_init(void)
986{ 1034{
987 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); 1035 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b98cb1416a2d..8c2cc2648f5a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -523,11 +523,16 @@ static void klist_children_put(struct klist_node *n)
523 * device_initialize - init device structure. 523 * device_initialize - init device structure.
524 * @dev: device. 524 * @dev: device.
525 * 525 *
526 * This prepares the device for use by other layers, 526 * This prepares the device for use by other layers by initializing
527 * including adding it to the device hierarchy. 527 * its fields.
528 * It is the first half of device_register(), if called by 528 * It is the first half of device_register(), if called by
529 * that, though it can also be called separately, so one 529 * that function, though it can also be called separately, so one
530 * may use @dev's fields (e.g. the refcount). 530 * may use @dev's fields. In particular, get_device()/put_device()
531 * may be used for reference counting of @dev after calling this
532 * function.
533 *
534 * NOTE: Use put_device() to give up your reference instead of freeing
535 * @dev directly once you have called this function.
531 */ 536 */
532void device_initialize(struct device *dev) 537void device_initialize(struct device *dev)
533{ 538{
@@ -835,9 +840,13 @@ static void device_remove_sys_dev_entry(struct device *dev)
835 * This is part 2 of device_register(), though may be called 840 * This is part 2 of device_register(), though may be called
836 * separately _iff_ device_initialize() has been called separately. 841 * separately _iff_ device_initialize() has been called separately.
837 * 842 *
838 * This adds it to the kobject hierarchy via kobject_add(), adds it 843 * This adds @dev to the kobject hierarchy via kobject_add(), adds it
839 * to the global and sibling lists for the device, then 844 * to the global and sibling lists for the device, then
840 * adds it to the other relevant subsystems of the driver model. 845 * adds it to the other relevant subsystems of the driver model.
846 *
847 * NOTE: _Never_ directly free @dev after calling this function, even
848 * if it returned an error! Always use put_device() to give up your
849 * reference instead.
841 */ 850 */
842int device_add(struct device *dev) 851int device_add(struct device *dev)
843{ 852{
@@ -965,6 +974,10 @@ done:
965 * I.e. you should only call the two helpers separately if 974 * I.e. you should only call the two helpers separately if
966 * have a clearly defined need to use and refcount the device 975 * have a clearly defined need to use and refcount the device
967 * before it is added to the hierarchy. 976 * before it is added to the hierarchy.
977 *
978 * NOTE: _Never_ directly free @dev after calling this function, even
979 * if it returned an error! Always use put_device() to give up the
980 * reference initialized in this function instead.
968 */ 981 */
969int device_register(struct device *dev) 982int device_register(struct device *dev)
970{ 983{
@@ -1243,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
1243 return dev; 1256 return dev;
1244 1257
1245error: 1258error:
1246 kfree(dev); 1259 put_device(dev);
1247 return ERR_PTR(retval); 1260 return ERR_PTR(retval);
1248} 1261}
1249EXPORT_SYMBOL_GPL(device_create_vargs); 1262EXPORT_SYMBOL_GPL(device_create_vargs);
@@ -1314,6 +1327,11 @@ EXPORT_SYMBOL_GPL(device_destroy);
1314 * device_rename - renames a device 1327 * device_rename - renames a device
1315 * @dev: the pointer to the struct device to be renamed 1328 * @dev: the pointer to the struct device to be renamed
1316 * @new_name: the new name of the device 1329 * @new_name: the new name of the device
1330 *
1331 * It is the responsibility of the caller to provide mutual
1332 * exclusion between two different calls of device_rename
1333 * on the same device to ensure that new_name is valid and
1334 * won't conflict with other devices.
1317 */ 1335 */
1318int device_rename(struct device *dev, char *new_name) 1336int device_rename(struct device *dev, char *new_name)
1319{ 1337{
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 3ac443b2ac08..20febc00a525 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data)
257 * is an error. 257 * is an error.
258 */ 258 */
259 259
260 if (drv->bus->match && !drv->bus->match(dev, drv))
261 return 0;
262
260 if (dev->parent) /* Needed for USB */ 263 if (dev->parent) /* Needed for USB */
261 down(&dev->parent->sem); 264 down(&dev->parent->sem);
262 down(&dev->sem); 265 down(&dev->sem);
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index c9c92b00fd55..b7e571031ecd 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -164,8 +164,7 @@ static ssize_t firmware_loading_store(struct device *dev,
164 } 164 }
165 /* fallthrough */ 165 /* fallthrough */
166 default: 166 default:
167 printk(KERN_ERR "%s: unexpected value (%d)\n", __func__, 167 dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
168 loading);
169 /* fallthrough */ 168 /* fallthrough */
170 case -1: 169 case -1:
171 fw_load_abort(fw_priv); 170 fw_load_abort(fw_priv);
@@ -309,7 +308,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
309 *dev_p = NULL; 308 *dev_p = NULL;
310 309
311 if (!fw_priv || !f_dev) { 310 if (!fw_priv || !f_dev) {
312 printk(KERN_ERR "%s: kmalloc failed\n", __func__); 311 dev_err(device, "%s: kmalloc failed\n", __func__);
313 retval = -ENOMEM; 312 retval = -ENOMEM;
314 goto error_kfree; 313 goto error_kfree;
315 } 314 }
@@ -329,8 +328,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
329 f_dev->uevent_suppress = 1; 328 f_dev->uevent_suppress = 1;
330 retval = device_register(f_dev); 329 retval = device_register(f_dev);
331 if (retval) { 330 if (retval) {
332 printk(KERN_ERR "%s: device_register failed\n", 331 dev_err(device, "%s: device_register failed\n", __func__);
333 __func__);
334 goto error_kfree; 332 goto error_kfree;
335 } 333 }
336 *dev_p = f_dev; 334 *dev_p = f_dev;
@@ -363,15 +361,13 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
363 fw_priv->fw = fw; 361 fw_priv->fw = fw;
364 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); 362 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
365 if (retval) { 363 if (retval) {
366 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", 364 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__);
367 __func__);
368 goto error_unreg; 365 goto error_unreg;
369 } 366 }
370 367
371 retval = device_create_file(f_dev, &dev_attr_loading); 368 retval = device_create_file(f_dev, &dev_attr_loading);
372 if (retval) { 369 if (retval) {
373 printk(KERN_ERR "%s: device_create_file failed\n", 370 dev_err(device, "%s: device_create_file failed\n", __func__);
374 __func__);
375 goto error_unreg; 371 goto error_unreg;
376 } 372 }
377 373
@@ -401,8 +397,8 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
401 397
402 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); 398 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
403 if (!firmware) { 399 if (!firmware) {
404 printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", 400 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
405 __func__); 401 __func__);
406 retval = -ENOMEM; 402 retval = -ENOMEM;
407 goto out; 403 goto out;
408 } 404 }
@@ -411,15 +407,15 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
411 builtin++) { 407 builtin++) {
412 if (strcmp(name, builtin->name)) 408 if (strcmp(name, builtin->name))
413 continue; 409 continue;
414 printk(KERN_INFO "firmware: using built-in firmware %s\n", 410 dev_info(device, "firmware: using built-in firmware %s\n",
415 name); 411 name);
416 firmware->size = builtin->size; 412 firmware->size = builtin->size;
417 firmware->data = builtin->data; 413 firmware->data = builtin->data;
418 return 0; 414 return 0;
419 } 415 }
420 416
421 if (uevent) 417 if (uevent)
422 printk(KERN_INFO "firmware: requesting %s\n", name); 418 dev_info(device, "firmware: requesting %s\n", name);
423 419
424 retval = fw_setup_device(firmware, &f_dev, name, device, uevent); 420 retval = fw_setup_device(firmware, &f_dev, name, device, uevent);
425 if (retval) 421 if (retval)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3f940393d6c7..dfcbfe504867 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -42,10 +42,8 @@ struct resource *platform_get_resource(struct platform_device *dev,
42 for (i = 0; i < dev->num_resources; i++) { 42 for (i = 0; i < dev->num_resources; i++) {
43 struct resource *r = &dev->resource[i]; 43 struct resource *r = &dev->resource[i];
44 44
45 if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| 45 if (type == resource_type(r) && num-- == 0)
46 IORESOURCE_IRQ|IORESOURCE_DMA)) == type) 46 return r;
47 if (num-- == 0)
48 return r;
49 } 47 }
50 return NULL; 48 return NULL;
51} 49}
@@ -78,10 +76,8 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
78 for (i = 0; i < dev->num_resources; i++) { 76 for (i = 0; i < dev->num_resources; i++) {
79 struct resource *r = &dev->resource[i]; 77 struct resource *r = &dev->resource[i];
80 78
81 if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| 79 if (type == resource_type(r) && !strcmp(r->name, name))
82 IORESOURCE_IRQ|IORESOURCE_DMA)) == type) 80 return r;
83 if (!strcmp(r->name, name))
84 return r;
85 } 81 }
86 return NULL; 82 return NULL;
87} 83}
@@ -259,9 +255,9 @@ int platform_device_add(struct platform_device *pdev)
259 255
260 p = r->parent; 256 p = r->parent;
261 if (!p) { 257 if (!p) {
262 if (r->flags & IORESOURCE_MEM) 258 if (resource_type(r) == IORESOURCE_MEM)
263 p = &iomem_resource; 259 p = &iomem_resource;
264 else if (r->flags & IORESOURCE_IO) 260 else if (resource_type(r) == IORESOURCE_IO)
265 p = &ioport_resource; 261 p = &ioport_resource;
266 } 262 }
267 263
@@ -282,9 +278,14 @@ int platform_device_add(struct platform_device *pdev)
282 return ret; 278 return ret;
283 279
284 failed: 280 failed:
285 while (--i >= 0) 281 while (--i >= 0) {
286 if (pdev->resource[i].flags & (IORESOURCE_MEM|IORESOURCE_IO)) 282 struct resource *r = &pdev->resource[i];
287 release_resource(&pdev->resource[i]); 283 unsigned long type = resource_type(r);
284
285 if (type == IORESOURCE_MEM || type == IORESOURCE_IO)
286 release_resource(r);
287 }
288
288 return ret; 289 return ret;
289} 290}
290EXPORT_SYMBOL_GPL(platform_device_add); 291EXPORT_SYMBOL_GPL(platform_device_add);
@@ -306,7 +307,9 @@ void platform_device_del(struct platform_device *pdev)
306 307
307 for (i = 0; i < pdev->num_resources; i++) { 308 for (i = 0; i < pdev->num_resources; i++) {
308 struct resource *r = &pdev->resource[i]; 309 struct resource *r = &pdev->resource[i];
309 if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO)) 310 unsigned long type = resource_type(r);
311
312 if (type == IORESOURCE_MEM || type == IORESOURCE_IO)
310 release_resource(r); 313 release_resource(r);
311 } 314 }
312 } 315 }
@@ -391,6 +394,53 @@ error:
391} 394}
392EXPORT_SYMBOL_GPL(platform_device_register_simple); 395EXPORT_SYMBOL_GPL(platform_device_register_simple);
393 396
397/**
398 * platform_device_register_data
399 * @parent: parent device for the device we're adding
400 * @name: base name of the device we're adding
401 * @id: instance id
402 * @data: platform specific data for this platform device
403 * @size: size of platform specific data
404 *
405 * This function creates a simple platform device that requires minimal
406 * resource and memory management. Canned release function freeing memory
407 * allocated for the device allows drivers using such devices to be
408 * unloaded without waiting for the last reference to the device to be
409 * dropped.
410 */
411struct platform_device *platform_device_register_data(
412 struct device *parent,
413 const char *name, int id,
414 const void *data, size_t size)
415{
416 struct platform_device *pdev;
417 int retval;
418
419 pdev = platform_device_alloc(name, id);
420 if (!pdev) {
421 retval = -ENOMEM;
422 goto error;
423 }
424
425 pdev->dev.parent = parent;
426
427 if (size) {
428 retval = platform_device_add_data(pdev, data, size);
429 if (retval)
430 goto error;
431 }
432
433 retval = platform_device_add(pdev);
434 if (retval)
435 goto error;
436
437 return pdev;
438
439error:
440 platform_device_put(pdev);
441 return ERR_PTR(retval);
442}
443
394static int platform_drv_probe(struct device *_dev) 444static int platform_drv_probe(struct device *_dev)
395{ 445{
396 struct platform_driver *drv = to_platform_driver(_dev->driver); 446 struct platform_driver *drv = to_platform_driver(_dev->driver);
@@ -862,7 +912,7 @@ static int platform_pm_restore_noirq(struct device *dev)
862 912
863#endif /* !CONFIG_HIBERNATION */ 913#endif /* !CONFIG_HIBERNATION */
864 914
865struct pm_ext_ops platform_pm_ops = { 915static struct pm_ext_ops platform_pm_ops = {
866 .base = { 916 .base = {
867 .prepare = platform_pm_prepare, 917 .prepare = platform_pm_prepare,
868 .complete = platform_pm_complete, 918 .complete = platform_pm_complete,
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 273a944d4040..692c20ba5144 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -83,7 +83,7 @@ void device_pm_add(struct device *dev)
83 * transition is in progress in order to avoid leaving them 83 * transition is in progress in order to avoid leaving them
84 * unhandled down the road 84 * unhandled down the road
85 */ 85 */
86 WARN_ON(true); 86 dev_WARN(dev, "Parentless device registered during a PM transaction\n");
87 } 87 }
88 88
89 list_add_tail(&dev->power.entry, &dpm_list); 89 list_add_tail(&dev->power.entry, &dpm_list);
@@ -778,10 +778,7 @@ EXPORT_SYMBOL_GPL(device_suspend);
778 778
779void __suspend_report_result(const char *function, void *fn, int ret) 779void __suspend_report_result(const char *function, void *fn, int ret)
780{ 780{
781 if (ret) { 781 if (ret)
782 printk(KERN_ERR "%s(): ", function); 782 printk(KERN_ERR "%s(): %pF returns %d\n", function, fn, ret);
783 print_fn_descriptor_symbol("%s returns ", fn);
784 printk("%d\n", ret);
785 }
786} 783}
787EXPORT_SYMBOL_GPL(__suspend_report_result); 784EXPORT_SYMBOL_GPL(__suspend_report_result);
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 1f56d2c5b7fc..200efc4d2c1e 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -284,9 +284,9 @@ aoechr_init(void)
284 return PTR_ERR(aoe_class); 284 return PTR_ERR(aoe_class);
285 } 285 }
286 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 286 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
287 device_create_drvdata(aoe_class, NULL, 287 device_create(aoe_class, NULL,
288 MKDEV(AOE_MAJOR, chardevs[i].minor), 288 MKDEV(AOE_MAJOR, chardevs[i].minor), NULL,
289 NULL, chardevs[i].name); 289 chardevs[i].name);
290 290
291 return 0; 291 return 0;
292} 292}
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index d731ca42f802..9dfa27163001 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -686,9 +686,8 @@ static int __init pg_init(void)
686 for (unit = 0; unit < PG_UNITS; unit++) { 686 for (unit = 0; unit < PG_UNITS; unit++) {
687 struct pg *dev = &devices[unit]; 687 struct pg *dev = &devices[unit];
688 if (dev->present) 688 if (dev->present)
689 device_create_drvdata(pg_class, NULL, 689 device_create(pg_class, NULL, MKDEV(major, unit), NULL,
690 MKDEV(major, unit), NULL, 690 "pg%u", unit);
691 "pg%u", unit);
692 } 691 }
693 err = 0; 692 err = 0;
694 goto out; 693 goto out;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 673b8b2fd337..5ae229656eaa 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -979,12 +979,10 @@ static int __init pt_init(void)
979 979
980 for (unit = 0; unit < PT_UNITS; unit++) 980 for (unit = 0; unit < PT_UNITS; unit++)
981 if (pt[unit].present) { 981 if (pt[unit].present) {
982 device_create_drvdata(pt_class, NULL, 982 device_create(pt_class, NULL, MKDEV(major, unit), NULL,
983 MKDEV(major, unit), NULL, 983 "pt%d", unit);
984 "pt%d", unit); 984 device_create(pt_class, NULL, MKDEV(major, unit + 128),
985 device_create_drvdata(pt_class, NULL, 985 NULL, "pt%dn", unit);
986 MKDEV(major, unit + 128), NULL,
987 "pt%dn", unit);
988 } 986 }
989 goto out; 987 goto out;
990 988
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 0e077150568b..195ca7c720f5 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -302,9 +302,8 @@ static struct kobj_type kobj_pkt_type_wqueue = {
302static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) 302static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
303{ 303{
304 if (class_pktcdvd) { 304 if (class_pktcdvd) {
305 pd->dev = device_create_drvdata(class_pktcdvd, NULL, 305 pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, NULL,
306 pd->pkt_dev, NULL, 306 "%s", pd->name);
307 "%s", pd->name);
308 if (IS_ERR(pd->dev)) 307 if (IS_ERR(pd->dev))
309 pd->dev = NULL; 308 pd->dev = NULL;
310 } 309 }
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 700ff9679457..122254155ae1 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1043,15 +1043,6 @@ config HPET
1043 open selects one of the timers supported by the HPET. The timers are 1043 open selects one of the timers supported by the HPET. The timers are
1044 non-periodic and/or periodic. 1044 non-periodic and/or periodic.
1045 1045
1046config HPET_RTC_IRQ
1047 bool
1048 default HPET_EMULATE_RTC
1049 depends on RTC && HPET
1050 help
1051 If you say Y here, you will disable RTC_IRQ in drivers/char/rtc.c. It
1052 is assumed the platform called hpet_alloc with the RTC IRQ values for
1053 the HPET timers.
1054
1055config HPET_MMAP 1046config HPET_MMAP
1056 bool "Allow mmap of HPET" 1047 bool "Allow mmap of HPET"
1057 default y 1048 default y
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 603a986e96af..3f98254b911f 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -223,12 +223,14 @@ static int amd_irongate_configure(void)
223 223
224 current_size = A_SIZE_LVL2(agp_bridge->current_size); 224 current_size = A_SIZE_LVL2(agp_bridge->current_size);
225 225
226 /* Get the memory mapped registers */ 226 if (!amd_irongate_private.registers) {
227 pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp); 227 /* Get the memory mapped registers */
228 temp = (temp & PCI_BASE_ADDRESS_MEM_MASK); 228 pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp);
229 amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); 229 temp = (temp & PCI_BASE_ADDRESS_MEM_MASK);
230 if (!amd_irongate_private.registers) 230 amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
231 return -ENOMEM; 231 if (!amd_irongate_private.registers)
232 return -ENOMEM;
233 }
232 234
233 /* Write out the address of the gatt table */ 235 /* Write out the address of the gatt table */
234 writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE); 236 writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE);
@@ -492,6 +494,26 @@ static void __devexit agp_amdk7_remove(struct pci_dev *pdev)
492 agp_put_bridge(bridge); 494 agp_put_bridge(bridge);
493} 495}
494 496
497#ifdef CONFIG_PM
498
499static int agp_amdk7_suspend(struct pci_dev *pdev, pm_message_t state)
500{
501 pci_save_state(pdev);
502 pci_set_power_state(pdev, pci_choose_state(pdev, state));
503
504 return 0;
505}
506
507static int agp_amdk7_resume(struct pci_dev *pdev)
508{
509 pci_set_power_state(pdev, PCI_D0);
510 pci_restore_state(pdev);
511
512 return amd_irongate_driver.configure();
513}
514
515#endif /* CONFIG_PM */
516
495/* must be the same order as name table above */ 517/* must be the same order as name table above */
496static struct pci_device_id agp_amdk7_pci_table[] = { 518static struct pci_device_id agp_amdk7_pci_table[] = {
497 { 519 {
@@ -528,6 +550,10 @@ static struct pci_driver agp_amdk7_pci_driver = {
528 .id_table = agp_amdk7_pci_table, 550 .id_table = agp_amdk7_pci_table,
529 .probe = agp_amdk7_probe, 551 .probe = agp_amdk7_probe,
530 .remove = agp_amdk7_remove, 552 .remove = agp_amdk7_remove,
553#ifdef CONFIG_PM
554 .suspend = agp_amdk7_suspend,
555 .resume = agp_amdk7_resume,
556#endif
531}; 557};
532 558
533static int __init agp_amdk7_init(void) 559static int __init agp_amdk7_init(void)
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 043e36628d6d..1108665913e2 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -54,8 +54,7 @@
54 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ 54 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
55 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 55 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
56 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ 56 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \
57 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB || \ 57 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB)
58 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB)
59 58
60#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \ 59#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
61 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \ 60 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
@@ -63,7 +62,8 @@
63 62
64#define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \ 63#define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \
65 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ 64 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \
66 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB) 65 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \
66 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB)
67 67
68extern int agp_memory_reserved; 68extern int agp_memory_reserved;
69 69
@@ -214,8 +214,8 @@ static int intel_i810_configure(void)
214 if (agp_bridge->driver->needs_scratch_page) { 214 if (agp_bridge->driver->needs_scratch_page) {
215 for (i = 0; i < current_size->num_entries; i++) { 215 for (i = 0; i < current_size->num_entries; i++) {
216 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); 216 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
217 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
218 } 217 }
218 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI posting. */
219 } 219 }
220 global_cache_flush(); 220 global_cache_flush();
221 return 0; 221 return 0;
@@ -525,8 +525,10 @@ static void intel_i830_init_gtt_entries(void)
525 size += 4; 525 size += 4;
526 } else if (IS_G4X) { 526 } else if (IS_G4X) {
527 /* On 4 series hardware, GTT stolen is separate from graphics 527 /* On 4 series hardware, GTT stolen is separate from graphics
528 * stolen, ignore it in stolen gtt entries counting */ 528 * stolen, ignore it in stolen gtt entries counting. However,
529 size = 0; 529 * 4KB of the stolen memory doesn't get mapped to the GTT.
530 */
531 size = 4;
530 } else { 532 } else {
531 /* On previous hardware, the GTT size was just what was 533 /* On previous hardware, the GTT size was just what was
532 * required to map the aperture. 534 * required to map the aperture.
@@ -773,8 +775,8 @@ static int intel_i830_configure(void)
773 if (agp_bridge->driver->needs_scratch_page) { 775 if (agp_bridge->driver->needs_scratch_page) {
774 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) { 776 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
775 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); 777 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
776 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
777 } 778 }
779 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI Posting. */
778 } 780 }
779 781
780 global_cache_flush(); 782 global_cache_flush();
@@ -989,8 +991,8 @@ static int intel_i915_configure(void)
989 if (agp_bridge->driver->needs_scratch_page) { 991 if (agp_bridge->driver->needs_scratch_page) {
990 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) { 992 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
991 writel(agp_bridge->scratch_page, intel_private.gtt+i); 993 writel(agp_bridge->scratch_page, intel_private.gtt+i);
992 readl(intel_private.gtt+i); /* PCI Posting. */
993 } 994 }
995 readl(intel_private.gtt+i-1); /* PCI Posting. */
994 } 996 }
995 997
996 global_cache_flush(); 998 global_cache_flush();
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index dc70d3771811..5bbed3d79db9 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -201,10 +201,15 @@ extern int agp_memory_reserved;
201static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 201static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
202{ 202{
203 int i, j; 203 int i, j;
204 int mask_type;
204 205
205 if ((type != 0) || (mem->type != 0)) 206 mask_type = agp_generic_type_to_mask_type(mem->bridge, type);
207 if (mask_type != 0 || type != mem->type)
206 return -EINVAL; 208 return -EINVAL;
207 209
210 if (mem->page_count == 0)
211 return 0;
212
208 if ((pg_start + mem->page_count) > 213 if ((pg_start + mem->page_count) >
209 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE)) 214 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE))
210 return -EINVAL; 215 return -EINVAL;
@@ -220,10 +225,13 @@ static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type
220 } 225 }
221 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 226 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
222 writel(agp_bridge->driver->mask_memory(agp_bridge, 227 writel(agp_bridge->driver->mask_memory(agp_bridge,
223 mem->memory[i], mem->type), 228 mem->memory[i], mask_type),
224 agp_bridge->gatt_table+nvidia_private.pg_offset+j); 229 agp_bridge->gatt_table+nvidia_private.pg_offset+j);
225 readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j); /* PCI Posting. */
226 } 230 }
231
232 /* PCI Posting. */
233 readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j - 1);
234
227 agp_bridge->driver->tlb_flush(mem); 235 agp_bridge->driver->tlb_flush(mem);
228 return 0; 236 return 0;
229} 237}
@@ -233,9 +241,15 @@ static int nvidia_remove_memory(struct agp_memory *mem, off_t pg_start, int type
233{ 241{
234 int i; 242 int i;
235 243
236 if ((type != 0) || (mem->type != 0)) 244 int mask_type;
245
246 mask_type = agp_generic_type_to_mask_type(mem->bridge, type);
247 if (mask_type != 0 || type != mem->type)
237 return -EINVAL; 248 return -EINVAL;
238 249
250 if (mem->page_count == 0)
251 return 0;
252
239 for (i = pg_start; i < (mem->page_count + pg_start); i++) 253 for (i = pg_start; i < (mem->page_count + pg_start); i++)
240 writel(agp_bridge->scratch_page, agp_bridge->gatt_table+nvidia_private.pg_offset+i); 254 writel(agp_bridge->scratch_page, agp_bridge->gatt_table+nvidia_private.pg_offset+i);
241 255
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index b899d9182c7d..05674febb0c6 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -478,7 +478,7 @@ static int do_ac_read(int IndexCard, char __user *buf,
478 struct st_ram_io *st_loc, struct mailbox *mailbox) 478 struct st_ram_io *st_loc, struct mailbox *mailbox)
479{ 479{
480 void __iomem *from = apbs[IndexCard].RamIO + RAM_TO_PC; 480 void __iomem *from = apbs[IndexCard].RamIO + RAM_TO_PC;
481 unsigned char *to = (unsigned char *)&mailbox; 481 unsigned char *to = (unsigned char *)mailbox;
482#ifdef DEBUG 482#ifdef DEBUG
483 int c; 483 int c;
484#endif 484#endif
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index b650b4e48e50..456f54db73e2 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -229,9 +229,8 @@ static int bsr_create_devs(struct device_node *bn)
229 if (result) 229 if (result)
230 goto out_err; 230 goto out_err;
231 231
232 cur->bsr_device = device_create_drvdata(bsr_class, NULL, 232 cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev,
233 cur->bsr_dev, 233 cur, cur->bsr_name);
234 cur, cur->bsr_name);
235 if (!cur->bsr_device) { 234 if (!cur->bsr_device) {
236 printk(KERN_ERR "device_create failed for %s\n", 235 printk(KERN_ERR "device_create failed for %s\n",
237 cur->bsr_name); 236 cur->bsr_name);
diff --git a/drivers/char/ds1286.c b/drivers/char/ds1286.c
index fb584938c9c3..5329d482b582 100644
--- a/drivers/char/ds1286.c
+++ b/drivers/char/ds1286.c
@@ -443,7 +443,6 @@ static void ds1286_get_time(struct rtc_time *rtc_tm)
443{ 443{
444 unsigned char save_control; 444 unsigned char save_control;
445 unsigned long flags; 445 unsigned long flags;
446 unsigned long uip_watchdog = jiffies;
447 446
448 /* 447 /*
449 * read RTC once any update in progress is done. The update 448 * read RTC once any update in progress is done. The update
@@ -456,8 +455,7 @@ static void ds1286_get_time(struct rtc_time *rtc_tm)
456 */ 455 */
457 456
458 if (ds1286_is_updating() != 0) 457 if (ds1286_is_updating() != 0)
459 while (time_before(jiffies, uip_watchdog + 2*HZ/100)) 458 msleep(20);
460 barrier();
461 459
462 /* 460 /*
463 * Only the values that we read from the RTC are set. We leave 461 * Only the values that we read from the RTC are set. We leave
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index ca7c72a486b2..85832ab924e6 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -508,8 +508,8 @@ static int __init dsp56k_init_driver(void)
508 err = PTR_ERR(dsp56k_class); 508 err = PTR_ERR(dsp56k_class);
509 goto out_chrdev; 509 goto out_chrdev;
510 } 510 }
511 device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), 511 device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL,
512 NULL, "dsp56k"); 512 "dsp56k");
513 513
514 printk(banner); 514 printk(banner);
515 goto out; 515 goto out;
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 51738bdd834e..d4e7dca06e4f 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -118,18 +118,21 @@ static int __init omap_rng_probe(struct platform_device *pdev)
118 118
119 mem = request_mem_region(res->start, res->end - res->start + 1, 119 mem = request_mem_region(res->start, res->end - res->start + 1,
120 pdev->name); 120 pdev->name);
121 if (mem == NULL) 121 if (mem == NULL) {
122 return -EBUSY; 122 ret = -EBUSY;
123 goto err_region;
124 }
123 125
124 dev_set_drvdata(&pdev->dev, mem); 126 dev_set_drvdata(&pdev->dev, mem);
125 rng_base = (u32 __force __iomem *)io_p2v(res->start); 127 rng_base = ioremap(res->start, res->end - res->start + 1);
128 if (!rng_base) {
129 ret = -ENOMEM;
130 goto err_ioremap;
131 }
126 132
127 ret = hwrng_register(&omap_rng_ops); 133 ret = hwrng_register(&omap_rng_ops);
128 if (ret) { 134 if (ret)
129 release_resource(mem); 135 goto err_register;
130 rng_base = NULL;
131 return ret;
132 }
133 136
134 dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n", 137 dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
135 omap_rng_read_reg(RNG_REV_REG)); 138 omap_rng_read_reg(RNG_REV_REG));
@@ -138,6 +141,18 @@ static int __init omap_rng_probe(struct platform_device *pdev)
138 rng_dev = pdev; 141 rng_dev = pdev;
139 142
140 return 0; 143 return 0;
144
145err_register:
146 iounmap(rng_base);
147 rng_base = NULL;
148err_ioremap:
149 release_resource(mem);
150err_region:
151 if (cpu_is_omap24xx()) {
152 clk_disable(rng_ick);
153 clk_put(rng_ick);
154 }
155 return ret;
141} 156}
142 157
143static int __exit omap_rng_remove(struct platform_device *pdev) 158static int __exit omap_rng_remove(struct platform_device *pdev)
@@ -148,6 +163,8 @@ static int __exit omap_rng_remove(struct platform_device *pdev)
148 163
149 omap_rng_write_reg(RNG_MASK_REG, 0x0); 164 omap_rng_write_reg(RNG_MASK_REG, 0x0);
150 165
166 iounmap(rng_base);
167
151 if (cpu_is_omap24xx()) { 168 if (cpu_is_omap24xx()) {
152 clk_disable(rng_ick); 169 clk_disable(rng_ick);
153 clk_put(rng_ick); 170 clk_put(rng_ick);
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 6774572d3759..70e0ebc30bd0 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -745,12 +745,12 @@ static int __init ip2_loadmain(void)
745 745
746 pB = i2BoardPtrTable[i]; 746 pB = i2BoardPtrTable[i];
747 if (pB != NULL) { 747 if (pB != NULL) {
748 device_create_drvdata(ip2_class, NULL, 748 device_create(ip2_class, NULL,
749 MKDEV(IP2_IPL_MAJOR, 4 * i), 749 MKDEV(IP2_IPL_MAJOR, 4 * i),
750 NULL, "ipl%d", i); 750 NULL, "ipl%d", i);
751 device_create_drvdata(ip2_class, NULL, 751 device_create(ip2_class, NULL,
752 MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 752 MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
753 NULL, "stat%d", i); 753 NULL, "stat%d", i);
754 754
755 for (box = 0; box < ABS_MAX_BOXES; box++) 755 for (box = 0; box < ABS_MAX_BOXES; box++)
756 for (j = 0; j < ABS_BIGGEST_BOX; j++) 756 for (j = 0; j < ABS_BIGGEST_BOX; j++)
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 64e1c169e826..835a33c8d5f5 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
871 entry->dev = dev; 871 entry->dev = dev;
872 872
873 mutex_lock(&reg_list_mutex); 873 mutex_lock(&reg_list_mutex);
874 device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num); 874 device_create(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
875 list_add(&entry->link, &reg_list); 875 list_add(&entry->link, &reg_list);
876 mutex_unlock(&reg_list_mutex); 876 mutex_unlock(&reg_list_mutex);
877} 877}
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 505d7a1f6b8c..44e5d60f517e 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -4600,9 +4600,8 @@ static int __init istallion_module_init(void)
4600 4600
4601 istallion_class = class_create(THIS_MODULE, "staliomem"); 4601 istallion_class = class_create(THIS_MODULE, "staliomem");
4602 for (i = 0; i < 4; i++) 4602 for (i = 0; i < 4; i++)
4603 device_create_drvdata(istallion_class, NULL, 4603 device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4604 MKDEV(STL_SIOMEMMAJOR, i), 4604 NULL, "staliomem%d", i);
4605 NULL, "staliomem%d", i);
4606 4605
4607 return 0; 4606 return 0;
4608err_deinit: 4607err_deinit:
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 7b3a212c86b1..de26a978fbdd 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1249,7 +1249,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1249 return; 1249 return;
1250 } 1250 }
1251 1251
1252 if (keycode > NR_KEYS) 1252 if (keycode >= NR_KEYS)
1253 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8) 1253 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
1254 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1); 1254 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1);
1255 else 1255 else
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 3f2719b9f77b..e444c2dba160 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -813,8 +813,8 @@ static int lp_register(int nr, struct parport *port)
813 if (reset) 813 if (reset)
814 lp_reset(nr); 814 lp_reset(nr);
815 815
816 device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, 816 device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
817 "lp%d", nr); 817 "lp%d", nr);
818 818
819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); 820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 672b08e694d0..6431f6921a67 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -992,9 +992,9 @@ static int __init chr_dev_init(void)
992 992
993 mem_class = class_create(THIS_MODULE, "mem"); 993 mem_class = class_create(THIS_MODULE, "mem");
994 for (i = 0; i < ARRAY_SIZE(devlist); i++) 994 for (i = 0; i < ARRAY_SIZE(devlist); i++)
995 device_create_drvdata(mem_class, NULL, 995 device_create(mem_class, NULL,
996 MKDEV(MEM_MAJOR, devlist[i].minor), 996 MKDEV(MEM_MAJOR, devlist[i].minor), NULL,
997 NULL, devlist[i].name); 997 devlist[i].name);
998 998
999 return 0; 999 return 0;
1000} 1000}
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 999aa779c08a..a5e0db9d7662 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
218 dev = MKDEV(MISC_MAJOR, misc->minor); 218 dev = MKDEV(MISC_MAJOR, misc->minor);
219 219
220 misc->this_device = device_create_drvdata(misc_class, misc->parent, 220 misc->this_device = device_create(misc_class, misc->parent, dev, NULL,
221 dev, NULL, "%s", misc->name); 221 "%s", misc->name);
222 if (IS_ERR(misc->this_device)) { 222 if (IS_ERR(misc->this_device)) {
223 err = PTR_ERR(misc->this_device); 223 err = PTR_ERR(misc->this_device);
224 goto out; 224 goto out;
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 5df4003ad873..12d327a2c9ba 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -513,7 +513,7 @@ static int moxa_real_load_code(struct moxa_board_conf *brd, const void *ptr,
513 size_t len) 513 size_t len)
514{ 514{
515 void __iomem *baseAddr = brd->basemem; 515 void __iomem *baseAddr = brd->basemem;
516 const u16 *uptr = ptr; 516 const __le16 *uptr = ptr;
517 size_t wlen, len2, j; 517 size_t wlen, len2, j;
518 unsigned long key, loadbuf, loadlen, checksum, checksum_ok; 518 unsigned long key, loadbuf, loadlen, checksum, checksum_ok;
519 unsigned int i, retry; 519 unsigned int i, retry;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 1c5bf99895ed..dbb912574569 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1871,7 +1871,7 @@ static int cm4000_probe(struct pcmcia_device *link)
1871 return ret; 1871 return ret;
1872 } 1872 }
1873 1873
1874 device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i); 1874 device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
1875 1875
1876 return 0; 1876 return 0;
1877} 1877}
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 2d7c906435b7..4f0723b07974 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -637,8 +637,7 @@ static int reader_probe(struct pcmcia_device *link)
637 return ret; 637 return ret;
638 } 638 }
639 639
640 device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL, 640 device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i);
641 "cmx%d", i);
642 641
643 return 0; 642 return 0;
644} 643}
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index bee39fdfba73..c84c34fb1231 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -760,9 +760,8 @@ static const struct file_operations pp_fops = {
760 760
761static void pp_attach(struct parport *port) 761static void pp_attach(struct parport *port)
762{ 762{
763 device_create_drvdata(ppdev_class, port->dev, 763 device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
764 MKDEV(PP_MAJOR, port->number), 764 NULL, "parport%d", port->number);
765 NULL, "parport%d", port->number);
766} 765}
767 766
768static void pp_detach(struct parport *port) 767static void pp_detach(struct parport *port)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 6af435b89867..c8752eaad483 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1205,7 +1205,7 @@ static int proc_do_uuid(ctl_table *table, int write, struct file *filp,
1205 return proc_dostring(&fake_table, write, filp, buffer, lenp, ppos); 1205 return proc_dostring(&fake_table, write, filp, buffer, lenp, ppos);
1206} 1206}
1207 1207
1208static int uuid_strategy(ctl_table *table, int __user *name, int nlen, 1208static int uuid_strategy(ctl_table *table,
1209 void __user *oldval, size_t __user *oldlenp, 1209 void __user *oldval, size_t __user *oldlenp,
1210 void __user *newval, size_t newlen) 1210 void __user *newval, size_t newlen)
1211{ 1211{
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 47b8cf281d4a..e139372d0e69 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
131static void bind_device(struct raw_config_request *rq) 131static void bind_device(struct raw_config_request *rq)
132{ 132{
133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
134 device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), 134 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL,
135 NULL, "raw%d", rq->raw_minor); 135 "raw%d", rq->raw_minor);
136} 136}
137 137
138/* 138/*
@@ -283,8 +283,7 @@ static int __init raw_init(void)
283 ret = PTR_ERR(raw_class); 283 ret = PTR_ERR(raw_class);
284 goto error_region; 284 goto error_region;
285 } 285 }
286 device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, 286 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
287 "rawctl");
288 287
289 return 0; 288 return 0;
290 289
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index b47710c17885..17683de95717 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -96,7 +96,7 @@ static unsigned long rtc_port;
96static int rtc_irq; 96static int rtc_irq;
97#endif 97#endif
98 98
99#ifdef CONFIG_HPET_RTC_IRQ 99#ifdef CONFIG_HPET_EMULATE_RTC
100#undef RTC_IRQ 100#undef RTC_IRQ
101#endif 101#endif
102 102
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 3ce60df14c0a..32b74de18f5f 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -444,8 +444,8 @@ scdrv_init(void)
444 continue; 444 continue;
445 } 445 }
446 446
447 device_create_drvdata(snsc_class, NULL, dev, NULL, 447 device_create(snsc_class, NULL, dev, NULL,
448 "%s", devname); 448 "%s", devname);
449 449
450 ia64_sn_irtr_intr_enable(scd->scd_nasid, 450 ia64_sn_irtr_intr_enable(scd->scd_nasid,
451 0 /*ignored */ , 451 0 /*ignored */ ,
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 8b8f07a7f505..963b03fb29e5 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -4743,8 +4743,8 @@ static int __init stallion_module_init(void)
4743 if (IS_ERR(stallion_class)) 4743 if (IS_ERR(stallion_class))
4744 printk("STALLION: failed to create class\n"); 4744 printk("STALLION: failed to create class\n");
4745 for (i = 0; i < 4; i++) 4745 for (i = 0; i < 4; i++)
4746 device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4746 device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4747 NULL, "staliomem%d", i); 4747 NULL, "staliomem%d", i);
4748 4748
4749 return 0; 4749 return 0;
4750err_unrtty: 4750err_unrtty:
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 8fdfe9c871e3..dce4cc0e6953 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -23,6 +23,7 @@
23#include <linux/reboot.h> 23#include <linux/reboot.h>
24#include <linux/sysrq.h> 24#include <linux/sysrq.h>
25#include <linux/kbd_kern.h> 25#include <linux/kbd_kern.h>
26#include <linux/proc_fs.h>
26#include <linux/quotaops.h> 27#include <linux/quotaops.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/module.h> 29#include <linux/module.h>
@@ -326,6 +327,7 @@ static struct sysrq_key_op sysrq_moom_op = {
326 .handler = sysrq_handle_moom, 327 .handler = sysrq_handle_moom,
327 .help_msg = "Full", 328 .help_msg = "Full",
328 .action_msg = "Manual OOM execution", 329 .action_msg = "Manual OOM execution",
330 .enable_mask = SYSRQ_ENABLE_SIGNAL,
329}; 331};
330 332
331static void sysrq_handle_kill(int key, struct tty_struct *tty) 333static void sysrq_handle_kill(int key, struct tty_struct *tty)
@@ -533,3 +535,32 @@ int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
533 return __sysrq_swap_key_ops(key, NULL, op_p); 535 return __sysrq_swap_key_ops(key, NULL, op_p);
534} 536}
535EXPORT_SYMBOL(unregister_sysrq_key); 537EXPORT_SYMBOL(unregister_sysrq_key);
538
539#ifdef CONFIG_PROC_FS
540/*
541 * writing 'C' to /proc/sysrq-trigger is like sysrq-C
542 */
543static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
544 size_t count, loff_t *ppos)
545{
546 if (count) {
547 char c;
548
549 if (get_user(c, buf))
550 return -EFAULT;
551 __handle_sysrq(c, NULL, 0);
552 }
553 return count;
554}
555
556static const struct file_operations proc_sysrq_trigger_operations = {
557 .write = write_sysrq_trigger,
558};
559
560static int __init sysrq_init(void)
561{
562 proc_create("sysrq-trigger", S_IWUSR, NULL, &proc_sysrq_trigger_operations);
563 return 0;
564}
565module_init(sysrq_init);
566#endif
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 1fee7034a386..e70d13defde4 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -525,19 +525,19 @@ void tpm_get_timeouts(struct tpm_chip *chip)
525 timeout = 525 timeout =
526 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX))); 526 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
527 if (timeout) 527 if (timeout)
528 chip->vendor.timeout_a = msecs_to_jiffies(timeout); 528 chip->vendor.timeout_a = usecs_to_jiffies(timeout);
529 timeout = 529 timeout =
530 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX))); 530 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
531 if (timeout) 531 if (timeout)
532 chip->vendor.timeout_b = msecs_to_jiffies(timeout); 532 chip->vendor.timeout_b = usecs_to_jiffies(timeout);
533 timeout = 533 timeout =
534 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX))); 534 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
535 if (timeout) 535 if (timeout)
536 chip->vendor.timeout_c = msecs_to_jiffies(timeout); 536 chip->vendor.timeout_c = usecs_to_jiffies(timeout);
537 timeout = 537 timeout =
538 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX))); 538 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
539 if (timeout) 539 if (timeout)
540 chip->vendor.timeout_d = msecs_to_jiffies(timeout); 540 chip->vendor.timeout_d = usecs_to_jiffies(timeout);
541 541
542duration: 542duration:
543 memcpy(data, tpm_cap, sizeof(tpm_cap)); 543 memcpy(data, tpm_cap, sizeof(tpm_cap));
@@ -554,15 +554,22 @@ duration:
554 return; 554 return;
555 555
556 chip->vendor.duration[TPM_SHORT] = 556 chip->vendor.duration[TPM_SHORT] =
557 msecs_to_jiffies(be32_to_cpu 557 usecs_to_jiffies(be32_to_cpu
558 (*((__be32 *) (data + 558 (*((__be32 *) (data +
559 TPM_GET_CAP_RET_UINT32_1_IDX)))); 559 TPM_GET_CAP_RET_UINT32_1_IDX))));
560 /* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above
561 * value wrong and apparently reports msecs rather than usecs. So we
562 * fix up the resulting too-small TPM_SHORT value to make things work.
563 */
564 if (chip->vendor.duration[TPM_SHORT] < (HZ/100))
565 chip->vendor.duration[TPM_SHORT] = HZ;
566
560 chip->vendor.duration[TPM_MEDIUM] = 567 chip->vendor.duration[TPM_MEDIUM] =
561 msecs_to_jiffies(be32_to_cpu 568 usecs_to_jiffies(be32_to_cpu
562 (*((__be32 *) (data + 569 (*((__be32 *) (data +
563 TPM_GET_CAP_RET_UINT32_2_IDX)))); 570 TPM_GET_CAP_RET_UINT32_2_IDX))));
564 chip->vendor.duration[TPM_LONG] = 571 chip->vendor.duration[TPM_LONG] =
565 msecs_to_jiffies(be32_to_cpu 572 usecs_to_jiffies(be32_to_cpu
566 (*((__be32 *) (data + 573 (*((__be32 *) (data +
567 TPM_GET_CAP_RET_UINT32_3_IDX)))); 574 TPM_GET_CAP_RET_UINT32_3_IDX))));
568} 575}
@@ -1180,11 +1187,8 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1180 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1187 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1181 devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); 1188 devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);
1182 1189
1183 if (chip == NULL || devname == NULL) { 1190 if (chip == NULL || devname == NULL)
1184 kfree(chip); 1191 goto out_free;
1185 kfree(devname);
1186 return NULL;
1187 }
1188 1192
1189 mutex_init(&chip->buffer_mutex); 1193 mutex_init(&chip->buffer_mutex);
1190 mutex_init(&chip->tpm_mutex); 1194 mutex_init(&chip->tpm_mutex);
@@ -1201,8 +1205,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1201 1205
1202 if (chip->dev_num >= TPM_NUM_DEVICES) { 1206 if (chip->dev_num >= TPM_NUM_DEVICES) {
1203 dev_err(dev, "No available tpm device numbers\n"); 1207 dev_err(dev, "No available tpm device numbers\n");
1204 kfree(chip); 1208 goto out_free;
1205 return NULL;
1206 } else if (chip->dev_num == 0) 1209 } else if (chip->dev_num == 0)
1207 chip->vendor.miscdev.minor = TPM_MINOR; 1210 chip->vendor.miscdev.minor = TPM_MINOR;
1208 else 1211 else
@@ -1243,6 +1246,11 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1243 spin_unlock(&driver_lock); 1246 spin_unlock(&driver_lock);
1244 1247
1245 return chip; 1248 return chip;
1249
1250out_free:
1251 kfree(chip);
1252 kfree(devname);
1253 return NULL;
1246} 1254}
1247EXPORT_SYMBOL_GPL(tpm_register_hardware); 1255EXPORT_SYMBOL_GPL(tpm_register_hardware);
1248 1256
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 3f48d88cffc0..59f472143f08 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2850,7 +2850,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
2850 else 2850 else
2851 tty_line_name(driver, index, name); 2851 tty_line_name(driver, index, name);
2852 2852
2853 return device_create_drvdata(tty_class, device, dev, NULL, name); 2853 return device_create(tty_class, device, dev, NULL, name);
2854} 2854}
2855EXPORT_SYMBOL(tty_register_device); 2855EXPORT_SYMBOL(tty_register_device);
2856 2856
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index c2ae52dd53d1..4f3b3f95fc42 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -481,10 +481,10 @@ static struct class *vc_class;
481 481
482void vcs_make_sysfs(struct tty_struct *tty) 482void vcs_make_sysfs(struct tty_struct *tty)
483{ 483{
484 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 484 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), NULL,
485 NULL, "vcs%u", tty->index + 1); 485 "vcs%u", tty->index + 1);
486 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 486 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), NULL,
487 NULL, "vcsa%u", tty->index + 1); 487 "vcsa%u", tty->index + 1);
488} 488}
489 489
490void vcs_remove_sysfs(struct tty_struct *tty) 490void vcs_remove_sysfs(struct tty_struct *tty)
@@ -499,7 +499,7 @@ int __init vcs_init(void)
499 panic("unable to get major %d for vcs device", VCS_MAJOR); 499 panic("unable to get major %d for vcs device", VCS_MAJOR);
500 vc_class = class_create(THIS_MODULE, "vc"); 500 vc_class = class_create(THIS_MODULE, "vc");
501 501
502 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 502 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
503 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 503 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
504 return 0; 504 return 0;
505} 505}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 7a70a40ad639..ffc9254f7e02 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
886 state[i].cur_part = 0; 886 state[i].cur_part = 0;
887 for (j = 0; j < MAX_PARTITIONS; ++j) 887 for (j = 0; j < MAX_PARTITIONS; ++j)
888 state[i].part_stat_rwi[j] = VIOT_IDLE; 888 state[i].part_stat_rwi[j] = VIOT_IDLE;
889 device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), 889 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL,
890 NULL, "iseries!vt%d", i); 890 "iseries!vt%d", i);
891 device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 891 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), NULL,
892 NULL, "iseries!nvt%d", i); 892 "iseries!nvt%d", i);
893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " 893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
894 "resource %10.10s type %4.4s, model %3.3s\n", 894 "resource %10.10s type %4.4s, model %3.3s\n",
895 i, viotape_unitinfo[i].rsrcname, 895 i, viotape_unitinfo[i].rsrcname,
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index a0f7ffb68087..d8f83e26e4a4 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -59,7 +59,7 @@
59 * by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998 59 * by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998
60 * 60 *
61 * Removed old-style timers, introduced console_timer, made timer 61 * Removed old-style timers, introduced console_timer, made timer
62 * deletion SMP-safe. 17Jun00, Andrew Morton <andrewm@uow.edu.au> 62 * deletion SMP-safe. 17Jun00, Andrew Morton
63 * 63 *
64 * Removed console_lock, enabled interrupts across all console operations 64 * Removed console_lock, enabled interrupts across all console operations
65 * 13 March 2001, Andrew Morton 65 * 13 March 2001, Andrew Morton
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 278c9857bcf5..ed132fe55d3d 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -657,8 +657,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
657 goto failed3; 657 goto failed3;
658 } 658 }
659 659
660 device_create_drvdata(icap_class, dev, devt, NULL, 660 device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
661 "%s%d", DRIVER_NAME, id);
662 return 0; /* success */ 661 return 0; /* success */
663 662
664 failed3: 663 failed3:
diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index 7af4b403bd2d..bb538b9690e0 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -15,9 +15,8 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot)
15 struct device *cd; 15 struct device *cd;
16 static int req_count; 16 static int req_count;
17 17
18 cd = device_create_drvdata(dca_class, dca->cd, 18 cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), NULL,
19 MKDEV(0, slot + 1), NULL, 19 "requester%d", req_count++);
20 "requester%d", req_count++);
21 if (IS_ERR(cd)) 20 if (IS_ERR(cd))
22 return PTR_ERR(cd); 21 return PTR_ERR(cd);
23 return 0; 22 return 0;
@@ -48,8 +47,7 @@ idr_try_again:
48 return err; 47 return err;
49 } 48 }
50 49
51 cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL, 50 cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
52 "dca%d", dca->id);
53 if (IS_ERR(cd)) { 51 if (IS_ERR(cd)) {
54 spin_lock(&dca_idr_lock); 52 spin_lock(&dca_idr_lock);
55 idr_remove(&dca_idr, dca->id); 53 idr_remove(&dca_idr, dca->id);
diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 4a16b5b61cfb..f0d9b415db50 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -119,6 +119,7 @@
119#define FERR_NF_UNCORRECTABLE (FERR_NF_M12ERR | \ 119#define FERR_NF_UNCORRECTABLE (FERR_NF_M12ERR | \
120 FERR_NF_M11ERR | \ 120 FERR_NF_M11ERR | \
121 FERR_NF_M10ERR | \ 121 FERR_NF_M10ERR | \
122 FERR_NF_M9ERR | \
122 FERR_NF_M8ERR | \ 123 FERR_NF_M8ERR | \
123 FERR_NF_M7ERR | \ 124 FERR_NF_M7ERR | \
124 FERR_NF_M6ERR | \ 125 FERR_NF_M6ERR | \
@@ -301,6 +302,9 @@ static char *numcol_toString[] = {
301}; 302};
302#endif 303#endif
303 304
305/* enables the report of miscellaneous messages as CE errors - default off */
306static int misc_messages;
307
304/* Enumeration of supported devices */ 308/* Enumeration of supported devices */
305enum i5000_chips { 309enum i5000_chips {
306 I5000P = 0, 310 I5000P = 0,
@@ -466,7 +470,8 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci,
466 struct i5000_error_info *info, 470 struct i5000_error_info *info,
467 int handle_errors) 471 int handle_errors)
468{ 472{
469 char msg[EDAC_MC_LABEL_LEN + 1 + 90]; 473 char msg[EDAC_MC_LABEL_LEN + 1 + 160];
474 char *specific = NULL;
470 u32 allErrors; 475 u32 allErrors;
471 int branch; 476 int branch;
472 int channel; 477 int channel;
@@ -480,11 +485,6 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci,
480 if (!allErrors) 485 if (!allErrors)
481 return; /* if no error, return now */ 486 return; /* if no error, return now */
482 487
483 /* ONLY ONE of the possible error bits will be set, as per the docs */
484 i5000_mc_printk(mci, KERN_ERR,
485 "FATAL ERRORS Found!!! 1st FATAL Err Reg= 0x%x\n",
486 allErrors);
487
488 branch = EXTRACT_FBDCHAN_INDX(info->ferr_fat_fbd); 488 branch = EXTRACT_FBDCHAN_INDX(info->ferr_fat_fbd);
489 channel = branch; 489 channel = branch;
490 490
@@ -501,28 +501,42 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci,
501 rdwr ? "Write" : "Read", ras, cas); 501 rdwr ? "Write" : "Read", ras, cas);
502 502
503 /* Only 1 bit will be on */ 503 /* Only 1 bit will be on */
504 if (allErrors & FERR_FAT_M1ERR) { 504 switch (allErrors) {
505 i5000_mc_printk(mci, KERN_ERR, 505 case FERR_FAT_M1ERR:
506 "Alert on non-redundant retry or fast " 506 specific = "Alert on non-redundant retry or fast "
507 "reset timeout\n"); 507 "reset timeout";
508 508 break;
509 } else if (allErrors & FERR_FAT_M2ERR) { 509 case FERR_FAT_M2ERR:
510 i5000_mc_printk(mci, KERN_ERR, 510 specific = "Northbound CRC error on non-redundant "
511 "Northbound CRC error on non-redundant " 511 "retry";
512 "retry\n"); 512 break;
513 513 case FERR_FAT_M3ERR:
514 } else if (allErrors & FERR_FAT_M3ERR) { 514 {
515 i5000_mc_printk(mci, KERN_ERR, 515 static int done;
516 ">Tmid Thermal event with intelligent " 516
517 "throttling disabled\n"); 517 /*
518 * This error is generated to inform that the intelligent
519 * throttling is disabled and the temperature passed the
520 * specified middle point. Since this is something the BIOS
521 * should take care of, we'll warn only once to avoid
522 * worthlessly flooding the log.
523 */
524 if (done)
525 return;
526 done++;
527
528 specific = ">Tmid Thermal event with intelligent "
529 "throttling disabled";
530 }
531 break;
518 } 532 }
519 533
520 /* Form out message */ 534 /* Form out message */
521 snprintf(msg, sizeof(msg), 535 snprintf(msg, sizeof(msg),
522 "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d CAS=%d " 536 "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d CAS=%d "
523 "FATAL Err=0x%x)", 537 "FATAL Err=0x%x (%s))",
524 branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas, 538 branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas,
525 allErrors); 539 allErrors, specific);
526 540
527 /* Call the helper to output message */ 541 /* Call the helper to output message */
528 edac_mc_handle_fbd_ue(mci, rank, channel, channel + 1, msg); 542 edac_mc_handle_fbd_ue(mci, rank, channel, channel + 1, msg);
@@ -539,7 +553,8 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
539 struct i5000_error_info *info, 553 struct i5000_error_info *info,
540 int handle_errors) 554 int handle_errors)
541{ 555{
542 char msg[EDAC_MC_LABEL_LEN + 1 + 90]; 556 char msg[EDAC_MC_LABEL_LEN + 1 + 170];
557 char *specific = NULL;
543 u32 allErrors; 558 u32 allErrors;
544 u32 ue_errors; 559 u32 ue_errors;
545 u32 ce_errors; 560 u32 ce_errors;
@@ -557,10 +572,6 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
557 return; /* if no error, return now */ 572 return; /* if no error, return now */
558 573
559 /* ONLY ONE of the possible error bits will be set, as per the docs */ 574 /* ONLY ONE of the possible error bits will be set, as per the docs */
560 i5000_mc_printk(mci, KERN_WARNING,
561 "NON-FATAL ERRORS Found!!! 1st NON-FATAL Err "
562 "Reg= 0x%x\n", allErrors);
563
564 ue_errors = allErrors & FERR_NF_UNCORRECTABLE; 575 ue_errors = allErrors & FERR_NF_UNCORRECTABLE;
565 if (ue_errors) { 576 if (ue_errors) {
566 debugf0("\tUncorrected bits= 0x%x\n", ue_errors); 577 debugf0("\tUncorrected bits= 0x%x\n", ue_errors);
@@ -579,12 +590,47 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
579 rank, channel, channel + 1, branch >> 1, bank, 590 rank, channel, channel + 1, branch >> 1, bank,
580 rdwr ? "Write" : "Read", ras, cas); 591 rdwr ? "Write" : "Read", ras, cas);
581 592
593 switch (ue_errors) {
594 case FERR_NF_M12ERR:
595 specific = "Non-Aliased Uncorrectable Patrol Data ECC";
596 break;
597 case FERR_NF_M11ERR:
598 specific = "Non-Aliased Uncorrectable Spare-Copy "
599 "Data ECC";
600 break;
601 case FERR_NF_M10ERR:
602 specific = "Non-Aliased Uncorrectable Mirrored Demand "
603 "Data ECC";
604 break;
605 case FERR_NF_M9ERR:
606 specific = "Non-Aliased Uncorrectable Non-Mirrored "
607 "Demand Data ECC";
608 break;
609 case FERR_NF_M8ERR:
610 specific = "Aliased Uncorrectable Patrol Data ECC";
611 break;
612 case FERR_NF_M7ERR:
613 specific = "Aliased Uncorrectable Spare-Copy Data ECC";
614 break;
615 case FERR_NF_M6ERR:
616 specific = "Aliased Uncorrectable Mirrored Demand "
617 "Data ECC";
618 break;
619 case FERR_NF_M5ERR:
620 specific = "Aliased Uncorrectable Non-Mirrored Demand "
621 "Data ECC";
622 break;
623 case FERR_NF_M4ERR:
624 specific = "Uncorrectable Data ECC on Replay";
625 break;
626 }
627
582 /* Form out message */ 628 /* Form out message */
583 snprintf(msg, sizeof(msg), 629 snprintf(msg, sizeof(msg),
584 "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d " 630 "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d "
585 "CAS=%d, UE Err=0x%x)", 631 "CAS=%d, UE Err=0x%x (%s))",
586 branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas, 632 branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas,
587 ue_errors); 633 ue_errors, specific);
588 634
589 /* Call the helper to output message */ 635 /* Call the helper to output message */
590 edac_mc_handle_fbd_ue(mci, rank, channel, channel + 1, msg); 636 edac_mc_handle_fbd_ue(mci, rank, channel, channel + 1, msg);
@@ -616,51 +662,74 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
616 rank, channel, branch >> 1, bank, 662 rank, channel, branch >> 1, bank,
617 rdwr ? "Write" : "Read", ras, cas); 663 rdwr ? "Write" : "Read", ras, cas);
618 664
665 switch (ce_errors) {
666 case FERR_NF_M17ERR:
667 specific = "Correctable Non-Mirrored Demand Data ECC";
668 break;
669 case FERR_NF_M18ERR:
670 specific = "Correctable Mirrored Demand Data ECC";
671 break;
672 case FERR_NF_M19ERR:
673 specific = "Correctable Spare-Copy Data ECC";
674 break;
675 case FERR_NF_M20ERR:
676 specific = "Correctable Patrol Data ECC";
677 break;
678 }
679
619 /* Form out message */ 680 /* Form out message */
620 snprintf(msg, sizeof(msg), 681 snprintf(msg, sizeof(msg),
621 "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d " 682 "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d "
622 "CAS=%d, CE Err=0x%x)", branch >> 1, bank, 683 "CAS=%d, CE Err=0x%x (%s))", branch >> 1, bank,
623 rdwr ? "Write" : "Read", ras, cas, ce_errors); 684 rdwr ? "Write" : "Read", ras, cas, ce_errors,
685 specific);
624 686
625 /* Call the helper to output message */ 687 /* Call the helper to output message */
626 edac_mc_handle_fbd_ce(mci, rank, channel, msg); 688 edac_mc_handle_fbd_ce(mci, rank, channel, msg);
627 } 689 }
628 690
629 /* See if any of the thermal errors have fired */ 691 if (!misc_messages)
630 misc_errors = allErrors & FERR_NF_THERMAL; 692 return;
631 if (misc_errors) {
632 i5000_printk(KERN_WARNING, "\tTHERMAL Error, bits= 0x%x\n",
633 misc_errors);
634 }
635
636 /* See if any of the thermal errors have fired */
637 misc_errors = allErrors & FERR_NF_NON_RETRY;
638 if (misc_errors) {
639 i5000_printk(KERN_WARNING, "\tNON-Retry Errors, bits= 0x%x\n",
640 misc_errors);
641 }
642 693
643 /* See if any of the thermal errors have fired */ 694 misc_errors = allErrors & (FERR_NF_NON_RETRY | FERR_NF_NORTH_CRC |
644 misc_errors = allErrors & FERR_NF_NORTH_CRC; 695 FERR_NF_SPD_PROTOCOL | FERR_NF_DIMM_SPARE);
645 if (misc_errors) { 696 if (misc_errors) {
646 i5000_printk(KERN_WARNING, 697 switch (misc_errors) {
647 "\tNORTHBOUND CRC Error, bits= 0x%x\n", 698 case FERR_NF_M13ERR:
648 misc_errors); 699 specific = "Non-Retry or Redundant Retry FBD Memory "
649 } 700 "Alert or Redundant Fast Reset Timeout";
701 break;
702 case FERR_NF_M14ERR:
703 specific = "Non-Retry or Redundant Retry FBD "
704 "Configuration Alert";
705 break;
706 case FERR_NF_M15ERR:
707 specific = "Non-Retry or Redundant Retry FBD "
708 "Northbound CRC error on read data";
709 break;
710 case FERR_NF_M21ERR:
711 specific = "FBD Northbound CRC error on "
712 "FBD Sync Status";
713 break;
714 case FERR_NF_M22ERR:
715 specific = "SPD protocol error";
716 break;
717 case FERR_NF_M27ERR:
718 specific = "DIMM-spare copy started";
719 break;
720 case FERR_NF_M28ERR:
721 specific = "DIMM-spare copy completed";
722 break;
723 }
724 branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd);
650 725
651 /* See if any of the thermal errors have fired */ 726 /* Form out message */
652 misc_errors = allErrors & FERR_NF_SPD_PROTOCOL; 727 snprintf(msg, sizeof(msg),
653 if (misc_errors) { 728 "(Branch=%d Err=%#x (%s))", branch >> 1,
654 i5000_printk(KERN_WARNING, 729 misc_errors, specific);
655 "\tSPD Protocol Error, bits= 0x%x\n",
656 misc_errors);
657 }
658 730
659 /* See if any of the thermal errors have fired */ 731 /* Call the helper to output message */
660 misc_errors = allErrors & FERR_NF_DIMM_SPARE; 732 edac_mc_handle_fbd_ce(mci, 0, 0, msg);
661 if (misc_errors) {
662 i5000_printk(KERN_WARNING, "\tDIMM-Spare Error, bits= 0x%x\n",
663 misc_errors);
664 } 733 }
665} 734}
666 735
@@ -1497,3 +1566,6 @@ MODULE_DESCRIPTION("MC Driver for Intel I5000 memory controllers - "
1497 1566
1498module_param(edac_op_state, int, 0444); 1567module_param(edac_op_state, int, 0444);
1499MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); 1568MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");
1569module_param(misc_messages, int, 0444);
1570MODULE_PARM_DESC(misc_messages, "Log miscellaneous non fatal messages");
1571
diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
index c5305e3ee434..577760a82a0f 100644
--- a/drivers/edac/i82443bxgx_edac.c
+++ b/drivers/edac/i82443bxgx_edac.c
@@ -114,6 +114,12 @@ struct i82443bxgx_edacmc_error_info {
114 114
115static struct edac_pci_ctl_info *i82443bxgx_pci; 115static struct edac_pci_ctl_info *i82443bxgx_pci;
116 116
117static struct pci_dev *mci_pdev; /* init dev: in case that AGP code has
118 * already registered driver
119 */
120
121static int i82443bxgx_registered = 1;
122
117static void i82443bxgx_edacmc_get_error_info(struct mem_ctl_info *mci, 123static void i82443bxgx_edacmc_get_error_info(struct mem_ctl_info *mci,
118 struct i82443bxgx_edacmc_error_info 124 struct i82443bxgx_edacmc_error_info
119 *info) 125 *info)
@@ -345,10 +351,17 @@ EXPORT_SYMBOL_GPL(i82443bxgx_edacmc_probe1);
345static int __devinit i82443bxgx_edacmc_init_one(struct pci_dev *pdev, 351static int __devinit i82443bxgx_edacmc_init_one(struct pci_dev *pdev,
346 const struct pci_device_id *ent) 352 const struct pci_device_id *ent)
347{ 353{
354 int rc;
355
348 debugf0("MC: " __FILE__ ": %s()\n", __func__); 356 debugf0("MC: " __FILE__ ": %s()\n", __func__);
349 357
350 /* don't need to call pci_device_enable() */ 358 /* don't need to call pci_device_enable() */
351 return i82443bxgx_edacmc_probe1(pdev, ent->driver_data); 359 rc = i82443bxgx_edacmc_probe1(pdev, ent->driver_data);
360
361 if (mci_pdev == NULL)
362 mci_pdev = pci_dev_get(pdev);
363
364 return rc;
352} 365}
353 366
354static void __devexit i82443bxgx_edacmc_remove_one(struct pci_dev *pdev) 367static void __devexit i82443bxgx_edacmc_remove_one(struct pci_dev *pdev)
@@ -387,15 +400,61 @@ static struct pci_driver i82443bxgx_edacmc_driver = {
387 400
388static int __init i82443bxgx_edacmc_init(void) 401static int __init i82443bxgx_edacmc_init(void)
389{ 402{
403 int pci_rc;
390 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 404 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
391 opstate_init(); 405 opstate_init();
392 406
393 return pci_register_driver(&i82443bxgx_edacmc_driver); 407 pci_rc = pci_register_driver(&i82443bxgx_edacmc_driver);
408 if (pci_rc < 0)
409 goto fail0;
410
411 if (mci_pdev == NULL) {
412 const struct pci_device_id *id = &i82443bxgx_pci_tbl[0];
413 int i = 0;
414 i82443bxgx_registered = 0;
415
416 while (mci_pdev == NULL && id->vendor != 0) {
417 mci_pdev = pci_get_device(id->vendor,
418 id->device, NULL);
419 i++;
420 id = &i82443bxgx_pci_tbl[i];
421 }
422 if (!mci_pdev) {
423 debugf0("i82443bxgx pci_get_device fail\n");
424 pci_rc = -ENODEV;
425 goto fail1;
426 }
427
428 pci_rc = i82443bxgx_edacmc_init_one(mci_pdev, i82443bxgx_pci_tbl);
429
430 if (pci_rc < 0) {
431 debugf0("i82443bxgx init fail\n");
432 pci_rc = -ENODEV;
433 goto fail1;
434 }
435 }
436
437 return 0;
438
439fail1:
440 pci_unregister_driver(&i82443bxgx_edacmc_driver);
441
442fail0:
443 if (mci_pdev != NULL)
444 pci_dev_put(mci_pdev);
445
446 return pci_rc;
394} 447}
395 448
396static void __exit i82443bxgx_edacmc_exit(void) 449static void __exit i82443bxgx_edacmc_exit(void)
397{ 450{
398 pci_unregister_driver(&i82443bxgx_edacmc_driver); 451 pci_unregister_driver(&i82443bxgx_edacmc_driver);
452
453 if (!i82443bxgx_registered)
454 i82443bxgx_edacmc_remove_one(mci_pdev);
455
456 if (mci_pdev)
457 pci_dev_put(mci_pdev);
399} 458}
400 459
401module_init(i82443bxgx_edacmc_init); 460module_init(i82443bxgx_edacmc_init);
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 2265d9ca1535..0cfcb2d075a0 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -17,6 +17,7 @@
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/mod_devicetable.h> 18#include <linux/mod_devicetable.h>
19#include <linux/edac.h> 19#include <linux/edac.h>
20#include <linux/smp.h>
20 21
21#include <linux/of_platform.h> 22#include <linux/of_platform.h>
22#include <linux/of_device.h> 23#include <linux/of_device.h>
@@ -40,7 +41,7 @@ static u32 orig_pci_err_en;
40#endif 41#endif
41 42
42static u32 orig_l2_err_disable; 43static u32 orig_l2_err_disable;
43static u32 orig_hid1; 44static u32 orig_hid1[2];
44 45
45/************************ MC SYSFS parts ***********************************/ 46/************************ MC SYSFS parts ***********************************/
46 47
@@ -647,6 +648,9 @@ static struct of_device_id mpc85xx_l2_err_of_match[] = {
647 { 648 {
648 .compatible = "fsl,8568-l2-cache-controller", 649 .compatible = "fsl,8568-l2-cache-controller",
649 }, 650 },
651 {
652 .compatible = "fsl,mpc8572-l2-cache-controller",
653 },
650 {}, 654 {},
651}; 655};
652 656
@@ -912,7 +916,8 @@ static int __devinit mpc85xx_mc_err_probe(struct of_device *op,
912 /* register interrupts */ 916 /* register interrupts */
913 pdata->irq = irq_of_parse_and_map(op->node, 0); 917 pdata->irq = irq_of_parse_and_map(op->node, 0);
914 res = devm_request_irq(&op->dev, pdata->irq, 918 res = devm_request_irq(&op->dev, pdata->irq,
915 mpc85xx_mc_isr, IRQF_DISABLED, 919 mpc85xx_mc_isr,
920 IRQF_DISABLED | IRQF_SHARED,
916 "[EDAC] MC err", mci); 921 "[EDAC] MC err", mci);
917 if (res < 0) { 922 if (res < 0) {
918 printk(KERN_ERR "%s: Unable to request irq %d for " 923 printk(KERN_ERR "%s: Unable to request irq %d for "
@@ -980,6 +985,9 @@ static struct of_device_id mpc85xx_mc_err_of_match[] = {
980 { 985 {
981 .compatible = "fsl,8568-memory-controller", 986 .compatible = "fsl,8568-memory-controller",
982 }, 987 },
988 {
989 .compatible = "fsl,mpc8572-memory-controller",
990 },
983 {}, 991 {},
984}; 992};
985 993
@@ -995,6 +1003,14 @@ static struct of_platform_driver mpc85xx_mc_err_driver = {
995 }, 1003 },
996}; 1004};
997 1005
1006
1007static void __init mpc85xx_mc_clear_rfxe(void *data)
1008{
1009 orig_hid1[smp_processor_id()] = mfspr(SPRN_HID1);
1010 mtspr(SPRN_HID1, (orig_hid1[smp_processor_id()] & ~0x20000));
1011}
1012
1013
998static int __init mpc85xx_mc_init(void) 1014static int __init mpc85xx_mc_init(void)
999{ 1015{
1000 int res = 0; 1016 int res = 0;
@@ -1030,19 +1046,22 @@ static int __init mpc85xx_mc_init(void)
1030 * need to clear HID1[RFXE] to disable machine check int 1046 * need to clear HID1[RFXE] to disable machine check int
1031 * so we can catch it 1047 * so we can catch it
1032 */ 1048 */
1033 if (edac_op_state == EDAC_OPSTATE_INT) { 1049 if (edac_op_state == EDAC_OPSTATE_INT)
1034 orig_hid1 = mfspr(SPRN_HID1); 1050 on_each_cpu(mpc85xx_mc_clear_rfxe, NULL, 0);
1035 mtspr(SPRN_HID1, (orig_hid1 & ~0x20000));
1036 }
1037 1051
1038 return 0; 1052 return 0;
1039} 1053}
1040 1054
1041module_init(mpc85xx_mc_init); 1055module_init(mpc85xx_mc_init);
1042 1056
1057static void __exit mpc85xx_mc_restore_hid1(void *data)
1058{
1059 mtspr(SPRN_HID1, orig_hid1[smp_processor_id()]);
1060}
1061
1043static void __exit mpc85xx_mc_exit(void) 1062static void __exit mpc85xx_mc_exit(void)
1044{ 1063{
1045 mtspr(SPRN_HID1, orig_hid1); 1064 on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0);
1046#ifdef CONFIG_PCI 1065#ifdef CONFIG_PCI
1047 of_unregister_platform_driver(&mpc85xx_pci_err_driver); 1066 of_unregister_platform_driver(&mpc85xx_pci_err_driver);
1048#endif 1067#endif
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index bbd73a406e53..418c18f07e9d 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -189,39 +189,16 @@ static const char gap_count_table[] = {
189 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 189 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
190}; 190};
191 191
192struct bm_data {
193 struct fw_transaction t;
194 struct {
195 __be32 arg;
196 __be32 data;
197 } lock;
198 u32 old;
199 int rcode;
200 struct completion done;
201};
202
203static void
204complete_bm_lock(struct fw_card *card, int rcode,
205 void *payload, size_t length, void *data)
206{
207 struct bm_data *bmd = data;
208
209 if (rcode == RCODE_COMPLETE)
210 bmd->old = be32_to_cpu(*(__be32 *) payload);
211 bmd->rcode = rcode;
212 complete(&bmd->done);
213}
214
215static void 192static void
216fw_card_bm_work(struct work_struct *work) 193fw_card_bm_work(struct work_struct *work)
217{ 194{
218 struct fw_card *card = container_of(work, struct fw_card, work.work); 195 struct fw_card *card = container_of(work, struct fw_card, work.work);
219 struct fw_device *root_device; 196 struct fw_device *root_device;
220 struct fw_node *root_node, *local_node; 197 struct fw_node *root_node, *local_node;
221 struct bm_data bmd;
222 unsigned long flags; 198 unsigned long flags;
223 int root_id, new_root_id, irm_id, gap_count, generation, grace; 199 int root_id, new_root_id, irm_id, gap_count, generation, grace, rcode;
224 bool do_reset = false; 200 bool do_reset = false;
201 __be32 lock_data[2];
225 202
226 spin_lock_irqsave(&card->lock, flags); 203 spin_lock_irqsave(&card->lock, flags);
227 local_node = card->local_node; 204 local_node = card->local_node;
@@ -263,33 +240,28 @@ fw_card_bm_work(struct work_struct *work)
263 goto pick_me; 240 goto pick_me;
264 } 241 }
265 242
266 bmd.lock.arg = cpu_to_be32(0x3f); 243 lock_data[0] = cpu_to_be32(0x3f);
267 bmd.lock.data = cpu_to_be32(local_node->node_id); 244 lock_data[1] = cpu_to_be32(local_node->node_id);
268 245
269 spin_unlock_irqrestore(&card->lock, flags); 246 spin_unlock_irqrestore(&card->lock, flags);
270 247
271 init_completion(&bmd.done); 248 rcode = fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP,
272 fw_send_request(card, &bmd.t, TCODE_LOCK_COMPARE_SWAP, 249 irm_id, generation, SCODE_100,
273 irm_id, generation, 250 CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID,
274 SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, 251 lock_data, sizeof(lock_data));
275 &bmd.lock, sizeof(bmd.lock),
276 complete_bm_lock, &bmd);
277 wait_for_completion(&bmd.done);
278 252
279 if (bmd.rcode == RCODE_GENERATION) { 253 if (rcode == RCODE_GENERATION)
280 /* 254 /* Another bus reset, BM work has been rescheduled. */
281 * Another bus reset happened. Just return,
282 * the BM work has been rescheduled.
283 */
284 goto out; 255 goto out;
285 }
286 256
287 if (bmd.rcode == RCODE_COMPLETE && bmd.old != 0x3f) 257 if (rcode == RCODE_COMPLETE &&
258 lock_data[0] != cpu_to_be32(0x3f))
288 /* Somebody else is BM, let them do the work. */ 259 /* Somebody else is BM, let them do the work. */
289 goto out; 260 goto out;
290 261
291 spin_lock_irqsave(&card->lock, flags); 262 spin_lock_irqsave(&card->lock, flags);
292 if (bmd.rcode != RCODE_COMPLETE) { 263
264 if (rcode != RCODE_COMPLETE) {
293 /* 265 /*
294 * The lock request failed, maybe the IRM 266 * The lock request failed, maybe the IRM
295 * isn't really IRM capable after all. Let's 267 * isn't really IRM capable after all. Let's
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 2e6d5848d217..ed03234cbea8 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -720,8 +720,8 @@ static int ioctl_create_iso_context(struct client *client, void *buffer)
720#define GET_PAYLOAD_LENGTH(v) ((v) & 0xffff) 720#define GET_PAYLOAD_LENGTH(v) ((v) & 0xffff)
721#define GET_INTERRUPT(v) (((v) >> 16) & 0x01) 721#define GET_INTERRUPT(v) (((v) >> 16) & 0x01)
722#define GET_SKIP(v) (((v) >> 17) & 0x01) 722#define GET_SKIP(v) (((v) >> 17) & 0x01)
723#define GET_TAG(v) (((v) >> 18) & 0x02) 723#define GET_TAG(v) (((v) >> 18) & 0x03)
724#define GET_SY(v) (((v) >> 20) & 0x04) 724#define GET_SY(v) (((v) >> 20) & 0x0f)
725#define GET_HEADER_LENGTH(v) (((v) >> 24) & 0xff) 725#define GET_HEADER_LENGTH(v) (((v) >> 24) & 0xff)
726 726
727static int ioctl_queue_iso(struct client *client, void *buffer) 727static int ioctl_queue_iso(struct client *client, void *buffer)
@@ -913,7 +913,7 @@ dispatch_ioctl(struct client *client, unsigned int cmd, void __user *arg)
913 return -EFAULT; 913 return -EFAULT;
914 } 914 }
915 915
916 return 0; 916 return retval;
917} 917}
918 918
919static long 919static long
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 0855fb5568e8..3fccdd484100 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -381,46 +381,21 @@ static struct device_attribute fw_device_attributes[] = {
381 __ATTR_NULL, 381 __ATTR_NULL,
382}; 382};
383 383
384struct read_quadlet_callback_data {
385 struct completion done;
386 int rcode;
387 u32 data;
388};
389
390static void
391complete_transaction(struct fw_card *card, int rcode,
392 void *payload, size_t length, void *data)
393{
394 struct read_quadlet_callback_data *callback_data = data;
395
396 if (rcode == RCODE_COMPLETE)
397 callback_data->data = be32_to_cpu(*(__be32 *)payload);
398 callback_data->rcode = rcode;
399 complete(&callback_data->done);
400}
401
402static int 384static int
403read_rom(struct fw_device *device, int generation, int index, u32 *data) 385read_rom(struct fw_device *device, int generation, int index, u32 *data)
404{ 386{
405 struct read_quadlet_callback_data callback_data; 387 int rcode;
406 struct fw_transaction t;
407 u64 offset;
408 388
409 /* device->node_id, accessed below, must not be older than generation */ 389 /* device->node_id, accessed below, must not be older than generation */
410 smp_rmb(); 390 smp_rmb();
411 391
412 init_completion(&callback_data.done); 392 rcode = fw_run_transaction(device->card, TCODE_READ_QUADLET_REQUEST,
413
414 offset = (CSR_REGISTER_BASE | CSR_CONFIG_ROM) + index * 4;
415 fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST,
416 device->node_id, generation, device->max_speed, 393 device->node_id, generation, device->max_speed,
417 offset, NULL, 4, complete_transaction, &callback_data); 394 (CSR_REGISTER_BASE | CSR_CONFIG_ROM) + index * 4,
418 395 data, 4);
419 wait_for_completion(&callback_data.done); 396 be32_to_cpus(data);
420
421 *data = callback_data.data;
422 397
423 return callback_data.rcode; 398 return rcode;
424} 399}
425 400
426#define READ_BIB_ROM_SIZE 256 401#define READ_BIB_ROM_SIZE 256
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index aaff50ebba1d..ef0b9b419c27 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -29,6 +29,7 @@
29 */ 29 */
30 30
31#include <linux/blkdev.h> 31#include <linux/blkdev.h>
32#include <linux/bug.h>
32#include <linux/delay.h> 33#include <linux/delay.h>
33#include <linux/device.h> 34#include <linux/device.h>
34#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
@@ -181,10 +182,16 @@ struct sbp2_target {
181#define SBP2_MAX_LOGIN_ORB_TIMEOUT 40000U /* Timeout in ms */ 182#define SBP2_MAX_LOGIN_ORB_TIMEOUT 40000U /* Timeout in ms */
182#define SBP2_ORB_TIMEOUT 2000U /* Timeout in ms */ 183#define SBP2_ORB_TIMEOUT 2000U /* Timeout in ms */
183#define SBP2_ORB_NULL 0x80000000 184#define SBP2_ORB_NULL 0x80000000
184#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
185#define SBP2_RETRY_LIMIT 0xf /* 15 retries */ 185#define SBP2_RETRY_LIMIT 0xf /* 15 retries */
186#define SBP2_CYCLE_LIMIT (0xc8 << 12) /* 200 125us cycles */ 186#define SBP2_CYCLE_LIMIT (0xc8 << 12) /* 200 125us cycles */
187 187
188/*
189 * The default maximum s/g segment size of a FireWire controller is
190 * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to
191 * be quadlet-aligned, we set the length limit to 0xffff & ~3.
192 */
193#define SBP2_MAX_SEG_SIZE 0xfffc
194
188/* Unit directory keys */ 195/* Unit directory keys */
189#define SBP2_CSR_UNIT_CHARACTERISTICS 0x3a 196#define SBP2_CSR_UNIT_CHARACTERISTICS 0x3a
190#define SBP2_CSR_FIRMWARE_REVISION 0x3c 197#define SBP2_CSR_FIRMWARE_REVISION 0x3c
@@ -621,25 +628,15 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
621 return retval; 628 return retval;
622} 629}
623 630
624static void
625complete_agent_reset_write(struct fw_card *card, int rcode,
626 void *payload, size_t length, void *done)
627{
628 complete(done);
629}
630
631static void sbp2_agent_reset(struct sbp2_logical_unit *lu) 631static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
632{ 632{
633 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 633 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
634 DECLARE_COMPLETION_ONSTACK(done); 634 __be32 d = 0;
635 struct fw_transaction t;
636 static u32 z;
637 635
638 fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, 636 fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
639 lu->tgt->node_id, lu->generation, device->max_speed, 637 lu->tgt->node_id, lu->generation, device->max_speed,
640 lu->command_block_agent_address + SBP2_AGENT_RESET, 638 lu->command_block_agent_address + SBP2_AGENT_RESET,
641 &z, sizeof(z), complete_agent_reset_write, &done); 639 &d, sizeof(d));
642 wait_for_completion(&done);
643} 640}
644 641
645static void 642static void
@@ -653,7 +650,7 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
653{ 650{
654 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 651 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
655 struct fw_transaction *t; 652 struct fw_transaction *t;
656 static u32 z; 653 static __be32 d;
657 654
658 t = kmalloc(sizeof(*t), GFP_ATOMIC); 655 t = kmalloc(sizeof(*t), GFP_ATOMIC);
659 if (t == NULL) 656 if (t == NULL)
@@ -662,7 +659,7 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
662 fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, 659 fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST,
663 lu->tgt->node_id, lu->generation, device->max_speed, 660 lu->tgt->node_id, lu->generation, device->max_speed,
664 lu->command_block_agent_address + SBP2_AGENT_RESET, 661 lu->command_block_agent_address + SBP2_AGENT_RESET,
665 &z, sizeof(z), complete_agent_reset_write_no_wait, t); 662 &d, sizeof(d), complete_agent_reset_write_no_wait, t);
666} 663}
667 664
668static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation) 665static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation)
@@ -823,13 +820,6 @@ static void sbp2_target_put(struct sbp2_target *tgt)
823 kref_put(&tgt->kref, sbp2_release_target); 820 kref_put(&tgt->kref, sbp2_release_target);
824} 821}
825 822
826static void
827complete_set_busy_timeout(struct fw_card *card, int rcode,
828 void *payload, size_t length, void *done)
829{
830 complete(done);
831}
832
833/* 823/*
834 * Write retransmit retry values into the BUSY_TIMEOUT register. 824 * Write retransmit retry values into the BUSY_TIMEOUT register.
835 * - The single-phase retry protocol is supported by all SBP-2 devices, but the 825 * - The single-phase retry protocol is supported by all SBP-2 devices, but the
@@ -849,17 +839,12 @@ complete_set_busy_timeout(struct fw_card *card, int rcode,
849static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) 839static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
850{ 840{
851 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 841 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
852 DECLARE_COMPLETION_ONSTACK(done); 842 __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT);
853 struct fw_transaction t;
854 static __be32 busy_timeout;
855
856 busy_timeout = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT);
857 843
858 fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, 844 fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
859 lu->tgt->node_id, lu->generation, device->max_speed, 845 lu->tgt->node_id, lu->generation, device->max_speed,
860 CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, &busy_timeout, 846 CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT,
861 sizeof(busy_timeout), complete_set_busy_timeout, &done); 847 &d, sizeof(d));
862 wait_for_completion(&done);
863} 848}
864 849
865static void sbp2_reconnect(struct work_struct *work); 850static void sbp2_reconnect(struct work_struct *work);
@@ -1121,6 +1106,10 @@ static int sbp2_probe(struct device *dev)
1121 struct Scsi_Host *shost; 1106 struct Scsi_Host *shost;
1122 u32 model, firmware_revision; 1107 u32 model, firmware_revision;
1123 1108
1109 if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE)
1110 BUG_ON(dma_set_max_seg_size(device->card->device,
1111 SBP2_MAX_SEG_SIZE));
1112
1124 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt)); 1113 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt));
1125 if (shost == NULL) 1114 if (shost == NULL)
1126 return -ENOMEM; 1115 return -ENOMEM;
@@ -1369,14 +1358,12 @@ static int
1369sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, 1358sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device,
1370 struct sbp2_logical_unit *lu) 1359 struct sbp2_logical_unit *lu)
1371{ 1360{
1372 struct scatterlist *sg; 1361 struct scatterlist *sg = scsi_sglist(orb->cmd);
1373 int sg_len, l, i, j, count; 1362 int i, n;
1374 dma_addr_t sg_addr; 1363
1375 1364 n = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd),
1376 sg = scsi_sglist(orb->cmd); 1365 orb->cmd->sc_data_direction);
1377 count = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd), 1366 if (n == 0)
1378 orb->cmd->sc_data_direction);
1379 if (count == 0)
1380 goto fail; 1367 goto fail;
1381 1368
1382 /* 1369 /*
@@ -1386,7 +1373,7 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device,
1386 * as the second generation iPod which doesn't support page 1373 * as the second generation iPod which doesn't support page
1387 * tables. 1374 * tables.
1388 */ 1375 */
1389 if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) { 1376 if (n == 1) {
1390 orb->request.data_descriptor.high = 1377 orb->request.data_descriptor.high =
1391 cpu_to_be32(lu->tgt->address_high); 1378 cpu_to_be32(lu->tgt->address_high);
1392 orb->request.data_descriptor.low = 1379 orb->request.data_descriptor.low =
@@ -1396,29 +1383,9 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device,
1396 return 0; 1383 return 0;
1397 } 1384 }
1398 1385
1399 /* 1386 for_each_sg(sg, sg, n, i) {
1400 * Convert the scatterlist to an sbp2 page table. If any 1387 orb->page_table[i].high = cpu_to_be32(sg_dma_len(sg) << 16);
1401 * scatterlist entries are too big for sbp2, we split them as we 1388 orb->page_table[i].low = cpu_to_be32(sg_dma_address(sg));
1402 * go. Even if we ask the block I/O layer to not give us sg
1403 * elements larger than 65535 bytes, some IOMMUs may merge sg elements
1404 * during DMA mapping, and Linux currently doesn't prevent this.
1405 */
1406 for (i = 0, j = 0; i < count; i++, sg = sg_next(sg)) {
1407 sg_len = sg_dma_len(sg);
1408 sg_addr = sg_dma_address(sg);
1409 while (sg_len) {
1410 /* FIXME: This won't get us out of the pinch. */
1411 if (unlikely(j >= ARRAY_SIZE(orb->page_table))) {
1412 fw_error("page table overflow\n");
1413 goto fail_page_table;
1414 }
1415 l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
1416 orb->page_table[j].low = cpu_to_be32(sg_addr);
1417 orb->page_table[j].high = cpu_to_be32(l << 16);
1418 sg_addr += l;
1419 sg_len -= l;
1420 j++;
1421 }
1422 } 1389 }
1423 1390
1424 orb->page_table_bus = 1391 orb->page_table_bus =
@@ -1437,13 +1404,13 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device,
1437 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high); 1404 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high);
1438 orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus); 1405 orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus);
1439 orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT | 1406 orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT |
1440 COMMAND_ORB_DATA_SIZE(j)); 1407 COMMAND_ORB_DATA_SIZE(n));
1441 1408
1442 return 0; 1409 return 0;
1443 1410
1444 fail_page_table: 1411 fail_page_table:
1445 dma_unmap_sg(device->card->device, sg, scsi_sg_count(orb->cmd), 1412 dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
1446 orb->cmd->sc_data_direction); 1413 scsi_sg_count(orb->cmd), orb->cmd->sc_data_direction);
1447 fail: 1414 fail:
1448 return -ENOMEM; 1415 return -ENOMEM;
1449} 1416}
@@ -1456,7 +1423,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1456 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 1423 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
1457 struct sbp2_command_orb *orb; 1424 struct sbp2_command_orb *orb;
1458 unsigned int max_payload; 1425 unsigned int max_payload;
1459 int retval = SCSI_MLQUEUE_HOST_BUSY; 1426 int generation, retval = SCSI_MLQUEUE_HOST_BUSY;
1460 1427
1461 /* 1428 /*
1462 * Bidirectional commands are not yet implemented, and unknown 1429 * Bidirectional commands are not yet implemented, and unknown
@@ -1500,6 +1467,9 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1500 if (cmd->sc_data_direction == DMA_FROM_DEVICE) 1467 if (cmd->sc_data_direction == DMA_FROM_DEVICE)
1501 orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION); 1468 orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION);
1502 1469
1470 generation = device->generation;
1471 smp_rmb(); /* sbp2_map_scatterlist looks at tgt->address_high */
1472
1503 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) 1473 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0)
1504 goto out; 1474 goto out;
1505 1475
@@ -1512,7 +1482,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1512 if (dma_mapping_error(device->card->device, orb->base.request_bus)) 1482 if (dma_mapping_error(device->card->device, orb->base.request_bus))
1513 goto out; 1483 goto out;
1514 1484
1515 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, lu->generation, 1485 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1516 lu->command_block_agent_address + SBP2_ORB_POINTER); 1486 lu->command_block_agent_address + SBP2_ORB_POINTER);
1517 retval = 0; 1487 retval = 0;
1518 out: 1488 out:
@@ -1564,6 +1534,8 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
1564 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) 1534 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1565 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); 1535 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
1566 1536
1537 blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE);
1538
1567 return 0; 1539 return 0;
1568} 1540}
1569 1541
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index e5d1a0b64fcf..022ac4fabb67 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -247,7 +247,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
247 */ 247 */
248void 248void
249fw_send_request(struct fw_card *card, struct fw_transaction *t, 249fw_send_request(struct fw_card *card, struct fw_transaction *t,
250 int tcode, int node_id, int generation, int speed, 250 int tcode, int destination_id, int generation, int speed,
251 unsigned long long offset, 251 unsigned long long offset,
252 void *payload, size_t length, 252 void *payload, size_t length,
253 fw_transaction_callback_t callback, void *callback_data) 253 fw_transaction_callback_t callback, void *callback_data)
@@ -279,13 +279,14 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f; 279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
280 card->tlabel_mask |= (1 << tlabel); 280 card->tlabel_mask |= (1 << tlabel);
281 281
282 t->node_id = node_id; 282 t->node_id = destination_id;
283 t->tlabel = tlabel; 283 t->tlabel = tlabel;
284 t->callback = callback; 284 t->callback = callback;
285 t->callback_data = callback_data; 285 t->callback_data = callback_data;
286 286
287 fw_fill_request(&t->packet, tcode, t->tlabel, node_id, card->node_id, 287 fw_fill_request(&t->packet, tcode, t->tlabel,
288 generation, speed, offset, payload, length); 288 destination_id, card->node_id, generation,
289 speed, offset, payload, length);
289 t->packet.callback = transmit_complete_callback; 290 t->packet.callback = transmit_complete_callback;
290 291
291 list_add_tail(&t->link, &card->transaction_list); 292 list_add_tail(&t->link, &card->transaction_list);
@@ -296,6 +297,45 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
296} 297}
297EXPORT_SYMBOL(fw_send_request); 298EXPORT_SYMBOL(fw_send_request);
298 299
300struct transaction_callback_data {
301 struct completion done;
302 void *payload;
303 int rcode;
304};
305
306static void transaction_callback(struct fw_card *card, int rcode,
307 void *payload, size_t length, void *data)
308{
309 struct transaction_callback_data *d = data;
310
311 if (rcode == RCODE_COMPLETE)
312 memcpy(d->payload, payload, length);
313 d->rcode = rcode;
314 complete(&d->done);
315}
316
317/**
318 * fw_run_transaction - send request and sleep until transaction is completed
319 *
320 * Returns the RCODE.
321 */
322int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
323 int generation, int speed, unsigned long long offset,
324 void *data, size_t length)
325{
326 struct transaction_callback_data d;
327 struct fw_transaction t;
328
329 init_completion(&d.done);
330 d.payload = data;
331 fw_send_request(card, &t, tcode, destination_id, generation, speed,
332 offset, data, length, transaction_callback, &d);
333 wait_for_completion(&d.done);
334
335 return d.rcode;
336}
337EXPORT_SYMBOL(fw_run_transaction);
338
299static DEFINE_MUTEX(phy_config_mutex); 339static DEFINE_MUTEX(phy_config_mutex);
300static DECLARE_COMPLETION(phy_config_done); 340static DECLARE_COMPLETION(phy_config_done);
301 341
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index 2ae1b0d6cb7b..027f58ce81ad 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -426,11 +426,14 @@ fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
426 426
427void 427void
428fw_send_request(struct fw_card *card, struct fw_transaction *t, 428fw_send_request(struct fw_card *card, struct fw_transaction *t,
429 int tcode, int node_id, int generation, int speed, 429 int tcode, int destination_id, int generation, int speed,
430 unsigned long long offset, 430 unsigned long long offset, void *data, size_t length,
431 void *data, size_t length,
432 fw_transaction_callback_t callback, void *callback_data); 431 fw_transaction_callback_t callback, void *callback_data);
433 432
433int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
434 int generation, int speed, unsigned long long offset,
435 void *data, size_t length);
436
434int fw_cancel_transaction(struct fw_card *card, 437int fw_cancel_transaction(struct fw_card *card,
435 struct fw_transaction *transaction); 438 struct fw_transaction *transaction);
436 439
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 455575be3560..3e526b6d00cb 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -15,6 +15,11 @@
15 */ 15 */
16static char dmi_empty_string[] = " "; 16static char dmi_empty_string[] = " ";
17 17
18/*
19 * Catch too early calls to dmi_check_system():
20 */
21static int dmi_initialized;
22
18static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) 23static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
19{ 24{
20 const u8 *bp = ((u8 *) dm) + dm->length; 25 const u8 *bp = ((u8 *) dm) + dm->length;
@@ -366,7 +371,7 @@ void __init dmi_scan_machine(void)
366 371
367 if (efi_enabled) { 372 if (efi_enabled) {
368 if (efi.smbios == EFI_INVALID_TABLE_ADDR) 373 if (efi.smbios == EFI_INVALID_TABLE_ADDR)
369 goto out; 374 goto error;
370 375
371 /* This is called as a core_initcall() because it isn't 376 /* This is called as a core_initcall() because it isn't
372 * needed during early boot. This also means we can 377 * needed during early boot. This also means we can
@@ -374,13 +379,13 @@ void __init dmi_scan_machine(void)
374 */ 379 */
375 p = dmi_ioremap(efi.smbios, 32); 380 p = dmi_ioremap(efi.smbios, 32);
376 if (p == NULL) 381 if (p == NULL)
377 goto out; 382 goto error;
378 383
379 rc = dmi_present(p + 0x10); /* offset of _DMI_ string */ 384 rc = dmi_present(p + 0x10); /* offset of _DMI_ string */
380 dmi_iounmap(p, 32); 385 dmi_iounmap(p, 32);
381 if (!rc) { 386 if (!rc) {
382 dmi_available = 1; 387 dmi_available = 1;
383 return; 388 goto out;
384 } 389 }
385 } 390 }
386 else { 391 else {
@@ -391,19 +396,22 @@ void __init dmi_scan_machine(void)
391 */ 396 */
392 p = dmi_ioremap(0xF0000, 0x10000); 397 p = dmi_ioremap(0xF0000, 0x10000);
393 if (p == NULL) 398 if (p == NULL)
394 goto out; 399 goto error;
395 400
396 for (q = p; q < p + 0x10000; q += 16) { 401 for (q = p; q < p + 0x10000; q += 16) {
397 rc = dmi_present(q); 402 rc = dmi_present(q);
398 if (!rc) { 403 if (!rc) {
399 dmi_available = 1; 404 dmi_available = 1;
400 dmi_iounmap(p, 0x10000); 405 dmi_iounmap(p, 0x10000);
401 return; 406 goto out;
402 } 407 }
403 } 408 }
404 dmi_iounmap(p, 0x10000); 409 dmi_iounmap(p, 0x10000);
405 } 410 }
406 out: printk(KERN_INFO "DMI not present or invalid.\n"); 411 error:
412 printk(KERN_INFO "DMI not present or invalid.\n");
413 out:
414 dmi_initialized = 1;
407} 415}
408 416
409/** 417/**
@@ -424,6 +432,8 @@ int dmi_check_system(const struct dmi_system_id *list)
424 int i, count = 0; 432 int i, count = 0;
425 const struct dmi_system_id *d = list; 433 const struct dmi_system_id *d = list;
426 434
435 WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
436
427 while (d->ident) { 437 while (d->ident) {
428 for (i = 0; i < ARRAY_SIZE(d->matches); i++) { 438 for (i = 0; i < ARRAY_SIZE(d->matches); i++) {
429 int s = d->matches[i].slot; 439 int s = d->matches[i].slot;
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index b91ef63126ed..deb154aa47c4 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -334,9 +334,9 @@ static void ibft_release(struct kobject *kobj)
334/* 334/*
335 * Routines for parsing the iBFT data to be human readable. 335 * Routines for parsing the iBFT data to be human readable.
336 */ 336 */
337ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, 337static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
338 struct ibft_attribute *attr, 338 struct ibft_attribute *attr,
339 char *buf) 339 char *buf)
340{ 340{
341 struct ibft_initiator *initiator = entry->initiator; 341 struct ibft_initiator *initiator = entry->initiator;
342 void *ibft_loc = entry->header; 342 void *ibft_loc = entry->header;
@@ -376,9 +376,9 @@ ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
376 return str - buf; 376 return str - buf;
377} 377}
378 378
379ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, 379static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
380 struct ibft_attribute *attr, 380 struct ibft_attribute *attr,
381 char *buf) 381 char *buf)
382{ 382{
383 struct ibft_nic *nic = entry->nic; 383 struct ibft_nic *nic = entry->nic;
384 void *ibft_loc = entry->header; 384 void *ibft_loc = entry->header;
@@ -440,9 +440,9 @@ ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
440 return str - buf; 440 return str - buf;
441}; 441};
442 442
443ssize_t ibft_attr_show_target(struct ibft_kobject *entry, 443static ssize_t ibft_attr_show_target(struct ibft_kobject *entry,
444 struct ibft_attribute *attr, 444 struct ibft_attribute *attr,
445 char *buf) 445 char *buf)
446{ 446{
447 struct ibft_tgt *tgt = entry->tgt; 447 struct ibft_tgt *tgt = entry->tgt;
448 void *ibft_loc = entry->header; 448 void *ibft_loc = entry->header;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8d2940517c99..9112830107a5 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -67,17 +67,28 @@ static inline void desc_set_label(struct gpio_desc *d, const char *label)
67 * when setting direction, and otherwise illegal. Until board setup code 67 * when setting direction, and otherwise illegal. Until board setup code
68 * and drivers use explicit requests everywhere (which won't happen when 68 * and drivers use explicit requests everywhere (which won't happen when
69 * those calls have no teeth) we can't avoid autorequesting. This nag 69 * those calls have no teeth) we can't avoid autorequesting. This nag
70 * message should motivate switching to explicit requests... 70 * message should motivate switching to explicit requests... so should
71 * the weaker cleanup after faults, compared to gpio_request().
71 */ 72 */
72static void gpio_ensure_requested(struct gpio_desc *desc) 73static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset)
73{ 74{
74 if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) { 75 if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
75 pr_warning("GPIO-%d autorequested\n", (int)(desc - gpio_desc)); 76 struct gpio_chip *chip = desc->chip;
77 int gpio = chip->base + offset;
78
79 if (!try_module_get(chip->owner)) {
80 pr_err("GPIO-%d: module can't be gotten \n", gpio);
81 clear_bit(FLAG_REQUESTED, &desc->flags);
82 /* lose */
83 return -EIO;
84 }
85 pr_warning("GPIO-%d autorequested\n", gpio);
76 desc_set_label(desc, "[auto]"); 86 desc_set_label(desc, "[auto]");
77 if (!try_module_get(desc->chip->owner)) 87 /* caller must chip->request() w/o spinlock */
78 pr_err("GPIO-%d: module can't be gotten \n", 88 if (chip->request)
79 (int)(desc - gpio_desc)); 89 return 1;
80 } 90 }
91 return 0;
81} 92}
82 93
83/* caller holds gpio_lock *OR* gpio is marked as requested */ 94/* caller holds gpio_lock *OR* gpio is marked as requested */
@@ -752,6 +763,7 @@ EXPORT_SYMBOL_GPL(gpiochip_remove);
752int gpio_request(unsigned gpio, const char *label) 763int gpio_request(unsigned gpio, const char *label)
753{ 764{
754 struct gpio_desc *desc; 765 struct gpio_desc *desc;
766 struct gpio_chip *chip;
755 int status = -EINVAL; 767 int status = -EINVAL;
756 unsigned long flags; 768 unsigned long flags;
757 769
@@ -760,14 +772,15 @@ int gpio_request(unsigned gpio, const char *label)
760 if (!gpio_is_valid(gpio)) 772 if (!gpio_is_valid(gpio))
761 goto done; 773 goto done;
762 desc = &gpio_desc[gpio]; 774 desc = &gpio_desc[gpio];
763 if (desc->chip == NULL) 775 chip = desc->chip;
776 if (chip == NULL)
764 goto done; 777 goto done;
765 778
766 if (!try_module_get(desc->chip->owner)) 779 if (!try_module_get(chip->owner))
767 goto done; 780 goto done;
768 781
769 /* NOTE: gpio_request() can be called in early boot, 782 /* NOTE: gpio_request() can be called in early boot,
770 * before IRQs are enabled. 783 * before IRQs are enabled, for non-sleeping (SOC) GPIOs.
771 */ 784 */
772 785
773 if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) { 786 if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
@@ -775,7 +788,20 @@ int gpio_request(unsigned gpio, const char *label)
775 status = 0; 788 status = 0;
776 } else { 789 } else {
777 status = -EBUSY; 790 status = -EBUSY;
778 module_put(desc->chip->owner); 791 module_put(chip->owner);
792 }
793
794 if (chip->request) {
795 /* chip->request may sleep */
796 spin_unlock_irqrestore(&gpio_lock, flags);
797 status = chip->request(chip, gpio - chip->base);
798 spin_lock_irqsave(&gpio_lock, flags);
799
800 if (status < 0) {
801 desc_set_label(desc, NULL);
802 module_put(chip->owner);
803 clear_bit(FLAG_REQUESTED, &desc->flags);
804 }
779 } 805 }
780 806
781done: 807done:
@@ -791,6 +817,9 @@ void gpio_free(unsigned gpio)
791{ 817{
792 unsigned long flags; 818 unsigned long flags;
793 struct gpio_desc *desc; 819 struct gpio_desc *desc;
820 struct gpio_chip *chip;
821
822 might_sleep();
794 823
795 if (!gpio_is_valid(gpio)) { 824 if (!gpio_is_valid(gpio)) {
796 WARN_ON(extra_checks); 825 WARN_ON(extra_checks);
@@ -802,9 +831,17 @@ void gpio_free(unsigned gpio)
802 spin_lock_irqsave(&gpio_lock, flags); 831 spin_lock_irqsave(&gpio_lock, flags);
803 832
804 desc = &gpio_desc[gpio]; 833 desc = &gpio_desc[gpio];
805 if (desc->chip && test_and_clear_bit(FLAG_REQUESTED, &desc->flags)) { 834 chip = desc->chip;
835 if (chip && test_bit(FLAG_REQUESTED, &desc->flags)) {
836 if (chip->free) {
837 spin_unlock_irqrestore(&gpio_lock, flags);
838 might_sleep_if(extra_checks && chip->can_sleep);
839 chip->free(chip, gpio - chip->base);
840 spin_lock_irqsave(&gpio_lock, flags);
841 }
806 desc_set_label(desc, NULL); 842 desc_set_label(desc, NULL);
807 module_put(desc->chip->owner); 843 module_put(desc->chip->owner);
844 clear_bit(FLAG_REQUESTED, &desc->flags);
808 } else 845 } else
809 WARN_ON(extra_checks); 846 WARN_ON(extra_checks);
810 847
@@ -869,7 +906,9 @@ int gpio_direction_input(unsigned gpio)
869 gpio -= chip->base; 906 gpio -= chip->base;
870 if (gpio >= chip->ngpio) 907 if (gpio >= chip->ngpio)
871 goto fail; 908 goto fail;
872 gpio_ensure_requested(desc); 909 status = gpio_ensure_requested(desc, gpio);
910 if (status < 0)
911 goto fail;
873 912
874 /* now we know the gpio is valid and chip won't vanish */ 913 /* now we know the gpio is valid and chip won't vanish */
875 914
@@ -877,9 +916,22 @@ int gpio_direction_input(unsigned gpio)
877 916
878 might_sleep_if(extra_checks && chip->can_sleep); 917 might_sleep_if(extra_checks && chip->can_sleep);
879 918
919 if (status) {
920 status = chip->request(chip, gpio);
921 if (status < 0) {
922 pr_debug("GPIO-%d: chip request fail, %d\n",
923 chip->base + gpio, status);
924 /* and it's not available to anyone else ...
925 * gpio_request() is the fully clean solution.
926 */
927 goto lose;
928 }
929 }
930
880 status = chip->direction_input(chip, gpio); 931 status = chip->direction_input(chip, gpio);
881 if (status == 0) 932 if (status == 0)
882 clear_bit(FLAG_IS_OUT, &desc->flags); 933 clear_bit(FLAG_IS_OUT, &desc->flags);
934lose:
883 return status; 935 return status;
884fail: 936fail:
885 spin_unlock_irqrestore(&gpio_lock, flags); 937 spin_unlock_irqrestore(&gpio_lock, flags);
@@ -907,7 +959,9 @@ int gpio_direction_output(unsigned gpio, int value)
907 gpio -= chip->base; 959 gpio -= chip->base;
908 if (gpio >= chip->ngpio) 960 if (gpio >= chip->ngpio)
909 goto fail; 961 goto fail;
910 gpio_ensure_requested(desc); 962 status = gpio_ensure_requested(desc, gpio);
963 if (status < 0)
964 goto fail;
911 965
912 /* now we know the gpio is valid and chip won't vanish */ 966 /* now we know the gpio is valid and chip won't vanish */
913 967
@@ -915,9 +969,22 @@ int gpio_direction_output(unsigned gpio, int value)
915 969
916 might_sleep_if(extra_checks && chip->can_sleep); 970 might_sleep_if(extra_checks && chip->can_sleep);
917 971
972 if (status) {
973 status = chip->request(chip, gpio);
974 if (status < 0) {
975 pr_debug("GPIO-%d: chip request fail, %d\n",
976 chip->base + gpio, status);
977 /* and it's not available to anyone else ...
978 * gpio_request() is the fully clean solution.
979 */
980 goto lose;
981 }
982 }
983
918 status = chip->direction_output(chip, gpio, value); 984 status = chip->direction_output(chip, gpio, value);
919 if (status == 0) 985 if (status == 0)
920 set_bit(FLAG_IS_OUT, &desc->flags); 986 set_bit(FLAG_IS_OUT, &desc->flags);
987lose:
921 return status; 988 return status;
922fail: 989fail:
923 spin_unlock_irqrestore(&gpio_lock, flags); 990 spin_unlock_irqrestore(&gpio_lock, flags);
@@ -1008,6 +1075,24 @@ int __gpio_cansleep(unsigned gpio)
1008} 1075}
1009EXPORT_SYMBOL_GPL(__gpio_cansleep); 1076EXPORT_SYMBOL_GPL(__gpio_cansleep);
1010 1077
1078/**
1079 * __gpio_to_irq() - return the IRQ corresponding to a GPIO
1080 * @gpio: gpio whose IRQ will be returned (already requested)
1081 * Context: any
1082 *
1083 * This is used directly or indirectly to implement gpio_to_irq().
1084 * It returns the number of the IRQ signaled by this (input) GPIO,
1085 * or a negative errno.
1086 */
1087int __gpio_to_irq(unsigned gpio)
1088{
1089 struct gpio_chip *chip;
1090
1091 chip = gpio_to_chip(gpio);
1092 return chip->to_irq ? chip->to_irq(chip, gpio - chip->base) : -ENXIO;
1093}
1094EXPORT_SYMBOL_GPL(__gpio_to_irq);
1095
1011 1096
1012 1097
1013/* There's no value in making it easy to inline GPIO calls that may sleep. 1098/* There's no value in making it easy to inline GPIO calls that may sleep.
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
index 39c795ad8312..8b24d784db93 100644
--- a/drivers/gpio/max7301.c
+++ b/drivers/gpio/max7301.c
@@ -255,10 +255,6 @@ static int __devinit max7301_probe(struct spi_device *spi)
255 ts->chip.dev = &spi->dev; 255 ts->chip.dev = &spi->dev;
256 ts->chip.owner = THIS_MODULE; 256 ts->chip.owner = THIS_MODULE;
257 257
258 ret = gpiochip_add(&ts->chip);
259 if (ret)
260 goto exit_destroy;
261
262 /* 258 /*
263 * tristate all pins in hardware and cache the 259 * tristate all pins in hardware and cache the
264 * register values for later use. 260 * register values for later use.
@@ -269,17 +265,19 @@ static int __devinit max7301_probe(struct spi_device *spi)
269 max7301_write(spi, 0x08 + i, 0xAA); 265 max7301_write(spi, 0x08 + i, 0xAA);
270 ts->port_config[i] = 0xAA; 266 ts->port_config[i] = 0xAA;
271 for (j = 0; j < 4; j++) { 267 for (j = 0; j < 4; j++) {
272 int idx = ts->chip.base + (i - 1) * 4 + j; 268 int offset = (i - 1) * 4 + j;
273 ret = gpio_direction_input(idx); 269 ret = max7301_direction_input(&ts->chip, offset);
274 if (ret) 270 if (ret)
275 goto exit_remove; 271 goto exit_destroy;
276 gpio_free(idx);
277 } 272 }
278 } 273 }
274
275 ret = gpiochip_add(&ts->chip);
276 if (ret)
277 goto exit_destroy;
278
279 return ret; 279 return ret;
280 280
281exit_remove:
282 gpiochip_remove(&ts->chip);
283exit_destroy: 281exit_destroy:
284 dev_set_drvdata(&spi->dev, NULL); 282 dev_set_drvdata(&spi->dev, NULL);
285 mutex_destroy(&ts->lock); 283 mutex_destroy(&ts->lock);
@@ -325,13 +323,15 @@ static int __init max7301_init(void)
325{ 323{
326 return spi_register_driver(&max7301_driver); 324 return spi_register_driver(&max7301_driver);
327} 325}
326/* register after spi postcore initcall and before
327 * subsys initcalls that may rely on these GPIOs
328 */
329subsys_initcall(max7301_init);
328 330
329static void __exit max7301_exit(void) 331static void __exit max7301_exit(void)
330{ 332{
331 spi_unregister_driver(&max7301_driver); 333 spi_unregister_driver(&max7301_driver);
332} 334}
333
334module_init(max7301_init);
335module_exit(max7301_exit); 335module_exit(max7301_exit);
336 336
337MODULE_AUTHOR("Juergen Beisert"); 337MODULE_AUTHOR("Juergen Beisert");
diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c
index b51c8135ca28..55ae9a41897a 100644
--- a/drivers/gpio/max732x.c
+++ b/drivers/gpio/max732x.c
@@ -372,7 +372,10 @@ static int __init max732x_init(void)
372{ 372{
373 return i2c_add_driver(&max732x_driver); 373 return i2c_add_driver(&max732x_driver);
374} 374}
375module_init(max732x_init); 375/* register after i2c postcore initcall and before
376 * subsys initcalls that may rely on these GPIOs
377 */
378subsys_initcall(max732x_init);
376 379
377static void __exit max732x_exit(void) 380static void __exit max732x_exit(void)
378{ 381{
diff --git a/drivers/gpio/mcp23s08.c b/drivers/gpio/mcp23s08.c
index 8a1b405fefda..89c1d222e9d1 100644
--- a/drivers/gpio/mcp23s08.c
+++ b/drivers/gpio/mcp23s08.c
@@ -419,7 +419,10 @@ static int __init mcp23s08_init(void)
419{ 419{
420 return spi_register_driver(&mcp23s08_driver); 420 return spi_register_driver(&mcp23s08_driver);
421} 421}
422module_init(mcp23s08_init); 422/* register after spi postcore initcall and before
423 * subsys initcalls that may rely on these GPIOs
424 */
425subsys_initcall(mcp23s08_init);
423 426
424static void __exit mcp23s08_exit(void) 427static void __exit mcp23s08_exit(void)
425{ 428{
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index cc8468692ae0..9ceeb89f1325 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -289,7 +289,10 @@ static int __init pca953x_init(void)
289{ 289{
290 return i2c_add_driver(&pca953x_driver); 290 return i2c_add_driver(&pca953x_driver);
291} 291}
292module_init(pca953x_init); 292/* register after i2c postcore initcall and before
293 * subsys initcalls that may rely on these GPIOs
294 */
295subsys_initcall(pca953x_init);
293 296
294static void __exit pca953x_exit(void) 297static void __exit pca953x_exit(void)
295{ 298{
diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c
index fc9c6ae739ee..4bc2070dd4a1 100644
--- a/drivers/gpio/pcf857x.c
+++ b/drivers/gpio/pcf857x.c
@@ -351,7 +351,10 @@ static int __init pcf857x_init(void)
351{ 351{
352 return i2c_add_driver(&pcf857x_driver); 352 return i2c_add_driver(&pcf857x_driver);
353} 353}
354module_init(pcf857x_init); 354/* register after i2c postcore initcall and before
355 * subsys initcalls that may rely on these GPIOs
356 */
357subsys_initcall(pcf857x_init);
355 358
356static void __exit pcf857x_exit(void) 359static void __exit pcf857x_exit(void)
357{ 360{
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 88974342933c..9ac4720e647b 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -517,7 +517,7 @@ static int i915_dispatch_flip(struct drm_device * dev)
517 RING_LOCALS; 517 RING_LOCALS;
518 518
519 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", 519 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n",
520 __FUNCTION__, 520 __func__,
521 dev_priv->current_page, 521 dev_priv->current_page,
522 dev_priv->sarea_priv->pf_current_page); 522 dev_priv->sarea_priv->pf_current_page);
523 523
@@ -642,7 +642,7 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
642static int i915_flip_bufs(struct drm_device *dev, void *data, 642static int i915_flip_bufs(struct drm_device *dev, void *data,
643 struct drm_file *file_priv) 643 struct drm_file *file_priv)
644{ 644{
645 DRM_DEBUG("%s\n", __FUNCTION__); 645 DRM_DEBUG("%s\n", __func__);
646 646
647 LOCK_TEST_WITH_RETURN(dev, file_priv); 647 LOCK_TEST_WITH_RETURN(dev, file_priv);
648 648
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index da64108de775..f5999a91614e 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -17,25 +17,6 @@ config HID
17 tristate "Generic HID support" 17 tristate "Generic HID support"
18 depends on INPUT 18 depends on INPUT
19 default y 19 default y
20 select HID_A4TECH if !EMBEDDED
21 select HID_APPLE if !EMBEDDED
22 select HID_BELKIN if !EMBEDDED
23 select HID_BRIGHT if !EMBEDDED
24 select HID_CHERRY if !EMBEDDED
25 select HID_CHICONY if !EMBEDDED
26 select HID_CYPRESS if !EMBEDDED
27 select HID_DELL if !EMBEDDED
28 select HID_EZKEY if !EMBEDDED
29 select HID_GYRATION if !EMBEDDED
30 select HID_LOGITECH if !EMBEDDED
31 select HID_MICROSOFT if !EMBEDDED
32 select HID_MONTEREY if !EMBEDDED
33 select HID_PANTHERLORD if !EMBEDDED
34 select HID_PETALYNX if !EMBEDDED
35 select HID_SAMSUNG if !EMBEDDED
36 select HID_SONY if !EMBEDDED
37 select HID_SUNPLUS if !EMBEDDED
38
39 ---help--- 20 ---help---
40 A human interface device (HID) is a type of computer device that 21 A human interface device (HID) is a type of computer device that
41 interacts directly with and takes input from humans. The term "HID" 22 interacts directly with and takes input from humans. The term "HID"
@@ -102,89 +83,86 @@ config HID_COMPAT
102 If unsure, say Y. 83 If unsure, say Y.
103 84
104config HID_A4TECH 85config HID_A4TECH
105 tristate "A4 tech" 86 tristate "A4 tech" if EMBEDDED
106 default m
107 depends on USB_HID 87 depends on USB_HID
88 default y
108 ---help--- 89 ---help---
109 Support for A4 tech X5 and WOP-35 / Trust 450L mice. 90 Support for A4 tech X5 and WOP-35 / Trust 450L mice.
110 91
111config HID_APPLE 92config HID_APPLE
112 tristate "Apple" 93 tristate "Apple" if EMBEDDED
113 default m
114 depends on (USB_HID || BT_HIDP) 94 depends on (USB_HID || BT_HIDP)
95 default y
115 ---help--- 96 ---help---
116 Support for some Apple devices which less or more break 97 Support for some Apple devices which less or more break
117 HID specification. 98 HID specification.
118 99
119 Say Y here if you want support for the special keys (Fn, Numlock) on 100 Say Y here if you want support for keyboards of Apple iBooks, PowerBooks,
120 Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB 101 MacBooks, MacBook Pros and Apple Aluminum.
121 keyboards.
122
123 If unsure, say M.
124 102
125config HID_BELKIN 103config HID_BELKIN
126 tristate "Belkin" 104 tristate "Belkin" if EMBEDDED
127 default m
128 depends on USB_HID 105 depends on USB_HID
106 default y
129 ---help--- 107 ---help---
130 Support for Belkin Flip KVM and Wireless keyboard. 108 Support for Belkin Flip KVM and Wireless keyboard.
131 109
132config HID_BRIGHT 110config HID_BRIGHT
133 tristate "Bright" 111 tristate "Bright" if EMBEDDED
134 default m
135 depends on USB_HID 112 depends on USB_HID
113 default y
136 ---help--- 114 ---help---
137 Support for Bright ABNT-2 keyboard. 115 Support for Bright ABNT-2 keyboard.
138 116
139config HID_CHERRY 117config HID_CHERRY
140 tristate "Cherry" 118 tristate "Cherry" if EMBEDDED
141 default m
142 depends on USB_HID 119 depends on USB_HID
120 default y
143 ---help--- 121 ---help---
144 Support for Cherry Cymotion. 122 Support for Cherry Cymotion keyboard.
145 123
146config HID_CHICONY 124config HID_CHICONY
147 tristate "Chicony" 125 tristate "Chicony" if EMBEDDED
148 default m
149 depends on USB_HID 126 depends on USB_HID
127 default y
150 ---help--- 128 ---help---
151 Support for Chicony Tactical pad. 129 Support for Chicony Tactical pad.
152 130
153config HID_CYPRESS 131config HID_CYPRESS
154 tristate "Cypress" 132 tristate "Cypress" if EMBEDDED
155 default m
156 depends on USB_HID 133 depends on USB_HID
134 default y
157 ---help--- 135 ---help---
158 Support for Cypress mouse and barcodes. 136 Support for cypress mouse and barcode readers.
159 137
160config HID_DELL 138config HID_DELL
161 tristate "Dell" 139 tristate "Dell" if EMBEDDED
162 default m
163 depends on USB_HID 140 depends on USB_HID
141 default y
164 ---help--- 142 ---help---
165 Support for Dell W7658. 143 Support for quirky Dell HID hardware that require
144 special LED handling (W7658 and SK8115 models)
166 145
167config HID_EZKEY 146config HID_EZKEY
168 tristate "Ezkey" 147 tristate "Ezkey" if EMBEDDED
169 default m
170 depends on USB_HID 148 depends on USB_HID
149 default y
171 ---help--- 150 ---help---
172 Support for Ezkey mouse and barcodes. 151 Support for Ezkey BTC 8193 keyboard.
173 152
174config HID_GYRATION 153config HID_GYRATION
175 tristate "Gyration" 154 tristate "Gyration" if EMBEDDED
176 default m
177 depends on USB_HID 155 depends on USB_HID
156 default y
178 ---help--- 157 ---help---
179 Support for Gyration remote. 158 Support for Gyration remote control.
180 159
181config HID_LOGITECH 160config HID_LOGITECH
182 tristate "Logitech" 161 tristate "Logitech" if EMBEDDED
183 default m
184 depends on USB_HID 162 depends on USB_HID
163 default y
185 ---help--- 164 ---help---
186 Support for some Logitech devices which breaks less or more 165 Support for Logitech devices that are not fully compliant with HID standard.
187 HID specification.
188 166
189config LOGITECH_FF 167config LOGITECH_FF
190 bool "Logitech force feedback" 168 bool "Logitech force feedback"
@@ -211,28 +189,26 @@ config LOGIRUMBLEPAD2_FF
211 Rumblepad 2 devices. 189 Rumblepad 2 devices.
212 190
213config HID_MICROSOFT 191config HID_MICROSOFT
214 tristate "Microsoft" 192 tristate "Microsoft" if EMBEDDED
215 default m
216 depends on USB_HID 193 depends on USB_HID
194 default y
217 ---help--- 195 ---help---
218 Support for some Microsoft devices which breaks less or more 196 Support for Microsoft devices that are not fully compliant with HID standard.
219 HID specification.
220 197
221config HID_MONTEREY 198config HID_MONTEREY
222 tristate "Monterey" 199 tristate "Monterey" if EMBEDDED
223 default m
224 depends on USB_HID 200 depends on USB_HID
201 default y
225 ---help--- 202 ---help---
226 Support for Monterey Genius KB29E. 203 Support for Monterey Genius KB29E.
227 204
228config HID_PANTHERLORD 205config HID_PANTHERLORD
229 tristate "Pantherlord devices support" 206 tristate "Pantherlord devices support" if EMBEDDED
230 default m
231 depends on USB_HID 207 depends on USB_HID
208 default y
232 ---help--- 209 ---help---
233 Support for PantherLord/GreenAsia based device support. 210 Support for PantherLord/GreenAsia based device support.
234 211
235
236config PANTHERLORD_FF 212config PANTHERLORD_FF
237 bool "Pantherlord force feedback support" 213 bool "Pantherlord force feedback support"
238 depends on HID_PANTHERLORD 214 depends on HID_PANTHERLORD
@@ -242,32 +218,32 @@ config PANTHERLORD_FF
242 or adapter and want to enable force feedback support for it. 218 or adapter and want to enable force feedback support for it.
243 219
244config HID_PETALYNX 220config HID_PETALYNX
245 tristate "Petalynx" 221 tristate "Petalynx" if EMBEDDED
246 default m
247 depends on USB_HID 222 depends on USB_HID
223 default y
248 ---help--- 224 ---help---
249 Support for Petalynx Maxter remote. 225 Support for Petalynx Maxter remote control.
250 226
251config HID_SAMSUNG 227config HID_SAMSUNG
252 tristate "Samsung" 228 tristate "Samsung" if EMBEDDED
253 default m
254 depends on USB_HID 229 depends on USB_HID
230 default y
255 ---help--- 231 ---help---
256 Support for Samsung IR remote. 232 Support for Samsung InfraRed remote control.
257 233
258config HID_SONY 234config HID_SONY
259 tristate "Sony" 235 tristate "Sony" if EMBEDDED
260 default m
261 depends on USB_HID 236 depends on USB_HID
237 default y
262 ---help--- 238 ---help---
263 Support for Sony PS3 controller. 239 Support for Sony PS3 controller.
264 240
265config HID_SUNPLUS 241config HID_SUNPLUS
266 tristate "Sunplus" 242 tristate "Sunplus" if EMBEDDED
267 default m
268 depends on USB_HID 243 depends on USB_HID
244 default y
269 ---help--- 245 ---help---
270 Support for Sunplus WDesktop input device. 246 Support for Sunplus wireless desktop.
271 247
272config THRUSTMASTER_FF 248config THRUSTMASTER_FF
273 tristate "ThrustMaster devices support" 249 tristate "ThrustMaster devices support"
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 8a7d9dbb4d07..721a36d97582 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1518,6 +1518,8 @@ static const struct hid_device_id hid_ignore_list[] = {
1518 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1518 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1519 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 1519 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1520 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1520 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1521 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) },
1522 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) },
1521 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) }, 1523 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1522 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) }, 1524 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1523 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1525 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index aad9ed1b406e..d9a1ba920c23 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -354,6 +354,8 @@
354 354
355#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2 355#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2
356#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038 356#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038
357#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036
358#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034
357 359
358#define USB_VENDOR_ID_SUN 0x0430 360#define USB_VENDOR_ID_SUN 0x0430
359#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 361#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 497e0d1dd3c3..af3edb98df43 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -326,9 +326,8 @@ int hidraw_connect(struct hid_device *hid)
326 goto out; 326 goto out;
327 } 327 }
328 328
329 dev->dev = device_create_drvdata(hidraw_class, NULL, 329 dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
330 MKDEV(hidraw_major, minor), NULL, 330 NULL, "%s%d", "hidraw", minor);
331 "%s%d", "hidraw", minor);
332 331
333 if (IS_ERR(dev->dev)) { 332 if (IS_ERR(dev->dev)) {
334 spin_lock(&minors_lock); 333 spin_lock(&minors_lock);
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 7321a88a5112..076a59cdabe9 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -55,8 +55,8 @@ again:
55 return ERR_PTR(err); 55 return ERR_PTR(err);
56 56
57 id = id & MAX_ID_MASK; 57 id = id & MAX_ID_MASK;
58 hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL, 58 hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
59 HWMON_ID_FORMAT, id); 59 HWMON_ID_FORMAT, id);
60 60
61 if (IS_ERR(hwdev)) { 61 if (IS_ERR(hwdev)) {
62 spin_lock(&idr_lock); 62 spin_lock(&idr_lock);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e7eb7bf9ddec..608038d64f81 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -589,11 +589,16 @@ omap_i2c_probe(struct platform_device *pdev)
589 589
590 dev->dev = &pdev->dev; 590 dev->dev = &pdev->dev;
591 dev->irq = irq->start; 591 dev->irq = irq->start;
592 dev->base = (void __iomem *) IO_ADDRESS(mem->start); 592 dev->base = ioremap(mem->start, mem->end - mem->start + 1);
593 if (!dev->base) {
594 r = -ENOMEM;
595 goto err_free_mem;
596 }
597
593 platform_set_drvdata(pdev, dev); 598 platform_set_drvdata(pdev, dev);
594 599
595 if ((r = omap_i2c_get_clocks(dev)) != 0) 600 if ((r = omap_i2c_get_clocks(dev)) != 0)
596 goto err_free_mem; 601 goto err_iounmap;
597 602
598 omap_i2c_unidle(dev); 603 omap_i2c_unidle(dev);
599 604
@@ -640,6 +645,8 @@ err_unuse_clocks:
640 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 645 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
641 omap_i2c_idle(dev); 646 omap_i2c_idle(dev);
642 omap_i2c_put_clocks(dev); 647 omap_i2c_put_clocks(dev);
648err_iounmap:
649 iounmap(dev->base);
643err_free_mem: 650err_free_mem:
644 platform_set_drvdata(pdev, NULL); 651 platform_set_drvdata(pdev, NULL);
645 kfree(dev); 652 kfree(dev);
@@ -661,6 +668,7 @@ omap_i2c_remove(struct platform_device *pdev)
661 i2c_del_adapter(&dev->adapter); 668 i2c_del_adapter(&dev->adapter);
662 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 669 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
663 omap_i2c_put_clocks(dev); 670 omap_i2c_put_clocks(dev);
671 iounmap(dev->base);
664 kfree(dev); 672 kfree(dev);
665 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 673 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
666 release_mem_region(mem->start, (mem->end - mem->start) + 1); 674 release_mem_region(mem->start, (mem->end - mem->start) + 1);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 307d976c9b69..c171988a9f51 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
521 return PTR_ERR(i2c_dev); 521 return PTR_ERR(i2c_dev);
522 522
523 /* register this i2c device with the driver core */ 523 /* register this i2c device with the driver core */
524 i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev, 524 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
525 MKDEV(I2C_MAJOR, adap->nr), 525 MKDEV(I2C_MAJOR, adap->nr), NULL,
526 NULL, "i2c-%d", adap->nr); 526 "i2c-%d", adap->nr);
527 if (IS_ERR(i2c_dev->dev)) { 527 if (IS_ERR(i2c_dev->dev)) {
528 res = PTR_ERR(i2c_dev->dev); 528 res = PTR_ERR(i2c_dev->dev);
529 goto error; 529 goto error;
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 6c6dd2facede..74a369a6116f 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -4,7 +4,7 @@
4 4
5# Select HAVE_IDE if IDE is supported 5# Select HAVE_IDE if IDE is supported
6config HAVE_IDE 6config HAVE_IDE
7 def_bool n 7 bool
8 8
9menuconfig IDE 9menuconfig IDE
10 tristate "ATA/ATAPI/MFM/RLL support" 10 tristate "ATA/ATAPI/MFM/RLL support"
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index f27baa5f140e..19f8c7770a25 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -657,8 +657,8 @@ static int ide_register_port(ide_hwif_t *hwif)
657 goto out; 657 goto out;
658 } 658 }
659 659
660 hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, 660 hwif->portdev = device_create(ide_port_class, &hwif->gendev,
661 MKDEV(0, 0), hwif, hwif->name); 661 MKDEV(0, 0), hwif, hwif->name);
662 if (IS_ERR(hwif->portdev)) { 662 if (IS_ERR(hwif->portdev)) {
663 ret = PTR_ERR(hwif->portdev); 663 ret = PTR_ERR(hwif->portdev);
664 device_unregister(&hwif->gendev); 664 device_unregister(&hwif->gendev);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 25ac60f53273..d879c7797cde 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2420,12 +2420,11 @@ static int ide_tape_probe(ide_drive_t *drive)
2420 2420
2421 idetape_setup(drive, tape, minor); 2421 idetape_setup(drive, tape, minor);
2422 2422
2423 device_create_drvdata(idetape_sysfs_class, &drive->gendev, 2423 device_create(idetape_sysfs_class, &drive->gendev,
2424 MKDEV(IDETAPE_MAJOR, minor), NULL, 2424 MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name);
2425 "%s", tape->name); 2425 device_create(idetape_sysfs_class, &drive->gendev,
2426 device_create_drvdata(idetape_sysfs_class, &drive->gendev, 2426 MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
2427 MKDEV(IDETAPE_MAJOR, minor + 128), NULL, 2427 "n%s", tape->name);
2428 "n%s", tape->name);
2429 2428
2430 g->fops = &idetape_block_ops; 2429 g->fops = &idetape_block_ops;
2431 ide_register_region(g); 2430 ide_register_region(g);
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index 9f95337139e3..5e38a68b8af2 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -84,7 +84,7 @@ static const u8 csr1212_key_id_type_map[0x30] = {
84 84
85 85
86#define quads_to_bytes(_q) ((_q) * sizeof(u32)) 86#define quads_to_bytes(_q) ((_q) * sizeof(u32))
87#define bytes_to_quads(_b) (((_b) + sizeof(u32) - 1) / sizeof(u32)) 87#define bytes_to_quads(_b) DIV_ROUND_UP(_b, sizeof(u32))
88 88
89static void free_keyval(struct csr1212_keyval *kv) 89static void free_keyval(struct csr1212_keyval *kv)
90{ 90{
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index b6eb2cf25914..2f83543a9dfc 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -918,7 +918,7 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
918 /* default SYT offset is 3 cycles */ 918 /* default SYT offset is 3 cycles */
919 init->syt_offset = 3; 919 init->syt_offset = 3;
920 920
921 if ( (init->channel > 63) || (init->channel < 0) ) 921 if (init->channel > 63)
922 init->channel = 63; 922 init->channel = 63;
923 923
924 chan_mask = (u64)1 << init->channel; 924 chan_mask = (u64)1 << init->channel;
@@ -2296,10 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host)
2296 2296
2297 ohci = (struct ti_ohci *)host->hostdata; 2297 ohci = (struct ti_ohci *)host->hostdata;
2298 2298
2299 device_create_drvdata(hpsb_protocol_class, NULL, 2299 device_create(hpsb_protocol_class, NULL,
2300 MKDEV(IEEE1394_MAJOR, 2300 MKDEV(IEEE1394_MAJOR,
2301 IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL, 2301 IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
2302 "dv1394-%d", id); 2302 NULL, "dv1394-%d", id);
2303 2303
2304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); 2304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
2305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); 2305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index b166b3575fa6..20128692b339 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -1361,7 +1361,7 @@ static unsigned int ether1394_encapsulate_prep(unsigned int max_payload,
1361 hdr->ff.dgl = dgl; 1361 hdr->ff.dgl = dgl;
1362 adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_FF]; 1362 adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_FF];
1363 } 1363 }
1364 return (dg_size + adj_max_payload - 1) / adj_max_payload; 1364 return DIV_ROUND_UP(dg_size, adj_max_payload);
1365} 1365}
1366 1366
1367static unsigned int ether1394_encapsulate(struct sk_buff *skb, 1367static unsigned int ether1394_encapsulate(struct sk_buff *skb,
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 16240a789650..2376b729e876 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -154,9 +154,6 @@ struct host_info {
154 154
155static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); 155static int nodemgr_bus_match(struct device * dev, struct device_driver * drv);
156static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env); 156static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env);
157static void nodemgr_resume_ne(struct node_entry *ne);
158static void nodemgr_remove_ne(struct node_entry *ne);
159static struct node_entry *find_entry_by_guid(u64 guid);
160 157
161struct bus_type ieee1394_bus_type = { 158struct bus_type ieee1394_bus_type = {
162 .name = "ieee1394", 159 .name = "ieee1394",
@@ -385,27 +382,6 @@ static ssize_t fw_get_ignore_driver(struct device *dev, struct device_attribute
385static DEVICE_ATTR(ignore_driver, S_IWUSR | S_IRUGO, fw_get_ignore_driver, fw_set_ignore_driver); 382static DEVICE_ATTR(ignore_driver, S_IWUSR | S_IRUGO, fw_get_ignore_driver, fw_set_ignore_driver);
386 383
387 384
388static ssize_t fw_set_destroy_node(struct bus_type *bus, const char *buf, size_t count)
389{
390 struct node_entry *ne;
391 u64 guid = (u64)simple_strtoull(buf, NULL, 16);
392
393 ne = find_entry_by_guid(guid);
394
395 if (ne == NULL || !ne->in_limbo)
396 return -EINVAL;
397
398 nodemgr_remove_ne(ne);
399
400 return count;
401}
402static ssize_t fw_get_destroy_node(struct bus_type *bus, char *buf)
403{
404 return sprintf(buf, "You can destroy in_limbo nodes by writing their GUID to this file\n");
405}
406static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node);
407
408
409static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf, 385static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf,
410 size_t count) 386 size_t count)
411{ 387{
@@ -442,7 +418,6 @@ static BUS_ATTR(ignore_drivers, S_IWUSR | S_IRUGO, fw_get_ignore_drivers, fw_set
442 418
443 419
444struct bus_attribute *const fw_bus_attrs[] = { 420struct bus_attribute *const fw_bus_attrs[] = {
445 &bus_attr_destroy_node,
446 &bus_attr_rescan, 421 &bus_attr_rescan,
447 &bus_attr_ignore_drivers, 422 &bus_attr_ignore_drivers,
448 NULL 423 NULL
@@ -734,10 +709,10 @@ static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
734 709
735static DEFINE_MUTEX(nodemgr_serialize_remove_uds); 710static DEFINE_MUTEX(nodemgr_serialize_remove_uds);
736 711
737static int __match_ne(struct device *dev, void *data) 712static int match_ne(struct device *dev, void *data)
738{ 713{
739 struct unit_directory *ud; 714 struct unit_directory *ud;
740 struct node_entry *ne = (struct node_entry *)data; 715 struct node_entry *ne = data;
741 716
742 ud = container_of(dev, struct unit_directory, unit_dev); 717 ud = container_of(dev, struct unit_directory, unit_dev);
743 return ud->ne == ne; 718 return ud->ne == ne;
@@ -754,8 +729,7 @@ static void nodemgr_remove_uds(struct node_entry *ne)
754 */ 729 */
755 mutex_lock(&nodemgr_serialize_remove_uds); 730 mutex_lock(&nodemgr_serialize_remove_uds);
756 for (;;) { 731 for (;;) {
757 dev = class_find_device(&nodemgr_ud_class, NULL, ne, 732 dev = class_find_device(&nodemgr_ud_class, NULL, ne, match_ne);
758 __match_ne);
759 if (!dev) 733 if (!dev)
760 break; 734 break;
761 ud = container_of(dev, struct unit_directory, unit_dev); 735 ud = container_of(dev, struct unit_directory, unit_dev);
@@ -785,7 +759,7 @@ static void nodemgr_remove_ne(struct node_entry *ne)
785 put_device(dev); 759 put_device(dev);
786} 760}
787 761
788static int __nodemgr_remove_host_dev(struct device *dev, void *data) 762static int remove_host_dev(struct device *dev, void *data)
789{ 763{
790 if (dev->bus == &ieee1394_bus_type) 764 if (dev->bus == &ieee1394_bus_type)
791 nodemgr_remove_ne(container_of(dev, struct node_entry, 765 nodemgr_remove_ne(container_of(dev, struct node_entry,
@@ -795,7 +769,7 @@ static int __nodemgr_remove_host_dev(struct device *dev, void *data)
795 769
796static void nodemgr_remove_host_dev(struct device *dev) 770static void nodemgr_remove_host_dev(struct device *dev)
797{ 771{
798 WARN_ON(device_for_each_child(dev, NULL, __nodemgr_remove_host_dev)); 772 device_for_each_child(dev, NULL, remove_host_dev);
799 sysfs_remove_link(&dev->kobj, "irm_id"); 773 sysfs_remove_link(&dev->kobj, "irm_id");
800 sysfs_remove_link(&dev->kobj, "busmgr_id"); 774 sysfs_remove_link(&dev->kobj, "busmgr_id");
801 sysfs_remove_link(&dev->kobj, "host_id"); 775 sysfs_remove_link(&dev->kobj, "host_id");
@@ -830,11 +804,10 @@ static void nodemgr_update_bus_options(struct node_entry *ne)
830} 804}
831 805
832 806
833static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr *csr, 807static struct node_entry *nodemgr_create_node(octlet_t guid,
834 struct host_info *hi, nodeid_t nodeid, 808 struct csr1212_csr *csr, struct hpsb_host *host,
835 unsigned int generation) 809 nodeid_t nodeid, unsigned int generation)
836{ 810{
837 struct hpsb_host *host = hi->host;
838 struct node_entry *ne; 811 struct node_entry *ne;
839 812
840 ne = kzalloc(sizeof(*ne), GFP_KERNEL); 813 ne = kzalloc(sizeof(*ne), GFP_KERNEL);
@@ -888,10 +861,10 @@ fail_alloc:
888 return NULL; 861 return NULL;
889} 862}
890 863
891static int __match_ne_guid(struct device *dev, void *data) 864static int match_ne_guid(struct device *dev, void *data)
892{ 865{
893 struct node_entry *ne; 866 struct node_entry *ne;
894 u64 *guid = (u64 *)data; 867 u64 *guid = data;
895 868
896 ne = container_of(dev, struct node_entry, node_dev); 869 ne = container_of(dev, struct node_entry, node_dev);
897 return ne->guid == *guid; 870 return ne->guid == *guid;
@@ -902,8 +875,7 @@ static struct node_entry *find_entry_by_guid(u64 guid)
902 struct device *dev; 875 struct device *dev;
903 struct node_entry *ne; 876 struct node_entry *ne;
904 877
905 dev = class_find_device(&nodemgr_ne_class, NULL, &guid, 878 dev = class_find_device(&nodemgr_ne_class, NULL, &guid, match_ne_guid);
906 __match_ne_guid);
907 if (!dev) 879 if (!dev)
908 return NULL; 880 return NULL;
909 ne = container_of(dev, struct node_entry, node_dev); 881 ne = container_of(dev, struct node_entry, node_dev);
@@ -912,21 +884,21 @@ static struct node_entry *find_entry_by_guid(u64 guid)
912 return ne; 884 return ne;
913} 885}
914 886
915struct match_nodeid_param { 887struct match_nodeid_parameter {
916 struct hpsb_host *host; 888 struct hpsb_host *host;
917 nodeid_t nodeid; 889 nodeid_t nodeid;
918}; 890};
919 891
920static int __match_ne_nodeid(struct device *dev, void *data) 892static int match_ne_nodeid(struct device *dev, void *data)
921{ 893{
922 int found = 0; 894 int found = 0;
923 struct node_entry *ne; 895 struct node_entry *ne;
924 struct match_nodeid_param *param = (struct match_nodeid_param *)data; 896 struct match_nodeid_parameter *p = data;
925 897
926 if (!dev) 898 if (!dev)
927 goto ret; 899 goto ret;
928 ne = container_of(dev, struct node_entry, node_dev); 900 ne = container_of(dev, struct node_entry, node_dev);
929 if (ne->host == param->host && ne->nodeid == param->nodeid) 901 if (ne->host == p->host && ne->nodeid == p->nodeid)
930 found = 1; 902 found = 1;
931ret: 903ret:
932 return found; 904 return found;
@@ -937,13 +909,12 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
937{ 909{
938 struct device *dev; 910 struct device *dev;
939 struct node_entry *ne; 911 struct node_entry *ne;
940 struct match_nodeid_param param; 912 struct match_nodeid_parameter p;
941 913
942 param.host = host; 914 p.host = host;
943 param.nodeid = nodeid; 915 p.nodeid = nodeid;
944 916
945 dev = class_find_device(&nodemgr_ne_class, NULL, &param, 917 dev = class_find_device(&nodemgr_ne_class, NULL, &p, match_ne_nodeid);
946 __match_ne_nodeid);
947 if (!dev) 918 if (!dev)
948 return NULL; 919 return NULL;
949 ne = container_of(dev, struct node_entry, node_dev); 920 ne = container_of(dev, struct node_entry, node_dev);
@@ -990,7 +961,7 @@ fail_devreg:
990 * immediate unit directories looking for software_id and 961 * immediate unit directories looking for software_id and
991 * software_version entries, in order to get driver autoloading working. */ 962 * software_version entries, in order to get driver autoloading working. */
992static struct unit_directory *nodemgr_process_unit_directory 963static struct unit_directory *nodemgr_process_unit_directory
993 (struct host_info *hi, struct node_entry *ne, struct csr1212_keyval *ud_kv, 964 (struct node_entry *ne, struct csr1212_keyval *ud_kv,
994 unsigned int *id, struct unit_directory *parent) 965 unsigned int *id, struct unit_directory *parent)
995{ 966{
996 struct unit_directory *ud; 967 struct unit_directory *ud;
@@ -1083,7 +1054,7 @@ static struct unit_directory *nodemgr_process_unit_directory
1083 nodemgr_register_device(ne, ud, &ne->device); 1054 nodemgr_register_device(ne, ud, &ne->device);
1084 1055
1085 /* process the child unit */ 1056 /* process the child unit */
1086 ud_child = nodemgr_process_unit_directory(hi, ne, kv, id, ud); 1057 ud_child = nodemgr_process_unit_directory(ne, kv, id, ud);
1087 1058
1088 if (ud_child == NULL) 1059 if (ud_child == NULL)
1089 break; 1060 break;
@@ -1137,7 +1108,7 @@ unit_directory_error:
1137} 1108}
1138 1109
1139 1110
1140static void nodemgr_process_root_directory(struct host_info *hi, struct node_entry *ne) 1111static void nodemgr_process_root_directory(struct node_entry *ne)
1141{ 1112{
1142 unsigned int ud_id = 0; 1113 unsigned int ud_id = 0;
1143 struct csr1212_dentry *dentry; 1114 struct csr1212_dentry *dentry;
@@ -1157,7 +1128,7 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1157 break; 1128 break;
1158 1129
1159 case CSR1212_KV_ID_UNIT: 1130 case CSR1212_KV_ID_UNIT:
1160 nodemgr_process_unit_directory(hi, ne, kv, &ud_id, NULL); 1131 nodemgr_process_unit_directory(ne, kv, &ud_id, NULL);
1161 break; 1132 break;
1162 1133
1163 case CSR1212_KV_ID_DESCRIPTOR: 1134 case CSR1212_KV_ID_DESCRIPTOR:
@@ -1273,8 +1244,7 @@ void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver)
1273 * the to take whatever actions required. 1244 * the to take whatever actions required.
1274 */ 1245 */
1275static void nodemgr_update_node(struct node_entry *ne, struct csr1212_csr *csr, 1246static void nodemgr_update_node(struct node_entry *ne, struct csr1212_csr *csr,
1276 struct host_info *hi, nodeid_t nodeid, 1247 nodeid_t nodeid, unsigned int generation)
1277 unsigned int generation)
1278{ 1248{
1279 if (ne->nodeid != nodeid) { 1249 if (ne->nodeid != nodeid) {
1280 HPSB_DEBUG("Node changed: " NODE_BUS_FMT " -> " NODE_BUS_FMT, 1250 HPSB_DEBUG("Node changed: " NODE_BUS_FMT " -> " NODE_BUS_FMT,
@@ -1305,19 +1275,23 @@ static void nodemgr_update_node(struct node_entry *ne, struct csr1212_csr *csr,
1305 csr1212_destroy_csr(csr); 1275 csr1212_destroy_csr(csr);
1306 } 1276 }
1307 1277
1308 if (ne->in_limbo)
1309 nodemgr_resume_ne(ne);
1310
1311 /* Mark the node current */ 1278 /* Mark the node current */
1312 ne->generation = generation; 1279 ne->generation = generation;
1313}
1314 1280
1281 if (ne->in_limbo) {
1282 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
1283 ne->in_limbo = false;
1315 1284
1285 HPSB_DEBUG("Node reactivated: "
1286 "ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
1287 NODE_BUS_ARGS(ne->host, ne->nodeid),
1288 (unsigned long long)ne->guid);
1289 }
1290}
1316 1291
1317static void nodemgr_node_scan_one(struct host_info *hi, 1292static void nodemgr_node_scan_one(struct hpsb_host *host,
1318 nodeid_t nodeid, int generation) 1293 nodeid_t nodeid, int generation)
1319{ 1294{
1320 struct hpsb_host *host = hi->host;
1321 struct node_entry *ne; 1295 struct node_entry *ne;
1322 octlet_t guid; 1296 octlet_t guid;
1323 struct csr1212_csr *csr; 1297 struct csr1212_csr *csr;
@@ -1373,16 +1347,15 @@ static void nodemgr_node_scan_one(struct host_info *hi,
1373 } 1347 }
1374 1348
1375 if (!ne) 1349 if (!ne)
1376 nodemgr_create_node(guid, csr, hi, nodeid, generation); 1350 nodemgr_create_node(guid, csr, host, nodeid, generation);
1377 else 1351 else
1378 nodemgr_update_node(ne, csr, hi, nodeid, generation); 1352 nodemgr_update_node(ne, csr, nodeid, generation);
1379} 1353}
1380 1354
1381 1355
1382static void nodemgr_node_scan(struct host_info *hi, int generation) 1356static void nodemgr_node_scan(struct hpsb_host *host, int generation)
1383{ 1357{
1384 int count; 1358 int count;
1385 struct hpsb_host *host = hi->host;
1386 struct selfid *sid = (struct selfid *)host->topology_map; 1359 struct selfid *sid = (struct selfid *)host->topology_map;
1387 nodeid_t nodeid = LOCAL_BUS; 1360 nodeid_t nodeid = LOCAL_BUS;
1388 1361
@@ -1395,89 +1368,26 @@ static void nodemgr_node_scan(struct host_info *hi, int generation)
1395 nodeid++; 1368 nodeid++;
1396 continue; 1369 continue;
1397 } 1370 }
1398 nodemgr_node_scan_one(hi, nodeid++, generation); 1371 nodemgr_node_scan_one(host, nodeid++, generation);
1399 }
1400}
1401
1402static int __nodemgr_driver_suspend(struct device *dev, void *data)
1403{
1404 struct unit_directory *ud;
1405 struct device_driver *drv;
1406 struct node_entry *ne = (struct node_entry *)data;
1407 int error;
1408
1409 ud = container_of(dev, struct unit_directory, unit_dev);
1410 if (ud->ne == ne) {
1411 drv = get_driver(ud->device.driver);
1412 if (drv) {
1413 error = 1; /* release if suspend is not implemented */
1414 if (drv->suspend) {
1415 down(&ud->device.sem);
1416 error = drv->suspend(&ud->device, PMSG_SUSPEND);
1417 up(&ud->device.sem);
1418 }
1419 if (error)
1420 device_release_driver(&ud->device);
1421 put_driver(drv);
1422 }
1423 }
1424
1425 return 0;
1426}
1427
1428static int __nodemgr_driver_resume(struct device *dev, void *data)
1429{
1430 struct unit_directory *ud;
1431 struct device_driver *drv;
1432 struct node_entry *ne = (struct node_entry *)data;
1433
1434 ud = container_of(dev, struct unit_directory, unit_dev);
1435 if (ud->ne == ne) {
1436 drv = get_driver(ud->device.driver);
1437 if (drv) {
1438 if (drv->resume) {
1439 down(&ud->device.sem);
1440 drv->resume(&ud->device);
1441 up(&ud->device.sem);
1442 }
1443 put_driver(drv);
1444 }
1445 } 1372 }
1446
1447 return 0;
1448} 1373}
1449 1374
1450static void nodemgr_suspend_ne(struct node_entry *ne) 1375static void nodemgr_pause_ne(struct node_entry *ne)
1451{ 1376{
1452 HPSB_DEBUG("Node suspended: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 1377 HPSB_DEBUG("Node paused: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
1453 NODE_BUS_ARGS(ne->host, ne->nodeid), 1378 NODE_BUS_ARGS(ne->host, ne->nodeid),
1454 (unsigned long long)ne->guid); 1379 (unsigned long long)ne->guid);
1455 1380
1456 ne->in_limbo = 1; 1381 ne->in_limbo = true;
1457 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); 1382 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
1458
1459 class_for_each_device(&nodemgr_ud_class, NULL, ne,
1460 __nodemgr_driver_suspend);
1461}
1462
1463
1464static void nodemgr_resume_ne(struct node_entry *ne)
1465{
1466 ne->in_limbo = 0;
1467 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
1468
1469 class_for_each_device(&nodemgr_ud_class, NULL, ne,
1470 __nodemgr_driver_resume);
1471 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
1472 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
1473} 1383}
1474 1384
1475static int __nodemgr_update_pdrv(struct device *dev, void *data) 1385static int update_pdrv(struct device *dev, void *data)
1476{ 1386{
1477 struct unit_directory *ud; 1387 struct unit_directory *ud;
1478 struct device_driver *drv; 1388 struct device_driver *drv;
1479 struct hpsb_protocol_driver *pdrv; 1389 struct hpsb_protocol_driver *pdrv;
1480 struct node_entry *ne = (struct node_entry *)data; 1390 struct node_entry *ne = data;
1481 int error; 1391 int error;
1482 1392
1483 ud = container_of(dev, struct unit_directory, unit_dev); 1393 ud = container_of(dev, struct unit_directory, unit_dev);
@@ -1503,11 +1413,9 @@ static int __nodemgr_update_pdrv(struct device *dev, void *data)
1503 1413
1504static void nodemgr_update_pdrv(struct node_entry *ne) 1414static void nodemgr_update_pdrv(struct node_entry *ne)
1505{ 1415{
1506 class_for_each_device(&nodemgr_ud_class, NULL, ne, 1416 class_for_each_device(&nodemgr_ud_class, NULL, ne, update_pdrv);
1507 __nodemgr_update_pdrv);
1508} 1417}
1509 1418
1510
1511/* Write the BROADCAST_CHANNEL as per IEEE1394a 8.3.2.3.11 and 8.4.2.3. This 1419/* Write the BROADCAST_CHANNEL as per IEEE1394a 8.3.2.3.11 and 8.4.2.3. This
1512 * seems like an optional service but in the end it is practically mandatory 1420 * seems like an optional service but in the end it is practically mandatory
1513 * as a consequence of these clauses. 1421 * as a consequence of these clauses.
@@ -1535,11 +1443,12 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1535} 1443}
1536 1444
1537 1445
1538static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation) 1446static void nodemgr_probe_ne(struct hpsb_host *host, struct node_entry *ne,
1447 int generation)
1539{ 1448{
1540 struct device *dev; 1449 struct device *dev;
1541 1450
1542 if (ne->host != hi->host || ne->in_limbo) 1451 if (ne->host != host || ne->in_limbo)
1543 return; 1452 return;
1544 1453
1545 dev = get_device(&ne->device); 1454 dev = get_device(&ne->device);
@@ -1554,40 +1463,40 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
1554 * down to the drivers. Otherwise, this is a dead node and we 1463 * down to the drivers. Otherwise, this is a dead node and we
1555 * suspend it. */ 1464 * suspend it. */
1556 if (ne->needs_probe) 1465 if (ne->needs_probe)
1557 nodemgr_process_root_directory(hi, ne); 1466 nodemgr_process_root_directory(ne);
1558 else if (ne->generation == generation) 1467 else if (ne->generation == generation)
1559 nodemgr_update_pdrv(ne); 1468 nodemgr_update_pdrv(ne);
1560 else 1469 else
1561 nodemgr_suspend_ne(ne); 1470 nodemgr_pause_ne(ne);
1562 1471
1563 put_device(dev); 1472 put_device(dev);
1564} 1473}
1565 1474
1566struct probe_param { 1475struct node_probe_parameter {
1567 struct host_info *hi; 1476 struct hpsb_host *host;
1568 int generation; 1477 int generation;
1569 bool probe_now; 1478 bool probe_now;
1570}; 1479};
1571 1480
1572static int node_probe(struct device *dev, void *data) 1481static int node_probe(struct device *dev, void *data)
1573{ 1482{
1574 struct probe_param *p = data; 1483 struct node_probe_parameter *p = data;
1575 struct node_entry *ne; 1484 struct node_entry *ne;
1576 1485
1577 if (p->generation != get_hpsb_generation(p->hi->host)) 1486 if (p->generation != get_hpsb_generation(p->host))
1578 return -EAGAIN; 1487 return -EAGAIN;
1579 1488
1580 ne = container_of(dev, struct node_entry, node_dev); 1489 ne = container_of(dev, struct node_entry, node_dev);
1581 if (ne->needs_probe == p->probe_now) 1490 if (ne->needs_probe == p->probe_now)
1582 nodemgr_probe_ne(p->hi, ne, p->generation); 1491 nodemgr_probe_ne(p->host, ne, p->generation);
1583 return 0; 1492 return 0;
1584} 1493}
1585 1494
1586static void nodemgr_node_probe(struct host_info *hi, int generation) 1495static int nodemgr_node_probe(struct hpsb_host *host, int generation)
1587{ 1496{
1588 struct probe_param p; 1497 struct node_probe_parameter p;
1589 1498
1590 p.hi = hi; 1499 p.host = host;
1591 p.generation = generation; 1500 p.generation = generation;
1592 /* 1501 /*
1593 * Do some processing of the nodes we've probed. This pulls them 1502 * Do some processing of the nodes we've probed. This pulls them
@@ -1604,11 +1513,11 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1604 */ 1513 */
1605 p.probe_now = false; 1514 p.probe_now = false;
1606 if (class_for_each_device(&nodemgr_ne_class, NULL, &p, node_probe) != 0) 1515 if (class_for_each_device(&nodemgr_ne_class, NULL, &p, node_probe) != 0)
1607 return; 1516 return 0;
1608 1517
1609 p.probe_now = true; 1518 p.probe_now = true;
1610 if (class_for_each_device(&nodemgr_ne_class, NULL, &p, node_probe) != 0) 1519 if (class_for_each_device(&nodemgr_ne_class, NULL, &p, node_probe) != 0)
1611 return; 1520 return 0;
1612 /* 1521 /*
1613 * Now let's tell the bus to rescan our devices. This may seem 1522 * Now let's tell the bus to rescan our devices. This may seem
1614 * like overhead, but the driver-model core will only scan a 1523 * like overhead, but the driver-model core will only scan a
@@ -1620,6 +1529,27 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1620 */ 1529 */
1621 if (bus_rescan_devices(&ieee1394_bus_type) != 0) 1530 if (bus_rescan_devices(&ieee1394_bus_type) != 0)
1622 HPSB_DEBUG("bus_rescan_devices had an error"); 1531 HPSB_DEBUG("bus_rescan_devices had an error");
1532
1533 return 1;
1534}
1535
1536static int remove_nodes_in_limbo(struct device *dev, void *data)
1537{
1538 struct node_entry *ne;
1539
1540 if (dev->bus != &ieee1394_bus_type)
1541 return 0;
1542
1543 ne = container_of(dev, struct node_entry, device);
1544 if (ne->in_limbo)
1545 nodemgr_remove_ne(ne);
1546
1547 return 0;
1548}
1549
1550static void nodemgr_remove_nodes_in_limbo(struct hpsb_host *host)
1551{
1552 device_for_each_child(&host->device, NULL, remove_nodes_in_limbo);
1623} 1553}
1624 1554
1625static int nodemgr_send_resume_packet(struct hpsb_host *host) 1555static int nodemgr_send_resume_packet(struct hpsb_host *host)
@@ -1730,10 +1660,9 @@ static int nodemgr_check_irm_capability(struct hpsb_host *host, int cycles)
1730 return 1; 1660 return 1;
1731} 1661}
1732 1662
1733static int nodemgr_host_thread(void *__hi) 1663static int nodemgr_host_thread(void *data)
1734{ 1664{
1735 struct host_info *hi = (struct host_info *)__hi; 1665 struct hpsb_host *host = data;
1736 struct hpsb_host *host = hi->host;
1737 unsigned int g, generation = 0; 1666 unsigned int g, generation = 0;
1738 int i, reset_cycles = 0; 1667 int i, reset_cycles = 0;
1739 1668
@@ -1787,36 +1716,48 @@ static int nodemgr_host_thread(void *__hi)
1787 * entries. This does not do the sysfs stuff, since that 1716 * entries. This does not do the sysfs stuff, since that
1788 * would trigger uevents and such, which is a bad idea at 1717 * would trigger uevents and such, which is a bad idea at
1789 * this point. */ 1718 * this point. */
1790 nodemgr_node_scan(hi, generation); 1719 nodemgr_node_scan(host, generation);
1791 1720
1792 /* This actually does the full probe, with sysfs 1721 /* This actually does the full probe, with sysfs
1793 * registration. */ 1722 * registration. */
1794 nodemgr_node_probe(hi, generation); 1723 if (!nodemgr_node_probe(host, generation))
1724 continue;
1795 1725
1796 /* Update some of our sysfs symlinks */ 1726 /* Update some of our sysfs symlinks */
1797 nodemgr_update_host_dev_links(host); 1727 nodemgr_update_host_dev_links(host);
1728
1729 /* Sleep 3 seconds */
1730 for (i = 3000/200; i; i--) {
1731 msleep_interruptible(200);
1732 if (kthread_should_stop())
1733 goto exit;
1734
1735 if (generation != get_hpsb_generation(host))
1736 break;
1737 }
1738 /* Remove nodes which are gone, unless a bus reset happened */
1739 if (!i)
1740 nodemgr_remove_nodes_in_limbo(host);
1798 } 1741 }
1799exit: 1742exit:
1800 HPSB_VERBOSE("NodeMgr: Exiting thread"); 1743 HPSB_VERBOSE("NodeMgr: Exiting thread");
1801 return 0; 1744 return 0;
1802} 1745}
1803 1746
1804struct host_iter_param { 1747struct per_host_parameter {
1805 void *data; 1748 void *data;
1806 int (*cb)(struct hpsb_host *, void *); 1749 int (*cb)(struct hpsb_host *, void *);
1807}; 1750};
1808 1751
1809static int __nodemgr_for_each_host(struct device *dev, void *data) 1752static int per_host(struct device *dev, void *data)
1810{ 1753{
1811 struct hpsb_host *host; 1754 struct hpsb_host *host;
1812 struct host_iter_param *hip = (struct host_iter_param *)data; 1755 struct per_host_parameter *p = data;
1813 int error = 0;
1814 1756
1815 host = container_of(dev, struct hpsb_host, host_dev); 1757 host = container_of(dev, struct hpsb_host, host_dev);
1816 error = hip->cb(host, hip->data); 1758 return p->cb(host, p->data);
1817
1818 return error;
1819} 1759}
1760
1820/** 1761/**
1821 * nodemgr_for_each_host - call a function for each IEEE 1394 host 1762 * nodemgr_for_each_host - call a function for each IEEE 1394 host
1822 * @data: an address to supply to the callback 1763 * @data: an address to supply to the callback
@@ -1831,15 +1772,11 @@ static int __nodemgr_for_each_host(struct device *dev, void *data)
1831 */ 1772 */
1832int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)) 1773int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *))
1833{ 1774{
1834 struct host_iter_param hip; 1775 struct per_host_parameter p;
1835 int error;
1836
1837 hip.cb = cb;
1838 hip.data = data;
1839 error = class_for_each_device(&hpsb_host_class, NULL, &hip,
1840 __nodemgr_for_each_host);
1841 1776
1842 return error; 1777 p.cb = cb;
1778 p.data = data;
1779 return class_for_each_device(&hpsb_host_class, NULL, &p, per_host);
1843} 1780}
1844 1781
1845/* The following two convenience functions use a struct node_entry 1782/* The following two convenience functions use a struct node_entry
@@ -1893,7 +1830,7 @@ static void nodemgr_add_host(struct hpsb_host *host)
1893 return; 1830 return;
1894 } 1831 }
1895 hi->host = host; 1832 hi->host = host;
1896 hi->thread = kthread_run(nodemgr_host_thread, hi, "knodemgrd_%d", 1833 hi->thread = kthread_run(nodemgr_host_thread, host, "knodemgrd_%d",
1897 host->id); 1834 host->id);
1898 if (IS_ERR(hi->thread)) { 1835 if (IS_ERR(hi->thread)) {
1899 HPSB_ERR("NodeMgr: cannot start thread for host %d", host->id); 1836 HPSB_ERR("NodeMgr: cannot start thread for host %d", host->id);
diff --git a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h
index 6eb26465a84c..4f287a3561ba 100644
--- a/drivers/ieee1394/nodemgr.h
+++ b/drivers/ieee1394/nodemgr.h
@@ -110,7 +110,7 @@ struct node_entry {
110 struct device node_dev; 110 struct device node_dev;
111 111
112 /* Means this node is not attached anymore */ 112 /* Means this node is not attached anymore */
113 int in_limbo; 113 bool in_limbo;
114 114
115 struct csr1212_csr *csr; 115 struct csr1212_csr *csr;
116}; 116};
diff --git a/drivers/ieee1394/raw1394-private.h b/drivers/ieee1394/raw1394-private.h
index a06aaad5b448..7a225a405987 100644
--- a/drivers/ieee1394/raw1394-private.h
+++ b/drivers/ieee1394/raw1394-private.h
@@ -22,6 +22,7 @@ enum raw1394_iso_state { RAW1394_ISO_INACTIVE = 0,
22struct file_info { 22struct file_info {
23 struct list_head list; 23 struct list_head list;
24 24
25 struct mutex state_mutex;
25 enum { opened, initialized, connected } state; 26 enum { opened, initialized, connected } state;
26 unsigned int protocol_version; 27 unsigned int protocol_version;
27 28
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 6fa9e4a21840..9f19ac492106 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -34,6 +34,7 @@
34#include <linux/fs.h> 34#include <linux/fs.h>
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/mutex.h>
37#include <linux/init.h> 38#include <linux/init.h>
38#include <linux/interrupt.h> 39#include <linux/interrupt.h>
39#include <linux/vmalloc.h> 40#include <linux/vmalloc.h>
@@ -2267,6 +2268,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
2267 return -EFAULT; 2268 return -EFAULT;
2268 } 2269 }
2269 2270
2271 mutex_lock(&fi->state_mutex);
2272
2270 switch (fi->state) { 2273 switch (fi->state) {
2271 case opened: 2274 case opened:
2272 retval = state_opened(fi, req); 2275 retval = state_opened(fi, req);
@@ -2281,6 +2284,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
2281 break; 2284 break;
2282 } 2285 }
2283 2286
2287 mutex_unlock(&fi->state_mutex);
2288
2284 if (retval < 0) { 2289 if (retval < 0) {
2285 free_pending_request(req); 2290 free_pending_request(req);
2286 } else { 2291 } else {
@@ -2541,109 +2546,120 @@ static int raw1394_read_cycle_timer(struct file_info *fi, void __user * uaddr)
2541static int raw1394_mmap(struct file *file, struct vm_area_struct *vma) 2546static int raw1394_mmap(struct file *file, struct vm_area_struct *vma)
2542{ 2547{
2543 struct file_info *fi = file->private_data; 2548 struct file_info *fi = file->private_data;
2549 int ret;
2550
2551 mutex_lock(&fi->state_mutex);
2544 2552
2545 if (fi->iso_state == RAW1394_ISO_INACTIVE) 2553 if (fi->iso_state == RAW1394_ISO_INACTIVE)
2546 return -EINVAL; 2554 ret = -EINVAL;
2555 else
2556 ret = dma_region_mmap(&fi->iso_handle->data_buf, file, vma);
2557
2558 mutex_unlock(&fi->state_mutex);
2547 2559
2548 return dma_region_mmap(&fi->iso_handle->data_buf, file, vma); 2560 return ret;
2549} 2561}
2550 2562
2551/* ioctl is only used for rawiso operations */ 2563static long raw1394_ioctl_inactive(struct file_info *fi, unsigned int cmd,
2552static long do_raw1394_ioctl(struct file *file, unsigned int cmd, 2564 void __user *argp)
2553 unsigned long arg) 2565{
2566 switch (cmd) {
2567 case RAW1394_IOC_ISO_XMIT_INIT:
2568 return raw1394_iso_xmit_init(fi, argp);
2569 case RAW1394_IOC_ISO_RECV_INIT:
2570 return raw1394_iso_recv_init(fi, argp);
2571 default:
2572 return -EINVAL;
2573 }
2574}
2575
2576static long raw1394_ioctl_recv(struct file_info *fi, unsigned int cmd,
2577 unsigned long arg)
2554{ 2578{
2555 struct file_info *fi = file->private_data;
2556 void __user *argp = (void __user *)arg; 2579 void __user *argp = (void __user *)arg;
2557 2580
2558 switch (fi->iso_state) { 2581 switch (cmd) {
2559 case RAW1394_ISO_INACTIVE: 2582 case RAW1394_IOC_ISO_RECV_START:{
2560 switch (cmd) { 2583 int args[3];
2561 case RAW1394_IOC_ISO_XMIT_INIT: 2584
2562 return raw1394_iso_xmit_init(fi, argp); 2585 if (copy_from_user(&args[0], argp, sizeof(args)))
2563 case RAW1394_IOC_ISO_RECV_INIT: 2586 return -EFAULT;
2564 return raw1394_iso_recv_init(fi, argp); 2587 return hpsb_iso_recv_start(fi->iso_handle,
2565 default: 2588 args[0], args[1], args[2]);
2566 break;
2567 } 2589 }
2568 break; 2590 case RAW1394_IOC_ISO_XMIT_RECV_STOP:
2569 case RAW1394_ISO_RECV: 2591 hpsb_iso_stop(fi->iso_handle);
2570 switch (cmd) { 2592 return 0;
2571 case RAW1394_IOC_ISO_RECV_START:{ 2593 case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL:
2572 /* copy args from user-space */ 2594 return hpsb_iso_recv_listen_channel(fi->iso_handle, arg);
2573 int args[3]; 2595 case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL:
2574 if (copy_from_user 2596 return hpsb_iso_recv_unlisten_channel(fi->iso_handle, arg);
2575 (&args[0], argp, sizeof(args))) 2597 case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK:{
2576 return -EFAULT; 2598 u64 mask;
2577 return hpsb_iso_recv_start(fi->iso_handle, 2599
2578 args[0], args[1], 2600 if (copy_from_user(&mask, argp, sizeof(mask)))
2579 args[2]); 2601 return -EFAULT;
2580 } 2602 return hpsb_iso_recv_set_channel_mask(fi->iso_handle,
2581 case RAW1394_IOC_ISO_XMIT_RECV_STOP: 2603 mask);
2582 hpsb_iso_stop(fi->iso_handle);
2583 return 0;
2584 case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL:
2585 return hpsb_iso_recv_listen_channel(fi->iso_handle,
2586 arg);
2587 case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL:
2588 return hpsb_iso_recv_unlisten_channel(fi->iso_handle,
2589 arg);
2590 case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK:{
2591 /* copy the u64 from user-space */
2592 u64 mask;
2593 if (copy_from_user(&mask, argp, sizeof(mask)))
2594 return -EFAULT;
2595 return hpsb_iso_recv_set_channel_mask(fi->
2596 iso_handle,
2597 mask);
2598 }
2599 case RAW1394_IOC_ISO_GET_STATUS:
2600 return raw1394_iso_get_status(fi, argp);
2601 case RAW1394_IOC_ISO_RECV_PACKETS:
2602 return raw1394_iso_recv_packets(fi, argp);
2603 case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS:
2604 return hpsb_iso_recv_release_packets(fi->iso_handle,
2605 arg);
2606 case RAW1394_IOC_ISO_RECV_FLUSH:
2607 return hpsb_iso_recv_flush(fi->iso_handle);
2608 case RAW1394_IOC_ISO_SHUTDOWN:
2609 raw1394_iso_shutdown(fi);
2610 return 0;
2611 case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
2612 queue_rawiso_event(fi);
2613 return 0;
2614 } 2604 }
2615 break; 2605 case RAW1394_IOC_ISO_GET_STATUS:
2616 case RAW1394_ISO_XMIT: 2606 return raw1394_iso_get_status(fi, argp);
2617 switch (cmd) { 2607 case RAW1394_IOC_ISO_RECV_PACKETS:
2618 case RAW1394_IOC_ISO_XMIT_START:{ 2608 return raw1394_iso_recv_packets(fi, argp);
2619 /* copy two ints from user-space */ 2609 case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS:
2620 int args[2]; 2610 return hpsb_iso_recv_release_packets(fi->iso_handle, arg);
2621 if (copy_from_user 2611 case RAW1394_IOC_ISO_RECV_FLUSH:
2622 (&args[0], argp, sizeof(args))) 2612 return hpsb_iso_recv_flush(fi->iso_handle);
2623 return -EFAULT; 2613 case RAW1394_IOC_ISO_SHUTDOWN:
2624 return hpsb_iso_xmit_start(fi->iso_handle, 2614 raw1394_iso_shutdown(fi);
2625 args[0], args[1]); 2615 return 0;
2626 } 2616 case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
2627 case RAW1394_IOC_ISO_XMIT_SYNC: 2617 queue_rawiso_event(fi);
2628 return hpsb_iso_xmit_sync(fi->iso_handle); 2618 return 0;
2629 case RAW1394_IOC_ISO_XMIT_RECV_STOP: 2619 default:
2630 hpsb_iso_stop(fi->iso_handle); 2620 return -EINVAL;
2631 return 0; 2621 }
2632 case RAW1394_IOC_ISO_GET_STATUS: 2622}
2633 return raw1394_iso_get_status(fi, argp); 2623
2634 case RAW1394_IOC_ISO_XMIT_PACKETS: 2624static long raw1394_ioctl_xmit(struct file_info *fi, unsigned int cmd,
2635 return raw1394_iso_send_packets(fi, argp); 2625 void __user *argp)
2636 case RAW1394_IOC_ISO_SHUTDOWN: 2626{
2637 raw1394_iso_shutdown(fi); 2627 switch (cmd) {
2638 return 0; 2628 case RAW1394_IOC_ISO_XMIT_START:{
2639 case RAW1394_IOC_ISO_QUEUE_ACTIVITY: 2629 int args[2];
2640 queue_rawiso_event(fi); 2630
2641 return 0; 2631 if (copy_from_user(&args[0], argp, sizeof(args)))
2632 return -EFAULT;
2633 return hpsb_iso_xmit_start(fi->iso_handle,
2634 args[0], args[1]);
2642 } 2635 }
2643 break; 2636 case RAW1394_IOC_ISO_XMIT_SYNC:
2637 return hpsb_iso_xmit_sync(fi->iso_handle);
2638 case RAW1394_IOC_ISO_XMIT_RECV_STOP:
2639 hpsb_iso_stop(fi->iso_handle);
2640 return 0;
2641 case RAW1394_IOC_ISO_GET_STATUS:
2642 return raw1394_iso_get_status(fi, argp);
2643 case RAW1394_IOC_ISO_XMIT_PACKETS:
2644 return raw1394_iso_send_packets(fi, argp);
2645 case RAW1394_IOC_ISO_SHUTDOWN:
2646 raw1394_iso_shutdown(fi);
2647 return 0;
2648 case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
2649 queue_rawiso_event(fi);
2650 return 0;
2644 default: 2651 default:
2645 break; 2652 return -EINVAL;
2646 } 2653 }
2654}
2655
2656/* ioctl is only used for rawiso operations */
2657static long raw1394_ioctl(struct file *file, unsigned int cmd,
2658 unsigned long arg)
2659{
2660 struct file_info *fi = file->private_data;
2661 void __user *argp = (void __user *)arg;
2662 long ret;
2647 2663
2648 /* state-independent commands */ 2664 /* state-independent commands */
2649 switch(cmd) { 2665 switch(cmd) {
@@ -2653,16 +2669,25 @@ static long do_raw1394_ioctl(struct file *file, unsigned int cmd,
2653 break; 2669 break;
2654 } 2670 }
2655 2671
2656 return -EINVAL; 2672 mutex_lock(&fi->state_mutex);
2657} 2673
2674 switch (fi->iso_state) {
2675 case RAW1394_ISO_INACTIVE:
2676 ret = raw1394_ioctl_inactive(fi, cmd, argp);
2677 break;
2678 case RAW1394_ISO_RECV:
2679 ret = raw1394_ioctl_recv(fi, cmd, arg);
2680 break;
2681 case RAW1394_ISO_XMIT:
2682 ret = raw1394_ioctl_xmit(fi, cmd, argp);
2683 break;
2684 default:
2685 ret = -EINVAL;
2686 break;
2687 }
2688
2689 mutex_unlock(&fi->state_mutex);
2658 2690
2659static long raw1394_ioctl(struct file *file, unsigned int cmd,
2660 unsigned long arg)
2661{
2662 long ret;
2663 lock_kernel();
2664 ret = do_raw1394_ioctl(file, cmd, arg);
2665 unlock_kernel();
2666 return ret; 2691 return ret;
2667} 2692}
2668 2693
@@ -2700,7 +2725,7 @@ static long raw1394_iso_xmit_recv_packets32(struct file *file, unsigned int cmd,
2700 !copy_from_user(&infos32, &arg->infos, sizeof infos32)) { 2725 !copy_from_user(&infos32, &arg->infos, sizeof infos32)) {
2701 infos = compat_ptr(infos32); 2726 infos = compat_ptr(infos32);
2702 if (!copy_to_user(&dst->infos, &infos, sizeof infos)) 2727 if (!copy_to_user(&dst->infos, &infos, sizeof infos))
2703 err = do_raw1394_ioctl(file, cmd, (unsigned long)dst); 2728 err = raw1394_ioctl(file, cmd, (unsigned long)dst);
2704 } 2729 }
2705 return err; 2730 return err;
2706} 2731}
@@ -2724,7 +2749,6 @@ static long raw1394_compat_ioctl(struct file *file,
2724 void __user *argp = (void __user *)arg; 2749 void __user *argp = (void __user *)arg;
2725 long err; 2750 long err;
2726 2751
2727 lock_kernel();
2728 switch (cmd) { 2752 switch (cmd) {
2729 /* These requests have same format as long as 'int' has same size. */ 2753 /* These requests have same format as long as 'int' has same size. */
2730 case RAW1394_IOC_ISO_RECV_INIT: 2754 case RAW1394_IOC_ISO_RECV_INIT:
@@ -2741,7 +2765,7 @@ static long raw1394_compat_ioctl(struct file *file,
2741 case RAW1394_IOC_ISO_GET_STATUS: 2765 case RAW1394_IOC_ISO_GET_STATUS:
2742 case RAW1394_IOC_ISO_SHUTDOWN: 2766 case RAW1394_IOC_ISO_SHUTDOWN:
2743 case RAW1394_IOC_ISO_QUEUE_ACTIVITY: 2767 case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
2744 err = do_raw1394_ioctl(file, cmd, arg); 2768 err = raw1394_ioctl(file, cmd, arg);
2745 break; 2769 break;
2746 /* These request have different format. */ 2770 /* These request have different format. */
2747 case RAW1394_IOC_ISO_RECV_PACKETS32: 2771 case RAW1394_IOC_ISO_RECV_PACKETS32:
@@ -2757,7 +2781,6 @@ static long raw1394_compat_ioctl(struct file *file,
2757 err = -EINVAL; 2781 err = -EINVAL;
2758 break; 2782 break;
2759 } 2783 }
2760 unlock_kernel();
2761 2784
2762 return err; 2785 return err;
2763} 2786}
@@ -2791,6 +2814,7 @@ static int raw1394_open(struct inode *inode, struct file *file)
2791 fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ 2814 fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */
2792 2815
2793 INIT_LIST_HEAD(&fi->list); 2816 INIT_LIST_HEAD(&fi->list);
2817 mutex_init(&fi->state_mutex);
2794 fi->state = opened; 2818 fi->state = opened;
2795 INIT_LIST_HEAD(&fi->req_pending); 2819 INIT_LIST_HEAD(&fi->req_pending);
2796 INIT_LIST_HEAD(&fi->req_complete); 2820 INIT_LIST_HEAD(&fi->req_complete);
@@ -3010,10 +3034,10 @@ static int __init init_raw1394(void)
3010 hpsb_register_highlevel(&raw1394_highlevel); 3034 hpsb_register_highlevel(&raw1394_highlevel);
3011 3035
3012 if (IS_ERR 3036 if (IS_ERR
3013 (device_create_drvdata( 3037 (device_create(hpsb_protocol_class, NULL,
3014 hpsb_protocol_class, NULL, 3038 MKDEV(IEEE1394_MAJOR,
3015 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 3039 IEEE1394_MINOR_BLOCK_RAW1394 * 16),
3016 NULL, RAW1394_DEVICE_NAME))) { 3040 NULL, RAW1394_DEVICE_NAME))) {
3017 ret = -EFAULT; 3041 ret = -EFAULT;
3018 goto out_unreg; 3042 goto out_unreg;
3019 } 3043 }
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 1d6ad3435537..c52f6e6e8af2 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -526,26 +526,41 @@ static void sbp2util_write_doorbell(struct work_struct *work)
526 526
527static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu) 527static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu)
528{ 528{
529 struct sbp2_fwhost_info *hi = lu->hi;
530 struct sbp2_command_info *cmd; 529 struct sbp2_command_info *cmd;
530 struct device *dmadev = lu->hi->host->device.parent;
531 int i, orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS; 531 int i, orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS;
532 532
533 for (i = 0; i < orbs; i++) { 533 for (i = 0; i < orbs; i++) {
534 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 534 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
535 if (!cmd) 535 if (!cmd)
536 return -ENOMEM; 536 goto failed_alloc;
537 cmd->command_orb_dma = dma_map_single(hi->host->device.parent, 537
538 &cmd->command_orb, 538 cmd->command_orb_dma =
539 sizeof(struct sbp2_command_orb), 539 dma_map_single(dmadev, &cmd->command_orb,
540 DMA_TO_DEVICE); 540 sizeof(struct sbp2_command_orb),
541 cmd->sge_dma = dma_map_single(hi->host->device.parent, 541 DMA_TO_DEVICE);
542 &cmd->scatter_gather_element, 542 if (dma_mapping_error(dmadev, cmd->command_orb_dma))
543 sizeof(cmd->scatter_gather_element), 543 goto failed_orb;
544 DMA_TO_DEVICE); 544
545 cmd->sge_dma =
546 dma_map_single(dmadev, &cmd->scatter_gather_element,
547 sizeof(cmd->scatter_gather_element),
548 DMA_TO_DEVICE);
549 if (dma_mapping_error(dmadev, cmd->sge_dma))
550 goto failed_sge;
551
545 INIT_LIST_HEAD(&cmd->list); 552 INIT_LIST_HEAD(&cmd->list);
546 list_add_tail(&cmd->list, &lu->cmd_orb_completed); 553 list_add_tail(&cmd->list, &lu->cmd_orb_completed);
547 } 554 }
548 return 0; 555 return 0;
556
557failed_sge:
558 dma_unmap_single(dmadev, cmd->command_orb_dma,
559 sizeof(struct sbp2_command_orb), DMA_TO_DEVICE);
560failed_orb:
561 kfree(cmd);
562failed_alloc:
563 return -ENOMEM;
549} 564}
550 565
551static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu, 566static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu,
@@ -641,24 +656,11 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
641static void sbp2util_mark_command_completed(struct sbp2_lu *lu, 656static void sbp2util_mark_command_completed(struct sbp2_lu *lu,
642 struct sbp2_command_info *cmd) 657 struct sbp2_command_info *cmd)
643{ 658{
644 struct hpsb_host *host = lu->ud->ne->host; 659 if (scsi_sg_count(cmd->Current_SCpnt))
645 660 dma_unmap_sg(lu->ud->ne->host->device.parent,
646 if (cmd->cmd_dma) { 661 scsi_sglist(cmd->Current_SCpnt),
647 if (cmd->dma_type == CMD_DMA_SINGLE) 662 scsi_sg_count(cmd->Current_SCpnt),
648 dma_unmap_single(host->device.parent, cmd->cmd_dma, 663 cmd->Current_SCpnt->sc_data_direction);
649 cmd->dma_size, cmd->dma_dir);
650 else if (cmd->dma_type == CMD_DMA_PAGE)
651 dma_unmap_page(host->device.parent, cmd->cmd_dma,
652 cmd->dma_size, cmd->dma_dir);
653 /* XXX: Check for CMD_DMA_NONE bug */
654 cmd->dma_type = CMD_DMA_NONE;
655 cmd->cmd_dma = 0;
656 }
657 if (cmd->sge_buffer) {
658 dma_unmap_sg(host->device.parent, cmd->sge_buffer,
659 cmd->dma_size, cmd->dma_dir);
660 cmd->sge_buffer = NULL;
661 }
662 list_move_tail(&cmd->list, &lu->cmd_orb_completed); 664 list_move_tail(&cmd->list, &lu->cmd_orb_completed);
663} 665}
664 666
@@ -823,6 +825,10 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
823#endif 825#endif
824 } 826 }
825 827
828 if (dma_get_max_seg_size(hi->host->device.parent) > SBP2_MAX_SEG_SIZE)
829 BUG_ON(dma_set_max_seg_size(hi->host->device.parent,
830 SBP2_MAX_SEG_SIZE));
831
826 /* Prevent unloading of the 1394 host */ 832 /* Prevent unloading of the 1394 host */
827 if (!try_module_get(hi->host->driver->owner)) { 833 if (!try_module_get(hi->host->driver->owner)) {
828 SBP2_ERR("failed to get a reference on 1394 host driver"); 834 SBP2_ERR("failed to get a reference on 1394 host driver");
@@ -1494,84 +1500,65 @@ static int sbp2_agent_reset(struct sbp2_lu *lu, int wait)
1494 return 0; 1500 return 0;
1495} 1501}
1496 1502
1497static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, 1503static int sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1498 struct sbp2_fwhost_info *hi, 1504 struct sbp2_fwhost_info *hi,
1499 struct sbp2_command_info *cmd, 1505 struct sbp2_command_info *cmd,
1500 unsigned int scsi_use_sg, 1506 unsigned int sg_count,
1501 struct scatterlist *sg, 1507 struct scatterlist *sg,
1502 u32 orb_direction, 1508 u32 orb_direction,
1503 enum dma_data_direction dma_dir) 1509 enum dma_data_direction dma_dir)
1504{ 1510{
1505 cmd->dma_dir = dma_dir; 1511 struct device *dmadev = hi->host->device.parent;
1512 struct sbp2_unrestricted_page_table *pt;
1513 int i, n;
1514
1515 n = dma_map_sg(dmadev, sg, sg_count, dma_dir);
1516 if (n == 0)
1517 return -ENOMEM;
1518
1506 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); 1519 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1507 orb->misc |= ORB_SET_DIRECTION(orb_direction); 1520 orb->misc |= ORB_SET_DIRECTION(orb_direction);
1508 1521
1509 /* special case if only one element (and less than 64KB in size) */ 1522 /* special case if only one element (and less than 64KB in size) */
1510 if (scsi_use_sg == 1 && sg->length <= SBP2_MAX_SG_ELEMENT_LENGTH) { 1523 if (n == 1) {
1511 1524 orb->misc |= ORB_SET_DATA_SIZE(sg_dma_len(sg));
1512 cmd->dma_size = sg->length; 1525 orb->data_descriptor_lo = sg_dma_address(sg);
1513 cmd->dma_type = CMD_DMA_PAGE;
1514 cmd->cmd_dma = dma_map_page(hi->host->device.parent,
1515 sg_page(sg), sg->offset,
1516 cmd->dma_size, cmd->dma_dir);
1517
1518 orb->data_descriptor_lo = cmd->cmd_dma;
1519 orb->misc |= ORB_SET_DATA_SIZE(cmd->dma_size);
1520
1521 } else { 1526 } else {
1522 struct sbp2_unrestricted_page_table *sg_element = 1527 pt = &cmd->scatter_gather_element[0];
1523 &cmd->scatter_gather_element[0];
1524 u32 sg_count, sg_len;
1525 dma_addr_t sg_addr;
1526 int i, count = dma_map_sg(hi->host->device.parent, sg,
1527 scsi_use_sg, dma_dir);
1528
1529 cmd->dma_size = scsi_use_sg;
1530 cmd->sge_buffer = sg;
1531
1532 /* use page tables (s/g) */
1533 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1534 orb->data_descriptor_lo = cmd->sge_dma;
1535 1528
1536 /* loop through and fill out our SBP-2 page tables 1529 dma_sync_single_for_cpu(dmadev, cmd->sge_dma,
1537 * (and split up anything too large) */ 1530 sizeof(cmd->scatter_gather_element),
1538 for (i = 0, sg_count = 0; i < count; i++, sg = sg_next(sg)) { 1531 DMA_TO_DEVICE);
1539 sg_len = sg_dma_len(sg); 1532
1540 sg_addr = sg_dma_address(sg); 1533 for_each_sg(sg, sg, n, i) {
1541 while (sg_len) { 1534 pt[i].high = cpu_to_be32(sg_dma_len(sg) << 16);
1542 sg_element[sg_count].segment_base_lo = sg_addr; 1535 pt[i].low = cpu_to_be32(sg_dma_address(sg));
1543 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
1544 sg_element[sg_count].length_segment_base_hi =
1545 PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH);
1546 sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH;
1547 sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH;
1548 } else {
1549 sg_element[sg_count].length_segment_base_hi =
1550 PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len);
1551 sg_len = 0;
1552 }
1553 sg_count++;
1554 }
1555 } 1536 }
1556 1537
1557 orb->misc |= ORB_SET_DATA_SIZE(sg_count); 1538 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1) |
1539 ORB_SET_DATA_SIZE(n);
1540 orb->data_descriptor_lo = cmd->sge_dma;
1558 1541
1559 sbp2util_cpu_to_be32_buffer(sg_element, 1542 dma_sync_single_for_device(dmadev, cmd->sge_dma,
1560 (sizeof(struct sbp2_unrestricted_page_table)) * 1543 sizeof(cmd->scatter_gather_element),
1561 sg_count); 1544 DMA_TO_DEVICE);
1562 } 1545 }
1546 return 0;
1563} 1547}
1564 1548
1565static void sbp2_create_command_orb(struct sbp2_lu *lu, 1549static int sbp2_create_command_orb(struct sbp2_lu *lu,
1566 struct sbp2_command_info *cmd, 1550 struct sbp2_command_info *cmd,
1567 struct scsi_cmnd *SCpnt) 1551 struct scsi_cmnd *SCpnt)
1568{ 1552{
1569 struct sbp2_fwhost_info *hi = lu->hi; 1553 struct device *dmadev = lu->hi->host->device.parent;
1570 struct sbp2_command_orb *orb = &cmd->command_orb; 1554 struct sbp2_command_orb *orb = &cmd->command_orb;
1571 u32 orb_direction;
1572 unsigned int scsi_request_bufflen = scsi_bufflen(SCpnt); 1555 unsigned int scsi_request_bufflen = scsi_bufflen(SCpnt);
1573 enum dma_data_direction dma_dir = SCpnt->sc_data_direction; 1556 enum dma_data_direction dma_dir = SCpnt->sc_data_direction;
1557 u32 orb_direction;
1558 int ret;
1574 1559
1560 dma_sync_single_for_cpu(dmadev, cmd->command_orb_dma,
1561 sizeof(struct sbp2_command_orb), DMA_TO_DEVICE);
1575 /* 1562 /*
1576 * Set-up our command ORB. 1563 * Set-up our command ORB.
1577 * 1564 *
@@ -1602,15 +1589,21 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
1602 orb->data_descriptor_hi = 0x0; 1589 orb->data_descriptor_hi = 0x0;
1603 orb->data_descriptor_lo = 0x0; 1590 orb->data_descriptor_lo = 0x0;
1604 orb->misc |= ORB_SET_DIRECTION(1); 1591 orb->misc |= ORB_SET_DIRECTION(1);
1605 } else 1592 ret = 0;
1606 sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_sg_count(SCpnt), 1593 } else {
1607 scsi_sglist(SCpnt), 1594 ret = sbp2_prep_command_orb_sg(orb, lu->hi, cmd,
1608 orb_direction, dma_dir); 1595 scsi_sg_count(SCpnt),
1609 1596 scsi_sglist(SCpnt),
1597 orb_direction, dma_dir);
1598 }
1610 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb)); 1599 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb));
1611 1600
1612 memset(orb->cdb, 0, sizeof(orb->cdb)); 1601 memset(orb->cdb, 0, sizeof(orb->cdb));
1613 memcpy(orb->cdb, SCpnt->cmnd, SCpnt->cmd_len); 1602 memcpy(orb->cdb, SCpnt->cmnd, SCpnt->cmd_len);
1603
1604 dma_sync_single_for_device(dmadev, cmd->command_orb_dma,
1605 sizeof(struct sbp2_command_orb), DMA_TO_DEVICE);
1606 return ret;
1614} 1607}
1615 1608
1616static void sbp2_link_orb_command(struct sbp2_lu *lu, 1609static void sbp2_link_orb_command(struct sbp2_lu *lu,
@@ -1624,14 +1617,6 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu,
1624 size_t length; 1617 size_t length;
1625 unsigned long flags; 1618 unsigned long flags;
1626 1619
1627 dma_sync_single_for_device(hi->host->device.parent,
1628 cmd->command_orb_dma,
1629 sizeof(struct sbp2_command_orb),
1630 DMA_TO_DEVICE);
1631 dma_sync_single_for_device(hi->host->device.parent, cmd->sge_dma,
1632 sizeof(cmd->scatter_gather_element),
1633 DMA_TO_DEVICE);
1634
1635 /* check to see if there are any previous orbs to use */ 1620 /* check to see if there are any previous orbs to use */
1636 spin_lock_irqsave(&lu->cmd_orb_lock, flags); 1621 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
1637 last_orb = lu->last_orb; 1622 last_orb = lu->last_orb;
@@ -1699,9 +1684,10 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
1699 if (!cmd) 1684 if (!cmd)
1700 return -EIO; 1685 return -EIO;
1701 1686
1702 sbp2_create_command_orb(lu, cmd, SCpnt); 1687 if (sbp2_create_command_orb(lu, cmd, SCpnt))
1703 sbp2_link_orb_command(lu, cmd); 1688 return -ENOMEM;
1704 1689
1690 sbp2_link_orb_command(lu, cmd);
1705 return 0; 1691 return 0;
1706} 1692}
1707 1693
@@ -1789,13 +1775,6 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
1789 else 1775 else
1790 cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo); 1776 cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo);
1791 if (cmd) { 1777 if (cmd) {
1792 dma_sync_single_for_cpu(hi->host->device.parent,
1793 cmd->command_orb_dma,
1794 sizeof(struct sbp2_command_orb),
1795 DMA_TO_DEVICE);
1796 dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma,
1797 sizeof(cmd->scatter_gather_element),
1798 DMA_TO_DEVICE);
1799 /* Grab SCSI command pointers and check status. */ 1778 /* Grab SCSI command pointers and check status. */
1800 /* 1779 /*
1801 * FIXME: If the src field in the status is 1, the ORB DMA must 1780 * FIXME: If the src field in the status is 1, the ORB DMA must
@@ -1912,7 +1891,6 @@ done:
1912 1891
1913static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status) 1892static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status)
1914{ 1893{
1915 struct sbp2_fwhost_info *hi = lu->hi;
1916 struct list_head *lh; 1894 struct list_head *lh;
1917 struct sbp2_command_info *cmd; 1895 struct sbp2_command_info *cmd;
1918 unsigned long flags; 1896 unsigned long flags;
@@ -1921,13 +1899,6 @@ static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status)
1921 while (!list_empty(&lu->cmd_orb_inuse)) { 1899 while (!list_empty(&lu->cmd_orb_inuse)) {
1922 lh = lu->cmd_orb_inuse.next; 1900 lh = lu->cmd_orb_inuse.next;
1923 cmd = list_entry(lh, struct sbp2_command_info, list); 1901 cmd = list_entry(lh, struct sbp2_command_info, list);
1924 dma_sync_single_for_cpu(hi->host->device.parent,
1925 cmd->command_orb_dma,
1926 sizeof(struct sbp2_command_orb),
1927 DMA_TO_DEVICE);
1928 dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma,
1929 sizeof(cmd->scatter_gather_element),
1930 DMA_TO_DEVICE);
1931 sbp2util_mark_command_completed(lu, cmd); 1902 sbp2util_mark_command_completed(lu, cmd);
1932 if (cmd->Current_SCpnt) { 1903 if (cmd->Current_SCpnt) {
1933 cmd->Current_SCpnt->result = status << 16; 1904 cmd->Current_SCpnt->result = status << 16;
@@ -2033,6 +2004,8 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2033 sdev->start_stop_pwr_cond = 1; 2004 sdev->start_stop_pwr_cond = 1;
2034 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) 2005 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
2035 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); 2006 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
2007
2008 blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE);
2036 return 0; 2009 return 0;
2037} 2010}
2038 2011
@@ -2049,7 +2022,6 @@ static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
2049static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) 2022static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2050{ 2023{
2051 struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0]; 2024 struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
2052 struct sbp2_fwhost_info *hi = lu->hi;
2053 struct sbp2_command_info *cmd; 2025 struct sbp2_command_info *cmd;
2054 unsigned long flags; 2026 unsigned long flags;
2055 2027
@@ -2063,14 +2035,6 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2063 spin_lock_irqsave(&lu->cmd_orb_lock, flags); 2035 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
2064 cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt); 2036 cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt);
2065 if (cmd) { 2037 if (cmd) {
2066 dma_sync_single_for_cpu(hi->host->device.parent,
2067 cmd->command_orb_dma,
2068 sizeof(struct sbp2_command_orb),
2069 DMA_TO_DEVICE);
2070 dma_sync_single_for_cpu(hi->host->device.parent,
2071 cmd->sge_dma,
2072 sizeof(cmd->scatter_gather_element),
2073 DMA_TO_DEVICE);
2074 sbp2util_mark_command_completed(lu, cmd); 2038 sbp2util_mark_command_completed(lu, cmd);
2075 if (cmd->Current_SCpnt) { 2039 if (cmd->Current_SCpnt) {
2076 cmd->Current_SCpnt->result = DID_ABORT << 16; 2040 cmd->Current_SCpnt->result = DID_ABORT << 16;
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index 875428bc8d29..c5036f1cc5b0 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -139,13 +139,10 @@ struct sbp2_logout_orb {
139 u32 status_fifo_lo; 139 u32 status_fifo_lo;
140} __attribute__((packed)); 140} __attribute__((packed));
141 141
142#define PAGE_TABLE_SET_SEGMENT_BASE_HI(v) ((v) & 0xffff)
143#define PAGE_TABLE_SET_SEGMENT_LENGTH(v) (((v) & 0xffff) << 16)
144
145struct sbp2_unrestricted_page_table { 142struct sbp2_unrestricted_page_table {
146 u32 length_segment_base_hi; 143 __be32 high;
147 u32 segment_base_lo; 144 __be32 low;
148} __attribute__((packed)); 145};
149 146
150#define RESP_STATUS_REQUEST_COMPLETE 0x0 147#define RESP_STATUS_REQUEST_COMPLETE 0x0
151#define RESP_STATUS_TRANSPORT_FAILURE 0x1 148#define RESP_STATUS_TRANSPORT_FAILURE 0x1
@@ -216,15 +213,18 @@ struct sbp2_status_block {
216#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e 213#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
217#define SBP2_SW_VERSION_ENTRY 0x00010483 214#define SBP2_SW_VERSION_ENTRY 0x00010483
218 215
219
220/* 216/*
221 * SCSI specific definitions 217 * The default maximum s/g segment size of a FireWire controller is
218 * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to
219 * be quadlet-aligned, we set the length limit to 0xffff & ~3.
222 */ 220 */
221#define SBP2_MAX_SEG_SIZE 0xfffc
223 222
224#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 223/*
225/* There is no real limitation of the queue depth (i.e. length of the linked 224 * There is no real limitation of the queue depth (i.e. length of the linked
226 * list of command ORBs) at the target. The chosen depth is merely an 225 * list of command ORBs) at the target. The chosen depth is merely an
227 * implementation detail of the sbp2 driver. */ 226 * implementation detail of the sbp2 driver.
227 */
228#define SBP2_MAX_CMDS 8 228#define SBP2_MAX_CMDS 8
229 229
230#define SBP2_SCSI_STATUS_GOOD 0x0 230#define SBP2_SCSI_STATUS_GOOD 0x0
@@ -240,12 +240,6 @@ struct sbp2_status_block {
240 * Representations of commands and devices 240 * Representations of commands and devices
241 */ 241 */
242 242
243enum sbp2_dma_types {
244 CMD_DMA_NONE,
245 CMD_DMA_PAGE,
246 CMD_DMA_SINGLE
247};
248
249/* Per SCSI command */ 243/* Per SCSI command */
250struct sbp2_command_info { 244struct sbp2_command_info {
251 struct list_head list; 245 struct list_head list;
@@ -258,11 +252,6 @@ struct sbp2_command_info {
258 struct sbp2_unrestricted_page_table 252 struct sbp2_unrestricted_page_table
259 scatter_gather_element[SG_ALL] __attribute__((aligned(8))); 253 scatter_gather_element[SG_ALL] __attribute__((aligned(8)));
260 dma_addr_t sge_dma; 254 dma_addr_t sge_dma;
261 void *sge_buffer;
262 dma_addr_t cmd_dma;
263 enum sbp2_dma_types dma_type;
264 unsigned long dma_size;
265 enum dma_data_direction dma_dir;
266}; 255};
267 256
268/* Per FireWire host */ 257/* Per FireWire host */
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 25db6e67fa4e..679a918a5cc7 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -893,7 +893,7 @@ static long video1394_ioctl(struct file *file,
893 if (unlikely(d == NULL)) 893 if (unlikely(d == NULL))
894 return -EFAULT; 894 return -EFAULT;
895 895
896 if (unlikely((v.buffer<0) || (v.buffer>=d->num_desc - 1))) { 896 if (unlikely(v.buffer >= d->num_desc - 1)) {
897 PRINT(KERN_ERR, ohci->host->id, 897 PRINT(KERN_ERR, ohci->host->id,
898 "Buffer %d out of range",v.buffer); 898 "Buffer %d out of range",v.buffer);
899 return -EINVAL; 899 return -EINVAL;
@@ -959,7 +959,7 @@ static long video1394_ioctl(struct file *file,
959 if (unlikely(d == NULL)) 959 if (unlikely(d == NULL))
960 return -EFAULT; 960 return -EFAULT;
961 961
962 if (unlikely((v.buffer<0) || (v.buffer>d->num_desc - 1))) { 962 if (unlikely(v.buffer > d->num_desc - 1)) {
963 PRINT(KERN_ERR, ohci->host->id, 963 PRINT(KERN_ERR, ohci->host->id,
964 "Buffer %d out of range",v.buffer); 964 "Buffer %d out of range",v.buffer);
965 return -EINVAL; 965 return -EINVAL;
@@ -1030,7 +1030,7 @@ static long video1394_ioctl(struct file *file,
1030 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel); 1030 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
1031 if (d == NULL) return -EFAULT; 1031 if (d == NULL) return -EFAULT;
1032 1032
1033 if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) { 1033 if (v.buffer >= d->num_desc - 1) {
1034 PRINT(KERN_ERR, ohci->host->id, 1034 PRINT(KERN_ERR, ohci->host->id,
1035 "Buffer %d out of range",v.buffer); 1035 "Buffer %d out of range",v.buffer);
1036 return -EINVAL; 1036 return -EINVAL;
@@ -1137,7 +1137,7 @@ static long video1394_ioctl(struct file *file,
1137 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel); 1137 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
1138 if (d == NULL) return -EFAULT; 1138 if (d == NULL) return -EFAULT;
1139 1139
1140 if ((v.buffer<0) || (v.buffer>=d->num_desc-1)) { 1140 if (v.buffer >= d->num_desc - 1) {
1141 PRINT(KERN_ERR, ohci->host->id, 1141 PRINT(KERN_ERR, ohci->host->id,
1142 "Buffer %d out of range",v.buffer); 1142 "Buffer %d out of range",v.buffer);
1143 return -EINVAL; 1143 return -EINVAL;
@@ -1341,9 +1341,8 @@ static void video1394_add_host (struct hpsb_host *host)
1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
1342 1342
1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
1344 device_create_drvdata(hpsb_protocol_class, NULL, 1344 device_create(hpsb_protocol_class, NULL, MKDEV(IEEE1394_MAJOR, minor),
1345 MKDEV(IEEE1394_MAJOR, minor), NULL, 1345 NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1346 "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1347} 1346}
1348 1347
1349 1348
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 3cab0cedfca2..a78d35aecee3 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3691,9 +3691,9 @@ static void cm_add_one(struct ib_device *ib_device)
3691 cm_dev->ib_device = ib_device; 3691 cm_dev->ib_device = ib_device;
3692 cm_get_ack_delay(cm_dev); 3692 cm_get_ack_delay(cm_dev);
3693 3693
3694 cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev, 3694 cm_dev->device = device_create(&cm_class, &ib_device->dev,
3695 MKDEV(0, 0), NULL, 3695 MKDEV(0, 0), NULL,
3696 "%s", ib_device->name); 3696 "%s", ib_device->name);
3697 if (!cm_dev->device) { 3697 if (!cm_dev->device) {
3698 kfree(cm_dev); 3698 kfree(cm_dev);
3699 return; 3699 return;
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 268a2d23b7c9..8c46f2257098 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1016,9 +1016,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1016 if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) 1016 if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
1017 goto err_cdev; 1017 goto err_cdev;
1018 1018
1019 port->dev = device_create_drvdata(umad_class, device->dma_device, 1019 port->dev = device_create(umad_class, device->dma_device,
1020 port->cdev->dev, port, 1020 port->cdev->dev, port,
1021 "umad%d", port->dev_num); 1021 "umad%d", port->dev_num);
1022 if (IS_ERR(port->dev)) 1022 if (IS_ERR(port->dev))
1023 goto err_cdev; 1023 goto err_cdev;
1024 1024
@@ -1036,9 +1036,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1036 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1036 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
1037 goto err_sm_cdev; 1037 goto err_sm_cdev;
1038 1038
1039 port->sm_dev = device_create_drvdata(umad_class, device->dma_device, 1039 port->sm_dev = device_create(umad_class, device->dma_device,
1040 port->sm_cdev->dev, port, 1040 port->sm_cdev->dev, port,
1041 "issm%d", port->dev_num); 1041 "issm%d", port->dev_num);
1042 if (IS_ERR(port->sm_dev)) 1042 if (IS_ERR(port->sm_dev))
1043 goto err_sm_cdev; 1043 goto err_sm_cdev;
1044 1044
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index aeee856c4060..d85af1b67027 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -764,12 +764,9 @@ static void ib_uverbs_add_one(struct ib_device *device)
764 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 764 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
765 goto err_cdev; 765 goto err_cdev;
766 766
767 uverbs_dev->dev = device_create_drvdata(uverbs_class, 767 uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
768 device->dma_device, 768 uverbs_dev->cdev->dev, uverbs_dev,
769 uverbs_dev->cdev->dev, 769 "uverbs%d", uverbs_dev->devnum);
770 uverbs_dev,
771 "uverbs%d",
772 uverbs_dev->devnum);
773 if (IS_ERR(uverbs_dev->dev)) 770 if (IS_ERR(uverbs_dev->dev))
774 goto err_cdev; 771 goto err_cdev;
775 772
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 56c0eda3c077..1af1f3a907c6 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
2455 goto err_cdev; 2455 goto err_cdev;
2456 } 2456 }
2457 2457
2458 device = device_create_drvdata(ipath_class, NULL, dev, NULL, name); 2458 device = device_create(ipath_class, NULL, dev, NULL, name);
2459 2459
2460 if (IS_ERR(device)) { 2460 if (IS_ERR(device)) {
2461 ret = PTR_ERR(device); 2461 ret = PTR_ERR(device);
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 078e4eed0894..2880eaae157a 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -231,6 +231,7 @@ static void gameport_find_driver(struct gameport *gameport)
231enum gameport_event_type { 231enum gameport_event_type {
232 GAMEPORT_REGISTER_PORT, 232 GAMEPORT_REGISTER_PORT,
233 GAMEPORT_REGISTER_DRIVER, 233 GAMEPORT_REGISTER_DRIVER,
234 GAMEPORT_ATTACH_DRIVER,
234}; 235};
235 236
236struct gameport_event { 237struct gameport_event {
@@ -245,11 +246,12 @@ static LIST_HEAD(gameport_event_list);
245static DECLARE_WAIT_QUEUE_HEAD(gameport_wait); 246static DECLARE_WAIT_QUEUE_HEAD(gameport_wait);
246static struct task_struct *gameport_task; 247static struct task_struct *gameport_task;
247 248
248static void gameport_queue_event(void *object, struct module *owner, 249static int gameport_queue_event(void *object, struct module *owner,
249 enum gameport_event_type event_type) 250 enum gameport_event_type event_type)
250{ 251{
251 unsigned long flags; 252 unsigned long flags;
252 struct gameport_event *event; 253 struct gameport_event *event;
254 int retval = 0;
253 255
254 spin_lock_irqsave(&gameport_event_lock, flags); 256 spin_lock_irqsave(&gameport_event_lock, flags);
255 257
@@ -268,24 +270,34 @@ static void gameport_queue_event(void *object, struct module *owner,
268 } 270 }
269 } 271 }
270 272
271 if ((event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC))) { 273 event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC);
272 if (!try_module_get(owner)) { 274 if (!event) {
273 printk(KERN_WARNING "gameport: Can't get module reference, dropping event %d\n", event_type); 275 printk(KERN_ERR
274 kfree(event); 276 "gameport: Not enough memory to queue event %d\n",
275 goto out; 277 event_type);
276 } 278 retval = -ENOMEM;
277 279 goto out;
278 event->type = event_type; 280 }
279 event->object = object;
280 event->owner = owner;
281 281
282 list_add_tail(&event->node, &gameport_event_list); 282 if (!try_module_get(owner)) {
283 wake_up(&gameport_wait); 283 printk(KERN_WARNING
284 } else { 284 "gameport: Can't get module reference, dropping event %d\n",
285 printk(KERN_ERR "gameport: Not enough memory to queue event %d\n", event_type); 285 event_type);
286 kfree(event);
287 retval = -EINVAL;
288 goto out;
286 } 289 }
290
291 event->type = event_type;
292 event->object = object;
293 event->owner = owner;
294
295 list_add_tail(&event->node, &gameport_event_list);
296 wake_up(&gameport_wait);
297
287out: 298out:
288 spin_unlock_irqrestore(&gameport_event_lock, flags); 299 spin_unlock_irqrestore(&gameport_event_lock, flags);
300 return retval;
289} 301}
290 302
291static void gameport_free_event(struct gameport_event *event) 303static void gameport_free_event(struct gameport_event *event)
@@ -378,9 +390,10 @@ static void gameport_handle_event(void)
378} 390}
379 391
380/* 392/*
381 * Remove all events that have been submitted for a given gameport port. 393 * Remove all events that have been submitted for a given object,
394 * be it a gameport port or a driver.
382 */ 395 */
383static void gameport_remove_pending_events(struct gameport *gameport) 396static void gameport_remove_pending_events(void *object)
384{ 397{
385 struct list_head *node, *next; 398 struct list_head *node, *next;
386 struct gameport_event *event; 399 struct gameport_event *event;
@@ -390,7 +403,7 @@ static void gameport_remove_pending_events(struct gameport *gameport)
390 403
391 list_for_each_safe(node, next, &gameport_event_list) { 404 list_for_each_safe(node, next, &gameport_event_list) {
392 event = list_entry(node, struct gameport_event, node); 405 event = list_entry(node, struct gameport_event, node);
393 if (event->object == gameport) { 406 if (event->object == object) {
394 list_del_init(node); 407 list_del_init(node);
395 gameport_free_event(event); 408 gameport_free_event(event);
396 } 409 }
@@ -705,10 +718,40 @@ static void gameport_add_driver(struct gameport_driver *drv)
705 drv->driver.name, error); 718 drv->driver.name, error);
706} 719}
707 720
708void __gameport_register_driver(struct gameport_driver *drv, struct module *owner) 721int __gameport_register_driver(struct gameport_driver *drv, struct module *owner,
722 const char *mod_name)
709{ 723{
724 int error;
725
710 drv->driver.bus = &gameport_bus; 726 drv->driver.bus = &gameport_bus;
711 gameport_queue_event(drv, owner, GAMEPORT_REGISTER_DRIVER); 727 drv->driver.owner = owner;
728 drv->driver.mod_name = mod_name;
729
730 /*
731 * Temporarily disable automatic binding because probing
732 * takes long time and we are better off doing it in kgameportd
733 */
734 drv->ignore = 1;
735
736 error = driver_register(&drv->driver);
737 if (error) {
738 printk(KERN_ERR
739 "gameport: driver_register() failed for %s, error: %d\n",
740 drv->driver.name, error);
741 return error;
742 }
743
744 /*
745 * Reset ignore flag and let kgameportd bind the driver to free ports
746 */
747 drv->ignore = 0;
748 error = gameport_queue_event(drv, NULL, GAMEPORT_ATTACH_DRIVER);
749 if (error) {
750 driver_unregister(&drv->driver);
751 return error;
752 }
753
754 return 0;
712} 755}
713 756
714void gameport_unregister_driver(struct gameport_driver *drv) 757void gameport_unregister_driver(struct gameport_driver *drv)
@@ -716,7 +759,9 @@ void gameport_unregister_driver(struct gameport_driver *drv)
716 struct gameport *gameport; 759 struct gameport *gameport;
717 760
718 mutex_lock(&gameport_mutex); 761 mutex_lock(&gameport_mutex);
762
719 drv->ignore = 1; /* so gameport_find_driver ignores it */ 763 drv->ignore = 1; /* so gameport_find_driver ignores it */
764 gameport_remove_pending_events(drv);
720 765
721start_over: 766start_over:
722 list_for_each_entry(gameport, &gameport_list, node) { 767 list_for_each_entry(gameport, &gameport_list, node) {
@@ -729,6 +774,7 @@ start_over:
729 } 774 }
730 775
731 driver_unregister(&drv->driver); 776 driver_unregister(&drv->driver);
777
732 mutex_unlock(&gameport_mutex); 778 mutex_unlock(&gameport_mutex);
733} 779}
734 780
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index 92498d470b1f..6489f4010c4f 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -414,8 +414,7 @@ static struct gameport_driver a3d_drv = {
414 414
415static int __init a3d_init(void) 415static int __init a3d_init(void)
416{ 416{
417 gameport_register_driver(&a3d_drv); 417 return gameport_register_driver(&a3d_drv);
418 return 0;
419} 418}
420 419
421static void __exit a3d_exit(void) 420static void __exit a3d_exit(void)
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index d1ca8a14950f..89c4c084d4ad 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -572,8 +572,7 @@ static struct gameport_driver adi_drv = {
572 572
573static int __init adi_init(void) 573static int __init adi_init(void)
574{ 574{
575 gameport_register_driver(&adi_drv); 575 return gameport_register_driver(&adi_drv);
576 return 0;
577} 576}
578 577
579static void __exit adi_exit(void) 578static void __exit adi_exit(void)
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 708c5ae13b24..356b3a25efa2 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -761,9 +761,7 @@ static struct gameport_driver analog_drv = {
761static int __init analog_init(void) 761static int __init analog_init(void)
762{ 762{
763 analog_parse_options(); 763 analog_parse_options();
764 gameport_register_driver(&analog_drv); 764 return gameport_register_driver(&analog_drv);
765
766 return 0;
767} 765}
768 766
769static void __exit analog_exit(void) 767static void __exit analog_exit(void)
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index 639b975a8ed7..3497b87c3d05 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -263,8 +263,7 @@ static struct gameport_driver cobra_drv = {
263 263
264static int __init cobra_init(void) 264static int __init cobra_init(void)
265{ 265{
266 gameport_register_driver(&cobra_drv); 266 return gameport_register_driver(&cobra_drv);
267 return 0;
268} 267}
269 268
270static void __exit cobra_exit(void) 269static void __exit cobra_exit(void)
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index cb6eef1f2d99..67c207f5b1a1 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -375,8 +375,7 @@ static struct gameport_driver gf2k_drv = {
375 375
376static int __init gf2k_init(void) 376static int __init gf2k_init(void)
377{ 377{
378 gameport_register_driver(&gf2k_drv); 378 return gameport_register_driver(&gf2k_drv);
379 return 0;
380} 379}
381 380
382static void __exit gf2k_exit(void) 381static void __exit gf2k_exit(void)
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index 684e07cfccc8..fc55899ba6c5 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -426,8 +426,7 @@ static struct gameport_driver grip_drv = {
426 426
427static int __init grip_init(void) 427static int __init grip_init(void)
428{ 428{
429 gameport_register_driver(&grip_drv); 429 return gameport_register_driver(&grip_drv);
430 return 0;
431} 430}
432 431
433static void __exit grip_exit(void) 432static void __exit grip_exit(void)
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 8279481b16e7..2d47baf47769 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -689,8 +689,7 @@ static struct gameport_driver grip_drv = {
689 689
690static int __init grip_init(void) 690static int __init grip_init(void)
691{ 691{
692 gameport_register_driver(&grip_drv); 692 return gameport_register_driver(&grip_drv);
693 return 0;
694} 693}
695 694
696static void __exit grip_exit(void) 695static void __exit grip_exit(void)
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 25ec3fad9f27..4058d4b272fe 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -283,8 +283,7 @@ static struct gameport_driver guillemot_drv = {
283 283
284static int __init guillemot_init(void) 284static int __init guillemot_init(void)
285{ 285{
286 gameport_register_driver(&guillemot_drv); 286 return gameport_register_driver(&guillemot_drv);
287 return 0;
288} 287}
289 288
290static void __exit guillemot_exit(void) 289static void __exit guillemot_exit(void)
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index 8c3290b68205..2478289aeeea 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -317,8 +317,7 @@ static struct gameport_driver interact_drv = {
317 317
318static int __init interact_init(void) 318static int __init interact_init(void)
319{ 319{
320 gameport_register_driver(&interact_drv); 320 return gameport_register_driver(&interact_drv);
321 return 0;
322} 321}
323 322
324static void __exit interact_exit(void) 323static void __exit interact_exit(void)
diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
index 2a1b82c8b31c..cd894a0564a2 100644
--- a/drivers/input/joystick/joydump.c
+++ b/drivers/input/joystick/joydump.c
@@ -161,8 +161,7 @@ static struct gameport_driver joydump_drv = {
161 161
162static int __init joydump_init(void) 162static int __init joydump_init(void)
163{ 163{
164 gameport_register_driver(&joydump_drv); 164 return gameport_register_driver(&joydump_drv);
165 return 0;
166} 165}
167 166
168static void __exit joydump_exit(void) 167static void __exit joydump_exit(void)
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 7b4865fdee54..ca13a6bec33e 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -818,8 +818,7 @@ static struct gameport_driver sw_drv = {
818 818
819static int __init sw_init(void) 819static int __init sw_init(void)
820{ 820{
821 gameport_register_driver(&sw_drv); 821 return gameport_register_driver(&sw_drv);
822 return 0;
823} 822}
824 823
825static void __exit sw_exit(void) 824static void __exit sw_exit(void)
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 60c37bcb938d..d6c609807115 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -438,8 +438,7 @@ static struct gameport_driver tmdc_drv = {
438 438
439static int __init tmdc_init(void) 439static int __init tmdc_init(void)
440{ 440{
441 gameport_register_driver(&tmdc_drv); 441 return gameport_register_driver(&tmdc_drv);
442 return 0;
443} 442}
444 443
445static void __exit tmdc_exit(void) 444static void __exit tmdc_exit(void)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 6791be81eb29..839d1c9622f6 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -455,10 +455,10 @@ static void xpad_bulk_out(struct urb *urb)
455 case -ENOENT: 455 case -ENOENT:
456 case -ESHUTDOWN: 456 case -ESHUTDOWN:
457 /* this urb is terminated, clean up */ 457 /* this urb is terminated, clean up */
458 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 458 dbg("%s - urb shutting down with status: %d", __func__, urb->status);
459 break; 459 break;
460 default: 460 default:
461 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 461 dbg("%s - nonzero urb status received: %d", __func__, urb->status);
462 } 462 }
463} 463}
464 464
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index b1ce10f50bcf..22016ca15351 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -834,10 +834,10 @@ static void atkbd_disconnect(struct serio *serio)
834} 834}
835 835
836/* 836/*
837 * Most special keys (Fn+F?) on Dell Latitudes do not generate release 837 * Most special keys (Fn+F?) on Dell laptops do not generate release
838 * events so we have to do it ourselves. 838 * events so we have to do it ourselves.
839 */ 839 */
840static void atkbd_latitude_keymap_fixup(struct atkbd *atkbd) 840static void atkbd_dell_laptop_keymap_fixup(struct atkbd *atkbd)
841{ 841{
842 const unsigned int forced_release_keys[] = { 842 const unsigned int forced_release_keys[] = {
843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, 843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93,
@@ -1207,15 +1207,13 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
1207{ 1207{
1208 struct input_dev *old_dev, *new_dev; 1208 struct input_dev *old_dev, *new_dev;
1209 unsigned long value; 1209 unsigned long value;
1210 char *rest;
1211 int err; 1210 int err;
1212 unsigned char old_extra, old_set; 1211 unsigned char old_extra, old_set;
1213 1212
1214 if (!atkbd->write) 1213 if (!atkbd->write)
1215 return -EIO; 1214 return -EIO;
1216 1215
1217 value = simple_strtoul(buf, &rest, 10); 1216 if (strict_strtoul(buf, 10, &value) || value > 1)
1218 if (*rest || value > 1)
1219 return -EINVAL; 1217 return -EINVAL;
1220 1218
1221 if (atkbd->extra != value) { 1219 if (atkbd->extra != value) {
@@ -1264,12 +1262,10 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou
1264{ 1262{
1265 struct input_dev *old_dev, *new_dev; 1263 struct input_dev *old_dev, *new_dev;
1266 unsigned long value; 1264 unsigned long value;
1267 char *rest;
1268 int err; 1265 int err;
1269 unsigned char old_scroll; 1266 unsigned char old_scroll;
1270 1267
1271 value = simple_strtoul(buf, &rest, 10); 1268 if (strict_strtoul(buf, 10, &value) || value > 1)
1272 if (*rest || value > 1)
1273 return -EINVAL; 1269 return -EINVAL;
1274 1270
1275 if (atkbd->scroll != value) { 1271 if (atkbd->scroll != value) {
@@ -1310,15 +1306,13 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
1310{ 1306{
1311 struct input_dev *old_dev, *new_dev; 1307 struct input_dev *old_dev, *new_dev;
1312 unsigned long value; 1308 unsigned long value;
1313 char *rest;
1314 int err; 1309 int err;
1315 unsigned char old_set, old_extra; 1310 unsigned char old_set, old_extra;
1316 1311
1317 if (!atkbd->write) 1312 if (!atkbd->write)
1318 return -EIO; 1313 return -EIO;
1319 1314
1320 value = simple_strtoul(buf, &rest, 10); 1315 if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))
1321 if (*rest || (value != 2 && value != 3))
1322 return -EINVAL; 1316 return -EINVAL;
1323 1317
1324 if (atkbd->set != value) { 1318 if (atkbd->set != value) {
@@ -1361,15 +1355,13 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1361{ 1355{
1362 struct input_dev *old_dev, *new_dev; 1356 struct input_dev *old_dev, *new_dev;
1363 unsigned long value; 1357 unsigned long value;
1364 char *rest;
1365 int err; 1358 int err;
1366 unsigned char old_softrepeat, old_softraw; 1359 unsigned char old_softrepeat, old_softraw;
1367 1360
1368 if (!atkbd->write) 1361 if (!atkbd->write)
1369 return -EIO; 1362 return -EIO;
1370 1363
1371 value = simple_strtoul(buf, &rest, 10); 1364 if (strict_strtoul(buf, 10, &value) || value > 1)
1372 if (*rest || value > 1)
1373 return -EINVAL; 1365 return -EINVAL;
1374 1366
1375 if (atkbd->softrepeat != value) { 1367 if (atkbd->softrepeat != value) {
@@ -1413,12 +1405,10 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1413{ 1405{
1414 struct input_dev *old_dev, *new_dev; 1406 struct input_dev *old_dev, *new_dev;
1415 unsigned long value; 1407 unsigned long value;
1416 char *rest;
1417 int err; 1408 int err;
1418 unsigned char old_softraw; 1409 unsigned char old_softraw;
1419 1410
1420 value = simple_strtoul(buf, &rest, 10); 1411 if (strict_strtoul(buf, 10, &value) || value > 1)
1421 if (*rest || value > 1)
1422 return -EINVAL; 1412 return -EINVAL;
1423 1413
1424 if (atkbd->softraw != value) { 1414 if (atkbd->softraw != value) {
@@ -1461,13 +1451,13 @@ static int __init atkbd_setup_fixup(const struct dmi_system_id *id)
1461 1451
1462static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = { 1452static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1463 { 1453 {
1464 .ident = "Dell Latitude series", 1454 .ident = "Dell Laptop",
1465 .matches = { 1455 .matches = {
1466 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1456 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
1467 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"), 1457 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
1468 }, 1458 },
1469 .callback = atkbd_setup_fixup, 1459 .callback = atkbd_setup_fixup,
1470 .driver_data = atkbd_latitude_keymap_fixup, 1460 .driver_data = atkbd_dell_laptop_keymap_fixup,
1471 }, 1461 },
1472 { 1462 {
1473 .ident = "HP 2133", 1463 .ident = "HP 2133",
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index e348cfccc17a..19284016e0f4 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * 9 *
10 * Modified: 10 * Modified:
11 * Copyright 2007 Analog Devices Inc. 11 * Copyright 2007-2008 Analog Devices Inc.
12 * 12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * 14 *
@@ -81,6 +81,9 @@ struct bf54x_kpad {
81 unsigned short *keycode; 81 unsigned short *keycode;
82 struct timer_list timer; 82 struct timer_list timer;
83 unsigned int keyup_test_jiffies; 83 unsigned int keyup_test_jiffies;
84 unsigned short kpad_msel;
85 unsigned short kpad_prescale;
86 unsigned short kpad_ctl;
84}; 87};
85 88
86static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad, 89static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad,
@@ -360,6 +363,10 @@ static int bfin_kpad_suspend(struct platform_device *pdev, pm_message_t state)
360{ 363{
361 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 364 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);
362 365
366 bf54x_kpad->kpad_msel = bfin_read_KPAD_MSEL();
367 bf54x_kpad->kpad_prescale = bfin_read_KPAD_PRESCALE();
368 bf54x_kpad->kpad_ctl = bfin_read_KPAD_CTL();
369
363 if (device_may_wakeup(&pdev->dev)) 370 if (device_may_wakeup(&pdev->dev))
364 enable_irq_wake(bf54x_kpad->irq); 371 enable_irq_wake(bf54x_kpad->irq);
365 372
@@ -370,6 +377,10 @@ static int bfin_kpad_resume(struct platform_device *pdev)
370{ 377{
371 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 378 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);
372 379
380 bfin_write_KPAD_MSEL(bf54x_kpad->kpad_msel);
381 bfin_write_KPAD_PRESCALE(bf54x_kpad->kpad_prescale);
382 bfin_write_KPAD_CTL(bf54x_kpad->kpad_ctl);
383
373 if (device_may_wakeup(&pdev->dev)) 384 if (device_may_wakeup(&pdev->dev))
374 disable_irq_wake(bf54x_kpad->irq); 385 disable_irq_wake(bf54x_kpad->irq);
375 386
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ec96b369dd7a..05f3f43582c2 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -36,9 +36,10 @@ struct gpio_keys_drvdata {
36 struct gpio_button_data data[0]; 36 struct gpio_button_data data[0];
37}; 37};
38 38
39static void gpio_keys_report_event(struct gpio_keys_button *button, 39static void gpio_keys_report_event(struct gpio_button_data *bdata)
40 struct input_dev *input)
41{ 40{
41 struct gpio_keys_button *button = bdata->button;
42 struct input_dev *input = bdata->input;
42 unsigned int type = button->type ?: EV_KEY; 43 unsigned int type = button->type ?: EV_KEY;
43 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; 44 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
44 45
@@ -50,34 +51,23 @@ static void gpio_check_button(unsigned long _data)
50{ 51{
51 struct gpio_button_data *data = (struct gpio_button_data *)_data; 52 struct gpio_button_data *data = (struct gpio_button_data *)_data;
52 53
53 gpio_keys_report_event(data->button, data->input); 54 gpio_keys_report_event(data);
54} 55}
55 56
56static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 57static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
57{ 58{
58 struct platform_device *pdev = dev_id; 59 struct gpio_button_data *bdata = dev_id;
59 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 60 struct gpio_keys_button *button = bdata->button;
60 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);
61 int i;
62 61
63 for (i = 0; i < pdata->nbuttons; i++) { 62 BUG_ON(irq != gpio_to_irq(button->gpio));
64 struct gpio_keys_button *button = &pdata->buttons[i];
65 63
66 if (irq == gpio_to_irq(button->gpio)) { 64 if (button->debounce_interval)
67 struct gpio_button_data *bdata = &ddata->data[i]; 65 mod_timer(&bdata->timer,
68 66 jiffies + msecs_to_jiffies(button->debounce_interval));
69 if (button->debounce_interval) 67 else
70 mod_timer(&bdata->timer, 68 gpio_keys_report_event(bdata);
71 jiffies +
72 msecs_to_jiffies(button->debounce_interval));
73 else
74 gpio_keys_report_event(button, bdata->input);
75
76 return IRQ_HANDLED;
77 }
78 }
79 69
80 return IRQ_NONE; 70 return IRQ_HANDLED;
81} 71}
82 72
83static int __devinit gpio_keys_probe(struct platform_device *pdev) 73static int __devinit gpio_keys_probe(struct platform_device *pdev)
@@ -151,7 +141,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
151 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | 141 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
152 IRQF_TRIGGER_FALLING, 142 IRQF_TRIGGER_FALLING,
153 button->desc ? button->desc : "gpio_keys", 143 button->desc ? button->desc : "gpio_keys",
154 pdev); 144 bdata);
155 if (error) { 145 if (error) {
156 pr_err("gpio-keys: Unable to claim irq %d; error %d\n", 146 pr_err("gpio-keys: Unable to claim irq %d; error %d\n",
157 irq, error); 147 irq, error);
@@ -178,7 +168,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
178 168
179 fail2: 169 fail2:
180 while (--i >= 0) { 170 while (--i >= 0) {
181 free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); 171 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
182 if (pdata->buttons[i].debounce_interval) 172 if (pdata->buttons[i].debounce_interval)
183 del_timer_sync(&ddata->data[i].timer); 173 del_timer_sync(&ddata->data[i].timer);
184 gpio_free(pdata->buttons[i].gpio); 174 gpio_free(pdata->buttons[i].gpio);
@@ -203,7 +193,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
203 193
204 for (i = 0; i < pdata->nbuttons; i++) { 194 for (i = 0; i < pdata->nbuttons; i++) {
205 int irq = gpio_to_irq(pdata->buttons[i].gpio); 195 int irq = gpio_to_irq(pdata->buttons[i].gpio);
206 free_irq(irq, pdev); 196 free_irq(irq, &ddata->data[i]);
207 if (pdata->buttons[i].debounce_interval) 197 if (pdata->buttons[i].debounce_interval)
208 del_timer_sync(&ddata->data[i].timer); 198 del_timer_sync(&ddata->data[i].timer);
209 gpio_free(pdata->buttons[i].gpio); 199 gpio_free(pdata->buttons[i].gpio);
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index dcea87a0bc56..69e674ecf19a 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -62,7 +62,7 @@ struct omap_kp {
62 unsigned int debounce; 62 unsigned int debounce;
63}; 63};
64 64
65DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0); 65static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0);
66 66
67static int *keymap; 67static int *keymap;
68static unsigned int *row_gpios; 68static unsigned int *row_gpios;
@@ -72,12 +72,9 @@ static unsigned int *col_gpios;
72static void set_col_gpio_val(struct omap_kp *omap_kp, u8 value) 72static void set_col_gpio_val(struct omap_kp *omap_kp, u8 value)
73{ 73{
74 int col; 74 int col;
75 for (col = 0; col < omap_kp->cols; col++) { 75
76 if (value & (1 << col)) 76 for (col = 0; col < omap_kp->cols; col++)
77 omap_set_gpio_dataout(col_gpios[col], 1); 77 gpio_set_value(col_gpios[col], value & (1 << col));
78 else
79 omap_set_gpio_dataout(col_gpios[col], 0);
80 }
81} 78}
82 79
83static u8 get_row_gpio_val(struct omap_kp *omap_kp) 80static u8 get_row_gpio_val(struct omap_kp *omap_kp)
@@ -86,7 +83,7 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp)
86 u8 value = 0; 83 u8 value = 0;
87 84
88 for (row = 0; row < omap_kp->rows; row++) { 85 for (row = 0; row < omap_kp->rows; row++) {
89 if (omap_get_gpio_datain(row_gpios[row])) 86 if (gpio_get_value(row_gpios[row]))
90 value |= (1 << row); 87 value |= (1 << row);
91 } 88 }
92 return value; 89 return value;
@@ -333,23 +330,23 @@ static int __init omap_kp_probe(struct platform_device *pdev)
333 if (cpu_is_omap24xx()) { 330 if (cpu_is_omap24xx()) {
334 /* Cols: outputs */ 331 /* Cols: outputs */
335 for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) { 332 for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
336 if (omap_request_gpio(col_gpios[col_idx]) < 0) { 333 if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
337 printk(KERN_ERR "Failed to request" 334 printk(KERN_ERR "Failed to request"
338 "GPIO%d for keypad\n", 335 "GPIO%d for keypad\n",
339 col_gpios[col_idx]); 336 col_gpios[col_idx]);
340 goto err1; 337 goto err1;
341 } 338 }
342 omap_set_gpio_direction(col_gpios[col_idx], 0); 339 gpio_direction_output(col_gpios[col_idx], 0);
343 } 340 }
344 /* Rows: inputs */ 341 /* Rows: inputs */
345 for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) { 342 for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) {
346 if (omap_request_gpio(row_gpios[row_idx]) < 0) { 343 if (gpio_request(row_gpios[row_idx], "omap_kp_row") < 0) {
347 printk(KERN_ERR "Failed to request" 344 printk(KERN_ERR "Failed to request"
348 "GPIO%d for keypad\n", 345 "GPIO%d for keypad\n",
349 row_gpios[row_idx]); 346 row_gpios[row_idx]);
350 goto err2; 347 goto err2;
351 } 348 }
352 omap_set_gpio_direction(row_gpios[row_idx], 1); 349 gpio_direction_input(row_gpios[row_idx]);
353 } 350 }
354 } else { 351 } else {
355 col_idx = 0; 352 col_idx = 0;
@@ -418,10 +415,10 @@ err3:
418 device_remove_file(&pdev->dev, &dev_attr_enable); 415 device_remove_file(&pdev->dev, &dev_attr_enable);
419err2: 416err2:
420 for (i = row_idx - 1; i >=0; i--) 417 for (i = row_idx - 1; i >=0; i--)
421 omap_free_gpio(row_gpios[i]); 418 gpio_free(row_gpios[i]);
422err1: 419err1:
423 for (i = col_idx - 1; i >=0; i--) 420 for (i = col_idx - 1; i >=0; i--)
424 omap_free_gpio(col_gpios[i]); 421 gpio_free(col_gpios[i]);
425 422
426 kfree(omap_kp); 423 kfree(omap_kp);
427 input_free_device(input_dev); 424 input_free_device(input_dev);
@@ -438,9 +435,9 @@ static int omap_kp_remove(struct platform_device *pdev)
438 if (cpu_is_omap24xx()) { 435 if (cpu_is_omap24xx()) {
439 int i; 436 int i;
440 for (i = 0; i < omap_kp->cols; i++) 437 for (i = 0; i < omap_kp->cols; i++)
441 omap_free_gpio(col_gpios[i]); 438 gpio_free(col_gpios[i]);
442 for (i = 0; i < omap_kp->rows; i++) { 439 for (i = 0; i < omap_kp->rows; i++) {
443 omap_free_gpio(row_gpios[i]); 440 gpio_free(row_gpios[i]);
444 free_irq(OMAP_GPIO_IRQ(row_gpios[i]), 0); 441 free_irq(OMAP_GPIO_IRQ(row_gpios[i]), 0);
445 } 442 }
446 } else { 443 } else {
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index e99b7882f382..199055db5082 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -180,6 +180,19 @@ config INPUT_YEALINK
180 To compile this driver as a module, choose M here: the module will be 180 To compile this driver as a module, choose M here: the module will be
181 called yealink. 181 called yealink.
182 182
183config INPUT_CM109
184 tristate "C-Media CM109 USB I/O Controller"
185 depends on EXPERIMENTAL
186 depends on USB_ARCH_HAS_HCD
187 select USB
188 help
189 Say Y here if you want to enable keyboard and buzzer functions of the
190 C-Media CM109 usb phones. The audio part is enabled by the generic
191 usb sound driver, so you might want to enable that as well.
192
193 To compile this driver as a module, choose M here: the module will be
194 called cm109.
195
183config INPUT_UINPUT 196config INPUT_UINPUT
184 tristate "User level driver support" 197 tristate "User level driver support"
185 help 198 help
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index f48009b52226..d7db2aeb8a98 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
16obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o 16obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
17obj-$(CONFIG_INPUT_POWERMATE) += powermate.o 17obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
18obj-$(CONFIG_INPUT_YEALINK) += yealink.o 18obj-$(CONFIG_INPUT_YEALINK) += yealink.o
19obj-$(CONFIG_INPUT_CM109) += cm109.o
19obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 20obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
20obj-$(CONFIG_INPUT_UINPUT) += uinput.o 21obj-$(CONFIG_INPUT_UINPUT) += uinput.o
21obj-$(CONFIG_INPUT_APANEL) += apanel.o 22obj-$(CONFIG_INPUT_APANEL) += apanel.o
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index a7fabafbd94c..3c9988dc0e9f 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * ati_remote2 - ATI/Philips USB RF remote driver 2 * ati_remote2 - ATI/Philips USB RF remote driver
3 * 3 *
4 * Copyright (C) 2005 Ville Syrjala <syrjala@sci.fi> 4 * Copyright (C) 2005-2008 Ville Syrjala <syrjala@sci.fi>
5 * Copyright (C) 2007 Peter Stokes <linux@dadeos.freeserve.co.uk> 5 * Copyright (C) 2007-2008 Peter Stokes <linux@dadeos.co.uk>
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
8 * it under the terms of the GNU General Public License version 2 8 * it under the terms of the GNU General Public License version 2
@@ -12,7 +12,7 @@
12#include <linux/usb/input.h> 12#include <linux/usb/input.h>
13 13
14#define DRIVER_DESC "ATI/Philips USB RF remote driver" 14#define DRIVER_DESC "ATI/Philips USB RF remote driver"
15#define DRIVER_VERSION "0.2" 15#define DRIVER_VERSION "0.3"
16 16
17MODULE_DESCRIPTION(DRIVER_DESC); 17MODULE_DESCRIPTION(DRIVER_DESC);
18MODULE_VERSION(DRIVER_VERSION); 18MODULE_VERSION(DRIVER_VERSION);
@@ -27,7 +27,7 @@ MODULE_LICENSE("GPL");
27 * A remote's "channel" may be altered by pressing and holding the "PC" button for 27 * A remote's "channel" may be altered by pressing and holding the "PC" button for
28 * approximately 3 seconds, after which the button will slowly flash the count of the 28 * approximately 3 seconds, after which the button will slowly flash the count of the
29 * currently configured "channel", using the numeric keypad enter a number between 1 and 29 * currently configured "channel", using the numeric keypad enter a number between 1 and
30 * 16 and then the "PC" button again, the button will slowly flash the count of the 30 * 16 and then press the "PC" button again, the button will slowly flash the count of the
31 * newly configured "channel". 31 * newly configured "channel".
32 */ 32 */
33 33
@@ -45,9 +45,25 @@ static struct usb_device_id ati_remote2_id_table[] = {
45}; 45};
46MODULE_DEVICE_TABLE(usb, ati_remote2_id_table); 46MODULE_DEVICE_TABLE(usb, ati_remote2_id_table);
47 47
48static struct { 48static DEFINE_MUTEX(ati_remote2_mutex);
49 int hw_code; 49
50 int key_code; 50enum {
51 ATI_REMOTE2_OPENED = 0x1,
52 ATI_REMOTE2_SUSPENDED = 0x2,
53};
54
55enum {
56 ATI_REMOTE2_AUX1,
57 ATI_REMOTE2_AUX2,
58 ATI_REMOTE2_AUX3,
59 ATI_REMOTE2_AUX4,
60 ATI_REMOTE2_PC,
61 ATI_REMOTE2_MODES,
62};
63
64static const struct {
65 u8 hw_code;
66 u16 keycode;
51} ati_remote2_key_table[] = { 67} ati_remote2_key_table[] = {
52 { 0x00, KEY_0 }, 68 { 0x00, KEY_0 },
53 { 0x01, KEY_1 }, 69 { 0x01, KEY_1 },
@@ -73,6 +89,7 @@ static struct {
73 { 0x37, KEY_RECORD }, 89 { 0x37, KEY_RECORD },
74 { 0x38, KEY_DVD }, 90 { 0x38, KEY_DVD },
75 { 0x39, KEY_TV }, 91 { 0x39, KEY_TV },
92 { 0x3f, KEY_PROG1 }, /* AUX1-AUX4 and PC */
76 { 0x54, KEY_MENU }, 93 { 0x54, KEY_MENU },
77 { 0x58, KEY_UP }, 94 { 0x58, KEY_UP },
78 { 0x59, KEY_DOWN }, 95 { 0x59, KEY_DOWN },
@@ -91,15 +108,9 @@ static struct {
91 { 0xa9, BTN_LEFT }, 108 { 0xa9, BTN_LEFT },
92 { 0xaa, BTN_RIGHT }, 109 { 0xaa, BTN_RIGHT },
93 { 0xbe, KEY_QUESTION }, 110 { 0xbe, KEY_QUESTION },
94 { 0xd5, KEY_FRONT },
95 { 0xd0, KEY_EDIT }, 111 { 0xd0, KEY_EDIT },
112 { 0xd5, KEY_FRONT },
96 { 0xf9, KEY_INFO }, 113 { 0xf9, KEY_INFO },
97 { (0x00 << 8) | 0x3f, KEY_PROG1 },
98 { (0x01 << 8) | 0x3f, KEY_PROG2 },
99 { (0x02 << 8) | 0x3f, KEY_PROG3 },
100 { (0x03 << 8) | 0x3f, KEY_PROG4 },
101 { (0x04 << 8) | 0x3f, KEY_PC },
102 { 0, KEY_RESERVED }
103}; 114};
104 115
105struct ati_remote2 { 116struct ati_remote2 {
@@ -117,46 +128,106 @@ struct ati_remote2 {
117 128
118 char name[64]; 129 char name[64];
119 char phys[64]; 130 char phys[64];
131
132 /* Each mode (AUX1-AUX4 and PC) can have an independent keymap. */
133 u16 keycode[ATI_REMOTE2_MODES][ARRAY_SIZE(ati_remote2_key_table)];
134
135 unsigned int flags;
120}; 136};
121 137
122static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); 138static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id);
123static void ati_remote2_disconnect(struct usb_interface *interface); 139static void ati_remote2_disconnect(struct usb_interface *interface);
140static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message);
141static int ati_remote2_resume(struct usb_interface *interface);
124 142
125static struct usb_driver ati_remote2_driver = { 143static struct usb_driver ati_remote2_driver = {
126 .name = "ati_remote2", 144 .name = "ati_remote2",
127 .probe = ati_remote2_probe, 145 .probe = ati_remote2_probe,
128 .disconnect = ati_remote2_disconnect, 146 .disconnect = ati_remote2_disconnect,
129 .id_table = ati_remote2_id_table, 147 .id_table = ati_remote2_id_table,
148 .suspend = ati_remote2_suspend,
149 .resume = ati_remote2_resume,
150 .supports_autosuspend = 1,
130}; 151};
131 152
132static int ati_remote2_open(struct input_dev *idev) 153static int ati_remote2_submit_urbs(struct ati_remote2 *ar2)
133{ 154{
134 struct ati_remote2 *ar2 = input_get_drvdata(idev);
135 int r; 155 int r;
136 156
137 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); 157 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL);
138 if (r) { 158 if (r) {
139 dev_err(&ar2->intf[0]->dev, 159 dev_err(&ar2->intf[0]->dev,
140 "%s: usb_submit_urb() = %d\n", __func__, r); 160 "%s(): usb_submit_urb() = %d\n", __func__, r);
141 return r; 161 return r;
142 } 162 }
143 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL); 163 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL);
144 if (r) { 164 if (r) {
145 usb_kill_urb(ar2->urb[0]); 165 usb_kill_urb(ar2->urb[0]);
146 dev_err(&ar2->intf[1]->dev, 166 dev_err(&ar2->intf[1]->dev,
147 "%s: usb_submit_urb() = %d\n", __func__, r); 167 "%s(): usb_submit_urb() = %d\n", __func__, r);
148 return r; 168 return r;
149 } 169 }
150 170
151 return 0; 171 return 0;
152} 172}
153 173
174static void ati_remote2_kill_urbs(struct ati_remote2 *ar2)
175{
176 usb_kill_urb(ar2->urb[1]);
177 usb_kill_urb(ar2->urb[0]);
178}
179
180static int ati_remote2_open(struct input_dev *idev)
181{
182 struct ati_remote2 *ar2 = input_get_drvdata(idev);
183 int r;
184
185 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
186
187 r = usb_autopm_get_interface(ar2->intf[0]);
188 if (r) {
189 dev_err(&ar2->intf[0]->dev,
190 "%s(): usb_autopm_get_interface() = %d\n", __func__, r);
191 goto fail1;
192 }
193
194 mutex_lock(&ati_remote2_mutex);
195
196 if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) {
197 r = ati_remote2_submit_urbs(ar2);
198 if (r)
199 goto fail2;
200 }
201
202 ar2->flags |= ATI_REMOTE2_OPENED;
203
204 mutex_unlock(&ati_remote2_mutex);
205
206 usb_autopm_put_interface(ar2->intf[0]);
207
208 return 0;
209
210 fail2:
211 mutex_unlock(&ati_remote2_mutex);
212 usb_autopm_put_interface(ar2->intf[0]);
213 fail1:
214 return r;
215}
216
154static void ati_remote2_close(struct input_dev *idev) 217static void ati_remote2_close(struct input_dev *idev)
155{ 218{
156 struct ati_remote2 *ar2 = input_get_drvdata(idev); 219 struct ati_remote2 *ar2 = input_get_drvdata(idev);
157 220
158 usb_kill_urb(ar2->urb[0]); 221 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
159 usb_kill_urb(ar2->urb[1]); 222
223 mutex_lock(&ati_remote2_mutex);
224
225 if (!(ar2->flags & ATI_REMOTE2_SUSPENDED))
226 ati_remote2_kill_urbs(ar2);
227
228 ar2->flags &= ~ATI_REMOTE2_OPENED;
229
230 mutex_unlock(&ati_remote2_mutex);
160} 231}
161 232
162static void ati_remote2_input_mouse(struct ati_remote2 *ar2) 233static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
@@ -172,7 +243,7 @@ static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
172 243
173 mode = data[0] & 0x0F; 244 mode = data[0] & 0x0F;
174 245
175 if (mode > 4) { 246 if (mode > ATI_REMOTE2_PC) {
176 dev_err(&ar2->intf[0]->dev, 247 dev_err(&ar2->intf[0]->dev,
177 "Unknown mode byte (%02x %02x %02x %02x)\n", 248 "Unknown mode byte (%02x %02x %02x %02x)\n",
178 data[3], data[2], data[1], data[0]); 249 data[3], data[2], data[1], data[0]);
@@ -191,7 +262,7 @@ static int ati_remote2_lookup(unsigned int hw_code)
191{ 262{
192 int i; 263 int i;
193 264
194 for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) 265 for (i = 0; i < ARRAY_SIZE(ati_remote2_key_table); i++)
195 if (ati_remote2_key_table[i].hw_code == hw_code) 266 if (ati_remote2_key_table[i].hw_code == hw_code)
196 return i; 267 return i;
197 268
@@ -211,7 +282,7 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
211 282
212 mode = data[0] & 0x0F; 283 mode = data[0] & 0x0F;
213 284
214 if (mode > 4) { 285 if (mode > ATI_REMOTE2_PC) {
215 dev_err(&ar2->intf[1]->dev, 286 dev_err(&ar2->intf[1]->dev,
216 "Unknown mode byte (%02x %02x %02x %02x)\n", 287 "Unknown mode byte (%02x %02x %02x %02x)\n",
217 data[3], data[2], data[1], data[0]); 288 data[3], data[2], data[1], data[0]);
@@ -219,10 +290,6 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
219 } 290 }
220 291
221 hw_code = data[2]; 292 hw_code = data[2];
222 /*
223 * Mode keys (AUX1-AUX4, PC) all generate the same code byte.
224 * Use the mode byte to figure out which one was pressed.
225 */
226 if (hw_code == 0x3f) { 293 if (hw_code == 0x3f) {
227 /* 294 /*
228 * For some incomprehensible reason the mouse pad generates 295 * For some incomprehensible reason the mouse pad generates
@@ -236,8 +303,6 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
236 303
237 if (data[1] == 0) 304 if (data[1] == 0)
238 ar2->mode = mode; 305 ar2->mode = mode;
239
240 hw_code |= mode << 8;
241 } 306 }
242 307
243 if (!((1 << mode) & mode_mask)) 308 if (!((1 << mode) & mode_mask))
@@ -260,8 +325,8 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
260 case 2: /* repeat */ 325 case 2: /* repeat */
261 326
262 /* No repeat for mouse buttons. */ 327 /* No repeat for mouse buttons. */
263 if (ati_remote2_key_table[index].key_code == BTN_LEFT || 328 if (ar2->keycode[mode][index] == BTN_LEFT ||
264 ati_remote2_key_table[index].key_code == BTN_RIGHT) 329 ar2->keycode[mode][index] == BTN_RIGHT)
265 return; 330 return;
266 331
267 if (!time_after_eq(jiffies, ar2->jiffies)) 332 if (!time_after_eq(jiffies, ar2->jiffies))
@@ -276,7 +341,7 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
276 return; 341 return;
277 } 342 }
278 343
279 input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]); 344 input_event(idev, EV_KEY, ar2->keycode[mode][index], data[1]);
280 input_sync(idev); 345 input_sync(idev);
281} 346}
282 347
@@ -287,6 +352,7 @@ static void ati_remote2_complete_mouse(struct urb *urb)
287 352
288 switch (urb->status) { 353 switch (urb->status) {
289 case 0: 354 case 0:
355 usb_mark_last_busy(ar2->udev);
290 ati_remote2_input_mouse(ar2); 356 ati_remote2_input_mouse(ar2);
291 break; 357 break;
292 case -ENOENT: 358 case -ENOENT:
@@ -297,6 +363,7 @@ static void ati_remote2_complete_mouse(struct urb *urb)
297 "%s(): urb status = %d\n", __func__, urb->status); 363 "%s(): urb status = %d\n", __func__, urb->status);
298 return; 364 return;
299 default: 365 default:
366 usb_mark_last_busy(ar2->udev);
300 dev_err(&ar2->intf[0]->dev, 367 dev_err(&ar2->intf[0]->dev,
301 "%s(): urb status = %d\n", __func__, urb->status); 368 "%s(): urb status = %d\n", __func__, urb->status);
302 } 369 }
@@ -314,6 +381,7 @@ static void ati_remote2_complete_key(struct urb *urb)
314 381
315 switch (urb->status) { 382 switch (urb->status) {
316 case 0: 383 case 0:
384 usb_mark_last_busy(ar2->udev);
317 ati_remote2_input_key(ar2); 385 ati_remote2_input_key(ar2);
318 break; 386 break;
319 case -ENOENT: 387 case -ENOENT:
@@ -324,6 +392,7 @@ static void ati_remote2_complete_key(struct urb *urb)
324 "%s(): urb status = %d\n", __func__, urb->status); 392 "%s(): urb status = %d\n", __func__, urb->status);
325 return; 393 return;
326 default: 394 default:
395 usb_mark_last_busy(ar2->udev);
327 dev_err(&ar2->intf[1]->dev, 396 dev_err(&ar2->intf[1]->dev,
328 "%s(): urb status = %d\n", __func__, urb->status); 397 "%s(): urb status = %d\n", __func__, urb->status);
329 } 398 }
@@ -334,10 +403,60 @@ static void ati_remote2_complete_key(struct urb *urb)
334 "%s(): usb_submit_urb() = %d\n", __func__, r); 403 "%s(): usb_submit_urb() = %d\n", __func__, r);
335} 404}
336 405
406static int ati_remote2_getkeycode(struct input_dev *idev,
407 int scancode, int *keycode)
408{
409 struct ati_remote2 *ar2 = input_get_drvdata(idev);
410 int index, mode;
411
412 mode = scancode >> 8;
413 if (mode > ATI_REMOTE2_PC || !((1 << mode) & mode_mask))
414 return -EINVAL;
415
416 index = ati_remote2_lookup(scancode & 0xFF);
417 if (index < 0)
418 return -EINVAL;
419
420 *keycode = ar2->keycode[mode][index];
421 return 0;
422}
423
424static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keycode)
425{
426 struct ati_remote2 *ar2 = input_get_drvdata(idev);
427 int index, mode, old_keycode;
428
429 mode = scancode >> 8;
430 if (mode > ATI_REMOTE2_PC || !((1 << mode) & mode_mask))
431 return -EINVAL;
432
433 index = ati_remote2_lookup(scancode & 0xFF);
434 if (index < 0)
435 return -EINVAL;
436
437 if (keycode < KEY_RESERVED || keycode > KEY_MAX)
438 return -EINVAL;
439
440 old_keycode = ar2->keycode[mode][index];
441 ar2->keycode[mode][index] = keycode;
442 set_bit(keycode, idev->keybit);
443
444 for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
445 for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
446 if (ar2->keycode[mode][index] == old_keycode)
447 return 0;
448 }
449 }
450
451 clear_bit(old_keycode, idev->keybit);
452
453 return 0;
454}
455
337static int ati_remote2_input_init(struct ati_remote2 *ar2) 456static int ati_remote2_input_init(struct ati_remote2 *ar2)
338{ 457{
339 struct input_dev *idev; 458 struct input_dev *idev;
340 int i, retval; 459 int index, mode, retval;
341 460
342 idev = input_allocate_device(); 461 idev = input_allocate_device();
343 if (!idev) 462 if (!idev)
@@ -350,8 +469,26 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
350 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 469 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
351 BIT_MASK(BTN_RIGHT); 470 BIT_MASK(BTN_RIGHT);
352 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 471 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
353 for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) 472
354 set_bit(ati_remote2_key_table[i].key_code, idev->keybit); 473 for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
474 for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
475 ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode;
476 set_bit(ar2->keycode[mode][index], idev->keybit);
477 }
478 }
479
480 /* AUX1-AUX4 and PC generate the same scancode. */
481 index = ati_remote2_lookup(0x3f);
482 ar2->keycode[ATI_REMOTE2_AUX1][index] = KEY_PROG1;
483 ar2->keycode[ATI_REMOTE2_AUX2][index] = KEY_PROG2;
484 ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3;
485 ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4;
486 ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC;
487 set_bit(KEY_PROG1, idev->keybit);
488 set_bit(KEY_PROG2, idev->keybit);
489 set_bit(KEY_PROG3, idev->keybit);
490 set_bit(KEY_PROG4, idev->keybit);
491 set_bit(KEY_PC, idev->keybit);
355 492
356 idev->rep[REP_DELAY] = 250; 493 idev->rep[REP_DELAY] = 250;
357 idev->rep[REP_PERIOD] = 33; 494 idev->rep[REP_PERIOD] = 33;
@@ -359,6 +496,9 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
359 idev->open = ati_remote2_open; 496 idev->open = ati_remote2_open;
360 idev->close = ati_remote2_close; 497 idev->close = ati_remote2_close;
361 498
499 idev->getkeycode = ati_remote2_getkeycode;
500 idev->setkeycode = ati_remote2_setkeycode;
501
362 idev->name = ar2->name; 502 idev->name = ar2->name;
363 idev->phys = ar2->phys; 503 idev->phys = ar2->phys;
364 504
@@ -490,6 +630,8 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
490 630
491 usb_set_intfdata(interface, ar2); 631 usb_set_intfdata(interface, ar2);
492 632
633 interface->needs_remote_wakeup = 1;
634
493 return 0; 635 return 0;
494 636
495 fail2: 637 fail2:
@@ -522,6 +664,57 @@ static void ati_remote2_disconnect(struct usb_interface *interface)
522 kfree(ar2); 664 kfree(ar2);
523} 665}
524 666
667static int ati_remote2_suspend(struct usb_interface *interface,
668 pm_message_t message)
669{
670 struct ati_remote2 *ar2;
671 struct usb_host_interface *alt = interface->cur_altsetting;
672
673 if (alt->desc.bInterfaceNumber)
674 return 0;
675
676 ar2 = usb_get_intfdata(interface);
677
678 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
679
680 mutex_lock(&ati_remote2_mutex);
681
682 if (ar2->flags & ATI_REMOTE2_OPENED)
683 ati_remote2_kill_urbs(ar2);
684
685 ar2->flags |= ATI_REMOTE2_SUSPENDED;
686
687 mutex_unlock(&ati_remote2_mutex);
688
689 return 0;
690}
691
692static int ati_remote2_resume(struct usb_interface *interface)
693{
694 struct ati_remote2 *ar2;
695 struct usb_host_interface *alt = interface->cur_altsetting;
696 int r = 0;
697
698 if (alt->desc.bInterfaceNumber)
699 return 0;
700
701 ar2 = usb_get_intfdata(interface);
702
703 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
704
705 mutex_lock(&ati_remote2_mutex);
706
707 if (ar2->flags & ATI_REMOTE2_OPENED)
708 r = ati_remote2_submit_urbs(ar2);
709
710 if (!r)
711 ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
712
713 mutex_unlock(&ati_remote2_mutex);
714
715 return r;
716}
717
525static int __init ati_remote2_init(void) 718static int __init ati_remote2_init(void)
526{ 719{
527 int r; 720 int r;
diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
new file mode 100644
index 000000000000..bce160f4349b
--- /dev/null
+++ b/drivers/input/misc/cm109.c
@@ -0,0 +1,882 @@
1/*
2 * Driver for the VoIP USB phones with CM109 chipsets.
3 *
4 * Copyright (C) 2007 - 2008 Alfred E. Heggestad <aeh@db.org>
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 as
8 * published by the Free Software Foundation, version 2.
9 */
10
11/*
12 * Tested devices:
13 * - Komunikate KIP1000
14 * - Genius G-talk
15 * - Allied-Telesis Corega USBPH01
16 * - ...
17 *
18 * This driver is based on the yealink.c driver
19 *
20 * Thanks to:
21 * - Authors of yealink.c
22 * - Thomas Reitmayr
23 * - Oliver Neukum for good review comments and code
24 * - Shaun Jackman <sjackman@gmail.com> for Genius G-talk keymap
25 * - Dmitry Torokhov for valuable input and review
26 *
27 * Todo:
28 * - Read/write EEPROM
29 */
30
31#include <linux/kernel.h>
32#include <linux/init.h>
33#include <linux/slab.h>
34#include <linux/module.h>
35#include <linux/moduleparam.h>
36#include <linux/rwsem.h>
37#include <linux/usb/input.h>
38
39#define DRIVER_VERSION "20080805"
40#define DRIVER_AUTHOR "Alfred E. Heggestad"
41#define DRIVER_DESC "CM109 phone driver"
42
43static char *phone = "kip1000";
44module_param(phone, charp, S_IRUSR);
45MODULE_PARM_DESC(phone, "Phone name {kip1000, gtalk, usbph01}");
46
47enum {
48 /* HID Registers */
49 HID_IR0 = 0x00, /* Record/Playback-mute button, Volume up/down */
50 HID_IR1 = 0x01, /* GPI, generic registers or EEPROM_DATA0 */
51 HID_IR2 = 0x02, /* Generic registers or EEPROM_DATA1 */
52 HID_IR3 = 0x03, /* Generic registers or EEPROM_CTRL */
53 HID_OR0 = 0x00, /* Mapping control, buzzer, SPDIF (offset 0x04) */
54 HID_OR1 = 0x01, /* GPO - General Purpose Output */
55 HID_OR2 = 0x02, /* Set GPIO to input/output mode */
56 HID_OR3 = 0x03, /* SPDIF status channel or EEPROM_CTRL */
57
58 /* HID_IR0 */
59 RECORD_MUTE = 1 << 3,
60 PLAYBACK_MUTE = 1 << 2,
61 VOLUME_DOWN = 1 << 1,
62 VOLUME_UP = 1 << 0,
63
64 /* HID_OR0 */
65 /* bits 7-6
66 0: HID_OR1-2 are used for GPO; HID_OR0, 3 are used for buzzer
67 and SPDIF
68 1: HID_OR0-3 are used as generic HID registers
69 2: Values written to HID_OR0-3 are also mapped to MCU_CTRL,
70 EEPROM_DATA0-1, EEPROM_CTRL (see Note)
71 3: Reserved
72 */
73 HID_OR_GPO_BUZ_SPDIF = 0 << 6,
74 HID_OR_GENERIC_HID_REG = 1 << 6,
75 HID_OR_MAP_MCU_EEPROM = 2 << 6,
76
77 BUZZER_ON = 1 << 5,
78
79 /* up to 256 normal keys, up to 16 special keys */
80 KEYMAP_SIZE = 256 + 16,
81};
82
83/* CM109 protocol packet */
84struct cm109_ctl_packet {
85 u8 byte[4];
86} __attribute__ ((packed));
87
88enum { USB_PKT_LEN = sizeof(struct cm109_ctl_packet) };
89
90/* CM109 device structure */
91struct cm109_dev {
92 struct input_dev *idev; /* input device */
93 struct usb_device *udev; /* usb device */
94 struct usb_interface *intf;
95
96 /* irq input channel */
97 struct cm109_ctl_packet *irq_data;
98 dma_addr_t irq_dma;
99 struct urb *urb_irq;
100
101 /* control output channel */
102 struct cm109_ctl_packet *ctl_data;
103 dma_addr_t ctl_dma;
104 struct usb_ctrlrequest *ctl_req;
105 dma_addr_t ctl_req_dma;
106 struct urb *urb_ctl;
107 /*
108 * The 3 bitfields below are protected by ctl_submit_lock.
109 * They have to be separate since they are accessed from IRQ
110 * context.
111 */
112 unsigned irq_urb_pending:1; /* irq_urb is in flight */
113 unsigned ctl_urb_pending:1; /* ctl_urb is in flight */
114 unsigned buzzer_pending:1; /* need to issue buzz command */
115 spinlock_t ctl_submit_lock;
116
117 unsigned char buzzer_state; /* on/off */
118
119 /* flags */
120 unsigned open:1;
121 unsigned resetting:1;
122 unsigned shutdown:1;
123
124 /* This mutex protects writes to the above flags */
125 struct mutex pm_mutex;
126
127 unsigned short keymap[KEYMAP_SIZE];
128
129 char phys[64]; /* physical device path */
130 int key_code; /* last reported key */
131 int keybit; /* 0=new scan 1,2,4,8=scan columns */
132 u8 gpi; /* Cached value of GPI (high nibble) */
133};
134
135/******************************************************************************
136 * CM109 key interface
137 *****************************************************************************/
138
139static unsigned short special_keymap(int code)
140{
141 if (code > 0xff) {
142 switch (code - 0xff) {
143 case RECORD_MUTE: return KEY_MUTE;
144 case PLAYBACK_MUTE: return KEY_MUTE;
145 case VOLUME_DOWN: return KEY_VOLUMEDOWN;
146 case VOLUME_UP: return KEY_VOLUMEUP;
147 }
148 }
149 return KEY_RESERVED;
150}
151
152/* Map device buttons to internal key events.
153 *
154 * The "up" and "down" keys, are symbolised by arrows on the button.
155 * The "pickup" and "hangup" keys are symbolised by a green and red phone
156 * on the button.
157
158 Komunikate KIP1000 Keyboard Matrix
159
160 -> -- 1 -- 2 -- 3 --> GPI pin 4 (0x10)
161 | | | |
162 <- -- 4 -- 5 -- 6 --> GPI pin 5 (0x20)
163 | | | |
164 END - 7 -- 8 -- 9 --> GPI pin 6 (0x40)
165 | | | |
166 OK -- * -- 0 -- # --> GPI pin 7 (0x80)
167 | | | |
168
169 /|\ /|\ /|\ /|\
170 | | | |
171GPO
172pin: 3 2 1 0
173 0x8 0x4 0x2 0x1
174
175 */
176static unsigned short keymap_kip1000(int scancode)
177{
178 switch (scancode) { /* phone key: */
179 case 0x82: return KEY_NUMERIC_0; /* 0 */
180 case 0x14: return KEY_NUMERIC_1; /* 1 */
181 case 0x12: return KEY_NUMERIC_2; /* 2 */
182 case 0x11: return KEY_NUMERIC_3; /* 3 */
183 case 0x24: return KEY_NUMERIC_4; /* 4 */
184 case 0x22: return KEY_NUMERIC_5; /* 5 */
185 case 0x21: return KEY_NUMERIC_6; /* 6 */
186 case 0x44: return KEY_NUMERIC_7; /* 7 */
187 case 0x42: return KEY_NUMERIC_8; /* 8 */
188 case 0x41: return KEY_NUMERIC_9; /* 9 */
189 case 0x81: return KEY_NUMERIC_POUND; /* # */
190 case 0x84: return KEY_NUMERIC_STAR; /* * */
191 case 0x88: return KEY_ENTER; /* pickup */
192 case 0x48: return KEY_ESC; /* hangup */
193 case 0x28: return KEY_LEFT; /* IN */
194 case 0x18: return KEY_RIGHT; /* OUT */
195 default: return special_keymap(scancode);
196 }
197}
198
199/*
200 Contributed by Shaun Jackman <sjackman@gmail.com>
201
202 Genius G-Talk keyboard matrix
203 0 1 2 3
204 4: 0 4 8 Talk
205 5: 1 5 9 End
206 6: 2 6 # Up
207 7: 3 7 * Down
208*/
209static unsigned short keymap_gtalk(int scancode)
210{
211 switch (scancode) {
212 case 0x11: return KEY_NUMERIC_0;
213 case 0x21: return KEY_NUMERIC_1;
214 case 0x41: return KEY_NUMERIC_2;
215 case 0x81: return KEY_NUMERIC_3;
216 case 0x12: return KEY_NUMERIC_4;
217 case 0x22: return KEY_NUMERIC_5;
218 case 0x42: return KEY_NUMERIC_6;
219 case 0x82: return KEY_NUMERIC_7;
220 case 0x14: return KEY_NUMERIC_8;
221 case 0x24: return KEY_NUMERIC_9;
222 case 0x44: return KEY_NUMERIC_POUND; /* # */
223 case 0x84: return KEY_NUMERIC_STAR; /* * */
224 case 0x18: return KEY_ENTER; /* Talk (green handset) */
225 case 0x28: return KEY_ESC; /* End (red handset) */
226 case 0x48: return KEY_UP; /* Menu up (rocker switch) */
227 case 0x88: return KEY_DOWN; /* Menu down (rocker switch) */
228 default: return special_keymap(scancode);
229 }
230}
231
232/*
233 * Keymap for Allied-Telesis Corega USBPH01
234 * http://www.alliedtelesis-corega.com/2/1344/1437/1360/chprd.html
235 *
236 * Contributed by july@nat.bg
237 */
238static unsigned short keymap_usbph01(int scancode)
239{
240 switch (scancode) {
241 case 0x11: return KEY_NUMERIC_0; /* 0 */
242 case 0x21: return KEY_NUMERIC_1; /* 1 */
243 case 0x41: return KEY_NUMERIC_2; /* 2 */
244 case 0x81: return KEY_NUMERIC_3; /* 3 */
245 case 0x12: return KEY_NUMERIC_4; /* 4 */
246 case 0x22: return KEY_NUMERIC_5; /* 5 */
247 case 0x42: return KEY_NUMERIC_6; /* 6 */
248 case 0x82: return KEY_NUMERIC_7; /* 7 */
249 case 0x14: return KEY_NUMERIC_8; /* 8 */
250 case 0x24: return KEY_NUMERIC_9; /* 9 */
251 case 0x44: return KEY_NUMERIC_POUND; /* # */
252 case 0x84: return KEY_NUMERIC_STAR; /* * */
253 case 0x18: return KEY_ENTER; /* pickup */
254 case 0x28: return KEY_ESC; /* hangup */
255 case 0x48: return KEY_LEFT; /* IN */
256 case 0x88: return KEY_RIGHT; /* OUT */
257 default: return special_keymap(scancode);
258 }
259}
260
261static unsigned short (*keymap)(int) = keymap_kip1000;
262
263/*
264 * Completes a request by converting the data into events for the
265 * input subsystem.
266 */
267static void report_key(struct cm109_dev *dev, int key)
268{
269 struct input_dev *idev = dev->idev;
270
271 if (dev->key_code >= 0) {
272 /* old key up */
273 input_report_key(idev, dev->key_code, 0);
274 }
275
276 dev->key_code = key;
277 if (key >= 0) {
278 /* new valid key */
279 input_report_key(idev, key, 1);
280 }
281
282 input_sync(idev);
283}
284
285/******************************************************************************
286 * CM109 usb communication interface
287 *****************************************************************************/
288
289static void cm109_submit_buzz_toggle(struct cm109_dev *dev)
290{
291 int error;
292
293 if (dev->buzzer_state)
294 dev->ctl_data->byte[HID_OR0] |= BUZZER_ON;
295 else
296 dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON;
297
298 error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC);
299 if (error)
300 err("%s: usb_submit_urb (urb_ctl) failed %d", __func__, error);
301}
302
303/*
304 * IRQ handler
305 */
306static void cm109_urb_irq_callback(struct urb *urb)
307{
308 struct cm109_dev *dev = urb->context;
309 const int status = urb->status;
310 int error;
311
312 dev_dbg(&urb->dev->dev, "### URB IRQ: [0x%02x 0x%02x 0x%02x 0x%02x] keybit=0x%02x\n",
313 dev->irq_data->byte[0],
314 dev->irq_data->byte[1],
315 dev->irq_data->byte[2],
316 dev->irq_data->byte[3],
317 dev->keybit);
318
319 if (status) {
320 if (status == -ESHUTDOWN)
321 return;
322 err("%s: urb status %d", __func__, status);
323 }
324
325 /* Special keys */
326 if (dev->irq_data->byte[HID_IR0] & 0x0f) {
327 const int code = (dev->irq_data->byte[HID_IR0] & 0x0f);
328 report_key(dev, dev->keymap[0xff + code]);
329 }
330
331 /* Scan key column */
332 if (dev->keybit == 0xf) {
333
334 /* Any changes ? */
335 if ((dev->gpi & 0xf0) == (dev->irq_data->byte[HID_IR1] & 0xf0))
336 goto out;
337
338 dev->gpi = dev->irq_data->byte[HID_IR1] & 0xf0;
339 dev->keybit = 0x1;
340 } else {
341 report_key(dev, dev->keymap[dev->irq_data->byte[HID_IR1]]);
342
343 dev->keybit <<= 1;
344 if (dev->keybit > 0x8)
345 dev->keybit = 0xf;
346 }
347
348 out:
349
350 spin_lock(&dev->ctl_submit_lock);
351
352 dev->irq_urb_pending = 0;
353
354 if (likely(!dev->shutdown)) {
355
356 if (dev->buzzer_state)
357 dev->ctl_data->byte[HID_OR0] |= BUZZER_ON;
358 else
359 dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON;
360
361 dev->ctl_data->byte[HID_OR1] = dev->keybit;
362 dev->ctl_data->byte[HID_OR2] = dev->keybit;
363
364 dev->buzzer_pending = 0;
365 dev->ctl_urb_pending = 1;
366
367 error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC);
368 if (error)
369 err("%s: usb_submit_urb (urb_ctl) failed %d",
370 __func__, error);
371 }
372
373 spin_unlock(&dev->ctl_submit_lock);
374}
375
376static void cm109_urb_ctl_callback(struct urb *urb)
377{
378 struct cm109_dev *dev = urb->context;
379 const int status = urb->status;
380 int error;
381
382 dev_dbg(&urb->dev->dev, "### URB CTL: [0x%02x 0x%02x 0x%02x 0x%02x]\n",
383 dev->ctl_data->byte[0],
384 dev->ctl_data->byte[1],
385 dev->ctl_data->byte[2],
386 dev->ctl_data->byte[3]);
387
388 if (status)
389 err("%s: urb status %d", __func__, status);
390
391 spin_lock(&dev->ctl_submit_lock);
392
393 dev->ctl_urb_pending = 0;
394
395 if (likely(!dev->shutdown)) {
396
397 if (dev->buzzer_pending) {
398 dev->buzzer_pending = 0;
399 dev->ctl_urb_pending = 1;
400 cm109_submit_buzz_toggle(dev);
401 } else if (likely(!dev->irq_urb_pending)) {
402 /* ask for key data */
403 dev->irq_urb_pending = 1;
404 error = usb_submit_urb(dev->urb_irq, GFP_ATOMIC);
405 if (error)
406 err("%s: usb_submit_urb (urb_irq) failed %d",
407 __func__, error);
408 }
409 }
410
411 spin_unlock(&dev->ctl_submit_lock);
412}
413
414static void cm109_toggle_buzzer_async(struct cm109_dev *dev)
415{
416 unsigned long flags;
417
418 spin_lock_irqsave(&dev->ctl_submit_lock, flags);
419
420 if (dev->ctl_urb_pending) {
421 /* URB completion will resubmit */
422 dev->buzzer_pending = 1;
423 } else {
424 dev->ctl_urb_pending = 1;
425 cm109_submit_buzz_toggle(dev);
426 }
427
428 spin_unlock_irqrestore(&dev->ctl_submit_lock, flags);
429}
430
431static void cm109_toggle_buzzer_sync(struct cm109_dev *dev, int on)
432{
433 int error;
434
435 if (on)
436 dev->ctl_data->byte[HID_OR0] |= BUZZER_ON;
437 else
438 dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON;
439
440 error = usb_control_msg(dev->udev,
441 usb_sndctrlpipe(dev->udev, 0),
442 dev->ctl_req->bRequest,
443 dev->ctl_req->bRequestType,
444 le16_to_cpu(dev->ctl_req->wValue),
445 le16_to_cpu(dev->ctl_req->wIndex),
446 dev->ctl_data,
447 USB_PKT_LEN, USB_CTRL_SET_TIMEOUT);
448 if (error && error != EINTR)
449 err("%s: usb_control_msg() failed %d", __func__, error);
450}
451
452static void cm109_stop_traffic(struct cm109_dev *dev)
453{
454 dev->shutdown = 1;
455 /*
456 * Make sure other CPUs see this
457 */
458 smp_wmb();
459
460 usb_kill_urb(dev->urb_ctl);
461 usb_kill_urb(dev->urb_irq);
462
463 cm109_toggle_buzzer_sync(dev, 0);
464
465 dev->shutdown = 0;
466 smp_wmb();
467}
468
469static void cm109_restore_state(struct cm109_dev *dev)
470{
471 if (dev->open) {
472 /*
473 * Restore buzzer state.
474 * This will also kick regular URB submission
475 */
476 cm109_toggle_buzzer_async(dev);
477 }
478}
479
480/******************************************************************************
481 * input event interface
482 *****************************************************************************/
483
484static int cm109_input_open(struct input_dev *idev)
485{
486 struct cm109_dev *dev = input_get_drvdata(idev);
487 int error;
488
489 error = usb_autopm_get_interface(dev->intf);
490 if (error < 0) {
491 err("%s - cannot autoresume, result %d",
492 __func__, error);
493 return error;
494 }
495
496 mutex_lock(&dev->pm_mutex);
497
498 dev->buzzer_state = 0;
499 dev->key_code = -1; /* no keys pressed */
500 dev->keybit = 0xf;
501
502 /* issue INIT */
503 dev->ctl_data->byte[HID_OR0] = HID_OR_GPO_BUZ_SPDIF;
504 dev->ctl_data->byte[HID_OR1] = dev->keybit;
505 dev->ctl_data->byte[HID_OR2] = dev->keybit;
506 dev->ctl_data->byte[HID_OR3] = 0x00;
507
508 error = usb_submit_urb(dev->urb_ctl, GFP_KERNEL);
509 if (error)
510 err("%s: usb_submit_urb (urb_ctl) failed %d", __func__, error);
511 else
512 dev->open = 1;
513
514 mutex_unlock(&dev->pm_mutex);
515
516 if (error)
517 usb_autopm_put_interface(dev->intf);
518
519 return error;
520}
521
522static void cm109_input_close(struct input_dev *idev)
523{
524 struct cm109_dev *dev = input_get_drvdata(idev);
525
526 mutex_lock(&dev->pm_mutex);
527
528 /*
529 * Once we are here event delivery is stopped so we
530 * don't need to worry about someone starting buzzer
531 * again
532 */
533 cm109_stop_traffic(dev);
534 dev->open = 0;
535
536 mutex_unlock(&dev->pm_mutex);
537
538 usb_autopm_put_interface(dev->intf);
539}
540
541static int cm109_input_ev(struct input_dev *idev, unsigned int type,
542 unsigned int code, int value)
543{
544 struct cm109_dev *dev = input_get_drvdata(idev);
545
546 dev_dbg(&dev->udev->dev,
547 "input_ev: type=%u code=%u value=%d\n", type, code, value);
548
549 if (type != EV_SND)
550 return -EINVAL;
551
552 switch (code) {
553 case SND_TONE:
554 case SND_BELL:
555 dev->buzzer_state = !!value;
556 if (!dev->resetting)
557 cm109_toggle_buzzer_async(dev);
558 return 0;
559
560 default:
561 return -EINVAL;
562 }
563}
564
565
566/******************************************************************************
567 * Linux interface and usb initialisation
568 *****************************************************************************/
569
570struct driver_info {
571 char *name;
572};
573
574static const struct driver_info info_cm109 = {
575 .name = "CM109 USB driver",
576};
577
578enum {
579 VENDOR_ID = 0x0d8c, /* C-Media Electronics */
580 PRODUCT_ID_CM109 = 0x000e, /* CM109 defines range 0x0008 - 0x000f */
581};
582
583/* table of devices that work with this driver */
584static const struct usb_device_id cm109_usb_table[] = {
585 {
586 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
587 USB_DEVICE_ID_MATCH_INT_INFO,
588 .idVendor = VENDOR_ID,
589 .idProduct = PRODUCT_ID_CM109,
590 .bInterfaceClass = USB_CLASS_HID,
591 .bInterfaceSubClass = 0,
592 .bInterfaceProtocol = 0,
593 .driver_info = (kernel_ulong_t) &info_cm109
594 },
595 /* you can add more devices here with product ID 0x0008 - 0x000f */
596 { }
597};
598
599static void cm109_usb_cleanup(struct cm109_dev *dev)
600{
601 if (dev->ctl_req)
602 usb_buffer_free(dev->udev, sizeof(*(dev->ctl_req)),
603 dev->ctl_req, dev->ctl_req_dma);
604 if (dev->ctl_data)
605 usb_buffer_free(dev->udev, USB_PKT_LEN,
606 dev->ctl_data, dev->ctl_dma);
607 if (dev->irq_data)
608 usb_buffer_free(dev->udev, USB_PKT_LEN,
609 dev->irq_data, dev->irq_dma);
610
611 usb_free_urb(dev->urb_irq); /* parameter validation in core/urb */
612 usb_free_urb(dev->urb_ctl); /* parameter validation in core/urb */
613 kfree(dev);
614}
615
616static void cm109_usb_disconnect(struct usb_interface *interface)
617{
618 struct cm109_dev *dev = usb_get_intfdata(interface);
619
620 usb_set_intfdata(interface, NULL);
621 input_unregister_device(dev->idev);
622 cm109_usb_cleanup(dev);
623}
624
625static int cm109_usb_probe(struct usb_interface *intf,
626 const struct usb_device_id *id)
627{
628 struct usb_device *udev = interface_to_usbdev(intf);
629 struct driver_info *nfo = (struct driver_info *)id->driver_info;
630 struct usb_host_interface *interface;
631 struct usb_endpoint_descriptor *endpoint;
632 struct cm109_dev *dev;
633 struct input_dev *input_dev = NULL;
634 int ret, pipe, i;
635 int error = -ENOMEM;
636
637 interface = intf->cur_altsetting;
638 endpoint = &interface->endpoint[0].desc;
639
640 if (!usb_endpoint_is_int_in(endpoint))
641 return -ENODEV;
642
643 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
644 if (!dev)
645 return -ENOMEM;
646
647 spin_lock_init(&dev->ctl_submit_lock);
648 mutex_init(&dev->pm_mutex);
649
650 dev->udev = udev;
651 dev->intf = intf;
652
653 dev->idev = input_dev = input_allocate_device();
654 if (!input_dev)
655 goto err_out;
656
657 /* allocate usb buffers */
658 dev->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
659 GFP_KERNEL, &dev->irq_dma);
660 if (!dev->irq_data)
661 goto err_out;
662
663 dev->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN,
664 GFP_KERNEL, &dev->ctl_dma);
665 if (!dev->ctl_data)
666 goto err_out;
667
668 dev->ctl_req = usb_buffer_alloc(udev, sizeof(*(dev->ctl_req)),
669 GFP_KERNEL, &dev->ctl_req_dma);
670 if (!dev->ctl_req)
671 goto err_out;
672
673 /* allocate urb structures */
674 dev->urb_irq = usb_alloc_urb(0, GFP_KERNEL);
675 if (!dev->urb_irq)
676 goto err_out;
677
678 dev->urb_ctl = usb_alloc_urb(0, GFP_KERNEL);
679 if (!dev->urb_ctl)
680 goto err_out;
681
682 /* get a handle to the interrupt data pipe */
683 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
684 ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
685 if (ret != USB_PKT_LEN)
686 err("invalid payload size %d, expected %d", ret, USB_PKT_LEN);
687
688 /* initialise irq urb */
689 usb_fill_int_urb(dev->urb_irq, udev, pipe, dev->irq_data,
690 USB_PKT_LEN,
691 cm109_urb_irq_callback, dev, endpoint->bInterval);
692 dev->urb_irq->transfer_dma = dev->irq_dma;
693 dev->urb_irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
694 dev->urb_irq->dev = udev;
695
696 /* initialise ctl urb */
697 dev->ctl_req->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE |
698 USB_DIR_OUT;
699 dev->ctl_req->bRequest = USB_REQ_SET_CONFIGURATION;
700 dev->ctl_req->wValue = cpu_to_le16(0x200);
701 dev->ctl_req->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber);
702 dev->ctl_req->wLength = cpu_to_le16(USB_PKT_LEN);
703
704 usb_fill_control_urb(dev->urb_ctl, udev, usb_sndctrlpipe(udev, 0),
705 (void *)dev->ctl_req, dev->ctl_data, USB_PKT_LEN,
706 cm109_urb_ctl_callback, dev);
707 dev->urb_ctl->setup_dma = dev->ctl_req_dma;
708 dev->urb_ctl->transfer_dma = dev->ctl_dma;
709 dev->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP |
710 URB_NO_TRANSFER_DMA_MAP;
711 dev->urb_ctl->dev = udev;
712
713 /* find out the physical bus location */
714 usb_make_path(udev, dev->phys, sizeof(dev->phys));
715 strlcat(dev->phys, "/input0", sizeof(dev->phys));
716
717 /* register settings for the input device */
718 input_dev->name = nfo->name;
719 input_dev->phys = dev->phys;
720 usb_to_input_id(udev, &input_dev->id);
721 input_dev->dev.parent = &intf->dev;
722
723 input_set_drvdata(input_dev, dev);
724 input_dev->open = cm109_input_open;
725 input_dev->close = cm109_input_close;
726 input_dev->event = cm109_input_ev;
727
728 input_dev->keycode = dev->keymap;
729 input_dev->keycodesize = sizeof(unsigned char);
730 input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
731
732 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
733 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
734
735 /* register available key events */
736 for (i = 0; i < KEYMAP_SIZE; i++) {
737 unsigned short k = keymap(i);
738 dev->keymap[i] = k;
739 __set_bit(k, input_dev->keybit);
740 }
741 __clear_bit(KEY_RESERVED, input_dev->keybit);
742
743 error = input_register_device(dev->idev);
744 if (error)
745 goto err_out;
746
747 usb_set_intfdata(intf, dev);
748
749 return 0;
750
751 err_out:
752 input_free_device(input_dev);
753 cm109_usb_cleanup(dev);
754 return error;
755}
756
757static int cm109_usb_suspend(struct usb_interface *intf, pm_message_t message)
758{
759 struct cm109_dev *dev = usb_get_intfdata(intf);
760
761 dev_info(&intf->dev, "cm109: usb_suspend (event=%d)\n", message.event);
762
763 mutex_lock(&dev->pm_mutex);
764 cm109_stop_traffic(dev);
765 mutex_unlock(&dev->pm_mutex);
766
767 return 0;
768}
769
770static int cm109_usb_resume(struct usb_interface *intf)
771{
772 struct cm109_dev *dev = usb_get_intfdata(intf);
773
774 dev_info(&intf->dev, "cm109: usb_resume\n");
775
776 mutex_lock(&dev->pm_mutex);
777 cm109_restore_state(dev);
778 mutex_unlock(&dev->pm_mutex);
779
780 return 0;
781}
782
783static int cm109_usb_pre_reset(struct usb_interface *intf)
784{
785 struct cm109_dev *dev = usb_get_intfdata(intf);
786
787 mutex_lock(&dev->pm_mutex);
788
789 /*
790 * Make sure input events don't try to toggle buzzer
791 * while we are resetting
792 */
793 dev->resetting = 1;
794 smp_wmb();
795
796 cm109_stop_traffic(dev);
797
798 return 0;
799}
800
801static int cm109_usb_post_reset(struct usb_interface *intf)
802{
803 struct cm109_dev *dev = usb_get_intfdata(intf);
804
805 dev->resetting = 0;
806 smp_wmb();
807
808 cm109_restore_state(dev);
809
810 mutex_unlock(&dev->pm_mutex);
811
812 return 0;
813}
814
815static struct usb_driver cm109_driver = {
816 .name = "cm109",
817 .probe = cm109_usb_probe,
818 .disconnect = cm109_usb_disconnect,
819 .suspend = cm109_usb_suspend,
820 .resume = cm109_usb_resume,
821 .reset_resume = cm109_usb_resume,
822 .pre_reset = cm109_usb_pre_reset,
823 .post_reset = cm109_usb_post_reset,
824 .id_table = cm109_usb_table,
825 .supports_autosuspend = 1,
826};
827
828static int __init cm109_select_keymap(void)
829{
830 /* Load the phone keymap */
831 if (!strcasecmp(phone, "kip1000")) {
832 keymap = keymap_kip1000;
833 printk(KERN_INFO KBUILD_MODNAME ": "
834 "Keymap for Komunikate KIP1000 phone loaded\n");
835 } else if (!strcasecmp(phone, "gtalk")) {
836 keymap = keymap_gtalk;
837 printk(KERN_INFO KBUILD_MODNAME ": "
838 "Keymap for Genius G-talk phone loaded\n");
839 } else if (!strcasecmp(phone, "usbph01")) {
840 keymap = keymap_usbph01;
841 printk(KERN_INFO KBUILD_MODNAME ": "
842 "Keymap for Allied-Telesis Corega USBPH01 phone loaded\n");
843 } else {
844 printk(KERN_ERR KBUILD_MODNAME ": "
845 "Unsupported phone: %s\n", phone);
846 return -EINVAL;
847 }
848
849 return 0;
850}
851
852static int __init cm109_init(void)
853{
854 int err;
855
856 err = cm109_select_keymap();
857 if (err)
858 return err;
859
860 err = usb_register(&cm109_driver);
861 if (err)
862 return err;
863
864 printk(KERN_INFO KBUILD_MODNAME ": "
865 DRIVER_DESC ": " DRIVER_VERSION " (C) " DRIVER_AUTHOR "\n");
866
867 return 0;
868}
869
870static void __exit cm109_exit(void)
871{
872 usb_deregister(&cm109_driver);
873}
874
875module_init(cm109_init);
876module_exit(cm109_exit);
877
878MODULE_DEVICE_TABLE(usb, cm109_usb_table);
879
880MODULE_AUTHOR(DRIVER_AUTHOR);
881MODULE_DESCRIPTION(DRIVER_DESC);
882MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index fe268be3293b..7c8957dd22c0 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -277,6 +277,16 @@ static struct key_entry keymap_fs_amilo_pro_v2000[] __initdata = {
277 { KE_END, 0 } 277 { KE_END, 0 }
278}; 278};
279 279
280static struct key_entry keymap_fs_amilo_pro_v3505[] __initdata = {
281 { KE_KEY, 0x01, {KEY_HELP} }, /* Fn+F1 */
282 { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Fn+F4 */
283 { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */
284 { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */
285 { KE_KEY, 0x36, {KEY_WWW} }, /* www button */
286 { KE_WIFI, 0x78 }, /* satelite dish button */
287 { KE_END, 0 }
288};
289
280static struct key_entry keymap_fujitsu_n3510[] __initdata = { 290static struct key_entry keymap_fujitsu_n3510[] __initdata = {
281 { KE_KEY, 0x11, {KEY_PROG1} }, 291 { KE_KEY, 0x11, {KEY_PROG1} },
282 { KE_KEY, 0x12, {KEY_PROG2} }, 292 { KE_KEY, 0x12, {KEY_PROG2} },
@@ -618,6 +628,15 @@ static struct dmi_system_id dmi_ids[] __initdata = {
618 }, 628 },
619 { 629 {
620 .callback = dmi_matched, 630 .callback = dmi_matched,
631 .ident = "Fujitsu-Siemens Amilo Pro Edition V3505",
632 .matches = {
633 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
634 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro Edition V3505"),
635 },
636 .driver_data = keymap_fs_amilo_pro_v3505
637 },
638 {
639 .callback = dmi_matched,
621 .ident = "Fujitsu-Siemens Amilo M7400", 640 .ident = "Fujitsu-Siemens Amilo M7400",
622 .matches = { 641 .matches = {
623 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 642 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
index facefd3dba29..11b5c7e84ed1 100644
--- a/drivers/input/misc/yealink.c
+++ b/drivers/input/misc/yealink.c
@@ -52,8 +52,8 @@
52#include <linux/module.h> 52#include <linux/module.h>
53#include <linux/rwsem.h> 53#include <linux/rwsem.h>
54#include <linux/usb/input.h> 54#include <linux/usb/input.h>
55#include <linux/map_to_7segment.h>
55 56
56#include "map_to_7segment.h"
57#include "yealink.h" 57#include "yealink.h"
58 58
59#define DRIVER_VERSION "yld-20051230" 59#define DRIVER_VERSION "yld-20051230"
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index f996546fc443..f488b6852baf 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -96,6 +96,16 @@ config MOUSE_PS2_TOUCHKIT
96 96
97 If unsure, say N. 97 If unsure, say N.
98 98
99config MOUSE_PS2_OLPC
100 bool "OLPC PS/2 mouse protocol extension"
101 depends on MOUSE_PS2 && OLPC
102 help
103 Say Y here if you have an OLPC XO-1 laptop (with built-in
104 PS/2 touchpad/tablet device). The manufacturer calls the
105 touchpad an HGPK.
106
107 If unsure, say N.
108
99config MOUSE_SERIAL 109config MOUSE_SERIAL
100 tristate "Serial mouse" 110 tristate "Serial mouse"
101 select SERIO 111 select SERIO
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index d4d202516090..8e6e69097801 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o
21psmouse-objs := psmouse-base.o synaptics.o 21psmouse-objs := psmouse-base.o synaptics.o
22 22
23psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o 23psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
24psmouse-$(CONFIG_MOUSE_PS2_OLPC) += hgpk.o
24psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o 25psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o
25psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o 26psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o
26psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o 27psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 385e32bcf6a6..cbedf957cc58 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -54,6 +54,7 @@ static const struct alps_model_info alps_model_data[] = {
54 { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 54 { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
55 { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 55 { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
56 { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ 56 { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
57 { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */
57 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */ 58 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */
58}; 59};
59 60
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index 1f41ae94f26b..079816e6b23b 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -136,12 +136,28 @@ MODULE_DEVICE_TABLE(usb, atp_table);
136#define ATP_GEYSER_MODE_REQUEST_INDEX 0 136#define ATP_GEYSER_MODE_REQUEST_INDEX 0
137#define ATP_GEYSER_MODE_VENDOR_VALUE 0x04 137#define ATP_GEYSER_MODE_VENDOR_VALUE 0x04
138 138
139/**
140 * enum atp_status_bits - status bit meanings
141 *
142 * These constants represent the meaning of the status bits.
143 * (only Geyser 3/4)
144 *
145 * @ATP_STATUS_BUTTON: The button was pressed
146 * @ATP_STATUS_BASE_UPDATE: Update of the base values (untouched pad)
147 * @ATP_STATUS_FROM_RESET: Reset previously performed
148 */
149enum atp_status_bits {
150 ATP_STATUS_BUTTON = BIT(0),
151 ATP_STATUS_BASE_UPDATE = BIT(2),
152 ATP_STATUS_FROM_RESET = BIT(4),
153};
154
139/* Structure to hold all of our device specific stuff */ 155/* Structure to hold all of our device specific stuff */
140struct atp { 156struct atp {
141 char phys[64]; 157 char phys[64];
142 struct usb_device *udev; /* usb device */ 158 struct usb_device *udev; /* usb device */
143 struct urb *urb; /* usb request block */ 159 struct urb *urb; /* usb request block */
144 signed char *data; /* transferred data */ 160 u8 *data; /* transferred data */
145 struct input_dev *input; /* input dev */ 161 struct input_dev *input; /* input dev */
146 enum atp_touchpad_type type; /* type of touchpad */ 162 enum atp_touchpad_type type; /* type of touchpad */
147 bool open; 163 bool open;
@@ -251,8 +267,6 @@ static void atp_reinit(struct work_struct *work)
251 int retval; 267 int retval;
252 268
253 dprintk("appletouch: putting appletouch to sleep (reinit)\n"); 269 dprintk("appletouch: putting appletouch to sleep (reinit)\n");
254 dev->idlecount = 0;
255
256 atp_geyser_init(udev); 270 atp_geyser_init(udev);
257 271
258 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); 272 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
@@ -327,11 +341,14 @@ static inline void atp_report_fingers(struct input_dev *input, int fingers)
327 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); 341 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2);
328} 342}
329 343
330static void atp_complete(struct urb *urb) 344/* Check URB status and for correct length of data package */
345
346#define ATP_URB_STATUS_SUCCESS 0
347#define ATP_URB_STATUS_ERROR 1
348#define ATP_URB_STATUS_ERROR_FATAL 2
349
350static int atp_status_check(struct urb *urb)
331{ 351{
332 int x, y, x_z, y_z, x_f, y_f;
333 int retval, i, j;
334 int key;
335 struct atp *dev = urb->context; 352 struct atp *dev = urb->context;
336 353
337 switch (urb->status) { 354 switch (urb->status) {
@@ -351,11 +368,12 @@ static void atp_complete(struct urb *urb)
351 /* This urb is terminated, clean up */ 368 /* This urb is terminated, clean up */
352 dbg("atp_complete: urb shutting down with status: %d", 369 dbg("atp_complete: urb shutting down with status: %d",
353 urb->status); 370 urb->status);
354 return; 371 return ATP_URB_STATUS_ERROR_FATAL;
372
355 default: 373 default:
356 dbg("atp_complete: nonzero urb status received: %d", 374 dbg("atp_complete: nonzero urb status received: %d",
357 urb->status); 375 urb->status);
358 goto exit; 376 return ATP_URB_STATUS_ERROR;
359 } 377 }
360 378
361 /* drop incomplete datasets */ 379 /* drop incomplete datasets */
@@ -363,30 +381,33 @@ static void atp_complete(struct urb *urb)
363 dprintk("appletouch: incomplete data package" 381 dprintk("appletouch: incomplete data package"
364 " (first byte: %d, length: %d).\n", 382 " (first byte: %d, length: %d).\n",
365 dev->data[0], dev->urb->actual_length); 383 dev->data[0], dev->urb->actual_length);
366 goto exit; 384 return ATP_URB_STATUS_ERROR;
367 } 385 }
368 386
369 /* reorder the sensors values */ 387 return ATP_URB_STATUS_SUCCESS;
370 if (dev->type == ATP_GEYSER3 || dev->type == ATP_GEYSER4) { 388}
371 memset(dev->xy_cur, 0, sizeof(dev->xy_cur));
372 389
373 /* 390/*
374 * The values are laid out like this: 391 * USB interrupt callback functions
375 * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ... 392 */
376 * '-' is an unused value.
377 */
378 393
379 /* read X values */ 394/* Interrupt function for older touchpads: FOUNTAIN/GEYSER1/GEYSER2 */
380 for (i = 0, j = 19; i < 20; i += 2, j += 3) { 395
381 dev->xy_cur[i] = dev->data[j + 1]; 396static void atp_complete_geyser_1_2(struct urb *urb)
382 dev->xy_cur[i + 1] = dev->data[j + 2]; 397{
383 } 398 int x, y, x_z, y_z, x_f, y_f;
384 /* read Y values */ 399 int retval, i, j;
385 for (i = 0, j = 1; i < 9; i += 2, j += 3) { 400 int key;
386 dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1]; 401 struct atp *dev = urb->context;
387 dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2]; 402 int status = atp_status_check(urb);
388 } 403
389 } else if (dev->type == ATP_GEYSER2) { 404 if (status == ATP_URB_STATUS_ERROR_FATAL)
405 return;
406 else if (status == ATP_URB_STATUS_ERROR)
407 goto exit;
408
409 /* reorder the sensors values */
410 if (dev->type == ATP_GEYSER2) {
390 memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); 411 memset(dev->xy_cur, 0, sizeof(dev->xy_cur));
391 412
392 /* 413 /*
@@ -427,34 +448,40 @@ static void atp_complete(struct urb *urb)
427 /* first sample */ 448 /* first sample */
428 dev->valid = true; 449 dev->valid = true;
429 dev->x_old = dev->y_old = -1; 450 dev->x_old = dev->y_old = -1;
451
452 /* Store first sample */
430 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); 453 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
431 454
432 if (dev->size_detect_done || 455 /* Perform size detection, if not done already */
433 dev->type == ATP_GEYSER3) /* No 17" Macbooks (yet) */ 456 if (!dev->size_detect_done) {
434 goto exit; 457
458 /* 17" Powerbooks have extra X sensors */
459 for (i = (dev->type == ATP_GEYSER2 ? 15 : 16);
460 i < ATP_XSENSORS; i++) {
461 if (!dev->xy_cur[i])
462 continue;
463
464 printk(KERN_INFO
465 "appletouch: 17\" model detected.\n");
466
467 if (dev->type == ATP_GEYSER2)
468 input_set_abs_params(dev->input, ABS_X,
469 0,
470 (20 - 1) *
471 ATP_XFACT - 1,
472 ATP_FUZZ, 0);
473 else
474 input_set_abs_params(dev->input, ABS_X,
475 0,
476 (26 - 1) *
477 ATP_XFACT - 1,
478 ATP_FUZZ, 0);
479 break;
480 }
435 481
436 /* 17" Powerbooks have extra X sensors */ 482 dev->size_detect_done = 1;
437 for (i = (dev->type == ATP_GEYSER2 ? 15 : 16); 483 goto exit;
438 i < ATP_XSENSORS; i++) {
439 if (!dev->xy_cur[i])
440 continue;
441
442 printk(KERN_INFO "appletouch: 17\" model detected.\n");
443 if (dev->type == ATP_GEYSER2)
444 input_set_abs_params(dev->input, ABS_X, 0,
445 (20 - 1) *
446 ATP_XFACT - 1,
447 ATP_FUZZ, 0);
448 else
449 input_set_abs_params(dev->input, ABS_X, 0,
450 (ATP_XSENSORS - 1) *
451 ATP_XFACT - 1,
452 ATP_FUZZ, 0);
453 break;
454 } 484 }
455
456 dev->size_detect_done = 1;
457 goto exit;
458 } 485 }
459 486
460 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { 487 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
@@ -475,7 +502,118 @@ static void atp_complete(struct urb *urb)
475 ATP_XFACT, &x_z, &x_f); 502 ATP_XFACT, &x_z, &x_f);
476 y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, 503 y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS,
477 ATP_YFACT, &y_z, &y_f); 504 ATP_YFACT, &y_z, &y_f);
478 key = dev->data[dev->datalen - 1] & 1; 505 key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON;
506
507 if (x && y) {
508 if (dev->x_old != -1) {
509 x = (dev->x_old * 3 + x) >> 2;
510 y = (dev->y_old * 3 + y) >> 2;
511 dev->x_old = x;
512 dev->y_old = y;
513
514 if (debug > 1)
515 printk(KERN_DEBUG "appletouch: "
516 "X: %3d Y: %3d Xz: %3d Yz: %3d\n",
517 x, y, x_z, y_z);
518
519 input_report_key(dev->input, BTN_TOUCH, 1);
520 input_report_abs(dev->input, ABS_X, x);
521 input_report_abs(dev->input, ABS_Y, y);
522 input_report_abs(dev->input, ABS_PRESSURE,
523 min(ATP_PRESSURE, x_z + y_z));
524 atp_report_fingers(dev->input, max(x_f, y_f));
525 }
526 dev->x_old = x;
527 dev->y_old = y;
528
529 } else if (!x && !y) {
530
531 dev->x_old = dev->y_old = -1;
532 input_report_key(dev->input, BTN_TOUCH, 0);
533 input_report_abs(dev->input, ABS_PRESSURE, 0);
534 atp_report_fingers(dev->input, 0);
535
536 /* reset the accumulator on release */
537 memset(dev->xy_acc, 0, sizeof(dev->xy_acc));
538 }
539
540 input_report_key(dev->input, BTN_LEFT, key);
541 input_sync(dev->input);
542
543 exit:
544 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
545 if (retval)
546 err("atp_complete: usb_submit_urb failed with result %d",
547 retval);
548}
549
550/* Interrupt function for older touchpads: GEYSER3/GEYSER4 */
551
552static void atp_complete_geyser_3_4(struct urb *urb)
553{
554 int x, y, x_z, y_z, x_f, y_f;
555 int retval, i, j;
556 int key;
557 struct atp *dev = urb->context;
558 int status = atp_status_check(urb);
559
560 if (status == ATP_URB_STATUS_ERROR_FATAL)
561 return;
562 else if (status == ATP_URB_STATUS_ERROR)
563 goto exit;
564
565 /* Reorder the sensors values:
566 *
567 * The values are laid out like this:
568 * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ...
569 * '-' is an unused value.
570 */
571
572 /* read X values */
573 for (i = 0, j = 19; i < 20; i += 2, j += 3) {
574 dev->xy_cur[i] = dev->data[j + 1];
575 dev->xy_cur[i + 1] = dev->data[j + 2];
576 }
577 /* read Y values */
578 for (i = 0, j = 1; i < 9; i += 2, j += 3) {
579 dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1];
580 dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2];
581 }
582
583 dbg_dump("sample", dev->xy_cur);
584
585 /* Just update the base values (i.e. touchpad in untouched state) */
586 if (dev->data[dev->datalen - 1] & ATP_STATUS_BASE_UPDATE) {
587
588 dprintk(KERN_DEBUG "appletouch: updated base values\n");
589
590 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
591 goto exit;
592 }
593
594 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
595 /* calculate the change */
596 dev->xy_acc[i] = dev->xy_cur[i] - dev->xy_old[i];
597
598 /* this is a round-robin value, so couple with that */
599 if (dev->xy_acc[i] > 127)
600 dev->xy_acc[i] -= 256;
601
602 if (dev->xy_acc[i] < -127)
603 dev->xy_acc[i] += 256;
604
605 /* prevent down drifting */
606 if (dev->xy_acc[i] < 0)
607 dev->xy_acc[i] = 0;
608 }
609
610 dbg_dump("accumulator", dev->xy_acc);
611
612 x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS,
613 ATP_XFACT, &x_z, &x_f);
614 y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS,
615 ATP_YFACT, &y_z, &y_f);
616 key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON;
479 617
480 if (x && y) { 618 if (x && y) {
481 if (dev->x_old != -1) { 619 if (dev->x_old != -1) {
@@ -514,28 +652,27 @@ static void atp_complete(struct urb *urb)
514 input_sync(dev->input); 652 input_sync(dev->input);
515 653
516 /* 654 /*
517 * Many Geysers will continue to send packets continually after 655 * Geysers 3/4 will continue to send packets continually after
518 * the first touch unless reinitialised. Do so if it's been 656 * the first touch unless reinitialised. Do so if it's been
519 * idle for a while in order to avoid waking the kernel up 657 * idle for a while in order to avoid waking the kernel up
520 * several hundred times a second. Re-initialization does not 658 * several hundred times a second.
521 * work on Fountain touchpads.
522 */ 659 */
523 if (dev->type != ATP_FOUNTAIN) { 660
524 /* 661 /*
525 * Button must not be pressed when entering suspend, 662 * Button must not be pressed when entering suspend,
526 * otherwise we will never release the button. 663 * otherwise we will never release the button.
527 */ 664 */
528 if (!x && !y && !key) { 665 if (!x && !y && !key) {
529 dev->idlecount++; 666 dev->idlecount++;
530 if (dev->idlecount == 10) { 667 if (dev->idlecount == 10) {
531 dev->valid = false; 668 dev->x_old = dev->y_old = -1;
532 schedule_work(&dev->work);
533 /* Don't resubmit urb here, wait for reinit */
534 return;
535 }
536 } else
537 dev->idlecount = 0; 669 dev->idlecount = 0;
538 } 670 schedule_work(&dev->work);
671 /* Don't resubmit urb here, wait for reinit */
672 return;
673 }
674 } else
675 dev->idlecount = 0;
539 676
540 exit: 677 exit:
541 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); 678 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
@@ -632,9 +769,19 @@ static int atp_probe(struct usb_interface *iface,
632 if (!dev->data) 769 if (!dev->data)
633 goto err_free_urb; 770 goto err_free_urb;
634 771
635 usb_fill_int_urb(dev->urb, udev, 772 /* Select the USB complete (callback) function */
636 usb_rcvintpipe(udev, int_in_endpointAddr), 773 if (dev->type == ATP_FOUNTAIN ||
637 dev->data, dev->datalen, atp_complete, dev, 1); 774 dev->type == ATP_GEYSER1 ||
775 dev->type == ATP_GEYSER2)
776 usb_fill_int_urb(dev->urb, udev,
777 usb_rcvintpipe(udev, int_in_endpointAddr),
778 dev->data, dev->datalen,
779 atp_complete_geyser_1_2, dev, 1);
780 else
781 usb_fill_int_urb(dev->urb, udev,
782 usb_rcvintpipe(udev, int_in_endpointAddr),
783 dev->data, dev->datalen,
784 atp_complete_geyser_3_4, dev, 1);
638 785
639 error = atp_handle_geyser(dev); 786 error = atp_handle_geyser(dev);
640 if (error) 787 if (error)
@@ -751,8 +898,6 @@ static int atp_suspend(struct usb_interface *iface, pm_message_t message)
751 struct atp *dev = usb_get_intfdata(iface); 898 struct atp *dev = usb_get_intfdata(iface);
752 899
753 usb_kill_urb(dev->urb); 900 usb_kill_urb(dev->urb);
754 dev->valid = false;
755
756 return 0; 901 return 0;
757} 902}
758 903
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
new file mode 100644
index 000000000000..e82d34201e97
--- /dev/null
+++ b/drivers/input/mouse/hgpk.c
@@ -0,0 +1,477 @@
1/*
2 * OLPC HGPK (XO-1) touchpad PS/2 mouse driver
3 *
4 * Copyright (c) 2006-2008 One Laptop Per Child
5 * Authors:
6 * Zephaniah E. Hull
7 * Andres Salomon <dilinger@debian.org>
8 *
9 * This driver is partly based on the ALPS driver, which is:
10 *
11 * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au>
12 * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
13 * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru>
14 * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
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/*
22 * The spec from ALPS is available from
23 * <http://wiki.laptop.org/go/Touch_Pad/Tablet>. It refers to this
24 * device as HGPK (Hybrid GS, PT, and Keymatrix).
25 *
26 * The earliest versions of the device had simultaneous reporting; that
27 * was removed. After that, the device used the Advanced Mode GS/PT streaming
28 * stuff. That turned out to be too buggy to support, so we've finally
29 * switched to Mouse Mode (which utilizes only the center 1/3 of the touchpad).
30 */
31
32#define DEBUG
33#include <linux/input.h>
34#include <linux/serio.h>
35#include <linux/libps2.h>
36#include <linux/delay.h>
37#include <asm/olpc.h>
38
39#include "psmouse.h"
40#include "hgpk.h"
41
42static int tpdebug;
43module_param(tpdebug, int, 0644);
44MODULE_PARM_DESC(tpdebug, "enable debugging, dumping packets to KERN_DEBUG.");
45
46static int recalib_delta = 100;
47module_param(recalib_delta, int, 0644);
48MODULE_PARM_DESC(recalib_delta,
49 "packets containing a delta this large will cause a recalibration.");
50
51/*
52 * When the touchpad gets ultra-sensitive, one can keep their finger 1/2"
53 * above the pad and still have it send packets. This causes a jump cursor
54 * when one places their finger on the pad. We can probably detect the
55 * jump as we see a large deltas (>= 100px). In mouse mode, I've been
56 * unable to even come close to 100px deltas during normal usage, so I think
57 * this threshold is safe. If a large delta occurs, trigger a recalibration.
58 */
59static void hgpk_jumpy_hack(struct psmouse *psmouse, int x, int y)
60{
61 struct hgpk_data *priv = psmouse->private;
62
63 if (abs(x) > recalib_delta || abs(y) > recalib_delta) {
64 hgpk_err(psmouse, ">%dpx jump detected (%d,%d)\n",
65 recalib_delta, x, y);
66 /* My car gets forty rods to the hogshead and that's the
67 * way I likes it! */
68 psmouse_queue_work(psmouse, &priv->recalib_wq,
69 msecs_to_jiffies(1000));
70 }
71}
72
73/*
74 * We have no idea why this particular hardware bug occurs. The touchpad
75 * will randomly start spewing packets without anything touching the
76 * pad. This wouldn't necessarily be bad, but it's indicative of a
77 * severely miscalibrated pad; attempting to use the touchpad while it's
78 * spewing means the cursor will jump all over the place, and act "drunk".
79 *
80 * The packets that are spewed tend to all have deltas between -2 and 2, and
81 * the cursor will move around without really going very far. It will
82 * tend to end up in the same location; if we tally up the changes over
83 * 100 packets, we end up w/ a final delta of close to 0. This happens
84 * pretty regularly when the touchpad is spewing, and is pretty hard to
85 * manually trigger (at least for *my* fingers). So, it makes a perfect
86 * scheme for detecting spews.
87 */
88static void hgpk_spewing_hack(struct psmouse *psmouse,
89 int l, int r, int x, int y)
90{
91 struct hgpk_data *priv = psmouse->private;
92
93 /* ignore button press packets; many in a row could trigger
94 * a false-positive! */
95 if (l || r)
96 return;
97
98 priv->x_tally += x;
99 priv->y_tally += y;
100
101 if (++priv->count > 100) {
102 if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) {
103 hgpk_dbg(psmouse, "packet spew detected (%d,%d)\n",
104 priv->x_tally, priv->y_tally);
105 psmouse_queue_work(psmouse, &priv->recalib_wq,
106 msecs_to_jiffies(1000));
107 }
108 /* reset every 100 packets */
109 priv->count = 0;
110 priv->x_tally = 0;
111 priv->y_tally = 0;
112 }
113}
114
115/*
116 * HGPK Mouse Mode format (standard mouse format, sans middle button)
117 *
118 * byte 0: y-over x-over y-neg x-neg 1 0 swr swl
119 * byte 1: x7 x6 x5 x4 x3 x2 x1 x0
120 * byte 2: y7 y6 y5 y4 y3 y2 y1 y0
121 *
122 * swr/swl are the left/right buttons.
123 * x-neg/y-neg are the x and y delta negative bits
124 * x-over/y-over are the x and y overflow bits
125 */
126static int hgpk_validate_byte(unsigned char *packet)
127{
128 return (packet[0] & 0x0C) == 0x08;
129}
130
131static void hgpk_process_packet(struct psmouse *psmouse)
132{
133 struct input_dev *dev = psmouse->dev;
134 unsigned char *packet = psmouse->packet;
135 int x, y, left, right;
136
137 left = packet[0] & 1;
138 right = (packet[0] >> 1) & 1;
139
140 x = packet[1] - ((packet[0] << 4) & 0x100);
141 y = ((packet[0] << 3) & 0x100) - packet[2];
142
143 hgpk_jumpy_hack(psmouse, x, y);
144 hgpk_spewing_hack(psmouse, left, right, x, y);
145
146 if (tpdebug)
147 hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y);
148
149 input_report_key(dev, BTN_LEFT, left);
150 input_report_key(dev, BTN_RIGHT, right);
151
152 input_report_rel(dev, REL_X, x);
153 input_report_rel(dev, REL_Y, y);
154
155 input_sync(dev);
156}
157
158static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse)
159{
160 struct hgpk_data *priv = psmouse->private;
161
162 if (hgpk_validate_byte(psmouse->packet)) {
163 hgpk_dbg(psmouse, "%s: (%d) %02x %02x %02x\n",
164 __func__, psmouse->pktcnt, psmouse->packet[0],
165 psmouse->packet[1], psmouse->packet[2]);
166 return PSMOUSE_BAD_DATA;
167 }
168
169 if (psmouse->pktcnt >= psmouse->pktsize) {
170 hgpk_process_packet(psmouse);
171 return PSMOUSE_FULL_PACKET;
172 }
173
174 if (priv->recalib_window) {
175 if (time_before(jiffies, priv->recalib_window)) {
176 /*
177 * ugh, got a packet inside our recalibration
178 * window, schedule another recalibration.
179 */
180 hgpk_dbg(psmouse,
181 "packet inside calibration window, "
182 "queueing another recalibration\n");
183 psmouse_queue_work(psmouse, &priv->recalib_wq,
184 msecs_to_jiffies(1000));
185 }
186 priv->recalib_window = 0;
187 }
188
189 return PSMOUSE_GOOD_DATA;
190}
191
192static int hgpk_force_recalibrate(struct psmouse *psmouse)
193{
194 struct ps2dev *ps2dev = &psmouse->ps2dev;
195 struct hgpk_data *priv = psmouse->private;
196
197 /* C-series touchpads added the recalibrate command */
198 if (psmouse->model < HGPK_MODEL_C)
199 return 0;
200
201 /* we don't want to race with the irq handler, nor with resyncs */
202 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
203
204 /* start by resetting the device */
205 psmouse_reset(psmouse);
206
207 /* send the recalibrate request */
208 if (ps2_command(ps2dev, NULL, 0xf5) ||
209 ps2_command(ps2dev, NULL, 0xf5) ||
210 ps2_command(ps2dev, NULL, 0xe6) ||
211 ps2_command(ps2dev, NULL, 0xf5)) {
212 return -1;
213 }
214
215 /* according to ALPS, 150mS is required for recalibration */
216 msleep(150);
217
218 /* XXX: If a finger is down during this delay, recalibration will
219 * detect capacitance incorrectly. This is a hardware bug, and
220 * we don't have a good way to deal with it. The 2s window stuff
221 * (below) is our best option for now.
222 */
223
224 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE))
225 return -1;
226
227 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
228
229 /* After we recalibrate, we shouldn't get any packets for 2s. If
230 * we do, it's likely that someone's finger was on the touchpad.
231 * If someone's finger *was* on the touchpad, it's probably
232 * miscalibrated. So, we should schedule another recalibration
233 */
234 priv->recalib_window = jiffies + msecs_to_jiffies(2000);
235
236 return 0;
237}
238
239/*
240 * This kills power to the touchpad; according to ALPS, current consumption
241 * goes down to 50uA after running this. To turn power back on, we drive
242 * MS-DAT low.
243 */
244static int hgpk_toggle_power(struct psmouse *psmouse, int enable)
245{
246 struct ps2dev *ps2dev = &psmouse->ps2dev;
247 int timeo;
248
249 /* Added on D-series touchpads */
250 if (psmouse->model < HGPK_MODEL_D)
251 return 0;
252
253 if (enable) {
254 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
255
256 /*
257 * Sending a byte will drive MS-DAT low; this will wake up
258 * the controller. Once we get an ACK back from it, it
259 * means we can continue with the touchpad re-init. ALPS
260 * tells us that 1s should be long enough, so set that as
261 * the upper bound.
262 */
263 for (timeo = 20; timeo > 0; timeo--) {
264 if (!ps2_sendbyte(&psmouse->ps2dev,
265 PSMOUSE_CMD_DISABLE, 20))
266 break;
267 msleep(50);
268 }
269
270 psmouse_reset(psmouse);
271
272 /* should be all set, enable the touchpad */
273 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
274 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
275
276 } else {
277 hgpk_dbg(psmouse, "Powering off touchpad.\n");
278 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
279
280 if (ps2_command(ps2dev, NULL, 0xec) ||
281 ps2_command(ps2dev, NULL, 0xec) ||
282 ps2_command(ps2dev, NULL, 0xea)) {
283 return -1;
284 }
285
286 /* probably won't see an ACK, the touchpad will be off */
287 ps2_sendbyte(&psmouse->ps2dev, 0xec, 20);
288 }
289
290 return 0;
291}
292
293static int hgpk_poll(struct psmouse *psmouse)
294{
295 /* We can't poll, so always return failure. */
296 return -1;
297}
298
299static int hgpk_reconnect(struct psmouse *psmouse)
300{
301 /* During suspend/resume the ps2 rails remain powered. We don't want
302 * to do a reset because it's flush data out of buffers; however,
303 * earlier prototypes (B1) had some brokenness that required a reset. */
304 if (olpc_board_at_least(olpc_board(0xb2)))
305 if (psmouse->ps2dev.serio->dev.power.power_state.event !=
306 PM_EVENT_ON)
307 return 0;
308
309 psmouse_reset(psmouse);
310
311 return 0;
312}
313
314static ssize_t hgpk_show_powered(struct psmouse *psmouse, void *data, char *buf)
315{
316 struct hgpk_data *priv = psmouse->private;
317
318 return sprintf(buf, "%d\n", priv->powered);
319}
320
321static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data,
322 const char *buf, size_t count)
323{
324 struct hgpk_data *priv = psmouse->private;
325 unsigned long value;
326 int err;
327
328 err = strict_strtoul(buf, 10, &value);
329 if (err || value > 1)
330 return -EINVAL;
331
332 if (value != priv->powered) {
333 /*
334 * hgpk_toggle_power will deal w/ state so
335 * we're not racing w/ irq
336 */
337 err = hgpk_toggle_power(psmouse, value);
338 if (!err)
339 priv->powered = value;
340 }
341
342 return err ? err : count;
343}
344
345__PSMOUSE_DEFINE_ATTR(powered, S_IWUSR | S_IRUGO, NULL,
346 hgpk_show_powered, hgpk_set_powered, 0);
347
348static void hgpk_disconnect(struct psmouse *psmouse)
349{
350 struct hgpk_data *priv = psmouse->private;
351
352 device_remove_file(&psmouse->ps2dev.serio->dev,
353 &psmouse_attr_powered.dattr);
354 psmouse_reset(psmouse);
355 kfree(priv);
356}
357
358static void hgpk_recalib_work(struct work_struct *work)
359{
360 struct delayed_work *w = container_of(work, struct delayed_work, work);
361 struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);
362 struct psmouse *psmouse = priv->psmouse;
363
364 hgpk_dbg(psmouse, "recalibrating touchpad..\n");
365
366 if (hgpk_force_recalibrate(psmouse))
367 hgpk_err(psmouse, "recalibration failed!\n");
368}
369
370static int hgpk_register(struct psmouse *psmouse)
371{
372 struct input_dev *dev = psmouse->dev;
373 int err;
374
375 /* unset the things that psmouse-base sets which we don't have */
376 __clear_bit(BTN_MIDDLE, dev->keybit);
377
378 /* set the things we do have */
379 __set_bit(EV_KEY, dev->evbit);
380 __set_bit(EV_REL, dev->evbit);
381
382 __set_bit(REL_X, dev->relbit);
383 __set_bit(REL_Y, dev->relbit);
384
385 __set_bit(BTN_LEFT, dev->keybit);
386 __set_bit(BTN_RIGHT, dev->keybit);
387
388 /* register handlers */
389 psmouse->protocol_handler = hgpk_process_byte;
390 psmouse->poll = hgpk_poll;
391 psmouse->disconnect = hgpk_disconnect;
392 psmouse->reconnect = hgpk_reconnect;
393 psmouse->pktsize = 3;
394
395 /* Disable the idle resync. */
396 psmouse->resync_time = 0;
397 /* Reset after a lot of bad bytes. */
398 psmouse->resetafter = 1024;
399
400 err = device_create_file(&psmouse->ps2dev.serio->dev,
401 &psmouse_attr_powered.dattr);
402 if (err)
403 hgpk_err(psmouse, "Failed to create sysfs attribute\n");
404
405 return err;
406}
407
408int hgpk_init(struct psmouse *psmouse)
409{
410 struct hgpk_data *priv;
411 int err = -ENOMEM;
412
413 priv = kzalloc(sizeof(struct hgpk_data), GFP_KERNEL);
414 if (!priv)
415 goto alloc_fail;
416
417 psmouse->private = priv;
418 priv->psmouse = psmouse;
419 priv->powered = 1;
420 INIT_DELAYED_WORK(&priv->recalib_wq, hgpk_recalib_work);
421
422 err = psmouse_reset(psmouse);
423 if (err)
424 goto init_fail;
425
426 err = hgpk_register(psmouse);
427 if (err)
428 goto init_fail;
429
430 return 0;
431
432init_fail:
433 kfree(priv);
434alloc_fail:
435 return err;
436}
437
438static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)
439{
440 struct ps2dev *ps2dev = &psmouse->ps2dev;
441 unsigned char param[3];
442
443 /* E7, E7, E7, E9 gets us a 3 byte identifier */
444 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
445 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
446 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
447 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
448 return -EIO;
449 }
450
451 hgpk_dbg(psmouse, "ID: %02x %02x %02x", param[0], param[1], param[2]);
452
453 /* HGPK signature: 0x67, 0x00, 0x<model> */
454 if (param[0] != 0x67 || param[1] != 0x00)
455 return -ENODEV;
456
457 hgpk_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]);
458
459 return param[2];
460}
461
462int hgpk_detect(struct psmouse *psmouse, int set_properties)
463{
464 int version;
465
466 version = hgpk_get_model(psmouse);
467 if (version < 0)
468 return version;
469
470 if (set_properties) {
471 psmouse->vendor = "ALPS";
472 psmouse->name = "HGPK";
473 psmouse->model = version;
474 }
475
476 return 0;
477}
diff --git a/drivers/input/mouse/hgpk.h b/drivers/input/mouse/hgpk.h
new file mode 100644
index 000000000000..a4b2a96f5f54
--- /dev/null
+++ b/drivers/input/mouse/hgpk.h
@@ -0,0 +1,49 @@
1/*
2 * OLPC HGPK (XO-1) touchpad PS/2 mouse driver
3 */
4
5#ifndef _HGPK_H
6#define _HGPK_H
7
8enum hgpk_model_t {
9 HGPK_MODEL_PREA = 0x0a, /* pre-B1s */
10 HGPK_MODEL_A = 0x14, /* found on B1s, PT disabled in hardware */
11 HGPK_MODEL_B = 0x28, /* B2s, has capacitance issues */
12 HGPK_MODEL_C = 0x3c,
13 HGPK_MODEL_D = 0x50, /* C1, mass production */
14};
15
16struct hgpk_data {
17 struct psmouse *psmouse;
18 int powered;
19 int count, x_tally, y_tally; /* hardware workaround stuff */
20 unsigned long recalib_window;
21 struct delayed_work recalib_wq;
22};
23
24#define hgpk_dbg(psmouse, format, arg...) \
25 dev_dbg(&(psmouse)->ps2dev.serio->dev, format, ## arg)
26#define hgpk_err(psmouse, format, arg...) \
27 dev_err(&(psmouse)->ps2dev.serio->dev, format, ## arg)
28#define hgpk_info(psmouse, format, arg...) \
29 dev_info(&(psmouse)->ps2dev.serio->dev, format, ## arg)
30#define hgpk_warn(psmouse, format, arg...) \
31 dev_warn(&(psmouse)->ps2dev.serio->dev, format, ## arg)
32#define hgpk_notice(psmouse, format, arg...) \
33 dev_notice(&(psmouse)->ps2dev.serio->dev, format, ## arg)
34
35#ifdef CONFIG_MOUSE_PS2_OLPC
36int hgpk_detect(struct psmouse *psmouse, int set_properties);
37int hgpk_init(struct psmouse *psmouse);
38#else
39static inline int hgpk_detect(struct psmouse *psmouse, int set_properties)
40{
41 return -ENODEV;
42}
43static inline int hgpk_init(struct psmouse *psmouse)
44{
45 return -ENODEV;
46}
47#endif
48
49#endif
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 0c5660d28caa..390f1dbb98a4 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -157,10 +157,8 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data,
157static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) 157static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count)
158{ 158{
159 unsigned long value; 159 unsigned long value;
160 char *rest;
161 160
162 value = simple_strtoul(buf, &rest, 10); 161 if (strict_strtoul(buf, 10, &value) || value > 1)
163 if (*rest || value > 1)
164 return -EINVAL; 162 return -EINVAL;
165 163
166 ps2pp_set_smartscroll(psmouse, value); 164 ps2pp_set_smartscroll(psmouse, value);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index f5a6be1d3c46..126e977e199e 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -25,6 +25,7 @@
25#include "synaptics.h" 25#include "synaptics.h"
26#include "logips2pp.h" 26#include "logips2pp.h"
27#include "alps.h" 27#include "alps.h"
28#include "hgpk.h"
28#include "lifebook.h" 29#include "lifebook.h"
29#include "trackpoint.h" 30#include "trackpoint.h"
30#include "touchkit_ps2.h" 31#include "touchkit_ps2.h"
@@ -201,6 +202,12 @@ static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
201 return PSMOUSE_FULL_PACKET; 202 return PSMOUSE_FULL_PACKET;
202} 203}
203 204
205void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
206 unsigned long delay)
207{
208 queue_delayed_work(kpsmoused_wq, work, delay);
209}
210
204/* 211/*
205 * __psmouse_set_state() sets new psmouse state and resets all flags. 212 * __psmouse_set_state() sets new psmouse state and resets all flags.
206 */ 213 */
@@ -220,7 +227,7 @@ static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_sta
220 * is not a concern. 227 * is not a concern.
221 */ 228 */
222 229
223static void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 230void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
224{ 231{
225 serio_pause_rx(psmouse->ps2dev.serio); 232 serio_pause_rx(psmouse->ps2dev.serio);
226 __psmouse_set_state(psmouse, new_state); 233 __psmouse_set_state(psmouse, new_state);
@@ -305,7 +312,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
305 psmouse->name, psmouse->phys, psmouse->pktcnt); 312 psmouse->name, psmouse->phys, psmouse->pktcnt);
306 psmouse->badbyte = psmouse->packet[0]; 313 psmouse->badbyte = psmouse->packet[0];
307 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 314 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
308 queue_work(kpsmoused_wq, &psmouse->resync_work); 315 psmouse_queue_work(psmouse, &psmouse->resync_work, 0);
309 goto out; 316 goto out;
310 } 317 }
311 318
@@ -342,7 +349,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
342 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { 349 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) {
343 psmouse->badbyte = psmouse->packet[0]; 350 psmouse->badbyte = psmouse->packet[0];
344 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 351 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
345 queue_work(kpsmoused_wq, &psmouse->resync_work); 352 psmouse_queue_work(psmouse, &psmouse->resync_work, 0);
346 goto out; 353 goto out;
347 } 354 }
348 355
@@ -630,8 +637,20 @@ static int psmouse_extensions(struct psmouse *psmouse,
630 } 637 }
631 } 638 }
632 639
633 if (max_proto > PSMOUSE_IMEX) { 640/*
641 * Try OLPC HGPK touchpad.
642 */
643 if (max_proto > PSMOUSE_IMEX &&
644 hgpk_detect(psmouse, set_properties) == 0) {
645 if (!set_properties || hgpk_init(psmouse) == 0)
646 return PSMOUSE_HGPK;
647/*
648 * Init failed, try basic relative protocols
649 */
650 max_proto = PSMOUSE_IMEX;
651 }
634 652
653 if (max_proto > PSMOUSE_IMEX) {
635 if (genius_detect(psmouse, set_properties) == 0) 654 if (genius_detect(psmouse, set_properties) == 0)
636 return PSMOUSE_GENPS; 655 return PSMOUSE_GENPS;
637 656
@@ -762,6 +781,14 @@ static const struct psmouse_protocol psmouse_protocols[] = {
762 .detect = touchkit_ps2_detect, 781 .detect = touchkit_ps2_detect,
763 }, 782 },
764#endif 783#endif
784#ifdef CONFIG_MOUSE_PS2_OLPC
785 {
786 .type = PSMOUSE_HGPK,
787 .name = "OLPC HGPK",
788 .alias = "hgpk",
789 .detect = hgpk_detect,
790 },
791#endif
765 { 792 {
766 .type = PSMOUSE_CORTRON, 793 .type = PSMOUSE_CORTRON,
767 .name = "CortronPS/2", 794 .name = "CortronPS/2",
@@ -935,7 +962,7 @@ static int psmouse_poll(struct psmouse *psmouse)
935static void psmouse_resync(struct work_struct *work) 962static void psmouse_resync(struct work_struct *work)
936{ 963{
937 struct psmouse *parent = NULL, *psmouse = 964 struct psmouse *parent = NULL, *psmouse =
938 container_of(work, struct psmouse, resync_work); 965 container_of(work, struct psmouse, resync_work.work);
939 struct serio *serio = psmouse->ps2dev.serio; 966 struct serio *serio = psmouse->ps2dev.serio;
940 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 967 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
941 int failed = 0, enabled = 0; 968 int failed = 0, enabled = 0;
@@ -1194,7 +1221,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1194 goto err_free; 1221 goto err_free;
1195 1222
1196 ps2_init(&psmouse->ps2dev, serio); 1223 ps2_init(&psmouse->ps2dev, serio);
1197 INIT_WORK(&psmouse->resync_work, psmouse_resync); 1224 INIT_DELAYED_WORK(&psmouse->resync_work, psmouse_resync);
1198 psmouse->dev = input_dev; 1225 psmouse->dev = input_dev;
1199 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1226 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys);
1200 1227
@@ -1395,25 +1422,29 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1395 1422
1396 psmouse = serio_get_drvdata(serio); 1423 psmouse = serio_get_drvdata(serio);
1397 1424
1398 if (psmouse->state == PSMOUSE_IGNORE) { 1425 if (attr->protect) {
1399 retval = -ENODEV; 1426 if (psmouse->state == PSMOUSE_IGNORE) {
1400 goto out_unlock; 1427 retval = -ENODEV;
1401 } 1428 goto out_unlock;
1429 }
1402 1430
1403 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1431 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1404 parent = serio_get_drvdata(serio->parent); 1432 parent = serio_get_drvdata(serio->parent);
1405 psmouse_deactivate(parent); 1433 psmouse_deactivate(parent);
1406 } 1434 }
1407 1435
1408 psmouse_deactivate(psmouse); 1436 psmouse_deactivate(psmouse);
1437 }
1409 1438
1410 retval = attr->set(psmouse, attr->data, buf, count); 1439 retval = attr->set(psmouse, attr->data, buf, count);
1411 1440
1412 if (retval != -ENODEV) 1441 if (attr->protect) {
1413 psmouse_activate(psmouse); 1442 if (retval != -ENODEV)
1443 psmouse_activate(psmouse);
1414 1444
1415 if (parent) 1445 if (parent)
1416 psmouse_activate(parent); 1446 psmouse_activate(parent);
1447 }
1417 1448
1418 out_unlock: 1449 out_unlock:
1419 mutex_unlock(&psmouse_mutex); 1450 mutex_unlock(&psmouse_mutex);
@@ -1433,10 +1464,8 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const
1433{ 1464{
1434 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); 1465 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1435 unsigned long value; 1466 unsigned long value;
1436 char *rest;
1437 1467
1438 value = simple_strtoul(buf, &rest, 10); 1468 if (strict_strtoul(buf, 10, &value))
1439 if (*rest)
1440 return -EINVAL; 1469 return -EINVAL;
1441 1470
1442 if ((unsigned int)value != value) 1471 if ((unsigned int)value != value)
@@ -1549,10 +1578,8 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1549static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1578static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1550{ 1579{
1551 unsigned long value; 1580 unsigned long value;
1552 char *rest;
1553 1581
1554 value = simple_strtoul(buf, &rest, 10); 1582 if (strict_strtoul(buf, 10, &value))
1555 if (*rest)
1556 return -EINVAL; 1583 return -EINVAL;
1557 1584
1558 psmouse->set_rate(psmouse, value); 1585 psmouse->set_rate(psmouse, value);
@@ -1562,10 +1589,8 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const
1562static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1589static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1563{ 1590{
1564 unsigned long value; 1591 unsigned long value;
1565 char *rest;
1566 1592
1567 value = simple_strtoul(buf, &rest, 10); 1593 if (strict_strtoul(buf, 10, &value))
1568 if (*rest)
1569 return -EINVAL; 1594 return -EINVAL;
1570 1595
1571 psmouse->set_resolution(psmouse, value); 1596 psmouse->set_resolution(psmouse, value);
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 1317bdd8cc7c..8b608a1cdd12 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -39,7 +39,7 @@ struct psmouse {
39 void *private; 39 void *private;
40 struct input_dev *dev; 40 struct input_dev *dev;
41 struct ps2dev ps2dev; 41 struct ps2dev ps2dev;
42 struct work_struct resync_work; 42 struct delayed_work resync_work;
43 char *vendor; 43 char *vendor;
44 char *name; 44 char *name;
45 unsigned char packet[8]; 45 unsigned char packet[8];
@@ -89,20 +89,24 @@ enum psmouse_type {
89 PSMOUSE_TRACKPOINT, 89 PSMOUSE_TRACKPOINT,
90 PSMOUSE_TOUCHKIT_PS2, 90 PSMOUSE_TOUCHKIT_PS2,
91 PSMOUSE_CORTRON, 91 PSMOUSE_CORTRON,
92 PSMOUSE_HGPK,
92 PSMOUSE_AUTO /* This one should always be last */ 93 PSMOUSE_AUTO /* This one should always be last */
93}; 94};
94 95
96void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
97 unsigned long delay);
95int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); 98int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
96int psmouse_reset(struct psmouse *psmouse); 99int psmouse_reset(struct psmouse *psmouse);
100void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
97void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 101void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
98 102
99
100struct psmouse_attribute { 103struct psmouse_attribute {
101 struct device_attribute dattr; 104 struct device_attribute dattr;
102 void *data; 105 void *data;
103 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); 106 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
104 ssize_t (*set)(struct psmouse *psmouse, void *data, 107 ssize_t (*set)(struct psmouse *psmouse, void *data,
105 const char *buf, size_t count); 108 const char *buf, size_t count);
109 int protect;
106}; 110};
107#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) 111#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
108 112
@@ -111,7 +115,7 @@ ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *at
111ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, 115ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
112 const char *buf, size_t count); 116 const char *buf, size_t count);
113 117
114#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ 118#define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \
115static ssize_t _show(struct psmouse *, void *data, char *); \ 119static ssize_t _show(struct psmouse *, void *data, char *); \
116static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ 120static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \
117static struct psmouse_attribute psmouse_attr_##_name = { \ 121static struct psmouse_attribute psmouse_attr_##_name = { \
@@ -126,6 +130,10 @@ static struct psmouse_attribute psmouse_attr_##_name = { \
126 .data = _data, \ 130 .data = _data, \
127 .show = _show, \ 131 .show = _show, \
128 .set = _set, \ 132 .set = _set, \
133 .protect = _protect, \
129} 134}
130 135
136#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
137 __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, 1)
138
131#endif /* _PSMOUSE_H */ 139#endif /* _PSMOUSE_H */
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 26b845fc186a..e68c814c4361 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -89,10 +89,8 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
89 struct trackpoint_attr_data *attr = data; 89 struct trackpoint_attr_data *attr = data;
90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
91 unsigned long value; 91 unsigned long value;
92 char *rest;
93 92
94 value = simple_strtoul(buf, &rest, 10); 93 if (strict_strtoul(buf, 10, &value) || value > 255)
95 if (*rest || value > 255)
96 return -EINVAL; 94 return -EINVAL;
97 95
98 *field = value; 96 *field = value;
@@ -117,10 +115,8 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
117 struct trackpoint_attr_data *attr = data; 115 struct trackpoint_attr_data *attr = data;
118 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 116 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
119 unsigned long value; 117 unsigned long value;
120 char *rest;
121 118
122 value = simple_strtoul(buf, &rest, 10); 119 if (strict_strtoul(buf, 10, &value) || value > 1)
123 if (*rest || value > 1)
124 return -EINVAL; 120 return -EINVAL;
125 121
126 if (attr->inverted) 122 if (attr->inverted)
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 5aafe24984c5..a321aea2c7b5 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -322,6 +322,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
322 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"), 322 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
323 }, 323 },
324 }, 324 },
325 {
326 .ident = "IBM 2656",
327 .matches = {
328 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
329 DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
330 },
331 },
325 { } 332 { }
326}; 333};
327 334
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index c9397c8ee97e..470770c09260 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -373,6 +373,12 @@ static struct serio_device_id serio_raw_serio_ids[] = {
373 .id = SERIO_ANY, 373 .id = SERIO_ANY,
374 .extra = SERIO_ANY, 374 .extra = SERIO_ANY,
375 }, 375 },
376 {
377 .type = SERIO_8042_XL,
378 .proto = SERIO_ANY,
379 .id = SERIO_ANY,
380 .extra = SERIO_ANY,
381 },
376 { 0 } 382 { 0 }
377}; 383};
378 384
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 8f037a1d44a6..e53c838f1866 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1202,16 +1202,22 @@ static ssize_t
1202store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1202store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1203{ 1203{
1204 struct aiptek *aiptek = dev_get_drvdata(dev); 1204 struct aiptek *aiptek = dev_get_drvdata(dev);
1205 int x; 1205 long x;
1206
1207 if (strict_strtol(buf, 10, &x)) {
1208 size_t len = buf[count - 1] == '\n' ? count - 1 : count;
1209
1210 if (strncmp(buf, "disable", len))
1211 return -EINVAL;
1206 1212
1207 if (strcmp(buf, "disable") == 0) {
1208 aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; 1213 aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE;
1209 } else { 1214 } else {
1210 x = (int)simple_strtol(buf, NULL, 10); 1215 if (x < AIPTEK_TILT_MIN || x > AIPTEK_TILT_MAX)
1211 if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX) { 1216 return -EINVAL;
1212 aiptek->newSetting.xTilt = x; 1217
1213 } 1218 aiptek->newSetting.xTilt = x;
1214 } 1219 }
1220
1215 return count; 1221 return count;
1216} 1222}
1217 1223
@@ -1238,16 +1244,22 @@ static ssize_t
1238store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1244store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1239{ 1245{
1240 struct aiptek *aiptek = dev_get_drvdata(dev); 1246 struct aiptek *aiptek = dev_get_drvdata(dev);
1241 int y; 1247 long y;
1248
1249 if (strict_strtol(buf, 10, &y)) {
1250 size_t len = buf[count - 1] == '\n' ? count - 1 : count;
1251
1252 if (strncmp(buf, "disable", len))
1253 return -EINVAL;
1242 1254
1243 if (strcmp(buf, "disable") == 0) {
1244 aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; 1255 aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE;
1245 } else { 1256 } else {
1246 y = (int)simple_strtol(buf, NULL, 10); 1257 if (y < AIPTEK_TILT_MIN || y > AIPTEK_TILT_MAX)
1247 if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX) { 1258 return -EINVAL;
1248 aiptek->newSetting.yTilt = y; 1259
1249 } 1260 aiptek->newSetting.yTilt = y;
1250 } 1261 }
1262
1251 return count; 1263 return count;
1252} 1264}
1253 1265
@@ -1269,8 +1281,12 @@ static ssize_t
1269store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1281store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1270{ 1282{
1271 struct aiptek *aiptek = dev_get_drvdata(dev); 1283 struct aiptek *aiptek = dev_get_drvdata(dev);
1284 long j;
1285
1286 if (strict_strtol(buf, 10, &j))
1287 return -EINVAL;
1272 1288
1273 aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10); 1289 aiptek->newSetting.jitterDelay = (int)j;
1274 return count; 1290 return count;
1275} 1291}
1276 1292
@@ -1294,8 +1310,12 @@ static ssize_t
1294store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1310store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1295{ 1311{
1296 struct aiptek *aiptek = dev_get_drvdata(dev); 1312 struct aiptek *aiptek = dev_get_drvdata(dev);
1313 long d;
1297 1314
1298 aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10); 1315 if (strict_strtol(buf, 10, &d))
1316 return -EINVAL;
1317
1318 aiptek->newSetting.programmableDelay = (int)d;
1299 return count; 1319 return count;
1300} 1320}
1301 1321
@@ -1541,8 +1561,11 @@ static ssize_t
1541store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1561store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1542{ 1562{
1543 struct aiptek *aiptek = dev_get_drvdata(dev); 1563 struct aiptek *aiptek = dev_get_drvdata(dev);
1564 long w;
1565
1566 if (strict_strtol(buf, 10, &w)) return -EINVAL;
1544 1567
1545 aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10); 1568 aiptek->newSetting.wheel = (int)w;
1546 return count; 1569 return count;
1547} 1570}
1548 1571
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 8583c766d565..b9b7fc6ff1eb 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -69,6 +69,17 @@ struct ts_event {
69 int ignore; 69 int ignore;
70}; 70};
71 71
72/*
73 * We allocate this separately to avoid cache line sharing issues when
74 * driver is used with DMA-based SPI controllers (like atmel_spi) on
75 * systems where main memory is not DMA-coherent (most non-x86 boards).
76 */
77struct ads7846_packet {
78 u8 read_x, read_y, read_z1, read_z2, pwrdown;
79 u16 dummy; /* for the pwrdown read */
80 struct ts_event tc;
81};
82
72struct ads7846 { 83struct ads7846 {
73 struct input_dev *input; 84 struct input_dev *input;
74 char phys[32]; 85 char phys[32];
@@ -86,9 +97,7 @@ struct ads7846 {
86 u16 x_plate_ohms; 97 u16 x_plate_ohms;
87 u16 pressure_max; 98 u16 pressure_max;
88 99
89 u8 read_x, read_y, read_z1, read_z2, pwrdown; 100 struct ads7846_packet *packet;
90 u16 dummy; /* for the pwrdown read */
91 struct ts_event tc;
92 101
93 struct spi_transfer xfer[18]; 102 struct spi_transfer xfer[18];
94 struct spi_message msg[5]; 103 struct spi_message msg[5];
@@ -463,10 +472,11 @@ static ssize_t ads7846_disable_store(struct device *dev,
463 const char *buf, size_t count) 472 const char *buf, size_t count)
464{ 473{
465 struct ads7846 *ts = dev_get_drvdata(dev); 474 struct ads7846 *ts = dev_get_drvdata(dev);
466 char *endp; 475 long i;
467 int i; 476
477 if (strict_strtoul(buf, 10, &i))
478 return -EINVAL;
468 479
469 i = simple_strtoul(buf, &endp, 10);
470 spin_lock_irq(&ts->lock); 480 spin_lock_irq(&ts->lock);
471 481
472 if (i) 482 if (i)
@@ -512,16 +522,17 @@ static int get_pendown_state(struct ads7846 *ts)
512static void ads7846_rx(void *ads) 522static void ads7846_rx(void *ads)
513{ 523{
514 struct ads7846 *ts = ads; 524 struct ads7846 *ts = ads;
525 struct ads7846_packet *packet = ts->packet;
515 unsigned Rt; 526 unsigned Rt;
516 u16 x, y, z1, z2; 527 u16 x, y, z1, z2;
517 528
518 /* ads7846_rx_val() did in-place conversion (including byteswap) from 529 /* ads7846_rx_val() did in-place conversion (including byteswap) from
519 * on-the-wire format as part of debouncing to get stable readings. 530 * on-the-wire format as part of debouncing to get stable readings.
520 */ 531 */
521 x = ts->tc.x; 532 x = packet->tc.x;
522 y = ts->tc.y; 533 y = packet->tc.y;
523 z1 = ts->tc.z1; 534 z1 = packet->tc.z1;
524 z2 = ts->tc.z2; 535 z2 = packet->tc.z2;
525 536
526 /* range filtering */ 537 /* range filtering */
527 if (x == MAX_12BIT) 538 if (x == MAX_12BIT)
@@ -545,10 +556,10 @@ static void ads7846_rx(void *ads)
545 * the maximum. Don't report it to user space, repeat at least 556 * the maximum. Don't report it to user space, repeat at least
546 * once more the measurement 557 * once more the measurement
547 */ 558 */
548 if (ts->tc.ignore || Rt > ts->pressure_max) { 559 if (packet->tc.ignore || Rt > ts->pressure_max) {
549#ifdef VERBOSE 560#ifdef VERBOSE
550 pr_debug("%s: ignored %d pressure %d\n", 561 pr_debug("%s: ignored %d pressure %d\n",
551 ts->spi->dev.bus_id, ts->tc.ignore, Rt); 562 ts->spi->dev.bus_id, packet->tc.ignore, Rt);
552#endif 563#endif
553 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), 564 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD),
554 HRTIMER_MODE_REL); 565 HRTIMER_MODE_REL);
@@ -641,6 +652,7 @@ static int ads7846_no_filter(void *ads, int data_idx, int *val)
641static void ads7846_rx_val(void *ads) 652static void ads7846_rx_val(void *ads)
642{ 653{
643 struct ads7846 *ts = ads; 654 struct ads7846 *ts = ads;
655 struct ads7846_packet *packet = ts->packet;
644 struct spi_message *m; 656 struct spi_message *m;
645 struct spi_transfer *t; 657 struct spi_transfer *t;
646 int val; 658 int val;
@@ -660,7 +672,7 @@ static void ads7846_rx_val(void *ads)
660 case ADS7846_FILTER_REPEAT: 672 case ADS7846_FILTER_REPEAT:
661 break; 673 break;
662 case ADS7846_FILTER_IGNORE: 674 case ADS7846_FILTER_IGNORE:
663 ts->tc.ignore = 1; 675 packet->tc.ignore = 1;
664 /* Last message will contain ads7846_rx() as the 676 /* Last message will contain ads7846_rx() as the
665 * completion function. 677 * completion function.
666 */ 678 */
@@ -668,7 +680,7 @@ static void ads7846_rx_val(void *ads)
668 break; 680 break;
669 case ADS7846_FILTER_OK: 681 case ADS7846_FILTER_OK:
670 *(u16 *)t->rx_buf = val; 682 *(u16 *)t->rx_buf = val;
671 ts->tc.ignore = 0; 683 packet->tc.ignore = 0;
672 m = &ts->msg[++ts->msg_idx]; 684 m = &ts->msg[++ts->msg_idx];
673 break; 685 break;
674 default: 686 default:
@@ -773,7 +785,6 @@ static void ads7846_disable(struct ads7846 *ts)
773 /* we know the chip's in lowpower mode since we always 785 /* we know the chip's in lowpower mode since we always
774 * leave it that way after every request 786 * leave it that way after every request
775 */ 787 */
776
777} 788}
778 789
779/* Must be called with ts->lock held */ 790/* Must be called with ts->lock held */
@@ -849,6 +860,7 @@ static int __devinit setup_pendown(struct spi_device *spi, struct ads7846 *ts)
849static int __devinit ads7846_probe(struct spi_device *spi) 860static int __devinit ads7846_probe(struct spi_device *spi)
850{ 861{
851 struct ads7846 *ts; 862 struct ads7846 *ts;
863 struct ads7846_packet *packet;
852 struct input_dev *input_dev; 864 struct input_dev *input_dev;
853 struct ads7846_platform_data *pdata = spi->dev.platform_data; 865 struct ads7846_platform_data *pdata = spi->dev.platform_data;
854 struct spi_message *m; 866 struct spi_message *m;
@@ -884,14 +896,16 @@ static int __devinit ads7846_probe(struct spi_device *spi)
884 return err; 896 return err;
885 897
886 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); 898 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL);
899 packet = kzalloc(sizeof(struct ads7846_packet), GFP_KERNEL);
887 input_dev = input_allocate_device(); 900 input_dev = input_allocate_device();
888 if (!ts || !input_dev) { 901 if (!ts || !packet || !input_dev) {
889 err = -ENOMEM; 902 err = -ENOMEM;
890 goto err_free_mem; 903 goto err_free_mem;
891 } 904 }
892 905
893 dev_set_drvdata(&spi->dev, ts); 906 dev_set_drvdata(&spi->dev, ts);
894 907
908 ts->packet = packet;
895 ts->spi = spi; 909 ts->spi = spi;
896 ts->input = input_dev; 910 ts->input = input_dev;
897 ts->vref_mv = pdata->vref_mv; 911 ts->vref_mv = pdata->vref_mv;
@@ -963,13 +977,13 @@ static int __devinit ads7846_probe(struct spi_device *spi)
963 spi_message_init(m); 977 spi_message_init(m);
964 978
965 /* y- still on; turn on only y+ (and ADC) */ 979 /* y- still on; turn on only y+ (and ADC) */
966 ts->read_y = READ_Y(vref); 980 packet->read_y = READ_Y(vref);
967 x->tx_buf = &ts->read_y; 981 x->tx_buf = &packet->read_y;
968 x->len = 1; 982 x->len = 1;
969 spi_message_add_tail(x, m); 983 spi_message_add_tail(x, m);
970 984
971 x++; 985 x++;
972 x->rx_buf = &ts->tc.y; 986 x->rx_buf = &packet->tc.y;
973 x->len = 2; 987 x->len = 2;
974 spi_message_add_tail(x, m); 988 spi_message_add_tail(x, m);
975 989
@@ -981,12 +995,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
981 x->delay_usecs = pdata->settle_delay_usecs; 995 x->delay_usecs = pdata->settle_delay_usecs;
982 996
983 x++; 997 x++;
984 x->tx_buf = &ts->read_y; 998 x->tx_buf = &packet->read_y;
985 x->len = 1; 999 x->len = 1;
986 spi_message_add_tail(x, m); 1000 spi_message_add_tail(x, m);
987 1001
988 x++; 1002 x++;
989 x->rx_buf = &ts->tc.y; 1003 x->rx_buf = &packet->tc.y;
990 x->len = 2; 1004 x->len = 2;
991 spi_message_add_tail(x, m); 1005 spi_message_add_tail(x, m);
992 } 1006 }
@@ -999,13 +1013,13 @@ static int __devinit ads7846_probe(struct spi_device *spi)
999 1013
1000 /* turn y- off, x+ on, then leave in lowpower */ 1014 /* turn y- off, x+ on, then leave in lowpower */
1001 x++; 1015 x++;
1002 ts->read_x = READ_X(vref); 1016 packet->read_x = READ_X(vref);
1003 x->tx_buf = &ts->read_x; 1017 x->tx_buf = &packet->read_x;
1004 x->len = 1; 1018 x->len = 1;
1005 spi_message_add_tail(x, m); 1019 spi_message_add_tail(x, m);
1006 1020
1007 x++; 1021 x++;
1008 x->rx_buf = &ts->tc.x; 1022 x->rx_buf = &packet->tc.x;
1009 x->len = 2; 1023 x->len = 2;
1010 spi_message_add_tail(x, m); 1024 spi_message_add_tail(x, m);
1011 1025
@@ -1014,12 +1028,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1014 x->delay_usecs = pdata->settle_delay_usecs; 1028 x->delay_usecs = pdata->settle_delay_usecs;
1015 1029
1016 x++; 1030 x++;
1017 x->tx_buf = &ts->read_x; 1031 x->tx_buf = &packet->read_x;
1018 x->len = 1; 1032 x->len = 1;
1019 spi_message_add_tail(x, m); 1033 spi_message_add_tail(x, m);
1020 1034
1021 x++; 1035 x++;
1022 x->rx_buf = &ts->tc.x; 1036 x->rx_buf = &packet->tc.x;
1023 x->len = 2; 1037 x->len = 2;
1024 spi_message_add_tail(x, m); 1038 spi_message_add_tail(x, m);
1025 } 1039 }
@@ -1033,13 +1047,13 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1033 spi_message_init(m); 1047 spi_message_init(m);
1034 1048
1035 x++; 1049 x++;
1036 ts->read_z1 = READ_Z1(vref); 1050 packet->read_z1 = READ_Z1(vref);
1037 x->tx_buf = &ts->read_z1; 1051 x->tx_buf = &packet->read_z1;
1038 x->len = 1; 1052 x->len = 1;
1039 spi_message_add_tail(x, m); 1053 spi_message_add_tail(x, m);
1040 1054
1041 x++; 1055 x++;
1042 x->rx_buf = &ts->tc.z1; 1056 x->rx_buf = &packet->tc.z1;
1043 x->len = 2; 1057 x->len = 2;
1044 spi_message_add_tail(x, m); 1058 spi_message_add_tail(x, m);
1045 1059
@@ -1048,12 +1062,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1048 x->delay_usecs = pdata->settle_delay_usecs; 1062 x->delay_usecs = pdata->settle_delay_usecs;
1049 1063
1050 x++; 1064 x++;
1051 x->tx_buf = &ts->read_z1; 1065 x->tx_buf = &packet->read_z1;
1052 x->len = 1; 1066 x->len = 1;
1053 spi_message_add_tail(x, m); 1067 spi_message_add_tail(x, m);
1054 1068
1055 x++; 1069 x++;
1056 x->rx_buf = &ts->tc.z1; 1070 x->rx_buf = &packet->tc.z1;
1057 x->len = 2; 1071 x->len = 2;
1058 spi_message_add_tail(x, m); 1072 spi_message_add_tail(x, m);
1059 } 1073 }
@@ -1065,13 +1079,13 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1065 spi_message_init(m); 1079 spi_message_init(m);
1066 1080
1067 x++; 1081 x++;
1068 ts->read_z2 = READ_Z2(vref); 1082 packet->read_z2 = READ_Z2(vref);
1069 x->tx_buf = &ts->read_z2; 1083 x->tx_buf = &packet->read_z2;
1070 x->len = 1; 1084 x->len = 1;
1071 spi_message_add_tail(x, m); 1085 spi_message_add_tail(x, m);
1072 1086
1073 x++; 1087 x++;
1074 x->rx_buf = &ts->tc.z2; 1088 x->rx_buf = &packet->tc.z2;
1075 x->len = 2; 1089 x->len = 2;
1076 spi_message_add_tail(x, m); 1090 spi_message_add_tail(x, m);
1077 1091
@@ -1080,12 +1094,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1080 x->delay_usecs = pdata->settle_delay_usecs; 1094 x->delay_usecs = pdata->settle_delay_usecs;
1081 1095
1082 x++; 1096 x++;
1083 x->tx_buf = &ts->read_z2; 1097 x->tx_buf = &packet->read_z2;
1084 x->len = 1; 1098 x->len = 1;
1085 spi_message_add_tail(x, m); 1099 spi_message_add_tail(x, m);
1086 1100
1087 x++; 1101 x++;
1088 x->rx_buf = &ts->tc.z2; 1102 x->rx_buf = &packet->tc.z2;
1089 x->len = 2; 1103 x->len = 2;
1090 spi_message_add_tail(x, m); 1104 spi_message_add_tail(x, m);
1091 } 1105 }
@@ -1099,13 +1113,13 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1099 spi_message_init(m); 1113 spi_message_init(m);
1100 1114
1101 x++; 1115 x++;
1102 ts->pwrdown = PWRDOWN; 1116 packet->pwrdown = PWRDOWN;
1103 x->tx_buf = &ts->pwrdown; 1117 x->tx_buf = &packet->pwrdown;
1104 x->len = 1; 1118 x->len = 1;
1105 spi_message_add_tail(x, m); 1119 spi_message_add_tail(x, m);
1106 1120
1107 x++; 1121 x++;
1108 x->rx_buf = &ts->dummy; 1122 x->rx_buf = &packet->dummy;
1109 x->len = 2; 1123 x->len = 2;
1110 CS_CHANGE(*x); 1124 CS_CHANGE(*x);
1111 spi_message_add_tail(x, m); 1125 spi_message_add_tail(x, m);
@@ -1158,6 +1172,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1158 ts->filter_cleanup(ts->filter_data); 1172 ts->filter_cleanup(ts->filter_data);
1159 err_free_mem: 1173 err_free_mem:
1160 input_free_device(input_dev); 1174 input_free_device(input_dev);
1175 kfree(packet);
1161 kfree(ts); 1176 kfree(ts);
1162 return err; 1177 return err;
1163} 1178}
@@ -1183,6 +1198,7 @@ static int __devexit ads7846_remove(struct spi_device *spi)
1183 if (ts->filter_cleanup) 1198 if (ts->filter_cleanup)
1184 ts->filter_cleanup(ts->filter_data); 1199 ts->filter_cleanup(ts->filter_data);
1185 1200
1201 kfree(ts->packet);
1186 kfree(ts); 1202 kfree(ts);
1187 1203
1188 dev_dbg(&spi->dev, "unregistered touchscreen\n"); 1204 dev_dbg(&spi->dev, "unregistered touchscreen\n");
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
index eee126b19e8b..a89a6a8f05e6 100644
--- a/drivers/input/touchscreen/atmel_tsadcc.c
+++ b/drivers/input/touchscreen/atmel_tsadcc.c
@@ -91,6 +91,9 @@ struct atmel_tsadcc {
91 char phys[32]; 91 char phys[32];
92 struct clk *clk; 92 struct clk *clk;
93 int irq; 93 int irq;
94 unsigned int prev_absx;
95 unsigned int prev_absy;
96 unsigned char bufferedmeasure;
94}; 97};
95 98
96static void __iomem *tsc_base; 99static void __iomem *tsc_base;
@@ -100,10 +103,9 @@ static void __iomem *tsc_base;
100 103
101static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev) 104static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
102{ 105{
103 struct input_dev *input_dev = ((struct atmel_tsadcc *)dev)->input; 106 struct atmel_tsadcc *ts_dev = (struct atmel_tsadcc *)dev;
107 struct input_dev *input_dev = ts_dev->input;
104 108
105 unsigned int absx;
106 unsigned int absy;
107 unsigned int status; 109 unsigned int status;
108 unsigned int reg; 110 unsigned int reg;
109 111
@@ -121,6 +123,7 @@ static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
121 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); 123 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
122 124
123 input_report_key(input_dev, BTN_TOUCH, 0); 125 input_report_key(input_dev, BTN_TOUCH, 0);
126 ts_dev->bufferedmeasure = 0;
124 input_sync(input_dev); 127 input_sync(input_dev);
125 128
126 } else if (status & ATMEL_TSADCC_PENCNT) { 129 } else if (status & ATMEL_TSADCC_PENCNT) {
@@ -138,16 +141,23 @@ static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
138 } else if (status & ATMEL_TSADCC_EOC(3)) { 141 } else if (status & ATMEL_TSADCC_EOC(3)) {
139 /* Conversion finished */ 142 /* Conversion finished */
140 143
141 absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10; 144 if (ts_dev->bufferedmeasure) {
142 absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2); 145 /* Last measurement is always discarded, since it can
143 146 * be erroneous.
144 absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; 147 * Always report previous measurement */
145 absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); 148 input_report_abs(input_dev, ABS_X, ts_dev->prev_absx);
146 149 input_report_abs(input_dev, ABS_Y, ts_dev->prev_absy);
147 input_report_abs(input_dev, ABS_X, absx); 150 input_report_key(input_dev, BTN_TOUCH, 1);
148 input_report_abs(input_dev, ABS_Y, absy); 151 input_sync(input_dev);
149 input_report_key(input_dev, BTN_TOUCH, 1); 152 } else
150 input_sync(input_dev); 153 ts_dev->bufferedmeasure = 1;
154
155 /* Now make new measurement */
156 ts_dev->prev_absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10;
157 ts_dev->prev_absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2);
158
159 ts_dev->prev_absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10;
160 ts_dev->prev_absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0);
151 } 161 }
152 162
153 return IRQ_HANDLED; 163 return IRQ_HANDLED;
@@ -223,6 +233,7 @@ static int __devinit atmel_tsadcc_probe(struct platform_device *pdev)
223 } 233 }
224 234
225 ts_dev->input = input_dev; 235 ts_dev->input = input_dev;
236 ts_dev->bufferedmeasure = 0;
226 237
227 snprintf(ts_dev->phys, sizeof(ts_dev->phys), 238 snprintf(ts_dev->phys, sizeof(ts_dev->phys),
228 "%s/input0", pdev->dev.bus_id); 239 "%s/input0", pdev->dev.bus_id);
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 37a555f37306..ba648750a8d9 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -3,8 +3,7 @@
3 * Wolfson WM97xx AC97 Codecs. 3 * Wolfson WM97xx AC97 Codecs.
4 * 4 *
5 * Copyright 2004, 2007 Wolfson Microelectronics PLC. 5 * Copyright 2004, 2007 Wolfson Microelectronics PLC.
6 * Author: Liam Girdwood 6 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
8 * Parts Copyright : Ian Molton <spyro@f2s.com> 7 * Parts Copyright : Ian Molton <spyro@f2s.com>
9 * Andrew Zabolotny <zap@homelink.ru> 8 * Andrew Zabolotny <zap@homelink.ru>
10 * 9 *
@@ -296,6 +295,6 @@ module_init(mainstone_wm97xx_init);
296module_exit(mainstone_wm97xx_exit); 295module_exit(mainstone_wm97xx_exit);
297 296
298/* Module information */ 297/* Module information */
299MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 298MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
300MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone"); 299MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone");
301MODULE_LICENSE("GPL"); 300MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c
index 372efbc694ff..6b5be742c27d 100644
--- a/drivers/input/touchscreen/wm9705.c
+++ b/drivers/input/touchscreen/wm9705.c
@@ -2,8 +2,7 @@
2 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec. 2 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec.
3 * 3 *
4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood 5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 * Parts Copyright : Ian Molton <spyro@f2s.com> 6 * Parts Copyright : Ian Molton <spyro@f2s.com>
8 * Andrew Zabolotny <zap@homelink.ru> 7 * Andrew Zabolotny <zap@homelink.ru>
9 * Russell King <rmk@arm.linux.org.uk> 8 * Russell King <rmk@arm.linux.org.uk>
@@ -347,6 +346,6 @@ struct wm97xx_codec_drv wm9705_codec = {
347EXPORT_SYMBOL_GPL(wm9705_codec); 346EXPORT_SYMBOL_GPL(wm9705_codec);
348 347
349/* Module information */ 348/* Module information */
350MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 349MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
351MODULE_DESCRIPTION("WM9705 Touch Screen Driver"); 350MODULE_DESCRIPTION("WM9705 Touch Screen Driver");
352MODULE_LICENSE("GPL"); 351MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c
index c8bb1e7335fc..7490b05c3566 100644
--- a/drivers/input/touchscreen/wm9712.c
+++ b/drivers/input/touchscreen/wm9712.c
@@ -2,8 +2,7 @@
2 * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs. 2 * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs.
3 * 3 *
4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood 5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 * Parts Copyright : Ian Molton <spyro@f2s.com> 6 * Parts Copyright : Ian Molton <spyro@f2s.com>
8 * Andrew Zabolotny <zap@homelink.ru> 7 * Andrew Zabolotny <zap@homelink.ru>
9 * Russell King <rmk@arm.linux.org.uk> 8 * Russell King <rmk@arm.linux.org.uk>
@@ -462,6 +461,6 @@ struct wm97xx_codec_drv wm9712_codec = {
462EXPORT_SYMBOL_GPL(wm9712_codec); 461EXPORT_SYMBOL_GPL(wm9712_codec);
463 462
464/* Module information */ 463/* Module information */
465MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 464MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
466MODULE_DESCRIPTION("WM9712 Touch Screen Driver"); 465MODULE_DESCRIPTION("WM9712 Touch Screen Driver");
467MODULE_LICENSE("GPL"); 466MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/wm9713.c b/drivers/input/touchscreen/wm9713.c
index 781ee83547e6..238b5132712e 100644
--- a/drivers/input/touchscreen/wm9713.c
+++ b/drivers/input/touchscreen/wm9713.c
@@ -2,8 +2,7 @@
2 * wm9713.c -- Codec touch driver for Wolfson WM9713 AC97 Codec. 2 * wm9713.c -- Codec touch driver for Wolfson WM9713 AC97 Codec.
3 * 3 *
4 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 4 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood 5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 * Parts Copyright : Ian Molton <spyro@f2s.com> 6 * Parts Copyright : Ian Molton <spyro@f2s.com>
8 * Andrew Zabolotny <zap@homelink.ru> 7 * Andrew Zabolotny <zap@homelink.ru>
9 * Russell King <rmk@arm.linux.org.uk> 8 * Russell King <rmk@arm.linux.org.uk>
@@ -476,6 +475,6 @@ struct wm97xx_codec_drv wm9713_codec = {
476EXPORT_SYMBOL_GPL(wm9713_codec); 475EXPORT_SYMBOL_GPL(wm9713_codec);
477 476
478/* Module information */ 477/* Module information */
479MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 478MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
480MODULE_DESCRIPTION("WM9713 Touch Screen Driver"); 479MODULE_DESCRIPTION("WM9713 Touch Screen Driver");
481MODULE_LICENSE("GPL"); 480MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index d589ab0e3adc..d15aa11d7056 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -3,8 +3,7 @@
3 * and WM9713 AC97 Codecs. 3 * and WM9713 AC97 Codecs.
4 * 4 *
5 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 5 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC.
6 * Author: Liam Girdwood 6 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
8 * Parts Copyright : Ian Molton <spyro@f2s.com> 7 * Parts Copyright : Ian Molton <spyro@f2s.com>
9 * Andrew Zabolotny <zap@homelink.ru> 8 * Andrew Zabolotny <zap@homelink.ru>
10 * Russell King <rmk@arm.linux.org.uk> 9 * Russell King <rmk@arm.linux.org.uk>
@@ -824,6 +823,6 @@ module_init(wm97xx_init);
824module_exit(wm97xx_exit); 823module_exit(wm97xx_exit);
825 824
826/* Module information */ 825/* Module information */
827MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 826MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
828MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver"); 827MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver");
829MODULE_LICENSE("GPL"); 828MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 798d7f3e42ef..1b5bf87c4cf4 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1553,8 +1553,7 @@ static int __init capi_init(void)
1553 return PTR_ERR(capi_class); 1553 return PTR_ERR(capi_class);
1554 } 1554 }
1555 1555
1556 device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL, 1556 device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
1557 "capi");
1558 1557
1559#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1558#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1560 if (capinc_tty_init() < 0) { 1559 if (capinc_tty_init() < 0) {
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 559a40861c39..ee74ee7b2acc 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -103,8 +103,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
103{ 103{
104 int rc; 104 int rc;
105 105
106 led_cdev->dev = device_create_drvdata(leds_class, parent, 0, led_cdev, 106 led_cdev->dev = device_create(leds_class, parent, 0, led_cdev,
107 "%s", led_cdev->name); 107 "%s", led_cdev->name);
108 if (IS_ERR(led_cdev->dev)) 108 if (IS_ERR(led_cdev->dev))
109 return PTR_ERR(led_cdev->dev); 109 return PTR_ERR(led_cdev->dev);
110 110
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index cae52485208a..23741cec45e3 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -862,8 +862,7 @@ adbdev_init(void)
862 adb_dev_class = class_create(THIS_MODULE, "adb"); 862 adb_dev_class = class_create(THIS_MODULE, "adb");
863 if (IS_ERR(adb_dev_class)) 863 if (IS_ERR(adb_dev_class))
864 return; 864 return;
865 device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, 865 device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
866 "adb");
867 866
868 platform_device_register(&adb_pfdev); 867 platform_device_register(&adb_pfdev);
869 platform_driver_probe(&adb_pfdrv, adb_dummy_probe); 868 platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 268547dbfbd3..f26c1f9a475b 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -287,6 +287,8 @@ static int run(mddev_t *mddev)
287 int i; 287 int i;
288 288
289 conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL); 289 conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL);
290 if (!conf)
291 return -ENOMEM;
290 292
291 for (i=0; i<Modes; i++) { 293 for (i=0; i<Modes; i++) {
292 atomic_set(&conf->counters[i], 0); 294 atomic_set(&conf->counters[i], 0);
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index b9cbee688fae..190147c79e79 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -16,16 +16,8 @@
16 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*/ 17*/
18 18
19#include <linux/module.h>
20
21#include <linux/raid/md.h>
22#include <linux/slab.h>
23#include <linux/raid/linear.h> 19#include <linux/raid/linear.h>
24 20
25#define MAJOR_NR MD_MAJOR
26#define MD_DRIVER
27#define MD_PERSONALITY
28
29/* 21/*
30 * find which device holds a particular offset 22 * find which device holds a particular offset
31 */ 23 */
@@ -33,16 +25,15 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
33{ 25{
34 dev_info_t *hash; 26 dev_info_t *hash;
35 linear_conf_t *conf = mddev_to_conf(mddev); 27 linear_conf_t *conf = mddev_to_conf(mddev);
36 sector_t block = sector >> 1;
37 28
38 /* 29 /*
39 * sector_div(a,b) returns the remainer and sets a to a/b 30 * sector_div(a,b) returns the remainer and sets a to a/b
40 */ 31 */
41 block >>= conf->preshift; 32 sector >>= conf->sector_shift;
42 (void)sector_div(block, conf->hash_spacing); 33 (void)sector_div(sector, conf->spacing);
43 hash = conf->hash_table[block]; 34 hash = conf->hash_table[sector];
44 35
45 while ((sector>>1) >= (hash->size + hash->offset)) 36 while (sector >= hash->num_sectors + hash->start_sector)
46 hash++; 37 hash++;
47 return hash; 38 return hash;
48} 39}
@@ -65,7 +56,7 @@ static int linear_mergeable_bvec(struct request_queue *q,
65 sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 56 sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
66 57
67 dev0 = which_dev(mddev, sector); 58 dev0 = which_dev(mddev, sector);
68 maxsectors = (dev0->size << 1) - (sector - (dev0->offset<<1)); 59 maxsectors = dev0->num_sectors - (sector - dev0->start_sector);
69 60
70 if (maxsectors < bio_sectors) 61 if (maxsectors < bio_sectors)
71 maxsectors = 0; 62 maxsectors = 0;
@@ -112,8 +103,8 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
112 dev_info_t **table; 103 dev_info_t **table;
113 mdk_rdev_t *rdev; 104 mdk_rdev_t *rdev;
114 int i, nb_zone, cnt; 105 int i, nb_zone, cnt;
115 sector_t min_spacing; 106 sector_t min_sectors;
116 sector_t curr_offset; 107 sector_t curr_sector;
117 struct list_head *tmp; 108 struct list_head *tmp;
118 109
119 conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t), 110 conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t),
@@ -145,7 +136,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
145 mddev->queue->max_sectors > (PAGE_SIZE>>9)) 136 mddev->queue->max_sectors > (PAGE_SIZE>>9))
146 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 137 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
147 138
148 disk->size = rdev->size; 139 disk->num_sectors = rdev->size * 2;
149 conf->array_sectors += rdev->size * 2; 140 conf->array_sectors += rdev->size * 2;
150 141
151 cnt++; 142 cnt++;
@@ -155,34 +146,34 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
155 goto out; 146 goto out;
156 } 147 }
157 148
158 min_spacing = conf->array_sectors / 2; 149 min_sectors = conf->array_sectors;
159 sector_div(min_spacing, PAGE_SIZE/sizeof(struct dev_info *)); 150 sector_div(min_sectors, PAGE_SIZE/sizeof(struct dev_info *));
160 151
161 /* min_spacing is the minimum spacing that will fit the hash 152 /* min_sectors is the minimum spacing that will fit the hash
162 * table in one PAGE. This may be much smaller than needed. 153 * table in one PAGE. This may be much smaller than needed.
163 * We find the smallest non-terminal set of consecutive devices 154 * We find the smallest non-terminal set of consecutive devices
164 * that is larger than min_spacing as use the size of that as 155 * that is larger than min_sectors and use the size of that as
165 * the actual spacing 156 * the actual spacing
166 */ 157 */
167 conf->hash_spacing = conf->array_sectors / 2; 158 conf->spacing = conf->array_sectors;
168 for (i=0; i < cnt-1 ; i++) { 159 for (i=0; i < cnt-1 ; i++) {
169 sector_t sz = 0; 160 sector_t tmp = 0;
170 int j; 161 int j;
171 for (j = i; j < cnt - 1 && sz < min_spacing; j++) 162 for (j = i; j < cnt - 1 && tmp < min_sectors; j++)
172 sz += conf->disks[j].size; 163 tmp += conf->disks[j].num_sectors;
173 if (sz >= min_spacing && sz < conf->hash_spacing) 164 if (tmp >= min_sectors && tmp < conf->spacing)
174 conf->hash_spacing = sz; 165 conf->spacing = tmp;
175 } 166 }
176 167
177 /* hash_spacing may be too large for sector_div to work with, 168 /* spacing may be too large for sector_div to work with,
178 * so we might need to pre-shift 169 * so we might need to pre-shift
179 */ 170 */
180 conf->preshift = 0; 171 conf->sector_shift = 0;
181 if (sizeof(sector_t) > sizeof(u32)) { 172 if (sizeof(sector_t) > sizeof(u32)) {
182 sector_t space = conf->hash_spacing; 173 sector_t space = conf->spacing;
183 while (space > (sector_t)(~(u32)0)) { 174 while (space > (sector_t)(~(u32)0)) {
184 space >>= 1; 175 space >>= 1;
185 conf->preshift++; 176 conf->sector_shift++;
186 } 177 }
187 } 178 }
188 /* 179 /*
@@ -194,9 +185,9 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
194 unsigned round; 185 unsigned round;
195 unsigned long base; 186 unsigned long base;
196 187
197 sz = conf->array_sectors >> (conf->preshift + 1); 188 sz = conf->array_sectors >> conf->sector_shift;
198 sz += 1; /* force round-up */ 189 sz += 1; /* force round-up */
199 base = conf->hash_spacing >> conf->preshift; 190 base = conf->spacing >> conf->sector_shift;
200 round = sector_div(sz, base); 191 round = sector_div(sz, base);
201 nb_zone = sz + (round ? 1 : 0); 192 nb_zone = sz + (round ? 1 : 0);
202 } 193 }
@@ -211,32 +202,31 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
211 * Here we generate the linear hash table 202 * Here we generate the linear hash table
212 * First calculate the device offsets. 203 * First calculate the device offsets.
213 */ 204 */
214 conf->disks[0].offset = 0; 205 conf->disks[0].start_sector = 0;
215 for (i = 1; i < raid_disks; i++) 206 for (i = 1; i < raid_disks; i++)
216 conf->disks[i].offset = 207 conf->disks[i].start_sector =
217 conf->disks[i-1].offset + 208 conf->disks[i-1].start_sector +
218 conf->disks[i-1].size; 209 conf->disks[i-1].num_sectors;
219 210
220 table = conf->hash_table; 211 table = conf->hash_table;
221 curr_offset = 0;
222 i = 0; 212 i = 0;
223 for (curr_offset = 0; 213 for (curr_sector = 0;
224 curr_offset < conf->array_sectors / 2; 214 curr_sector < conf->array_sectors;
225 curr_offset += conf->hash_spacing) { 215 curr_sector += conf->spacing) {
226 216
227 while (i < raid_disks-1 && 217 while (i < raid_disks-1 &&
228 curr_offset >= conf->disks[i+1].offset) 218 curr_sector >= conf->disks[i+1].start_sector)
229 i++; 219 i++;
230 220
231 *table ++ = conf->disks + i; 221 *table ++ = conf->disks + i;
232 } 222 }
233 223
234 if (conf->preshift) { 224 if (conf->sector_shift) {
235 conf->hash_spacing >>= conf->preshift; 225 conf->spacing >>= conf->sector_shift;
236 /* round hash_spacing up so that when we divide by it, 226 /* round spacing up so that when we divide by it,
237 * we err on the side of "too-low", which is safest. 227 * we err on the side of "too-low", which is safest.
238 */ 228 */
239 conf->hash_spacing++; 229 conf->spacing++;
240 } 230 }
241 231
242 BUG_ON(table - conf->hash_table > nb_zone); 232 BUG_ON(table - conf->hash_table > nb_zone);
@@ -317,7 +307,6 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
317 const int rw = bio_data_dir(bio); 307 const int rw = bio_data_dir(bio);
318 mddev_t *mddev = q->queuedata; 308 mddev_t *mddev = q->queuedata;
319 dev_info_t *tmp_dev; 309 dev_info_t *tmp_dev;
320 sector_t block;
321 int cpu; 310 int cpu;
322 311
323 if (unlikely(bio_barrier(bio))) { 312 if (unlikely(bio_barrier(bio))) {
@@ -332,29 +321,33 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
332 part_stat_unlock(); 321 part_stat_unlock();
333 322
334 tmp_dev = which_dev(mddev, bio->bi_sector); 323 tmp_dev = which_dev(mddev, bio->bi_sector);
335 block = bio->bi_sector >> 1;
336 324
337 if (unlikely(block >= (tmp_dev->size + tmp_dev->offset) 325 if (unlikely(bio->bi_sector >= (tmp_dev->num_sectors +
338 || block < tmp_dev->offset)) { 326 tmp_dev->start_sector)
327 || (bio->bi_sector <
328 tmp_dev->start_sector))) {
339 char b[BDEVNAME_SIZE]; 329 char b[BDEVNAME_SIZE];
340 330
341 printk("linear_make_request: Block %llu out of bounds on " 331 printk("linear_make_request: Sector %llu out of bounds on "
342 "dev %s size %llu offset %llu\n", 332 "dev %s: %llu sectors, offset %llu\n",
343 (unsigned long long)block, 333 (unsigned long long)bio->bi_sector,
344 bdevname(tmp_dev->rdev->bdev, b), 334 bdevname(tmp_dev->rdev->bdev, b),
345 (unsigned long long)tmp_dev->size, 335 (unsigned long long)tmp_dev->num_sectors,
346 (unsigned long long)tmp_dev->offset); 336 (unsigned long long)tmp_dev->start_sector);
347 bio_io_error(bio); 337 bio_io_error(bio);
348 return 0; 338 return 0;
349 } 339 }
350 if (unlikely(bio->bi_sector + (bio->bi_size >> 9) > 340 if (unlikely(bio->bi_sector + (bio->bi_size >> 9) >
351 (tmp_dev->offset + tmp_dev->size)<<1)) { 341 tmp_dev->start_sector + tmp_dev->num_sectors)) {
352 /* This bio crosses a device boundary, so we have to 342 /* This bio crosses a device boundary, so we have to
353 * split it. 343 * split it.
354 */ 344 */
355 struct bio_pair *bp; 345 struct bio_pair *bp;
346
356 bp = bio_split(bio, 347 bp = bio_split(bio,
357 ((tmp_dev->offset + tmp_dev->size)<<1) - bio->bi_sector); 348 tmp_dev->start_sector + tmp_dev->num_sectors
349 - bio->bi_sector);
350
358 if (linear_make_request(q, &bp->bio1)) 351 if (linear_make_request(q, &bp->bio1))
359 generic_make_request(&bp->bio1); 352 generic_make_request(&bp->bio1);
360 if (linear_make_request(q, &bp->bio2)) 353 if (linear_make_request(q, &bp->bio2))
@@ -364,7 +357,8 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
364 } 357 }
365 358
366 bio->bi_bdev = tmp_dev->rdev->bdev; 359 bio->bi_bdev = tmp_dev->rdev->bdev;
367 bio->bi_sector = bio->bi_sector - (tmp_dev->offset << 1) + tmp_dev->rdev->data_offset; 360 bio->bi_sector = bio->bi_sector - tmp_dev->start_sector
361 + tmp_dev->rdev->data_offset;
368 362
369 return 1; 363 return 1;
370} 364}
@@ -372,29 +366,6 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
372static void linear_status (struct seq_file *seq, mddev_t *mddev) 366static void linear_status (struct seq_file *seq, mddev_t *mddev)
373{ 367{
374 368
375#undef MD_DEBUG
376#ifdef MD_DEBUG
377 int j;
378 linear_conf_t *conf = mddev_to_conf(mddev);
379 sector_t s = 0;
380
381 seq_printf(seq, " ");
382 for (j = 0; j < mddev->raid_disks; j++)
383 {
384 char b[BDEVNAME_SIZE];
385 s += conf->smallest_size;
386 seq_printf(seq, "[%s",
387 bdevname(conf->hash_table[j][0].rdev->bdev,b));
388
389 while (s > conf->hash_table[j][0].offset +
390 conf->hash_table[j][0].size)
391 seq_printf(seq, "/%s] ",
392 bdevname(conf->hash_table[j][1].rdev->bdev,b));
393 else
394 seq_printf(seq, "] ");
395 }
396 seq_printf(seq, "\n");
397#endif
398 seq_printf(seq, " %dk rounding", mddev->chunk_size/1024); 369 seq_printf(seq, " %dk rounding", mddev->chunk_size/1024);
399} 370}
400 371
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0a3a4bdcd4af..aaa3d465de4e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -32,31 +32,21 @@
32 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 32 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33*/ 33*/
34 34
35#include <linux/module.h>
36#include <linux/kernel.h>
37#include <linux/kthread.h> 35#include <linux/kthread.h>
38#include <linux/linkage.h>
39#include <linux/raid/md.h> 36#include <linux/raid/md.h>
40#include <linux/raid/bitmap.h> 37#include <linux/raid/bitmap.h>
41#include <linux/sysctl.h> 38#include <linux/sysctl.h>
42#include <linux/buffer_head.h> /* for invalidate_bdev */ 39#include <linux/buffer_head.h> /* for invalidate_bdev */
43#include <linux/poll.h> 40#include <linux/poll.h>
44#include <linux/mutex.h>
45#include <linux/ctype.h> 41#include <linux/ctype.h>
46#include <linux/freezer.h> 42#include <linux/hdreg.h>
47 43#include <linux/proc_fs.h>
48#include <linux/init.h> 44#include <linux/random.h>
49 45#include <linux/reboot.h>
50#include <linux/file.h> 46#include <linux/file.h>
51 47#include <linux/delay.h>
52#ifdef CONFIG_KMOD
53#include <linux/kmod.h>
54#endif
55
56#include <asm/unaligned.h>
57 48
58#define MAJOR_NR MD_MAJOR 49#define MAJOR_NR MD_MAJOR
59#define MD_DRIVER
60 50
61/* 63 partitions with the alternate major number (mdp) */ 51/* 63 partitions with the alternate major number (mdp) */
62#define MdpMinorShift 6 52#define MdpMinorShift 6
@@ -66,7 +56,7 @@
66 56
67 57
68#ifndef MODULE 58#ifndef MODULE
69static void autostart_arrays (int part); 59static void autostart_arrays(int part);
70#endif 60#endif
71 61
72static LIST_HEAD(pers_list); 62static LIST_HEAD(pers_list);
@@ -212,7 +202,7 @@ static DEFINE_SPINLOCK(all_mddevs_lock);
212 ) 202 )
213 203
214 204
215static int md_fail_request (struct request_queue *q, struct bio *bio) 205static int md_fail_request(struct request_queue *q, struct bio *bio)
216{ 206{
217 bio_io_error(bio); 207 bio_io_error(bio);
218 return 0; 208 return 0;
@@ -2106,8 +2096,6 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2106 2096
2107 if (strict_strtoull(buf, 10, &size) < 0) 2097 if (strict_strtoull(buf, 10, &size) < 0)
2108 return -EINVAL; 2098 return -EINVAL;
2109 if (size < my_mddev->size)
2110 return -EINVAL;
2111 if (my_mddev->pers && rdev->raid_disk >= 0) { 2099 if (my_mddev->pers && rdev->raid_disk >= 0) {
2112 if (my_mddev->persistent) { 2100 if (my_mddev->persistent) {
2113 size = super_types[my_mddev->major_version]. 2101 size = super_types[my_mddev->major_version].
@@ -2118,9 +2106,9 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2118 size = (rdev->bdev->bd_inode->i_size >> 10); 2106 size = (rdev->bdev->bd_inode->i_size >> 10);
2119 size -= rdev->data_offset/2; 2107 size -= rdev->data_offset/2;
2120 } 2108 }
2121 if (size < my_mddev->size)
2122 return -EINVAL; /* component must fit device */
2123 } 2109 }
2110 if (size < my_mddev->size)
2111 return -EINVAL; /* component must fit device */
2124 2112
2125 rdev->size = size; 2113 rdev->size = size;
2126 if (size > oldsize && my_mddev->external) { 2114 if (size > oldsize && my_mddev->external) {
@@ -2406,12 +2394,11 @@ safe_delay_store(mddev_t *mddev, const char *cbuf, size_t len)
2406 int i; 2394 int i;
2407 unsigned long msec; 2395 unsigned long msec;
2408 char buf[30]; 2396 char buf[30];
2409 char *e; 2397
2410 /* remove a period, and count digits after it */ 2398 /* remove a period, and count digits after it */
2411 if (len >= sizeof(buf)) 2399 if (len >= sizeof(buf))
2412 return -EINVAL; 2400 return -EINVAL;
2413 strlcpy(buf, cbuf, len); 2401 strlcpy(buf, cbuf, sizeof(buf));
2414 buf[len] = 0;
2415 for (i=0; i<len; i++) { 2402 for (i=0; i<len; i++) {
2416 if (dot) { 2403 if (dot) {
2417 if (isdigit(buf[i])) { 2404 if (isdigit(buf[i])) {
@@ -2424,8 +2411,7 @@ safe_delay_store(mddev_t *mddev, const char *cbuf, size_t len)
2424 buf[i] = 0; 2411 buf[i] = 0;
2425 } 2412 }
2426 } 2413 }
2427 msec = simple_strtoul(buf, &e, 10); 2414 if (strict_strtoul(buf, 10, &msec) < 0)
2428 if (e == buf || (*e && *e != '\n'))
2429 return -EINVAL; 2415 return -EINVAL;
2430 msec = (msec * 1000) / scale; 2416 msec = (msec * 1000) / scale;
2431 if (msec == 0) 2417 if (msec == 0)
@@ -2727,9 +2713,9 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
2727 break; 2713 break;
2728 case read_auto: 2714 case read_auto:
2729 if (mddev->pers) { 2715 if (mddev->pers) {
2730 if (mddev->ro != 1) 2716 if (mddev->ro == 0)
2731 err = do_md_stop(mddev, 1, 0); 2717 err = do_md_stop(mddev, 1, 0);
2732 else 2718 else if (mddev->ro == 1)
2733 err = restart_array(mddev); 2719 err = restart_array(mddev);
2734 if (err == 0) { 2720 if (err == 0) {
2735 mddev->ro = 2; 2721 mddev->ro = 2;
@@ -2945,7 +2931,13 @@ metadata_store(mddev_t *mddev, const char *buf, size_t len)
2945{ 2931{
2946 int major, minor; 2932 int major, minor;
2947 char *e; 2933 char *e;
2948 if (!list_empty(&mddev->disks)) 2934 /* Changing the details of 'external' metadata is
2935 * always permitted. Otherwise there must be
2936 * no devices attached to the array.
2937 */
2938 if (mddev->external && strncmp(buf, "external:", 9) == 0)
2939 ;
2940 else if (!list_empty(&mddev->disks))
2949 return -EBUSY; 2941 return -EBUSY;
2950 2942
2951 if (cmd_match(buf, "none")) { 2943 if (cmd_match(buf, "none")) {
@@ -3527,17 +3519,12 @@ static int do_md_run(mddev_t * mddev)
3527 return -EINVAL; 3519 return -EINVAL;
3528 } 3520 }
3529 /* 3521 /*
3530 * chunk-size has to be a power of 2 and multiples of PAGE_SIZE 3522 * chunk-size has to be a power of 2
3531 */ 3523 */
3532 if ( (1 << ffz(~chunk_size)) != chunk_size) { 3524 if ( (1 << ffz(~chunk_size)) != chunk_size) {
3533 printk(KERN_ERR "chunk_size of %d not valid\n", chunk_size); 3525 printk(KERN_ERR "chunk_size of %d not valid\n", chunk_size);
3534 return -EINVAL; 3526 return -EINVAL;
3535 } 3527 }
3536 if (chunk_size < PAGE_SIZE) {
3537 printk(KERN_ERR "too small chunk_size: %d < %ld\n",
3538 chunk_size, PAGE_SIZE);
3539 return -EINVAL;
3540 }
3541 3528
3542 /* devices must have minimum size of one chunk */ 3529 /* devices must have minimum size of one chunk */
3543 rdev_for_each(rdev, tmp, mddev) { 3530 rdev_for_each(rdev, tmp, mddev) {
@@ -3555,12 +3542,10 @@ static int do_md_run(mddev_t * mddev)
3555 } 3542 }
3556 } 3543 }
3557 3544
3558#ifdef CONFIG_KMOD
3559 if (mddev->level != LEVEL_NONE) 3545 if (mddev->level != LEVEL_NONE)
3560 request_module("md-level-%d", mddev->level); 3546 request_module("md-level-%d", mddev->level);
3561 else if (mddev->clevel[0]) 3547 else if (mddev->clevel[0])
3562 request_module("md-%s", mddev->clevel); 3548 request_module("md-%s", mddev->clevel);
3563#endif
3564 3549
3565 /* 3550 /*
3566 * Drop all container device buffers, from now on 3551 * Drop all container device buffers, from now on
@@ -3971,10 +3956,10 @@ static void autorun_array(mddev_t *mddev)
3971 } 3956 }
3972 printk("\n"); 3957 printk("\n");
3973 3958
3974 err = do_md_run (mddev); 3959 err = do_md_run(mddev);
3975 if (err) { 3960 if (err) {
3976 printk(KERN_WARNING "md: do_md_run() returned %d\n", err); 3961 printk(KERN_WARNING "md: do_md_run() returned %d\n", err);
3977 do_md_stop (mddev, 0, 0); 3962 do_md_stop(mddev, 0, 0);
3978 } 3963 }
3979} 3964}
3980 3965
@@ -4333,7 +4318,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
4333 4318
4334 if (!(info->state & (1<<MD_DISK_FAULTY))) { 4319 if (!(info->state & (1<<MD_DISK_FAULTY))) {
4335 int err; 4320 int err;
4336 rdev = md_import_device (dev, -1, 0); 4321 rdev = md_import_device(dev, -1, 0);
4337 if (IS_ERR(rdev)) { 4322 if (IS_ERR(rdev)) {
4338 printk(KERN_WARNING 4323 printk(KERN_WARNING
4339 "md: error, md_import_device() returned %ld\n", 4324 "md: error, md_import_device() returned %ld\n",
@@ -4415,7 +4400,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
4415 return -EINVAL; 4400 return -EINVAL;
4416 } 4401 }
4417 4402
4418 rdev = md_import_device (dev, -1, 0); 4403 rdev = md_import_device(dev, -1, 0);
4419 if (IS_ERR(rdev)) { 4404 if (IS_ERR(rdev)) {
4420 printk(KERN_WARNING 4405 printk(KERN_WARNING
4421 "md: error, md_import_device() returned %ld\n", 4406 "md: error, md_import_device() returned %ld\n",
@@ -4934,11 +4919,11 @@ static int md_ioctl(struct inode *inode, struct file *file,
4934 goto done_unlock; 4919 goto done_unlock;
4935 4920
4936 case STOP_ARRAY: 4921 case STOP_ARRAY:
4937 err = do_md_stop (mddev, 0, 1); 4922 err = do_md_stop(mddev, 0, 1);
4938 goto done_unlock; 4923 goto done_unlock;
4939 4924
4940 case STOP_ARRAY_RO: 4925 case STOP_ARRAY_RO:
4941 err = do_md_stop (mddev, 1, 1); 4926 err = do_md_stop(mddev, 1, 1);
4942 goto done_unlock; 4927 goto done_unlock;
4943 4928
4944 } 4929 }
@@ -4987,7 +4972,7 @@ static int md_ioctl(struct inode *inode, struct file *file,
4987 goto done_unlock; 4972 goto done_unlock;
4988 4973
4989 case RUN_ARRAY: 4974 case RUN_ARRAY:
4990 err = do_md_run (mddev); 4975 err = do_md_run(mddev);
4991 goto done_unlock; 4976 goto done_unlock;
4992 4977
4993 case SET_BITMAP_FILE: 4978 case SET_BITMAP_FILE:
@@ -5425,11 +5410,11 @@ static int md_seq_show(struct seq_file *seq, void *v)
5425 seq_printf(seq, " super non-persistent"); 5410 seq_printf(seq, " super non-persistent");
5426 5411
5427 if (mddev->pers) { 5412 if (mddev->pers) {
5428 mddev->pers->status (seq, mddev); 5413 mddev->pers->status(seq, mddev);
5429 seq_printf(seq, "\n "); 5414 seq_printf(seq, "\n ");
5430 if (mddev->pers->sync_request) { 5415 if (mddev->pers->sync_request) {
5431 if (mddev->curr_resync > 2) { 5416 if (mddev->curr_resync > 2) {
5432 status_resync (seq, mddev); 5417 status_resync(seq, mddev);
5433 seq_printf(seq, "\n "); 5418 seq_printf(seq, "\n ");
5434 } else if (mddev->curr_resync == 1 || mddev->curr_resync == 2) 5419 } else if (mddev->curr_resync == 1 || mddev->curr_resync == 2)
5435 seq_printf(seq, "\tresync=DELAYED\n "); 5420 seq_printf(seq, "\tresync=DELAYED\n ");
@@ -6260,7 +6245,7 @@ static int md_notify_reboot(struct notifier_block *this,
6260 * appears to still be in use. Hence 6245 * appears to still be in use. Hence
6261 * the '100'. 6246 * the '100'.
6262 */ 6247 */
6263 do_md_stop (mddev, 1, 100); 6248 do_md_stop(mddev, 1, 100);
6264 mddev_unlock(mddev); 6249 mddev_unlock(mddev);
6265 } 6250 }
6266 /* 6251 /*
@@ -6304,7 +6289,7 @@ static int __init md_init(void)
6304 raid_table_header = register_sysctl_table(raid_root_table); 6289 raid_table_header = register_sysctl_table(raid_root_table);
6305 6290
6306 md_geninit(); 6291 md_geninit();
6307 return (0); 6292 return 0;
6308} 6293}
6309 6294
6310 6295
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 8bb8794129b3..8744014b9d80 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -19,16 +19,7 @@
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/spinlock.h>
25#include <linux/raid/multipath.h> 22#include <linux/raid/multipath.h>
26#include <linux/buffer_head.h>
27#include <asm/atomic.h>
28
29#define MAJOR_NR MD_MAJOR
30#define MD_DRIVER
31#define MD_PERSONALITY
32 23
33#define MAX_WORK_PER_DISK 128 24#define MAX_WORK_PER_DISK 128
34 25
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 53508a8a981d..8ac6488ad0dc 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -18,13 +18,8 @@
18 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#include <linux/module.h>
22#include <linux/raid/raid0.h> 21#include <linux/raid/raid0.h>
23 22
24#define MAJOR_NR MD_MAJOR
25#define MD_DRIVER
26#define MD_PERSONALITY
27
28static void raid0_unplug(struct request_queue *q) 23static void raid0_unplug(struct request_queue *q)
29{ 24{
30 mddev_t *mddev = q->queuedata; 25 mddev_t *mddev = q->queuedata;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index b9764429d856..9c788e2489b1 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include "dm-bio-list.h" 34#include "dm-bio-list.h"
35#include <linux/delay.h>
35#include <linux/raid/raid1.h> 36#include <linux/raid/raid1.h>
36#include <linux/raid/bitmap.h> 37#include <linux/raid/bitmap.h>
37 38
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 8bdc9bfc2887..da5129a24b18 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include "dm-bio-list.h" 21#include "dm-bio-list.h"
22#include <linux/delay.h>
22#include <linux/raid/raid10.h> 23#include <linux/raid/raid10.h>
23#include <linux/raid/bitmap.h> 24#include <linux/raid/bitmap.h>
24 25
@@ -2028,8 +2029,9 @@ static int run(mddev_t *mddev)
2028 int nc, fc, fo; 2029 int nc, fc, fo;
2029 sector_t stride, size; 2030 sector_t stride, size;
2030 2031
2031 if (mddev->chunk_size == 0) { 2032 if (mddev->chunk_size < PAGE_SIZE) {
2032 printk(KERN_ERR "md/raid10: non-zero chunk size required.\n"); 2033 printk(KERN_ERR "md/raid10: chunk size must be "
2034 "at least PAGE_SIZE(%ld).\n", PAGE_SIZE);
2033 return -EINVAL; 2035 return -EINVAL;
2034 } 2036 }
2035 2037
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ae16794bef20..a36a7435edf5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -43,12 +43,7 @@
43 * miss any bits. 43 * miss any bits.
44 */ 44 */
45 45
46#include <linux/module.h>
47#include <linux/slab.h>
48#include <linux/highmem.h>
49#include <linux/bitops.h>
50#include <linux/kthread.h> 46#include <linux/kthread.h>
51#include <asm/atomic.h>
52#include "raid6.h" 47#include "raid6.h"
53 48
54#include <linux/raid/bitmap.h> 49#include <linux/raid/bitmap.h>
@@ -275,7 +270,7 @@ static int grow_buffers(struct stripe_head *sh, int num)
275 return 0; 270 return 0;
276} 271}
277 272
278static void raid5_build_block (struct stripe_head *sh, int i); 273static void raid5_build_block(struct stripe_head *sh, int i);
279 274
280static void init_stripe(struct stripe_head *sh, sector_t sector, int pd_idx, int disks) 275static void init_stripe(struct stripe_head *sh, sector_t sector, int pd_idx, int disks)
281{ 276{
@@ -1151,7 +1146,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
1151 release_stripe(sh); 1146 release_stripe(sh);
1152} 1147}
1153 1148
1154static void raid5_end_write_request (struct bio *bi, int error) 1149static void raid5_end_write_request(struct bio *bi, int error)
1155{ 1150{
1156 struct stripe_head *sh = bi->bi_private; 1151 struct stripe_head *sh = bi->bi_private;
1157 raid5_conf_t *conf = sh->raid_conf; 1152 raid5_conf_t *conf = sh->raid_conf;
@@ -1183,7 +1178,7 @@ static void raid5_end_write_request (struct bio *bi, int error)
1183 1178
1184static sector_t compute_blocknr(struct stripe_head *sh, int i); 1179static sector_t compute_blocknr(struct stripe_head *sh, int i);
1185 1180
1186static void raid5_build_block (struct stripe_head *sh, int i) 1181static void raid5_build_block(struct stripe_head *sh, int i)
1187{ 1182{
1188 struct r5dev *dev = &sh->dev[i]; 1183 struct r5dev *dev = &sh->dev[i];
1189 1184
@@ -1221,10 +1216,10 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
1221 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 1216 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
1222 } 1217 }
1223 set_bit(Faulty, &rdev->flags); 1218 set_bit(Faulty, &rdev->flags);
1224 printk (KERN_ALERT 1219 printk(KERN_ALERT
1225 "raid5: Disk failure on %s, disabling device.\n" 1220 "raid5: Disk failure on %s, disabling device.\n"
1226 "raid5: Operation continuing on %d devices.\n", 1221 "raid5: Operation continuing on %d devices.\n",
1227 bdevname(rdev->bdev,b), conf->raid_disks - mddev->degraded); 1222 bdevname(rdev->bdev,b), conf->raid_disks - mddev->degraded);
1228 } 1223 }
1229} 1224}
1230 1225
@@ -1320,8 +1315,8 @@ static sector_t raid5_compute_sector(sector_t r_sector, unsigned int raid_disks,
1320 *dd_idx = (*pd_idx + 2 + *dd_idx) % raid_disks; 1315 *dd_idx = (*pd_idx + 2 + *dd_idx) % raid_disks;
1321 break; 1316 break;
1322 default: 1317 default:
1323 printk (KERN_CRIT "raid6: unsupported algorithm %d\n", 1318 printk(KERN_CRIT "raid6: unsupported algorithm %d\n",
1324 conf->algorithm); 1319 conf->algorithm);
1325 } 1320 }
1326 break; 1321 break;
1327 } 1322 }
@@ -1396,8 +1391,8 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i)
1396 } 1391 }
1397 break; 1392 break;
1398 default: 1393 default:
1399 printk (KERN_CRIT "raid6: unsupported algorithm %d\n", 1394 printk(KERN_CRIT "raid6: unsupported algorithm %d\n",
1400 conf->algorithm); 1395 conf->algorithm);
1401 } 1396 }
1402 break; 1397 break;
1403 } 1398 }
@@ -1405,7 +1400,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i)
1405 chunk_number = stripe * data_disks + i; 1400 chunk_number = stripe * data_disks + i;
1406 r_sector = (sector_t)chunk_number * sectors_per_chunk + chunk_offset; 1401 r_sector = (sector_t)chunk_number * sectors_per_chunk + chunk_offset;
1407 1402
1408 check = raid5_compute_sector (r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf); 1403 check = raid5_compute_sector(r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf);
1409 if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) { 1404 if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) {
1410 printk(KERN_ERR "compute_blocknr: map not correct\n"); 1405 printk(KERN_ERR "compute_blocknr: map not correct\n");
1411 return 0; 1406 return 0;
@@ -4012,6 +4007,13 @@ static int run(mddev_t *mddev)
4012 return -EIO; 4007 return -EIO;
4013 } 4008 }
4014 4009
4010 if (mddev->chunk_size < PAGE_SIZE) {
4011 printk(KERN_ERR "md/raid5: chunk_size must be at least "
4012 "PAGE_SIZE but %d < %ld\n",
4013 mddev->chunk_size, PAGE_SIZE);
4014 return -EINVAL;
4015 }
4016
4015 if (mddev->reshape_position != MaxSector) { 4017 if (mddev->reshape_position != MaxSector) {
4016 /* Check that we can continue the reshape. 4018 /* Check that we can continue the reshape.
4017 * Currently only disks can change, it must 4019 * Currently only disks can change, it must
@@ -4289,7 +4291,7 @@ static int stop(mddev_t *mddev)
4289} 4291}
4290 4292
4291#ifdef DEBUG 4293#ifdef DEBUG
4292static void print_sh (struct seq_file *seq, struct stripe_head *sh) 4294static void print_sh(struct seq_file *seq, struct stripe_head *sh)
4293{ 4295{
4294 int i; 4296 int i;
4295 4297
@@ -4305,7 +4307,7 @@ static void print_sh (struct seq_file *seq, struct stripe_head *sh)
4305 seq_printf(seq, "\n"); 4307 seq_printf(seq, "\n");
4306} 4308}
4307 4309
4308static void printall (struct seq_file *seq, raid5_conf_t *conf) 4310static void printall(struct seq_file *seq, raid5_conf_t *conf)
4309{ 4311{
4310 struct stripe_head *sh; 4312 struct stripe_head *sh;
4311 struct hlist_node *hn; 4313 struct hlist_node *hn;
@@ -4323,7 +4325,7 @@ static void printall (struct seq_file *seq, raid5_conf_t *conf)
4323} 4325}
4324#endif 4326#endif
4325 4327
4326static void status (struct seq_file *seq, mddev_t *mddev) 4328static void status(struct seq_file *seq, mddev_t *mddev)
4327{ 4329{
4328 raid5_conf_t *conf = (raid5_conf_t *) mddev->private; 4330 raid5_conf_t *conf = (raid5_conf_t *) mddev->private;
4329 int i; 4331 int i;
diff --git a/drivers/md/raid6.h b/drivers/md/raid6.h
index 31cbee71365f..98dcde88470e 100644
--- a/drivers/md/raid6.h
+++ b/drivers/md/raid6.h
@@ -18,15 +18,6 @@
18/* Set to 1 to use kernel-wide empty_zero_page */ 18/* Set to 1 to use kernel-wide empty_zero_page */
19#define RAID6_USE_EMPTY_ZERO_PAGE 0 19#define RAID6_USE_EMPTY_ZERO_PAGE 0
20 20
21#include <linux/module.h>
22#include <linux/stddef.h>
23#include <linux/compiler.h>
24#include <linux/types.h>
25#include <linux/kernel.h>
26#include <linux/errno.h>
27#include <linux/mempool.h>
28#include <linux/list.h>
29#include <linux/vmalloc.h>
30#include <linux/raid/md.h> 21#include <linux/raid/md.h>
31#include <linux/raid/raid5.h> 22#include <linux/raid/raid5.h>
32 23
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index e7132770a3bf..665776d72a48 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -233,7 +233,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
233 233
234 mutex_unlock(&dvbdev_register_lock); 234 mutex_unlock(&dvbdev_register_lock);
235 235
236 clsdev = device_create_drvdata(dvb_class, adap->device, 236 clsdev = device_create(dvb_class, adap->device,
237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id); 238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
239 if (IS_ERR(clsdev)) { 239 if (IS_ERR(clsdev)) {
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index c325e926de8a..1798b779a25a 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -39,10 +39,6 @@
39#include <asm/io.h> 39#include <asm/io.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41 41
42#ifdef CONFIG_KMOD
43#include <linux/kmod.h>
44#endif
45
46#include "cpia.h" 42#include "cpia.h"
47 43
48static int video_nr = -1; 44static int video_nr = -1;
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index b26b563a0b0a..9e4f50639975 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -45,10 +45,6 @@
45 45
46#include <linux/workqueue.h> 46#include <linux/workqueue.h>
47 47
48#ifdef CONFIG_KMOD
49#include <linux/kmod.h>
50#endif
51
52#include "usbvision.h" 48#include "usbvision.h"
53 49
54static unsigned int core_debug; 50static unsigned int core_debug;
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index e10b256aeba4..77aeb39b2750 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -69,10 +69,6 @@
69 69
70#include <linux/workqueue.h> 70#include <linux/workqueue.h>
71 71
72#ifdef CONFIG_KMOD
73#include <linux/kmod.h>
74#endif
75
76#include "usbvision.h" 72#include "usbvision.h"
77#include "usbvision-cards.h" 73#include "usbvision-cards.h"
78 74
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index 79937d1031fc..928cb4037372 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -36,10 +36,6 @@
36#include <asm/system.h> 36#include <asm/system.h>
37#include <asm/pgtable.h> 37#include <asm/pgtable.h>
38 38
39#ifdef CONFIG_KMOD
40#include <linux/kmod.h>
41#endif
42
43static unsigned int debug; 39static unsigned int debug;
44module_param(debug, int, 0644); 40module_param(debug, int, 0644);
45MODULE_PARM_DESC(debug, "enable debug messages"); 41MODULE_PARM_DESC(debug, "enable debug messages");
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 20c3be8617ea..846763d7349e 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -60,10 +60,6 @@
60#include <media/v4l2-common.h> 60#include <media/v4l2-common.h>
61#include <media/v4l2-chip-ident.h> 61#include <media/v4l2-chip-ident.h>
62 62
63#ifdef CONFIG_KMOD
64#include <linux/kmod.h>
65#endif
66
67#include <linux/videodev2.h> 63#include <linux/videodev2.h>
68 64
69MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr"); 65MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 8ec57df1904f..1efc5f3462c6 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -30,10 +30,7 @@
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/time.h> 31#include <linux/time.h>
32#include <linux/version.h> 32#include <linux/version.h>
33
34#ifdef CONFIG_KMOD
35#include <linux/kmod.h> 33#include <linux/kmod.h>
36#endif
37 34
38#include <linux/i2c.h> 35#include <linux/i2c.h>
39#include <linux/i2c-algo-sgi.h> 36#include <linux/i2c-algo-sgi.h>
@@ -4634,7 +4631,7 @@ static int __init vino_module_init(void)
4634 } 4631 }
4635 vino_init_stage++; 4632 vino_init_stage++;
4636 4633
4637#if defined(CONFIG_KMOD) && defined(MODULE) 4634#ifdef MODULE
4638 request_module("saa7191"); 4635 request_module("saa7191");
4639 request_module("indycam"); 4636 request_module("indycam");
4640#endif 4637#endif
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 11edf79f57be..dcd45dbd82dc 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -111,7 +111,7 @@ static int specific_debug = W9968CF_SPECIFIC_DEBUG;
111 111
112static unsigned int param_nv[24]; /* number of values per parameter */ 112static unsigned int param_nv[24]; /* number of values per parameter */
113 113
114#ifdef CONFIG_KMOD 114#ifdef CONFIG_MODULES
115module_param(ovmod_load, bool, 0644); 115module_param(ovmod_load, bool, 0644);
116#endif 116#endif
117module_param(simcams, ushort, 0644); 117module_param(simcams, ushort, 0644);
@@ -144,7 +144,7 @@ module_param(debug, ushort, 0644);
144module_param(specific_debug, bool, 0644); 144module_param(specific_debug, bool, 0644);
145#endif 145#endif
146 146
147#ifdef CONFIG_KMOD 147#ifdef CONFIG_MODULES
148MODULE_PARM_DESC(ovmod_load, 148MODULE_PARM_DESC(ovmod_load,
149 "\n<0|1> Automatic 'ovcamchip' module loading." 149 "\n<0|1> Automatic 'ovcamchip' module loading."
150 "\n0 disabled, 1 enabled." 150 "\n0 disabled, 1 enabled."
diff --git a/drivers/message/i2o/Makefile b/drivers/message/i2o/Makefile
index 2c2e39aa1efa..b0982dacfd0a 100644
--- a/drivers/message/i2o/Makefile
+++ b/drivers/message/i2o/Makefile
@@ -5,7 +5,7 @@
5# In the future, some of these should be built conditionally. 5# In the future, some of these should be built conditionally.
6# 6#
7 7
8i2o_core-y += iop.o driver.o device.o debug.o pci.o exec-osm.o 8i2o_core-y += iop.o driver.o device.o debug.o pci.o exec-osm.o memory.o
9i2o_bus-y += bus-osm.o 9i2o_bus-y += bus-osm.o
10i2o_config-y += config-osm.o 10i2o_config-y += config-osm.o
11obj-$(CONFIG_I2O) += i2o_core.o 11obj-$(CONFIG_I2O) += i2o_core.o
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 8774c670e668..54c2e9ae23e5 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -467,7 +467,7 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
467 467
468 res.virt = NULL; 468 res.virt = NULL;
469 469
470 if (i2o_dma_alloc(dev, &res, reslen, GFP_KERNEL)) 470 if (i2o_dma_alloc(dev, &res, reslen))
471 return -ENOMEM; 471 return -ENOMEM;
472 472
473 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); 473 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 6cbcc21de518..56faef1a1d55 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -388,8 +388,8 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
388 388
389 dev = &c->pdev->dev; 389 dev = &c->pdev->dev;
390 390
391 if (i2o_dma_realloc 391 if (i2o_dma_realloc(dev, &c->dlct,
392 (dev, &c->dlct, le32_to_cpu(sb->expected_lct_size), GFP_KERNEL)) 392 le32_to_cpu(sb->expected_lct_size)))
393 return -ENOMEM; 393 return -ENOMEM;
394 394
395 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); 395 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 4238de98d4a6..a3fabdbe6ca6 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -260,7 +260,7 @@ static int i2o_cfg_swdl(unsigned long arg)
260 if (IS_ERR(msg)) 260 if (IS_ERR(msg))
261 return PTR_ERR(msg); 261 return PTR_ERR(msg);
262 262
263 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) { 263 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize)) {
264 i2o_msg_nop(c, msg); 264 i2o_msg_nop(c, msg);
265 return -ENOMEM; 265 return -ENOMEM;
266 } 266 }
@@ -339,7 +339,7 @@ static int i2o_cfg_swul(unsigned long arg)
339 if (IS_ERR(msg)) 339 if (IS_ERR(msg))
340 return PTR_ERR(msg); 340 return PTR_ERR(msg);
341 341
342 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) { 342 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize)) {
343 i2o_msg_nop(c, msg); 343 i2o_msg_nop(c, msg);
344 return -ENOMEM; 344 return -ENOMEM;
345 } 345 }
@@ -634,9 +634,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
634 sg_size = sg[i].flag_count & 0xffffff; 634 sg_size = sg[i].flag_count & 0xffffff;
635 p = &(sg_list[sg_index]); 635 p = &(sg_list[sg_index]);
636 /* Allocate memory for the transfer */ 636 /* Allocate memory for the transfer */
637 if (i2o_dma_alloc 637 if (i2o_dma_alloc(&c->pdev->dev, p, sg_size)) {
638 (&c->pdev->dev, p, sg_size,
639 PCI_DMA_BIDIRECTIONAL)) {
640 printk(KERN_DEBUG 638 printk(KERN_DEBUG
641 "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 639 "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
642 c->name, sg_size, i, sg_count); 640 c->name, sg_size, i, sg_count);
@@ -780,12 +778,11 @@ static int i2o_cfg_passthru(unsigned long arg)
780 u32 size = 0; 778 u32 size = 0;
781 u32 reply_size = 0; 779 u32 reply_size = 0;
782 u32 rcode = 0; 780 u32 rcode = 0;
783 void *sg_list[SG_TABLESIZE]; 781 struct i2o_dma sg_list[SG_TABLESIZE];
784 u32 sg_offset = 0; 782 u32 sg_offset = 0;
785 u32 sg_count = 0; 783 u32 sg_count = 0;
786 int sg_index = 0; 784 int sg_index = 0;
787 u32 i = 0; 785 u32 i = 0;
788 void *p = NULL;
789 i2o_status_block *sb; 786 i2o_status_block *sb;
790 struct i2o_message *msg; 787 struct i2o_message *msg;
791 unsigned int iop; 788 unsigned int iop;
@@ -842,6 +839,7 @@ static int i2o_cfg_passthru(unsigned long arg)
842 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); 839 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
843 if (sg_offset) { 840 if (sg_offset) {
844 struct sg_simple_element *sg; 841 struct sg_simple_element *sg;
842 struct i2o_dma *p;
845 843
846 if (sg_offset * 4 >= size) { 844 if (sg_offset * 4 >= size) {
847 rcode = -EFAULT; 845 rcode = -EFAULT;
@@ -871,22 +869,22 @@ static int i2o_cfg_passthru(unsigned long arg)
871 goto sg_list_cleanup; 869 goto sg_list_cleanup;
872 } 870 }
873 sg_size = sg[i].flag_count & 0xffffff; 871 sg_size = sg[i].flag_count & 0xffffff;
872 p = &(sg_list[sg_index]);
873 if (i2o_dma_alloc(&c->pdev->dev, p, sg_size)) {
874 /* Allocate memory for the transfer */ 874 /* Allocate memory for the transfer */
875 p = kmalloc(sg_size, GFP_KERNEL);
876 if (!p) {
877 printk(KERN_DEBUG 875 printk(KERN_DEBUG
878 "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 876 "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
879 c->name, sg_size, i, sg_count); 877 c->name, sg_size, i, sg_count);
880 rcode = -ENOMEM; 878 rcode = -ENOMEM;
881 goto sg_list_cleanup; 879 goto sg_list_cleanup;
882 } 880 }
883 sg_list[sg_index++] = p; // sglist indexed with input frame, not our internal frame. 881 sg_index++;
884 /* Copy in the user's SG buffer if necessary */ 882 /* Copy in the user's SG buffer if necessary */
885 if (sg[i]. 883 if (sg[i].
886 flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) { 884 flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) {
887 // TODO 64bit fix 885 // TODO 64bit fix
888 if (copy_from_user 886 if (copy_from_user
889 (p, (void __user *)sg[i].addr_bus, 887 (p->virt, (void __user *)sg[i].addr_bus,
890 sg_size)) { 888 sg_size)) {
891 printk(KERN_DEBUG 889 printk(KERN_DEBUG
892 "%s: Could not copy SG buf %d FROM user\n", 890 "%s: Could not copy SG buf %d FROM user\n",
@@ -895,8 +893,7 @@ static int i2o_cfg_passthru(unsigned long arg)
895 goto sg_list_cleanup; 893 goto sg_list_cleanup;
896 } 894 }
897 } 895 }
898 //TODO 64bit fix 896 sg[i].addr_bus = p->phys;
899 sg[i].addr_bus = virt_to_bus(p);
900 } 897 }
901 } 898 }
902 899
@@ -908,7 +905,7 @@ static int i2o_cfg_passthru(unsigned long arg)
908 } 905 }
909 906
910 if (sg_offset) { 907 if (sg_offset) {
911 u32 rmsg[128]; 908 u32 rmsg[I2O_OUTBOUND_MSG_FRAME_SIZE];
912 /* Copy back the Scatter Gather buffers back to user space */ 909 /* Copy back the Scatter Gather buffers back to user space */
913 u32 j; 910 u32 j;
914 // TODO 64bit fix 911 // TODO 64bit fix
@@ -942,11 +939,11 @@ static int i2o_cfg_passthru(unsigned long arg)
942 sg_size = sg[j].flag_count & 0xffffff; 939 sg_size = sg[j].flag_count & 0xffffff;
943 // TODO 64bit fix 940 // TODO 64bit fix
944 if (copy_to_user 941 if (copy_to_user
945 ((void __user *)sg[j].addr_bus, sg_list[j], 942 ((void __user *)sg[j].addr_bus, sg_list[j].virt,
946 sg_size)) { 943 sg_size)) {
947 printk(KERN_WARNING 944 printk(KERN_WARNING
948 "%s: Could not copy %p TO user %x\n", 945 "%s: Could not copy %p TO user %x\n",
949 c->name, sg_list[j], 946 c->name, sg_list[j].virt,
950 sg[j].addr_bus); 947 sg[j].addr_bus);
951 rcode = -EFAULT; 948 rcode = -EFAULT;
952 goto sg_list_cleanup; 949 goto sg_list_cleanup;
@@ -973,7 +970,7 @@ sg_list_cleanup:
973 } 970 }
974 971
975 for (i = 0; i < sg_index; i++) 972 for (i = 0; i < sg_index; i++)
976 kfree(sg_list[i]); 973 i2o_dma_free(&c->pdev->dev, &sg_list[i]);
977 974
978cleanup: 975cleanup:
979 kfree(reply); 976 kfree(reply);
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index da715e11c1b2..be2b5926d26c 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -1004,7 +1004,7 @@ static int i2o_hrt_get(struct i2o_controller *c)
1004 1004
1005 size = hrt->num_entries * hrt->entry_len << 2; 1005 size = hrt->num_entries * hrt->entry_len << 2;
1006 if (size > c->hrt.len) { 1006 if (size > c->hrt.len) {
1007 if (i2o_dma_realloc(dev, &c->hrt, size, GFP_KERNEL)) 1007 if (i2o_dma_realloc(dev, &c->hrt, size))
1008 return -ENOMEM; 1008 return -ENOMEM;
1009 else 1009 else
1010 hrt = c->hrt.virt; 1010 hrt = c->hrt.virt;
diff --git a/drivers/message/i2o/memory.c b/drivers/message/i2o/memory.c
new file mode 100644
index 000000000000..f5cc95c564e2
--- /dev/null
+++ b/drivers/message/i2o/memory.c
@@ -0,0 +1,313 @@
1/*
2 * Functions to handle I2O memory
3 *
4 * Pulled from the inlines in i2o headers and uninlined
5 *
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#include <linux/module.h>
14#include <linux/i2o.h>
15#include <linux/delay.h>
16#include <linux/string.h>
17#include <linux/slab.h>
18#include "core.h"
19
20/* Protects our 32/64bit mask switching */
21static DEFINE_MUTEX(mem_lock);
22
23/**
24 * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL
25 * @c: I2O controller for which the calculation should be done
26 * @body_size: maximum body size used for message in 32-bit words.
27 *
28 * Return the maximum number of SG elements in a SG list.
29 */
30u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size)
31{
32 i2o_status_block *sb = c->status_block.virt;
33 u16 sg_count =
34 (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) -
35 body_size;
36
37 if (c->pae_support) {
38 /*
39 * for 64-bit a SG attribute element must be added and each
40 * SG element needs 12 bytes instead of 8.
41 */
42 sg_count -= 2;
43 sg_count /= 3;
44 } else
45 sg_count /= 2;
46
47 if (c->short_req && (sg_count > 8))
48 sg_count = 8;
49
50 return sg_count;
51}
52EXPORT_SYMBOL_GPL(i2o_sg_tablesize);
53
54
55/**
56 * i2o_dma_map_single - Map pointer to controller and fill in I2O message.
57 * @c: I2O controller
58 * @ptr: pointer to the data which should be mapped
59 * @size: size of data in bytes
60 * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
61 * @sg_ptr: pointer to the SG list inside the I2O message
62 *
63 * This function does all necessary DMA handling and also writes the I2O
64 * SGL elements into the I2O message. For details on DMA handling see also
65 * dma_map_single(). The pointer sg_ptr will only be set to the end of the
66 * SG list if the allocation was successful.
67 *
68 * Returns DMA address which must be checked for failures using
69 * dma_mapping_error().
70 */
71dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
72 size_t size,
73 enum dma_data_direction direction,
74 u32 ** sg_ptr)
75{
76 u32 sg_flags;
77 u32 *mptr = *sg_ptr;
78 dma_addr_t dma_addr;
79
80 switch (direction) {
81 case DMA_TO_DEVICE:
82 sg_flags = 0xd4000000;
83 break;
84 case DMA_FROM_DEVICE:
85 sg_flags = 0xd0000000;
86 break;
87 default:
88 return 0;
89 }
90
91 dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction);
92 if (!dma_mapping_error(&c->pdev->dev, dma_addr)) {
93#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
94 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
95 *mptr++ = cpu_to_le32(0x7C020002);
96 *mptr++ = cpu_to_le32(PAGE_SIZE);
97 }
98#endif
99
100 *mptr++ = cpu_to_le32(sg_flags | size);
101 *mptr++ = cpu_to_le32(i2o_dma_low(dma_addr));
102#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
103 if ((sizeof(dma_addr_t) > 4) && c->pae_support)
104 *mptr++ = cpu_to_le32(i2o_dma_high(dma_addr));
105#endif
106 *sg_ptr = mptr;
107 }
108 return dma_addr;
109}
110EXPORT_SYMBOL_GPL(i2o_dma_map_single);
111
112/**
113 * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message.
114 * @c: I2O controller
115 * @sg: SG list to be mapped
116 * @sg_count: number of elements in the SG list
117 * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
118 * @sg_ptr: pointer to the SG list inside the I2O message
119 *
120 * This function does all necessary DMA handling and also writes the I2O
121 * SGL elements into the I2O message. For details on DMA handling see also
122 * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG
123 * list if the allocation was successful.
124 *
125 * Returns 0 on failure or 1 on success.
126 */
127int i2o_dma_map_sg(struct i2o_controller *c, struct scatterlist *sg,
128 int sg_count, enum dma_data_direction direction, u32 ** sg_ptr)
129{
130 u32 sg_flags;
131 u32 *mptr = *sg_ptr;
132
133 switch (direction) {
134 case DMA_TO_DEVICE:
135 sg_flags = 0x14000000;
136 break;
137 case DMA_FROM_DEVICE:
138 sg_flags = 0x10000000;
139 break;
140 default:
141 return 0;
142 }
143
144 sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction);
145 if (!sg_count)
146 return 0;
147
148#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
149 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
150 *mptr++ = cpu_to_le32(0x7C020002);
151 *mptr++ = cpu_to_le32(PAGE_SIZE);
152 }
153#endif
154
155 while (sg_count-- > 0) {
156 if (!sg_count)
157 sg_flags |= 0xC0000000;
158 *mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg));
159 *mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg)));
160#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
161 if ((sizeof(dma_addr_t) > 4) && c->pae_support)
162 *mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg)));
163#endif
164 sg = sg_next(sg);
165 }
166 *sg_ptr = mptr;
167
168 return 1;
169}
170EXPORT_SYMBOL_GPL(i2o_dma_map_sg);
171
172/**
173 * i2o_dma_alloc - Allocate DMA memory
174 * @dev: struct device pointer to the PCI device of the I2O controller
175 * @addr: i2o_dma struct which should get the DMA buffer
176 * @len: length of the new DMA memory
177 *
178 * Allocate a coherent DMA memory and write the pointers into addr.
179 *
180 * Returns 0 on success or -ENOMEM on failure.
181 */
182int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len)
183{
184 struct pci_dev *pdev = to_pci_dev(dev);
185 int dma_64 = 0;
186
187 mutex_lock(&mem_lock);
188 if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_64BIT_MASK)) {
189 dma_64 = 1;
190 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
191 mutex_unlock(&mem_lock);
192 return -ENOMEM;
193 }
194 }
195
196 addr->virt = dma_alloc_coherent(dev, len, &addr->phys, GFP_KERNEL);
197
198 if ((sizeof(dma_addr_t) > 4) && dma_64)
199 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK))
200 printk(KERN_WARNING "i2o: unable to set 64-bit DMA");
201 mutex_unlock(&mem_lock);
202
203 if (!addr->virt)
204 return -ENOMEM;
205
206 memset(addr->virt, 0, len);
207 addr->len = len;
208
209 return 0;
210}
211EXPORT_SYMBOL_GPL(i2o_dma_alloc);
212
213
214/**
215 * i2o_dma_free - Free DMA memory
216 * @dev: struct device pointer to the PCI device of the I2O controller
217 * @addr: i2o_dma struct which contains the DMA buffer
218 *
219 * Free a coherent DMA memory and set virtual address of addr to NULL.
220 */
221void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
222{
223 if (addr->virt) {
224 if (addr->phys)
225 dma_free_coherent(dev, addr->len, addr->virt,
226 addr->phys);
227 else
228 kfree(addr->virt);
229 addr->virt = NULL;
230 }
231}
232EXPORT_SYMBOL_GPL(i2o_dma_free);
233
234
235/**
236 * i2o_dma_realloc - Realloc DMA memory
237 * @dev: struct device pointer to the PCI device of the I2O controller
238 * @addr: pointer to a i2o_dma struct DMA buffer
239 * @len: new length of memory
240 *
241 * If there was something allocated in the addr, free it first. If len > 0
242 * than try to allocate it and write the addresses back to the addr
243 * structure. If len == 0 set the virtual address to NULL.
244 *
245 * Returns the 0 on success or negative error code on failure.
246 */
247int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, size_t len)
248{
249 i2o_dma_free(dev, addr);
250
251 if (len)
252 return i2o_dma_alloc(dev, addr, len);
253
254 return 0;
255}
256EXPORT_SYMBOL_GPL(i2o_dma_realloc);
257
258/*
259 * i2o_pool_alloc - Allocate an slab cache and mempool
260 * @mempool: pointer to struct i2o_pool to write data into.
261 * @name: name which is used to identify cache
262 * @size: size of each object
263 * @min_nr: minimum number of objects
264 *
265 * First allocates a slab cache with name and size. Then allocates a
266 * mempool which uses the slab cache for allocation and freeing.
267 *
268 * Returns 0 on success or negative error code on failure.
269 */
270int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
271 size_t size, int min_nr)
272{
273 pool->name = kmalloc(strlen(name) + 1, GFP_KERNEL);
274 if (!pool->name)
275 goto exit;
276 strcpy(pool->name, name);
277
278 pool->slab =
279 kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
280 if (!pool->slab)
281 goto free_name;
282
283 pool->mempool = mempool_create_slab_pool(min_nr, pool->slab);
284 if (!pool->mempool)
285 goto free_slab;
286
287 return 0;
288
289free_slab:
290 kmem_cache_destroy(pool->slab);
291
292free_name:
293 kfree(pool->name);
294
295exit:
296 return -ENOMEM;
297}
298EXPORT_SYMBOL_GPL(i2o_pool_alloc);
299
300/*
301 * i2o_pool_free - Free slab cache and mempool again
302 * @mempool: pointer to struct i2o_pool which should be freed
303 *
304 * Note that you have to return all objects to the mempool again before
305 * calling i2o_pool_free().
306 */
307void i2o_pool_free(struct i2o_pool *pool)
308{
309 mempool_destroy(pool->mempool);
310 kmem_cache_destroy(pool->slab);
311 kfree(pool->name);
312};
313EXPORT_SYMBOL_GPL(i2o_pool_free);
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 685a89547a51..610ef1204e68 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -186,31 +186,29 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
186 } 186 }
187 } 187 }
188 188
189 if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) { 189 if (i2o_dma_alloc(dev, &c->status, 8)) {
190 i2o_pci_free(c); 190 i2o_pci_free(c);
191 return -ENOMEM; 191 return -ENOMEM;
192 } 192 }
193 193
194 if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt), GFP_KERNEL)) { 194 if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt))) {
195 i2o_pci_free(c); 195 i2o_pci_free(c);
196 return -ENOMEM; 196 return -ENOMEM;
197 } 197 }
198 198
199 if (i2o_dma_alloc(dev, &c->dlct, 8192, GFP_KERNEL)) { 199 if (i2o_dma_alloc(dev, &c->dlct, 8192)) {
200 i2o_pci_free(c); 200 i2o_pci_free(c);
201 return -ENOMEM; 201 return -ENOMEM;
202 } 202 }
203 203
204 if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block), 204 if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block))) {
205 GFP_KERNEL)) {
206 i2o_pci_free(c); 205 i2o_pci_free(c);
207 return -ENOMEM; 206 return -ENOMEM;
208 } 207 }
209 208
210 if (i2o_dma_alloc 209 if (i2o_dma_alloc(dev, &c->out_queue,
211 (dev, &c->out_queue, 210 I2O_MAX_OUTBOUND_MSG_FRAMES * I2O_OUTBOUND_MSG_FRAME_SIZE *
212 I2O_MAX_OUTBOUND_MSG_FRAMES * I2O_OUTBOUND_MSG_FRAME_SIZE * 211 sizeof(u32))) {
213 sizeof(u32), GFP_KERNEL)) {
214 i2o_pci_free(c); 212 i2o_pci_free(c);
215 return -ENOMEM; 213 return -ENOMEM;
216 } 214 }
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a726f3b01a6b..efd3aa08b88b 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -15,7 +15,7 @@ if MISC_DEVICES
15 15
16config ATMEL_PWM 16config ATMEL_PWM
17 tristate "Atmel AT32/AT91 PWM support" 17 tristate "Atmel AT32/AT91 PWM support"
18 depends on AVR32 || ARCH_AT91 18 depends on AVR32 || ARCH_AT91SAM9263 || ARCH_AT91SAM9RL || ARCH_AT91CAP9
19 help 19 help
20 This option enables device driver support for the PWM channels 20 This option enables device driver support for the PWM channels
21 on certain Atmel prcoessors. Pulse Width Modulation is used for 21 on certain Atmel prcoessors. Pulse Width Modulation is used for
@@ -409,6 +409,7 @@ config EEEPC_LAPTOP
409 depends on BACKLIGHT_CLASS_DEVICE 409 depends on BACKLIGHT_CLASS_DEVICE
410 depends on HWMON 410 depends on HWMON
411 depends on EXPERIMENTAL 411 depends on EXPERIMENTAL
412 depends on RFKILL
412 ---help--- 413 ---help---
413 This driver supports the Fn-Fx keys on Eee PC laptops. 414 This driver supports the Fn-Fx keys on Eee PC laptops.
414 It also adds the ability to switch camera/wlan on/off. 415 It also adds the ability to switch camera/wlan on/off.
diff --git a/drivers/misc/hp-wmi.c b/drivers/misc/hp-wmi.c
index 6d407c2a4f91..5dabfb69ee53 100644
--- a/drivers/misc/hp-wmi.c
+++ b/drivers/misc/hp-wmi.c
@@ -309,7 +309,7 @@ static int hp_wmi_setkeycode(struct input_dev *dev, int scancode, int keycode)
309 return -EINVAL; 309 return -EINVAL;
310} 310}
311 311
312void hp_wmi_notify(u32 value, void *context) 312static void hp_wmi_notify(u32 value, void *context)
313{ 313{
314 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; 314 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
315 static struct key_entry *key; 315 static struct key_entry *key;
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index daf585689ce3..abdebe347383 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -399,9 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev,
399 goto err_irq; 399 goto err_irq;
400 } 400 }
401 401
402 if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev, 402 if (IS_ERR(device_create(phantom_class, &pdev->dev,
403 MKDEV(phantom_major, minor), 403 MKDEV(phantom_major, minor), NULL,
404 NULL, "phantom%u", minor))) 404 "phantom%u", minor)))
405 dev_err(&pdev->dev, "can't create device\n"); 405 dev_err(&pdev->dev, "can't create device\n");
406 406
407 pci_set_drvdata(pdev, pht); 407 pci_set_drvdata(pdev, pht);
diff --git a/drivers/misc/sgi-gru/gru.h b/drivers/misc/sgi-gru/gru.h
index 40df7cb3f0a5..f93f03a9e6e9 100644
--- a/drivers/misc/sgi-gru/gru.h
+++ b/drivers/misc/sgi-gru/gru.h
@@ -30,9 +30,9 @@
30/* 30/*
31 * Size used to map GRU GSeg 31 * Size used to map GRU GSeg
32 */ 32 */
33#if defined CONFIG_IA64 33#if defined(CONFIG_IA64)
34#define GRU_GSEG_PAGESIZE (256 * 1024UL) 34#define GRU_GSEG_PAGESIZE (256 * 1024UL)
35#elif defined CONFIG_X86_64 35#elif defined(CONFIG_X86_64)
36#define GRU_GSEG_PAGESIZE (256 * 1024UL) /* ZZZ 2MB ??? */ 36#define GRU_GSEG_PAGESIZE (256 * 1024UL) /* ZZZ 2MB ??? */
37#else 37#else
38#error "Unsupported architecture" 38#error "Unsupported architecture"
diff --git a/drivers/misc/sgi-gru/gru_instructions.h b/drivers/misc/sgi-gru/gru_instructions.h
index 0dc36225c7c6..48762e7b98be 100644
--- a/drivers/misc/sgi-gru/gru_instructions.h
+++ b/drivers/misc/sgi-gru/gru_instructions.h
@@ -26,7 +26,7 @@
26 * Architecture dependent functions 26 * Architecture dependent functions
27 */ 27 */
28 28
29#if defined CONFIG_IA64 29#if defined(CONFIG_IA64)
30#include <linux/compiler.h> 30#include <linux/compiler.h>
31#include <asm/intrinsics.h> 31#include <asm/intrinsics.h>
32#define __flush_cache(p) ia64_fc(p) 32#define __flush_cache(p) ia64_fc(p)
@@ -36,7 +36,7 @@
36 barrier(); \ 36 barrier(); \
37 *((volatile int *)(p)) = v; /* force st.rel */ \ 37 *((volatile int *)(p)) = v; /* force st.rel */ \
38 } while (0) 38 } while (0)
39#elif defined CONFIG_X86_64 39#elif defined(CONFIG_X86_64)
40#define __flush_cache(p) clflush(p) 40#define __flush_cache(p) clflush(p)
41#define gru_ordered_store_int(p,v) \ 41#define gru_ordered_store_int(p,v) \
42 do { \ 42 do { \
@@ -299,6 +299,7 @@ static inline void gru_flush_cache(void *p)
299static inline void gru_start_instruction(struct gru_instruction *ins, int op32) 299static inline void gru_start_instruction(struct gru_instruction *ins, int op32)
300{ 300{
301 gru_ordered_store_int(ins, op32); 301 gru_ordered_store_int(ins, op32);
302 gru_flush_cache(ins);
302} 303}
303 304
304 305
@@ -604,8 +605,9 @@ static inline int gru_get_cb_substatus(void *cb)
604static inline int gru_check_status(void *cb) 605static inline int gru_check_status(void *cb)
605{ 606{
606 struct gru_control_block_status *cbs = (void *)cb; 607 struct gru_control_block_status *cbs = (void *)cb;
607 int ret = cbs->istatus; 608 int ret;
608 609
610 ret = cbs->istatus;
609 if (ret == CBS_CALL_OS) 611 if (ret == CBS_CALL_OS)
610 ret = gru_check_status_proc(cb); 612 ret = gru_check_status_proc(cb);
611 return ret; 613 return ret;
@@ -617,7 +619,7 @@ static inline int gru_check_status(void *cb)
617static inline int gru_wait(void *cb) 619static inline int gru_wait(void *cb)
618{ 620{
619 struct gru_control_block_status *cbs = (void *)cb; 621 struct gru_control_block_status *cbs = (void *)cb;
620 int ret = cbs->istatus;; 622 int ret = cbs->istatus;
621 623
622 if (ret != CBS_IDLE) 624 if (ret != CBS_IDLE)
623 ret = gru_wait_proc(cb); 625 ret = gru_wait_proc(cb);
diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
index 3d33015bbf31..8c389d606c30 100644
--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -214,12 +214,14 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
214} 214}
215 215
216/* 216/*
217 *
218 * atomic_pte_lookup 217 * atomic_pte_lookup
219 * 218 *
220 * Convert a user virtual address to a physical address 219 * Convert a user virtual address to a physical address
221 * Only supports Intel large pages (2MB only) on x86_64. 220 * Only supports Intel large pages (2MB only) on x86_64.
222 * ZZZ - hugepage support is incomplete 221 * ZZZ - hugepage support is incomplete
222 *
223 * NOTE: mmap_sem is already held on entry to this function. This
224 * guarantees existence of the page tables.
223 */ 225 */
224static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr, 226static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
225 int write, unsigned long *paddr, int *pageshift) 227 int write, unsigned long *paddr, int *pageshift)
@@ -229,9 +231,6 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
229 pud_t *pudp; 231 pud_t *pudp;
230 pte_t pte; 232 pte_t pte;
231 233
232 WARN_ON(irqs_disabled()); /* ZZZ debug */
233
234 local_irq_disable();
235 pgdp = pgd_offset(vma->vm_mm, vaddr); 234 pgdp = pgd_offset(vma->vm_mm, vaddr);
236 if (unlikely(pgd_none(*pgdp))) 235 if (unlikely(pgd_none(*pgdp)))
237 goto err; 236 goto err;
@@ -250,8 +249,6 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
250#endif 249#endif
251 pte = *pte_offset_kernel(pmdp, vaddr); 250 pte = *pte_offset_kernel(pmdp, vaddr);
252 251
253 local_irq_enable();
254
255 if (unlikely(!pte_present(pte) || 252 if (unlikely(!pte_present(pte) ||
256 (write && (!pte_write(pte) || !pte_dirty(pte))))) 253 (write && (!pte_write(pte) || !pte_dirty(pte)))))
257 return 1; 254 return 1;
@@ -324,6 +321,7 @@ static int gru_try_dropin(struct gru_thread_state *gts,
324 * Atomic lookup is faster & usually works even if called in non-atomic 321 * Atomic lookup is faster & usually works even if called in non-atomic
325 * context. 322 * context.
326 */ 323 */
324 rmb(); /* Must/check ms_range_active before loading PTEs */
327 ret = atomic_pte_lookup(vma, vaddr, write, &paddr, &pageshift); 325 ret = atomic_pte_lookup(vma, vaddr, write, &paddr, &pageshift);
328 if (ret) { 326 if (ret) {
329 if (!cb) 327 if (!cb)
@@ -543,6 +541,7 @@ int gru_get_exception_detail(unsigned long arg)
543 ucbnum = get_cb_number((void *)excdet.cb); 541 ucbnum = get_cb_number((void *)excdet.cb);
544 cbrnum = thread_cbr_number(gts, ucbnum); 542 cbrnum = thread_cbr_number(gts, ucbnum);
545 cbe = get_cbe_by_index(gts->ts_gru, cbrnum); 543 cbe = get_cbe_by_index(gts->ts_gru, cbrnum);
544 prefetchw(cbe); /* Harmless on hardware, required for emulator */
546 excdet.opc = cbe->opccpy; 545 excdet.opc = cbe->opccpy;
547 excdet.exopc = cbe->exopccpy; 546 excdet.exopc = cbe->exopccpy;
548 excdet.ecause = cbe->ecause; 547 excdet.ecause = cbe->ecause;
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c
index d61cee796efd..5c027b6b4e5a 100644
--- a/drivers/misc/sgi-gru/grufile.c
+++ b/drivers/misc/sgi-gru/grufile.c
@@ -113,7 +113,7 @@ static int gru_file_mmap(struct file *file, struct vm_area_struct *vma)
113 return -EPERM; 113 return -EPERM;
114 114
115 if (vma->vm_start & (GRU_GSEG_PAGESIZE - 1) || 115 if (vma->vm_start & (GRU_GSEG_PAGESIZE - 1) ||
116 vma->vm_end & (GRU_GSEG_PAGESIZE - 1)) 116 vma->vm_end & (GRU_GSEG_PAGESIZE - 1))
117 return -EINVAL; 117 return -EINVAL;
118 118
119 vma->vm_flags |= 119 vma->vm_flags |=
@@ -398,6 +398,12 @@ static int __init gru_init(void)
398 irq = get_base_irq(); 398 irq = get_base_irq();
399 for (chip = 0; chip < GRU_CHIPLETS_PER_BLADE; chip++) { 399 for (chip = 0; chip < GRU_CHIPLETS_PER_BLADE; chip++) {
400 ret = request_irq(irq + chip, gru_intr, 0, id, NULL); 400 ret = request_irq(irq + chip, gru_intr, 0, id, NULL);
401 /* TODO: fix irq handling on x86. For now ignore failures because
402 * interrupts are not required & not yet fully supported */
403 if (ret) {
404 printk("!!!WARNING: GRU ignoring request failure!!!\n");
405 ret = 0;
406 }
401 if (ret) { 407 if (ret) {
402 printk(KERN_ERR "%s: request_irq failed\n", 408 printk(KERN_ERR "%s: request_irq failed\n",
403 GRU_DRIVER_ID_STR); 409 GRU_DRIVER_ID_STR);
diff --git a/drivers/misc/sgi-gru/gruhandles.h b/drivers/misc/sgi-gru/gruhandles.h
index d16031d62673..b63018d60fe1 100644
--- a/drivers/misc/sgi-gru/gruhandles.h
+++ b/drivers/misc/sgi-gru/gruhandles.h
@@ -91,12 +91,7 @@
91#define GSEGPOFF(h) ((h) & (GRU_SIZE - 1)) 91#define GSEGPOFF(h) ((h) & (GRU_SIZE - 1))
92 92
93/* Convert an arbitrary handle address to the beginning of the GRU segment */ 93/* Convert an arbitrary handle address to the beginning of the GRU segment */
94#ifndef __PLUGIN__
95#define GRUBASE(h) ((void *)((unsigned long)(h) & ~(GRU_SIZE - 1))) 94#define GRUBASE(h) ((void *)((unsigned long)(h) & ~(GRU_SIZE - 1)))
96#else
97extern void *gmu_grubase(void *h);
98#define GRUBASE(h) gmu_grubase(h)
99#endif
100 95
101/* General addressing macros. */ 96/* General addressing macros. */
102static inline void *get_gseg_base_address(void *base, int ctxnum) 97static inline void *get_gseg_base_address(void *base, int ctxnum)
diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
index dfd49af0fe18..880c55dfb662 100644
--- a/drivers/misc/sgi-gru/grukservices.c
+++ b/drivers/misc/sgi-gru/grukservices.c
@@ -122,6 +122,7 @@ int gru_get_cb_exception_detail(void *cb,
122 struct gru_control_block_extended *cbe; 122 struct gru_control_block_extended *cbe;
123 123
124 cbe = get_cbe(GRUBASE(cb), get_cb_number(cb)); 124 cbe = get_cbe(GRUBASE(cb), get_cb_number(cb));
125 prefetchw(cbe); /* Harmless on hardware, required for emulator */
125 excdet->opc = cbe->opccpy; 126 excdet->opc = cbe->opccpy;
126 excdet->exopc = cbe->exopccpy; 127 excdet->exopc = cbe->exopccpy;
127 excdet->ecause = cbe->ecause; 128 excdet->ecause = cbe->ecause;
@@ -466,7 +467,7 @@ int gru_send_message_gpa(unsigned long mq, void *mesg, unsigned int bytes)
466 STAT(mesq_send); 467 STAT(mesq_send);
467 BUG_ON(bytes < sizeof(int) || bytes > 2 * GRU_CACHE_LINE_BYTES); 468 BUG_ON(bytes < sizeof(int) || bytes > 2 * GRU_CACHE_LINE_BYTES);
468 469
469 clines = (bytes + GRU_CACHE_LINE_BYTES - 1) / GRU_CACHE_LINE_BYTES; 470 clines = DIV_ROUND_UP(bytes, GRU_CACHE_LINE_BYTES);
470 if (gru_get_cpu_resources(bytes, &cb, &dsr)) 471 if (gru_get_cpu_resources(bytes, &cb, &dsr))
471 return MQE_BUG_NO_RESOURCES; 472 return MQE_BUG_NO_RESOURCES;
472 memcpy(dsr, mesg, bytes); 473 memcpy(dsr, mesg, bytes);
diff --git a/drivers/misc/sgi-gru/grumain.c b/drivers/misc/sgi-gru/grumain.c
index 0eeb8dddd2f5..e11e1ac50900 100644
--- a/drivers/misc/sgi-gru/grumain.c
+++ b/drivers/misc/sgi-gru/grumain.c
@@ -432,29 +432,35 @@ static inline long gru_copy_handle(void *d, void *s)
432 return GRU_HANDLE_BYTES; 432 return GRU_HANDLE_BYTES;
433} 433}
434 434
435/* rewrite in assembly & use lots of prefetch */ 435static void gru_prefetch_context(void *gseg, void *cb, void *cbe, unsigned long cbrmap,
436static void gru_load_context_data(void *save, void *grubase, int ctxnum, 436 unsigned long length)
437 unsigned long cbrmap, unsigned long dsrmap)
438{ 437{
439 void *gseg, *cb, *cbe;
440 unsigned long length;
441 int i, scr; 438 int i, scr;
442 439
443 gseg = grubase + ctxnum * GRU_GSEG_STRIDE;
444 length = hweight64(dsrmap) * GRU_DSR_AU_BYTES;
445 prefetch_data(gseg + GRU_DS_BASE, length / GRU_CACHE_LINE_BYTES, 440 prefetch_data(gseg + GRU_DS_BASE, length / GRU_CACHE_LINE_BYTES,
446 GRU_CACHE_LINE_BYTES); 441 GRU_CACHE_LINE_BYTES);
447 442
448 cb = gseg + GRU_CB_BASE;
449 cbe = grubase + GRU_CBE_BASE;
450 for_each_cbr_in_allocation_map(i, &cbrmap, scr) { 443 for_each_cbr_in_allocation_map(i, &cbrmap, scr) {
451 prefetch_data(cb, 1, GRU_CACHE_LINE_BYTES); 444 prefetch_data(cb, 1, GRU_CACHE_LINE_BYTES);
452 prefetch_data(cbe + i * GRU_HANDLE_STRIDE, 1, 445 prefetch_data(cbe + i * GRU_HANDLE_STRIDE, 1,
453 GRU_CACHE_LINE_BYTES); 446 GRU_CACHE_LINE_BYTES);
454 cb += GRU_HANDLE_STRIDE; 447 cb += GRU_HANDLE_STRIDE;
455 } 448 }
449}
450
451static void gru_load_context_data(void *save, void *grubase, int ctxnum,
452 unsigned long cbrmap, unsigned long dsrmap)
453{
454 void *gseg, *cb, *cbe;
455 unsigned long length;
456 int i, scr;
456 457
458 gseg = grubase + ctxnum * GRU_GSEG_STRIDE;
457 cb = gseg + GRU_CB_BASE; 459 cb = gseg + GRU_CB_BASE;
460 cbe = grubase + GRU_CBE_BASE;
461 length = hweight64(dsrmap) * GRU_DSR_AU_BYTES;
462 gru_prefetch_context(gseg, cb, cbe, cbrmap, length);
463
458 for_each_cbr_in_allocation_map(i, &cbrmap, scr) { 464 for_each_cbr_in_allocation_map(i, &cbrmap, scr) {
459 save += gru_copy_handle(cb, save); 465 save += gru_copy_handle(cb, save);
460 save += gru_copy_handle(cbe + i * GRU_HANDLE_STRIDE, save); 466 save += gru_copy_handle(cbe + i * GRU_HANDLE_STRIDE, save);
@@ -472,15 +478,16 @@ static void gru_unload_context_data(void *save, void *grubase, int ctxnum,
472 int i, scr; 478 int i, scr;
473 479
474 gseg = grubase + ctxnum * GRU_GSEG_STRIDE; 480 gseg = grubase + ctxnum * GRU_GSEG_STRIDE;
475
476 cb = gseg + GRU_CB_BASE; 481 cb = gseg + GRU_CB_BASE;
477 cbe = grubase + GRU_CBE_BASE; 482 cbe = grubase + GRU_CBE_BASE;
483 length = hweight64(dsrmap) * GRU_DSR_AU_BYTES;
484 gru_prefetch_context(gseg, cb, cbe, cbrmap, length);
485
478 for_each_cbr_in_allocation_map(i, &cbrmap, scr) { 486 for_each_cbr_in_allocation_map(i, &cbrmap, scr) {
479 save += gru_copy_handle(save, cb); 487 save += gru_copy_handle(save, cb);
480 save += gru_copy_handle(save, cbe + i * GRU_HANDLE_STRIDE); 488 save += gru_copy_handle(save, cbe + i * GRU_HANDLE_STRIDE);
481 cb += GRU_HANDLE_STRIDE; 489 cb += GRU_HANDLE_STRIDE;
482 } 490 }
483 length = hweight64(dsrmap) * GRU_DSR_AU_BYTES;
484 memcpy(save, gseg + GRU_DS_BASE, length); 491 memcpy(save, gseg + GRU_DS_BASE, length);
485} 492}
486 493
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index c16028872bbb..1b9fc3c6b875 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -172,7 +172,7 @@ struct mmc_omap_host {
172 struct omap_mmc_platform_data *pdata; 172 struct omap_mmc_platform_data *pdata;
173}; 173};
174 174
175void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot) 175static void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot)
176{ 176{
177 unsigned long tick_ns; 177 unsigned long tick_ns;
178 178
@@ -182,7 +182,7 @@ void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot)
182 } 182 }
183} 183}
184 184
185void mmc_omap_fclk_enable(struct mmc_omap_host *host, unsigned int enable) 185static void mmc_omap_fclk_enable(struct mmc_omap_host *host, unsigned int enable)
186{ 186{
187 unsigned long flags; 187 unsigned long flags;
188 188
@@ -1455,7 +1455,9 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1455 1455
1456 host->irq = irq; 1456 host->irq = irq;
1457 host->phys_base = host->mem_res->start; 1457 host->phys_base = host->mem_res->start;
1458 host->virt_base = (void __iomem *) IO_ADDRESS(host->phys_base); 1458 host->virt_base = ioremap(res->start, res->end - res->start + 1);
1459 if (!host->virt_base)
1460 goto err_ioremap;
1459 1461
1460 if (cpu_is_omap24xx()) { 1462 if (cpu_is_omap24xx()) {
1461 host->iclk = clk_get(&pdev->dev, "mmc_ick"); 1463 host->iclk = clk_get(&pdev->dev, "mmc_ick");
@@ -1510,6 +1512,8 @@ err_free_iclk:
1510 clk_put(host->iclk); 1512 clk_put(host->iclk);
1511 } 1513 }
1512err_free_mmc_host: 1514err_free_mmc_host:
1515 iounmap(host->virt_base);
1516err_ioremap:
1513 kfree(host); 1517 kfree(host);
1514err_free_mem_region: 1518err_free_mem_region:
1515 release_mem_region(res->start, res->end - res->start + 1); 1519 release_mem_region(res->start, res->end - res->start + 1);
@@ -1536,6 +1540,7 @@ static int mmc_omap_remove(struct platform_device *pdev)
1536 if (host->fclk && !IS_ERR(host->fclk)) 1540 if (host->fclk && !IS_ERR(host->fclk))
1537 clk_put(host->fclk); 1541 clk_put(host->fclk);
1538 1542
1543 iounmap(host->virt_base);
1539 release_mem_region(pdev->resource[0].start, 1544 release_mem_region(pdev->resource[0].start,
1540 pdev->resource[0].end - pdev->resource[0].start + 1); 1545 pdev->resource[0].end - pdev->resource[0].start + 1);
1541 1546
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index e00d424e6575..1c74762dec89 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -26,13 +26,11 @@ static void mtd_notify_add(struct mtd_info* mtd)
26 if (!mtd) 26 if (!mtd)
27 return; 27 return;
28 28
29 device_create_drvdata(mtd_class, NULL, 29 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
30 MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 30 NULL, "mtd%d", mtd->index);
31 NULL, "mtd%d", mtd->index);
32 31
33 device_create_drvdata(mtd_class, NULL, 32 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
34 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 33 NULL, "mtd%dro", mtd->index);
35 NULL, "mtd%dro", mtd->index);
36} 34}
37 35
38static void mtd_notify_remove(struct mtd_info* mtd) 36static void mtd_notify_remove(struct mtd_info* mtd)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index edb90b58a9b1..9a06dc93ee0d 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -564,10 +564,8 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
564 564
565 for ( ; ret <= 0 && *types; types++) { 565 for ( ; ret <= 0 && *types; types++) {
566 parser = get_partition_parser(*types); 566 parser = get_partition_parser(*types);
567#ifdef CONFIG_KMOD
568 if (!parser && !request_module("%s", *types)) 567 if (!parser && !request_module("%s", *types))
569 parser = get_partition_parser(*types); 568 parser = get_partition_parser(*types);
570#endif
571 if (!parser) { 569 if (!parser) {
572 printk(KERN_NOTICE "%s partition parsing not available\n", 570 printk(KERN_NOTICE "%s partition parsing not available\n",
573 *types); 571 *types);
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 26d42987971f..782994ead0e8 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -145,7 +145,7 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd,
145 145
146static int ams_delta_nand_ready(struct mtd_info *mtd) 146static int ams_delta_nand_ready(struct mtd_info *mtd)
147{ 147{
148 return omap_get_gpio_datain(AMS_DELTA_GPIO_PIN_NAND_RB); 148 return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
149} 149}
150 150
151/* 151/*
@@ -185,7 +185,7 @@ static int __init ams_delta_init(void)
185 this->read_buf = ams_delta_read_buf; 185 this->read_buf = ams_delta_read_buf;
186 this->verify_buf = ams_delta_verify_buf; 186 this->verify_buf = ams_delta_verify_buf;
187 this->cmd_ctrl = ams_delta_hwcontrol; 187 this->cmd_ctrl = ams_delta_hwcontrol;
188 if (!omap_request_gpio(AMS_DELTA_GPIO_PIN_NAND_RB)) { 188 if (gpio_request(AMS_DELTA_GPIO_PIN_NAND_RB, "nand_rdy") == 0) {
189 this->dev_ready = ams_delta_nand_ready; 189 this->dev_ready = ams_delta_nand_ready;
190 } else { 190 } else {
191 this->dev_ready = NULL; 191 this->dev_ready = NULL;
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index b9d097c9f6bb..3a7bc524af33 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -40,7 +40,7 @@
40 v1.14 10/15/97 Avoided waiting..discard message for fast machines -djb 40 v1.14 10/15/97 Avoided waiting..discard message for fast machines -djb
41 v1.15 1/31/98 Faster recovery for Tx errors. -djb 41 v1.15 1/31/98 Faster recovery for Tx errors. -djb
42 v1.16 2/3/98 Different ID port handling to avoid sound cards. -djb 42 v1.16 2/3/98 Different ID port handling to avoid sound cards. -djb
43 v1.18 12Mar2001 Andrew Morton <andrewm@uow.edu.au> 43 v1.18 12Mar2001 Andrew Morton
44 - Avoid bogus detect of 3c590's (Andrzej Krzysztofowicz) 44 - Avoid bogus detect of 3c590's (Andrzej Krzysztofowicz)
45 - Reviewed against 1.18 from scyld.com 45 - Reviewed against 1.18 from scyld.com
46 v1.18a 17Nov2001 Jeff Garzik <jgarzik@pobox.com> 46 v1.18a 17Nov2001 Jeff Garzik <jgarzik@pobox.com>
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index a28de8182802..7107620f615d 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -36,8 +36,7 @@
36 36
37 Alan Cox : Removed 1.2 support, added 2.1 extra counters. 37 Alan Cox : Removed 1.2 support, added 2.1 extra counters.
38 38
39 Andrew Morton : andrewm@uow.edu.au 39 Andrew Morton : Kernel 2.3.48
40 : Kernel 2.3.48
41 : Handle kmalloc() failures 40 : Handle kmalloc() failures
42 : Other resource allocation fixes 41 : Other resource allocation fixes
43 : Add SMP locks 42 : Add SMP locks
@@ -49,7 +48,7 @@
49 : Fixed an out-of-mem bug in dma_rx() 48 : Fixed an out-of-mem bug in dma_rx()
50 : Updated Documentation/networking/cs89x0.txt 49 : Updated Documentation/networking/cs89x0.txt
51 50
52 Andrew Morton : andrewm@uow.edu.au / Kernel 2.3.99-pre1 51 Andrew Morton : Kernel 2.3.99-pre1
53 : Use skb_reserve to longword align IP header (two places) 52 : Use skb_reserve to longword align IP header (two places)
54 : Remove a delay loop from dma_rx() 53 : Remove a delay loop from dma_rx()
55 : Replace '100' with HZ 54 : Replace '100' with HZ
@@ -57,11 +56,11 @@
57 : Added 'cs89x0_dma=N' kernel boot option 56 : Added 'cs89x0_dma=N' kernel boot option
58 : Correctly initialise lp->lock in non-module compile 57 : Correctly initialise lp->lock in non-module compile
59 58
60 Andrew Morton : andrewm@uow.edu.au / Kernel 2.3.99-pre4-1 59 Andrew Morton : Kernel 2.3.99-pre4-1
61 : MOD_INC/DEC race fix (see 60 : MOD_INC/DEC race fix (see
62 : http://www.uwsg.indiana.edu/hypermail/linux/kernel/0003.3/1532.html) 61 : http://www.uwsg.indiana.edu/hypermail/linux/kernel/0003.3/1532.html)
63 62
64 Andrew Morton : andrewm@uow.edu.au / Kernel 2.4.0-test7-pre2 63 Andrew Morton : Kernel 2.4.0-test7-pre2
65 : Enhanced EEPROM support to cover more devices, 64 : Enhanced EEPROM support to cover more devices,
66 : abstracted IRQ mapping to support CONFIG_ARCH_CLPS7500 arch 65 : abstracted IRQ mapping to support CONFIG_ARCH_CLPS7500 arch
67 : (Jason Gunthorpe <jgg@ualberta.ca>) 66 : (Jason Gunthorpe <jgg@ualberta.ca>)
@@ -156,7 +155,7 @@
156#include "cs89x0.h" 155#include "cs89x0.h"
157 156
158static char version[] __initdata = 157static char version[] __initdata =
159"cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton <andrewm@uow.edu.au>\n"; 158"cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n";
160 159
161#define DRV_NAME "cs89x0" 160#define DRV_NAME "cs89x0"
162 161
@@ -1877,7 +1876,7 @@ MODULE_PARM_DESC(dmasize , "(ignored)");
1877MODULE_PARM_DESC(use_dma , "(ignored)"); 1876MODULE_PARM_DESC(use_dma , "(ignored)");
1878#endif 1877#endif
1879 1878
1880MODULE_AUTHOR("Mike Cruse, Russwll Nelson <nelson@crynwr.com>, Andrew Morton <andrewm@uow.edu.au>"); 1879MODULE_AUTHOR("Mike Cruse, Russwll Nelson <nelson@crynwr.com>, Andrew Morton");
1881MODULE_LICENSE("GPL"); 1880MODULE_LICENSE("GPL");
1882 1881
1883 1882
diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c
index 36030241f7a9..2a9930e6e2af 100644
--- a/drivers/net/irda/sir_dongle.c
+++ b/drivers/net/irda/sir_dongle.c
@@ -67,9 +67,7 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type)
67 const struct dongle_driver *drv = NULL; 67 const struct dongle_driver *drv = NULL;
68 int err = -EINVAL; 68 int err = -EINVAL;
69 69
70#ifdef CONFIG_KMOD
71 request_module("irda-dongle-%d", type); 70 request_module("irda-dongle-%d", type);
72#endif
73 71
74 if (dev->dongle_drv != NULL) 72 if (dev->dongle_drv != NULL)
75 return -EBUSY; 73 return -EBUSY;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f11e900b437b..e11b03b2b25a 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -309,11 +309,6 @@ void phy_disconnect(struct phy_device *phydev)
309} 309}
310EXPORT_SYMBOL(phy_disconnect); 310EXPORT_SYMBOL(phy_disconnect);
311 311
312static int phy_compare_id(struct device *dev, void *data)
313{
314 return strcmp((char *)data, dev->bus_id) ? 0 : 1;
315}
316
317/** 312/**
318 * phy_attach - attach a network device to a particular PHY device 313 * phy_attach - attach a network device to a particular PHY device
319 * @dev: network device to attach 314 * @dev: network device to attach
@@ -337,8 +332,7 @@ struct phy_device *phy_attach(struct net_device *dev,
337 332
338 /* Search the list of PHY devices on the mdio bus for the 333 /* Search the list of PHY devices on the mdio bus for the
339 * PHY with the requested name */ 334 * PHY with the requested name */
340 d = bus_find_device(bus, NULL, (void *)bus_id, phy_compare_id); 335 d = bus_find_device_by_name(bus, NULL, bus_id);
341
342 if (d) { 336 if (d) {
343 phydev = to_phy_device(d); 337 phydev = to_phy_device(d);
344 } else { 338 } else {
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 0ca0fcbb7c01..7e857e938adb 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -866,8 +866,8 @@ static int __init ppp_init(void)
866 err = PTR_ERR(ppp_class); 866 err = PTR_ERR(ppp_class);
867 goto out_chrdev; 867 goto out_chrdev;
868 } 868 }
869 device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), 869 device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL,
870 NULL, "ppp"); 870 "ppp");
871 } 871 }
872 872
873out: 873out:
@@ -2127,13 +2127,9 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2127 || ccp_option[1] < 2 || ccp_option[1] > data.length) 2127 || ccp_option[1] < 2 || ccp_option[1] > data.length)
2128 goto out; 2128 goto out;
2129 2129
2130 cp = find_compressor(ccp_option[0]); 2130 cp = try_then_request_module(
2131#ifdef CONFIG_KMOD 2131 find_compressor(ccp_option[0]),
2132 if (!cp) { 2132 "ppp-compress-%d", ccp_option[0]);
2133 request_module("ppp-compress-%d", ccp_option[0]);
2134 cp = find_compressor(ccp_option[0]);
2135 }
2136#endif /* CONFIG_KMOD */
2137 if (!cp) 2133 if (!cp)
2138 goto out; 2134 goto out;
2139 2135
diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c
index c6898c1fc54d..03aecc97fb45 100644
--- a/drivers/net/pppox.c
+++ b/drivers/net/pppox.c
@@ -115,13 +115,8 @@ static int pppox_create(struct net *net, struct socket *sock, int protocol)
115 goto out; 115 goto out;
116 116
117 rc = -EPROTONOSUPPORT; 117 rc = -EPROTONOSUPPORT;
118#ifdef CONFIG_KMOD 118 if (!pppox_protos[protocol])
119 if (!pppox_protos[protocol]) { 119 request_module("pppox-proto-%d", protocol);
120 char buffer[32];
121 sprintf(buffer, "pppox-proto-%d", protocol);
122 request_module(buffer);
123 }
124#endif
125 if (!pppox_protos[protocol] || 120 if (!pppox_protos[protocol] ||
126 !try_module_get(pppox_protos[protocol]->owner)) 121 !try_module_get(pppox_protos[protocol]->owner))
127 goto out; 122 goto out;
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index f14051556c87..7f97f8d08c39 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -388,8 +388,8 @@ static int __init cosa_init(void)
388 goto out_chrdev; 388 goto out_chrdev;
389 } 389 }
390 for (i = 0; i < nr_cards; i++) 390 for (i = 0; i < nr_cards; i++)
391 device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i), 391 device_create(cosa_class, NULL, MKDEV(cosa_major, i), NULL,
392 NULL, "cosa%d", i); 392 "cosa%d", i);
393 err = 0; 393 err = 0;
394 goto out; 394 goto out;
395 395
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 74726990d59e..f05f584ab7bc 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -1640,6 +1640,11 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
1640 return ret; 1640 return ret;
1641} 1641}
1642 1642
1643static int ath9k_no_fragmentation(struct ieee80211_hw *hw, u32 value)
1644{
1645 return -EOPNOTSUPP;
1646}
1647
1643static struct ieee80211_ops ath9k_ops = { 1648static struct ieee80211_ops ath9k_ops = {
1644 .tx = ath9k_tx, 1649 .tx = ath9k_tx,
1645 .start = ath9k_start, 1650 .start = ath9k_start,
@@ -1664,7 +1669,8 @@ static struct ieee80211_ops ath9k_ops = {
1664 .get_tsf = ath9k_get_tsf, 1669 .get_tsf = ath9k_get_tsf,
1665 .reset_tsf = ath9k_reset_tsf, 1670 .reset_tsf = ath9k_reset_tsf,
1666 .tx_last_beacon = NULL, 1671 .tx_last_beacon = NULL,
1667 .ampdu_action = ath9k_ampdu_action 1672 .ampdu_action = ath9k_ampdu_action,
1673 .set_frag_threshold = ath9k_no_fragmentation,
1668}; 1674};
1669 1675
1670static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1676static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index f6003e7996af..5155b8a760a7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -833,12 +833,12 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
833 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 833 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
834 case CSR_HW_REV_TYPE_5100: 834 case CSR_HW_REV_TYPE_5100:
835 case CSR_HW_REV_TYPE_5300: 835 case CSR_HW_REV_TYPE_5300:
836 /* 5X00 wants in Celsius */ 836 case CSR_HW_REV_TYPE_5350:
837 /* 5X00 and 5350 wants in Celsius */
837 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD; 838 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
838 break; 839 break;
839 case CSR_HW_REV_TYPE_5150: 840 case CSR_HW_REV_TYPE_5150:
840 case CSR_HW_REV_TYPE_5350: 841 /* 5150 wants in Kelvin */
841 /* 5X50 wants in Kelvin */
842 priv->hw_params.ct_kill_threshold = 842 priv->hw_params.ct_kill_threshold =
843 CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD); 843 CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
844 break; 844 break;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 93944de923ca..e2a58e477036 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -2422,7 +2422,7 @@ static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
2422 void *priv_sta) 2422 void *priv_sta)
2423{ 2423{
2424 struct iwl_lq_sta *lq_sta = priv_sta; 2424 struct iwl_lq_sta *lq_sta = priv_sta;
2425 struct iwl_priv *priv = priv_r; 2425 struct iwl_priv *priv __maybe_unused = priv_r;
2426 2426
2427 IWL_DEBUG_RATE("enter\n"); 2427 IWL_DEBUG_RATE("enter\n");
2428 kfree(lq_sta); 2428 kfree(lq_sta);
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index a912fb68c099..297696de2da0 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -823,7 +823,9 @@ int lbs_update_channel(struct lbs_private *priv)
823int lbs_set_channel(struct lbs_private *priv, u8 channel) 823int lbs_set_channel(struct lbs_private *priv, u8 channel)
824{ 824{
825 struct cmd_ds_802_11_rf_channel cmd; 825 struct cmd_ds_802_11_rf_channel cmd;
826#ifdef DEBUG
826 u8 old_channel = priv->curbssparams.channel; 827 u8 old_channel = priv->curbssparams.channel;
828#endif
827 int ret = 0; 829 int ret = 0;
828 830
829 lbs_deb_enter(LBS_DEB_CMD); 831 lbs_deb_enter(LBS_DEB_CMD);
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index c9e4a435b2fc..1a019e98dac3 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -533,11 +533,11 @@ static int __init init_mac80211_hwsim(void)
533 data = hw->priv; 533 data = hw->priv;
534 data->hw = hw; 534 data->hw = hw;
535 535
536 data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw, 536 data->dev = device_create(hwsim_class, NULL, 0, hw,
537 "hwsim%d", i); 537 "hwsim%d", i);
538 if (IS_ERR(data->dev)) { 538 if (IS_ERR(data->dev)) {
539 printk(KERN_DEBUG 539 printk(KERN_DEBUG
540 "mac80211_hwsim: device_create_drvdata " 540 "mac80211_hwsim: device_create "
541 "failed (%ld)\n", PTR_ERR(data->dev)); 541 "failed (%ld)\n", PTR_ERR(data->dev));
542 err = -ENOMEM; 542 err = -ENOMEM;
543 goto failed_drvdata; 543 goto failed_drvdata;
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index e585684e59a0..6fcf2bda7cdf 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -378,6 +378,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
378 struct orinoco_private *priv = netdev_priv(dev); 378 struct orinoco_private *priv = netdev_priv(dev);
379 struct orinoco_pccard *card = priv->card; 379 struct orinoco_pccard *card = priv->card;
380 int err = 0; 380 int err = 0;
381 unsigned long flags;
381 382
382 if (! test_bit(0, &card->hard_reset_in_progress)) { 383 if (! test_bit(0, &card->hard_reset_in_progress)) {
383 err = orinoco_reinit_firmware(dev); 384 err = orinoco_reinit_firmware(dev);
@@ -387,7 +388,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
387 return -EIO; 388 return -EIO;
388 } 389 }
389 390
390 spin_lock(&priv->lock); 391 spin_lock_irqsave(&priv->lock, flags);
391 392
392 netif_device_attach(dev); 393 netif_device_attach(dev);
393 priv->hw_unavailable--; 394 priv->hw_unavailable--;
@@ -399,7 +400,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
399 dev->name, err); 400 dev->name, err);
400 } 401 }
401 402
402 spin_unlock(&priv->lock); 403 spin_unlock_irqrestore(&priv->lock, flags);
403 } 404 }
404 405
405 return err; 406 return err;
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 1994aa199d37..117c7d3a52b0 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -479,7 +479,6 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
479 printk(KERN_ERR "p54: eeprom parse failed!\n"); 479 printk(KERN_ERR "p54: eeprom parse failed!\n");
480 return err; 480 return err;
481} 481}
482EXPORT_SYMBOL_GPL(p54_parse_eeprom);
483 482
484static int p54_rssi_to_dbm(struct ieee80211_hw *dev, int rssi) 483static int p54_rssi_to_dbm(struct ieee80211_hw *dev, int rssi)
485{ 484{
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index 1912f5e9a0a9..75d749bccb0d 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -39,6 +39,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
39 {USB_DEVICE(0x0846, 0x4200)}, /* Netgear WG121 */ 39 {USB_DEVICE(0x0846, 0x4200)}, /* Netgear WG121 */
40 {USB_DEVICE(0x0846, 0x4210)}, /* Netgear WG121 the second ? */ 40 {USB_DEVICE(0x0846, 0x4210)}, /* Netgear WG121 the second ? */
41 {USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */ 41 {USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */
42 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */
42 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion 40900, Roper Europe */ 43 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion 40900, Roper Europe */
43 {USB_DEVICE(0x124a, 0x4023)}, /* Shuttle PN15, Airvast WM168g, IOGear GWU513 */ 44 {USB_DEVICE(0x124a, 0x4023)}, /* Shuttle PN15, Airvast WM168g, IOGear GWU513 */
44 {USB_DEVICE(0x1915, 0x2234)}, /* Linksys WUSB54G OEM */ 45 {USB_DEVICE(0x1915, 0x2234)}, /* Linksys WUSB54G OEM */
@@ -63,8 +64,8 @@ static struct usb_device_id p54u_table[] __devinitdata = {
63 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion MD40900 */ 64 {USB_DEVICE(0x0cde, 0x0006)}, /* Medion MD40900 */
64 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */ 65 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */
65 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */ 66 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */
66 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */
67 {USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */ 67 {USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */
68 {USB_DEVICE(0x1260, 0xee22)}, /* SMC 2862W-G version 2 */
68 {USB_DEVICE(0x13b1, 0x000a)}, /* Linksys WUSB54G ver 2 */ 69 {USB_DEVICE(0x13b1, 0x000a)}, /* Linksys WUSB54G ver 2 */
69 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */ 70 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
70 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */ 71 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 1676ac484790..451d410ecdae 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -374,7 +374,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
374 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); 374 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
375 struct txentry_desc txdesc; 375 struct txentry_desc txdesc;
376 struct skb_frame_desc *skbdesc; 376 struct skb_frame_desc *skbdesc;
377 unsigned int iv_len; 377 unsigned int iv_len = 0;
378 378
379 if (unlikely(rt2x00queue_full(queue))) 379 if (unlikely(rt2x00queue_full(queue)))
380 return -EINVAL; 380 return -EINVAL;
@@ -395,6 +395,9 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
395 entry->skb = skb; 395 entry->skb = skb;
396 rt2x00queue_create_tx_descriptor(entry, &txdesc); 396 rt2x00queue_create_tx_descriptor(entry, &txdesc);
397 397
398 if (IEEE80211_SKB_CB(skb)->control.hw_key != NULL)
399 iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len;
400
398 /* 401 /*
399 * All information is retreived from the skb->cb array, 402 * All information is retreived from the skb->cb array,
400 * now we should claim ownership of the driver part of that 403 * now we should claim ownership of the driver part of that
@@ -410,9 +413,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
410 * the frame so we can provide it to the driver seperately. 413 * the frame so we can provide it to the driver seperately.
411 */ 414 */
412 if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) && 415 if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) &&
413 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags) && 416 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags)) {
414 (IEEE80211_SKB_CB(skb)->control.hw_key != NULL)) {
415 iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len;
416 rt2x00crypto_tx_remove_iv(skb, iv_len); 417 rt2x00crypto_tx_remove_iv(skb, iv_len);
417 } 418 }
418 419
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index e9902613e2ee..431e3c78bf27 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -33,10 +33,13 @@ MODULE_LICENSE("GPL");
33static struct usb_device_id rtl8187_table[] __devinitdata = { 33static struct usb_device_id rtl8187_table[] __devinitdata = {
34 /* Asus */ 34 /* Asus */
35 {USB_DEVICE(0x0b05, 0x171d), .driver_info = DEVICE_RTL8187}, 35 {USB_DEVICE(0x0b05, 0x171d), .driver_info = DEVICE_RTL8187},
36 /* Belkin */
37 {USB_DEVICE(0x050d, 0x705e), .driver_info = DEVICE_RTL8187B},
36 /* Realtek */ 38 /* Realtek */
37 {USB_DEVICE(0x0bda, 0x8187), .driver_info = DEVICE_RTL8187}, 39 {USB_DEVICE(0x0bda, 0x8187), .driver_info = DEVICE_RTL8187},
38 {USB_DEVICE(0x0bda, 0x8189), .driver_info = DEVICE_RTL8187B}, 40 {USB_DEVICE(0x0bda, 0x8189), .driver_info = DEVICE_RTL8187B},
39 {USB_DEVICE(0x0bda, 0x8197), .driver_info = DEVICE_RTL8187B}, 41 {USB_DEVICE(0x0bda, 0x8197), .driver_info = DEVICE_RTL8187B},
42 {USB_DEVICE(0x0bda, 0x8198), .driver_info = DEVICE_RTL8187B},
40 /* Netgear */ 43 /* Netgear */
41 {USB_DEVICE(0x0846, 0x6100), .driver_info = DEVICE_RTL8187}, 44 {USB_DEVICE(0x0846, 0x6100), .driver_info = DEVICE_RTL8187},
42 {USB_DEVICE(0x0846, 0x6a00), .driver_info = DEVICE_RTL8187}, 45 {USB_DEVICE(0x0846, 0x6a00), .driver_info = DEVICE_RTL8187},
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index b0c71c3be467..852789ad34b3 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -426,10 +426,11 @@ spectrum_cs_suspend(struct pcmcia_device *link)
426{ 426{
427 struct net_device *dev = link->priv; 427 struct net_device *dev = link->priv;
428 struct orinoco_private *priv = netdev_priv(dev); 428 struct orinoco_private *priv = netdev_priv(dev);
429 unsigned long flags;
429 int err = 0; 430 int err = 0;
430 431
431 /* Mark the device as stopped, to block IO until later */ 432 /* Mark the device as stopped, to block IO until later */
432 spin_lock(&priv->lock); 433 spin_lock_irqsave(&priv->lock, flags);
433 434
434 err = __orinoco_down(dev); 435 err = __orinoco_down(dev);
435 if (err) 436 if (err)
@@ -439,7 +440,7 @@ spectrum_cs_suspend(struct pcmcia_device *link)
439 netif_device_detach(dev); 440 netif_device_detach(dev);
440 priv->hw_unavailable++; 441 priv->hw_unavailable++;
441 442
442 spin_unlock(&priv->lock); 443 spin_unlock_irqrestore(&priv->lock, flags);
443 444
444 return err; 445 return err;
445} 446}
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 3c3dd403f5dd..5c7a87e38951 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -471,7 +471,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
471 unsigned int offset = offset_in_page(data); 471 unsigned int offset = offset_in_page(data);
472 unsigned int len = skb_headlen(skb); 472 unsigned int len = skb_headlen(skb);
473 473
474 frags += (offset + len + PAGE_SIZE - 1) / PAGE_SIZE; 474 frags += DIV_ROUND_UP(offset + len, PAGE_SIZE);
475 if (unlikely(frags > MAX_SKB_FRAGS + 1)) { 475 if (unlikely(frags > MAX_SKB_FRAGS + 1)) {
476 printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n", 476 printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n",
477 frags); 477 frags);
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 2f047e573d86..f5f75844954c 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -126,7 +126,7 @@ static void nubus_advance(unsigned char **ptr, int len, int map)
126 { 126 {
127 while(not_useful(p,map)) 127 while(not_useful(p,map))
128 p++; 128 p++;
129 p++; 129 p++;
130 len--; 130 len--;
131 } 131 }
132 *ptr = p; 132 *ptr = p;
diff --git a/drivers/parport/ChangeLog b/drivers/parport/ChangeLog
index db717c1d62a5..8565bbbeb6ec 100644
--- a/drivers/parport/ChangeLog
+++ b/drivers/parport/ChangeLog
@@ -311,7 +311,7 @@
311 * ieee1284_ops.c (parport_ieee1284_read_nibble): Reset nAutoFd 311 * ieee1284_ops.c (parport_ieee1284_read_nibble): Reset nAutoFd
312 on timeout. Matches 2.2.x behaviour. 312 on timeout. Matches 2.2.x behaviour.
313 313
3142001-03-02 Andrew Morton <andrewm@uow.edu.au> 3142001-03-02 Andrew Morton
315 315
316 * parport_pc.c (registered_parport): New static variable. 316 * parport_pc.c (registered_parport): New static variable.
317 (parport_pc_find_ports): Set it when we register PCI driver. 317 (parport_pc_find_ports): Set it when we register PCI driver.
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index e97059415ab4..ac2a805ac7ea 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -1,4 +1,4 @@
1/* $Id: parport_ieee1284.c,v 1.4 1997/10/19 21:37:21 philip Exp $ 1/*
2 * IEEE-1284 implementation for parport. 2 * IEEE-1284 implementation for parport.
3 * 3 *
4 * Authors: Phil Blundell <philb@gnu.org> 4 * Authors: Phil Blundell <philb@gnu.org>
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index cd565bb4e1a9..0f6550719bcf 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -1,4 +1,4 @@
1/* $Id: parport_probe.c,v 1.1 1999/07/03 08:56:17 davem Exp $ 1/*
2 * Parallel port device probing code 2 * Parallel port device probing code
3 * 3 *
4 * Authors: Carsten Gross, carsten@sol.wohnheim.uni-ulm.de 4 * Authors: Carsten Gross, carsten@sol.wohnheim.uni-ulm.de
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index a8a62bbbb576..0ebca450ed29 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -1,4 +1,4 @@
1/* $Id: parport_share.c,v 1.15 1998/01/11 12:06:17 philip Exp $ 1/*
2 * Parallel-port resource manager code. 2 * Parallel-port resource manager code.
3 * 3 *
4 * Authors: David Campbell <campbell@tirian.che.curtin.edu.au> 4 * Authors: David Campbell <campbell@tirian.che.curtin.edu.au>
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index bd2c01674f5e..e842e756308a 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -28,9 +28,9 @@
28 28
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/dmar.h> 30#include <linux/dmar.h>
31#include <linux/iova.h>
32#include <linux/intel-iommu.h>
31#include <linux/timer.h> 33#include <linux/timer.h>
32#include "iova.h"
33#include "intel-iommu.h"
34 34
35#undef PREFIX 35#undef PREFIX
36#define PREFIX "DMAR:" 36#define PREFIX "DMAR:"
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 8467d0287325..7d27631e6e62 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -276,7 +276,7 @@ int __init ibmphp_access_ebda (void)
276 iounmap (io_mem); 276 iounmap (io_mem);
277 debug ("returned ebda segment: %x\n", ebda_seg); 277 debug ("returned ebda segment: %x\n", ebda_seg);
278 278
279 io_mem = ioremap (ebda_seg<<4, 65000); 279 io_mem = ioremap(ebda_seg<<4, 1024);
280 if (!io_mem ) 280 if (!io_mem )
281 return -ENOMEM; 281 return -ENOMEM;
282 next_offset = 0x180; 282 next_offset = 0x180;
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 389fdd6f4a9f..fc5f2dbf5323 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -33,8 +33,8 @@
33#include <linux/dma-mapping.h> 33#include <linux/dma-mapping.h>
34#include <linux/mempool.h> 34#include <linux/mempool.h>
35#include <linux/timer.h> 35#include <linux/timer.h>
36#include "iova.h" 36#include <linux/iova.h>
37#include "intel-iommu.h" 37#include <linux/intel-iommu.h>
38#include <asm/proto.h> /* force_iommu in this header in x86-64*/ 38#include <asm/proto.h> /* force_iommu in this header in x86-64*/
39#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
40#include <asm/iommu.h> 40#include <asm/iommu.h>
@@ -156,7 +156,7 @@ static inline void *alloc_domain_mem(void)
156 return iommu_kmem_cache_alloc(iommu_domain_cache); 156 return iommu_kmem_cache_alloc(iommu_domain_cache);
157} 157}
158 158
159static inline void free_domain_mem(void *vaddr) 159static void free_domain_mem(void *vaddr)
160{ 160{
161 kmem_cache_free(iommu_domain_cache, vaddr); 161 kmem_cache_free(iommu_domain_cache, vaddr);
162} 162}
@@ -1341,7 +1341,7 @@ static void domain_remove_dev_info(struct dmar_domain *domain)
1341 * find_domain 1341 * find_domain
1342 * Note: we use struct pci_dev->dev.archdata.iommu stores the info 1342 * Note: we use struct pci_dev->dev.archdata.iommu stores the info
1343 */ 1343 */
1344struct dmar_domain * 1344static struct dmar_domain *
1345find_domain(struct pci_dev *pdev) 1345find_domain(struct pci_dev *pdev)
1346{ 1346{
1347 struct device_domain_info *info; 1347 struct device_domain_info *info;
@@ -2318,3 +2318,111 @@ int __init intel_iommu_init(void)
2318 return 0; 2318 return 0;
2319} 2319}
2320 2320
2321void intel_iommu_domain_exit(struct dmar_domain *domain)
2322{
2323 u64 end;
2324
2325 /* Domain 0 is reserved, so dont process it */
2326 if (!domain)
2327 return;
2328
2329 end = DOMAIN_MAX_ADDR(domain->gaw);
2330 end = end & (~PAGE_MASK_4K);
2331
2332 /* clear ptes */
2333 dma_pte_clear_range(domain, 0, end);
2334
2335 /* free page tables */
2336 dma_pte_free_pagetable(domain, 0, end);
2337
2338 iommu_free_domain(domain);
2339 free_domain_mem(domain);
2340}
2341EXPORT_SYMBOL_GPL(intel_iommu_domain_exit);
2342
2343struct dmar_domain *intel_iommu_domain_alloc(struct pci_dev *pdev)
2344{
2345 struct dmar_drhd_unit *drhd;
2346 struct dmar_domain *domain;
2347 struct intel_iommu *iommu;
2348
2349 drhd = dmar_find_matched_drhd_unit(pdev);
2350 if (!drhd) {
2351 printk(KERN_ERR "intel_iommu_domain_alloc: drhd == NULL\n");
2352 return NULL;
2353 }
2354
2355 iommu = drhd->iommu;
2356 if (!iommu) {
2357 printk(KERN_ERR
2358 "intel_iommu_domain_alloc: iommu == NULL\n");
2359 return NULL;
2360 }
2361 domain = iommu_alloc_domain(iommu);
2362 if (!domain) {
2363 printk(KERN_ERR
2364 "intel_iommu_domain_alloc: domain == NULL\n");
2365 return NULL;
2366 }
2367 if (domain_init(domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) {
2368 printk(KERN_ERR
2369 "intel_iommu_domain_alloc: domain_init() failed\n");
2370 intel_iommu_domain_exit(domain);
2371 return NULL;
2372 }
2373 return domain;
2374}
2375EXPORT_SYMBOL_GPL(intel_iommu_domain_alloc);
2376
2377int intel_iommu_context_mapping(
2378 struct dmar_domain *domain, struct pci_dev *pdev)
2379{
2380 int rc;
2381 rc = domain_context_mapping(domain, pdev);
2382 return rc;
2383}
2384EXPORT_SYMBOL_GPL(intel_iommu_context_mapping);
2385
2386int intel_iommu_page_mapping(
2387 struct dmar_domain *domain, dma_addr_t iova,
2388 u64 hpa, size_t size, int prot)
2389{
2390 int rc;
2391 rc = domain_page_mapping(domain, iova, hpa, size, prot);
2392 return rc;
2393}
2394EXPORT_SYMBOL_GPL(intel_iommu_page_mapping);
2395
2396void intel_iommu_detach_dev(struct dmar_domain *domain, u8 bus, u8 devfn)
2397{
2398 detach_domain_for_dev(domain, bus, devfn);
2399}
2400EXPORT_SYMBOL_GPL(intel_iommu_detach_dev);
2401
2402struct dmar_domain *
2403intel_iommu_find_domain(struct pci_dev *pdev)
2404{
2405 return find_domain(pdev);
2406}
2407EXPORT_SYMBOL_GPL(intel_iommu_find_domain);
2408
2409int intel_iommu_found(void)
2410{
2411 return g_num_of_iommus;
2412}
2413EXPORT_SYMBOL_GPL(intel_iommu_found);
2414
2415u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova)
2416{
2417 struct dma_pte *pte;
2418 u64 pfn;
2419
2420 pfn = 0;
2421 pte = addr_to_dma_pte(domain, iova);
2422
2423 if (pte)
2424 pfn = dma_pte_addr(*pte);
2425
2426 return pfn >> PAGE_SHIFT_4K;
2427}
2428EXPORT_SYMBOL_GPL(intel_iommu_iova_to_pfn);
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c
index bb642cc5e18c..738d4c89581c 100644
--- a/drivers/pci/intr_remapping.c
+++ b/drivers/pci/intr_remapping.c
@@ -4,7 +4,7 @@
4#include <linux/pci.h> 4#include <linux/pci.h>
5#include <linux/irq.h> 5#include <linux/irq.h>
6#include <asm/io_apic.h> 6#include <asm/io_apic.h>
7#include "intel-iommu.h" 7#include <linux/intel-iommu.h>
8#include "intr_remapping.h" 8#include "intr_remapping.h"
9 9
10static struct ioapic_scope ir_ioapic[MAX_IO_APICS]; 10static struct ioapic_scope ir_ioapic[MAX_IO_APICS];
diff --git a/drivers/pci/intr_remapping.h b/drivers/pci/intr_remapping.h
index 05f2635bbe4e..ca48f0df8ac9 100644
--- a/drivers/pci/intr_remapping.h
+++ b/drivers/pci/intr_remapping.h
@@ -1,4 +1,4 @@
1#include "intel-iommu.h" 1#include <linux/intel-iommu.h>
2 2
3struct ioapic_scope { 3struct ioapic_scope {
4 struct intel_iommu *iommu; 4 struct intel_iommu *iommu;
diff --git a/drivers/pci/iova.c b/drivers/pci/iova.c
index 3ef4ac064315..2287116e9822 100644
--- a/drivers/pci/iova.c
+++ b/drivers/pci/iova.c
@@ -7,7 +7,7 @@
7 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 */ 8 */
9 9
10#include "iova.h" 10#include <linux/iova.h>
11 11
12void 12void
13init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit) 13init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 36698e57b97f..dd9161a054e1 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1237,8 +1237,11 @@ EXPORT_SYMBOL(pci_scan_bridge);
1237EXPORT_SYMBOL_GPL(pci_scan_child_bus); 1237EXPORT_SYMBOL_GPL(pci_scan_child_bus);
1238#endif 1238#endif
1239 1239
1240static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b) 1240static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)
1241{ 1241{
1242 const struct pci_dev *a = to_pci_dev(d_a);
1243 const struct pci_dev *b = to_pci_dev(d_b);
1244
1242 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1; 1245 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1;
1243 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1; 1246 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1;
1244 1247
@@ -1251,50 +1254,7 @@ static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev
1251 return 0; 1254 return 0;
1252} 1255}
1253 1256
1254/*
1255 * Yes, this forcably breaks the klist abstraction temporarily. It
1256 * just wants to sort the klist, not change reference counts and
1257 * take/drop locks rapidly in the process. It does all this while
1258 * holding the lock for the list, so objects can't otherwise be
1259 * added/removed while we're swizzling.
1260 */
1261static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list)
1262{
1263 struct list_head *pos;
1264 struct klist_node *n;
1265 struct device *dev;
1266 struct pci_dev *b;
1267
1268 list_for_each(pos, list) {
1269 n = container_of(pos, struct klist_node, n_node);
1270 dev = container_of(n, struct device, knode_bus);
1271 b = to_pci_dev(dev);
1272 if (pci_sort_bf_cmp(a, b) <= 0) {
1273 list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node);
1274 return;
1275 }
1276 }
1277 list_move_tail(&a->dev.knode_bus.n_node, list);
1278}
1279
1280void __init pci_sort_breadthfirst(void) 1257void __init pci_sort_breadthfirst(void)
1281{ 1258{
1282 LIST_HEAD(sorted_devices); 1259 bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp);
1283 struct list_head *pos, *tmp;
1284 struct klist_node *n;
1285 struct device *dev;
1286 struct pci_dev *pdev;
1287 struct klist *device_klist;
1288
1289 device_klist = bus_get_device_klist(&pci_bus_type);
1290
1291 spin_lock(&device_klist->k_lock);
1292 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1293 n = container_of(pos, struct klist_node, n_node);
1294 dev = container_of(n, struct device, knode_bus);
1295 pdev = to_pci_dev(dev);
1296 pci_insertion_sort_klist(pdev, &sorted_devices);
1297 }
1298 list_splice(&sorted_devices, &device_klist->k_list);
1299 spin_unlock(&device_klist->k_lock);
1300} 1260}
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 9236e7f869c8..e872ac925b4b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1561,8 +1561,7 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_f
1561 if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) && 1561 if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) &&
1562 (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { 1562 (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
1563#ifdef DEBUG 1563#ifdef DEBUG
1564 dev_dbg(&dev->dev, "calling "); 1564 dev_dbg(&dev->dev, "calling %pF\n", f->hook);
1565 print_fn_descriptor_symbol("%s\n", f->hook);
1566#endif 1565#endif
1567 f->hook(dev); 1566 f->hook(dev);
1568 } 1567 }
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 3abbfad9ddab..d5e2106760f8 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -378,11 +378,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
378 align = 0; 378 align = 0;
379 min_align = 0; 379 min_align = 0;
380 for (order = 0; order <= max_order; order++) { 380 for (order = 0; order <= max_order; order++) {
381#ifdef CONFIG_RESOURCES_64BIT 381 resource_size_t align1 = 1;
382 resource_size_t align1 = 1ULL << (order + 20); 382
383#else 383 align1 <<= (order + 20);
384 resource_size_t align1 = 1U << (order + 20); 384
385#endif
386 if (!align) 385 if (!align)
387 min_align = align1; 386 min_align = align1;
388 else if (ALIGN(align + min_align, min_align) < align1) 387 else if (ALIGN(align + min_align, min_align) < align1)
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 74d1c906c5d6..b46c60b72708 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -64,10 +64,11 @@ sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o
64sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o 64sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o
65 65
66pxa2xx_lubbock_cs-y += pxa2xx_lubbock.o sa1111_generic.o 66pxa2xx_lubbock_cs-y += pxa2xx_lubbock.o sa1111_generic.o
67pxa2xx_cm_x2xx_cs-y += pxa2xx_cm_x2xx.o pxa2xx_cm_x255.o pxa2xx_cm_x270.o
67pxa2xx-obj-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock_cs.o 68pxa2xx-obj-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock_cs.o
68pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o 69pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o
69pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o 70pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o
70pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx.o pxa2xx_cm_x255.o pxa2xx_cm_x270.o 71pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx_cs.o
71pxa2xx-obj-$(CONFIG_ARCH_VIPER) += pxa2xx_viper.o 72pxa2xx-obj-$(CONFIG_ARCH_VIPER) += pxa2xx_viper.o
72pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps.o 73pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps.o
73pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o 74pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 9fd7bb9b7dce..3b8b9d3cb03d 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6extern spinlock_t pnp_lock; 6extern spinlock_t pnp_lock;
7extern struct device_attribute pnp_interface_attrs[];
7void *pnp_alloc(long size); 8void *pnp_alloc(long size);
8 9
9int pnp_register_protocol(struct pnp_protocol *protocol); 10int pnp_register_protocol(struct pnp_protocol *protocol);
@@ -16,7 +17,6 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
16 17
17int pnp_add_device(struct pnp_dev *dev); 18int pnp_add_device(struct pnp_dev *dev);
18struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); 19struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
19int pnp_interface_attach_device(struct pnp_dev *dev);
20 20
21int pnp_add_card(struct pnp_card *card); 21int pnp_add_card(struct pnp_card *card);
22void pnp_remove_card(struct pnp_card *card); 22void pnp_remove_card(struct pnp_card *card);
@@ -147,7 +147,7 @@ char *pnp_resource_type_name(struct resource *res);
147void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc); 147void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
148 148
149void pnp_free_resources(struct pnp_dev *dev); 149void pnp_free_resources(struct pnp_dev *dev);
150int pnp_resource_type(struct resource *res); 150unsigned long pnp_resource_type(struct resource *res);
151 151
152struct pnp_resource { 152struct pnp_resource {
153 struct list_head list; 153 struct list_head list;
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index a411582bcd72..817fe626e15b 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
159 159
160int __pnp_add_device(struct pnp_dev *dev) 160int __pnp_add_device(struct pnp_dev *dev)
161{ 161{
162 int ret;
163
164 pnp_fixup_device(dev); 162 pnp_fixup_device(dev);
165 dev->status = PNP_READY; 163 dev->status = PNP_READY;
166 spin_lock(&pnp_lock); 164 spin_lock(&pnp_lock);
167 list_add_tail(&dev->global_list, &pnp_global); 165 list_add_tail(&dev->global_list, &pnp_global);
168 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 166 list_add_tail(&dev->protocol_list, &dev->protocol->devices);
169 spin_unlock(&pnp_lock); 167 spin_unlock(&pnp_lock);
170 168 return device_register(&dev->dev);
171 ret = device_register(&dev->dev);
172 if (ret)
173 return ret;
174
175 pnp_interface_attach_device(dev);
176 return 0;
177} 169}
178 170
179/* 171/*
@@ -218,7 +210,6 @@ void __pnp_remove_device(struct pnp_dev *dev)
218 210
219static int __init pnp_init(void) 211static int __init pnp_init(void)
220{ 212{
221 printk(KERN_INFO "Linux Plug and Play Support v0.97 (c) Adam Belay\n");
222 return bus_register(&pnp_bus_type); 213 return bus_register(&pnp_bus_type);
223} 214}
224 215
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index d3f869ee1d92..e3f7e89c4dfb 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = {
206 .remove = pnp_device_remove, 206 .remove = pnp_device_remove,
207 .suspend = pnp_bus_suspend, 207 .suspend = pnp_bus_suspend,
208 .resume = pnp_bus_resume, 208 .resume = pnp_bus_resume,
209 .dev_attrs = pnp_interface_attrs,
209}; 210};
210 211
211int pnp_register_driver(struct pnp_driver *drv) 212int pnp_register_driver(struct pnp_driver *drv)
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index a876ecf7028c..478a4a739c00 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev,
243 return ret; 243 return ret;
244} 244}
245 245
246static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
247
248static ssize_t pnp_show_current_resources(struct device *dmdev, 246static ssize_t pnp_show_current_resources(struct device *dmdev,
249 struct device_attribute *attr, 247 struct device_attribute *attr,
250 char *buf) 248 char *buf)
@@ -420,9 +418,6 @@ done:
420 return count; 418 return count;
421} 419}
422 420
423static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR,
424 pnp_show_current_resources, pnp_set_current_resources);
425
426static ssize_t pnp_show_current_ids(struct device *dmdev, 421static ssize_t pnp_show_current_ids(struct device *dmdev,
427 struct device_attribute *attr, char *buf) 422 struct device_attribute *attr, char *buf)
428{ 423{
@@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev,
437 return (str - buf); 432 return (str - buf);
438} 433}
439 434
440static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); 435struct device_attribute pnp_interface_attrs[] = {
441 436 __ATTR(resources, S_IRUGO | S_IWUSR,
442int pnp_interface_attach_device(struct pnp_dev *dev) 437 pnp_show_current_resources,
443{ 438 pnp_set_current_resources),
444 int rc = device_create_file(&dev->dev, &dev_attr_options); 439 __ATTR(options, S_IRUGO, pnp_show_options, NULL),
445 440 __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
446 if (rc) 441 __ATTR_NULL,
447 goto err; 442};
448 rc = device_create_file(&dev->dev, &dev_attr_resources);
449 if (rc)
450 goto err_opt;
451 rc = device_create_file(&dev->dev, &dev_attr_id);
452 if (rc)
453 goto err_res;
454
455 return 0;
456
457err_res:
458 device_remove_file(&dev->dev, &dev_attr_resources);
459err_opt:
460 device_remove_file(&dev->dev, &dev_attr_options);
461err:
462 return rc;
463}
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index 0bdf9b8a5e58..c144bd575611 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -245,7 +245,7 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
245 */ 245 */
246 for_each_pci_dev(pdev) { 246 for_each_pci_dev(pdev) {
247 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 247 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
248 unsigned int type; 248 unsigned long type;
249 249
250 type = pci_resource_flags(pdev, i) & 250 type = pci_resource_flags(pdev, i) &
251 (IORESOURCE_IO | IORESOURCE_MEM); 251 (IORESOURCE_IO | IORESOURCE_MEM);
@@ -338,8 +338,7 @@ void pnp_fixup_device(struct pnp_dev *dev)
338 if (!compare_pnp_id(dev->id, f->id)) 338 if (!compare_pnp_id(dev->id, f->id))
339 continue; 339 continue;
340#ifdef DEBUG 340#ifdef DEBUG
341 dev_dbg(&dev->dev, "%s: calling ", f->id); 341 dev_dbg(&dev->dev, "%s: calling %pF\n", f->id, f->quirk_function);
342 print_fn_descriptor_symbol("%s\n", f->quirk_function);
343#endif 342#endif
344 f->quirk_function(dev); 343 f->quirk_function(dev);
345 } 344 }
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 4cfe3a1efdfb..dbae23acdd5b 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -467,14 +467,14 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
467#endif 467#endif
468} 468}
469 469
470int pnp_resource_type(struct resource *res) 470unsigned long pnp_resource_type(struct resource *res)
471{ 471{
472 return res->flags & (IORESOURCE_IO | IORESOURCE_MEM | 472 return res->flags & (IORESOURCE_IO | IORESOURCE_MEM |
473 IORESOURCE_IRQ | IORESOURCE_DMA); 473 IORESOURCE_IRQ | IORESOURCE_DMA);
474} 474}
475 475
476struct resource *pnp_get_resource(struct pnp_dev *dev, 476struct resource *pnp_get_resource(struct pnp_dev *dev,
477 unsigned int type, unsigned int num) 477 unsigned long type, unsigned int num)
478{ 478{
479 struct pnp_resource *pnp_res; 479 struct pnp_resource *pnp_res;
480 struct resource *res; 480 struct resource *res;
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 32570af3c5c9..5fbca2681baa 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -205,9 +205,9 @@ static int olpc_bat_get_property(struct power_supply *psy,
205 union power_supply_propval *val) 205 union power_supply_propval *val)
206{ 206{
207 int ret = 0; 207 int ret = 0;
208 int16_t ec_word; 208 __be16 ec_word;
209 uint8_t ec_byte; 209 uint8_t ec_byte;
210 uint64_t ser_buf; 210 __be64 ser_buf;
211 211
212 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1); 212 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1);
213 if (ret) 213 if (ret)
@@ -257,16 +257,14 @@ static int olpc_bat_get_property(struct power_supply *psy,
257 if (ret) 257 if (ret)
258 return ret; 258 return ret;
259 259
260 ec_word = be16_to_cpu(ec_word); 260 val->intval = (int)be16_to_cpu(ec_word) * 9760L / 32;
261 val->intval = ec_word * 9760L / 32;
262 break; 261 break;
263 case POWER_SUPPLY_PROP_CURRENT_AVG: 262 case POWER_SUPPLY_PROP_CURRENT_AVG:
264 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2); 263 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2);
265 if (ret) 264 if (ret)
266 return ret; 265 return ret;
267 266
268 ec_word = be16_to_cpu(ec_word); 267 val->intval = (int)be16_to_cpu(ec_word) * 15625L / 120;
269 val->intval = ec_word * 15625L / 120;
270 break; 268 break;
271 case POWER_SUPPLY_PROP_CAPACITY: 269 case POWER_SUPPLY_PROP_CAPACITY:
272 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1); 270 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1);
@@ -278,24 +276,22 @@ static int olpc_bat_get_property(struct power_supply *psy,
278 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); 276 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2);
279 if (ret) 277 if (ret)
280 return ret; 278 return ret;
281 ec_word = be16_to_cpu(ec_word); 279
282 val->intval = ec_word * 100 / 256; 280 val->intval = (int)be16_to_cpu(ec_word) * 100 / 256;
283 break; 281 break;
284 case POWER_SUPPLY_PROP_TEMP_AMBIENT: 282 case POWER_SUPPLY_PROP_TEMP_AMBIENT:
285 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); 283 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
286 if (ret) 284 if (ret)
287 return ret; 285 return ret;
288 286
289 ec_word = be16_to_cpu(ec_word); 287 val->intval = (int)be16_to_cpu(ec_word) * 100 / 256;
290 val->intval = ec_word * 100 / 256;
291 break; 288 break;
292 case POWER_SUPPLY_PROP_CHARGE_COUNTER: 289 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
293 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2); 290 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);
294 if (ret) 291 if (ret)
295 return ret; 292 return ret;
296 293
297 ec_word = be16_to_cpu(ec_word); 294 val->intval = (int)be16_to_cpu(ec_word) * 6250 / 15;
298 val->intval = ec_word * 6250 / 15;
299 break; 295 break;
300 case POWER_SUPPLY_PROP_SERIAL_NUMBER: 296 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
301 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8); 297 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8);
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index cb1ccb472921..3007695f90c8 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -91,8 +91,8 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
91{ 91{
92 int rc = 0; 92 int rc = 0;
93 93
94 psy->dev = device_create_drvdata(power_supply_class, parent, 0, 94 psy->dev = device_create(power_supply_class, parent, 0, psy,
95 psy, "%s", psy->name); 95 "%s", psy->name);
96 if (IS_ERR(psy->dev)) { 96 if (IS_ERR(psy->dev)) {
97 rc = PTR_ERR(psy->dev); 97 rc = PTR_ERR(psy->dev);
98 goto dev_create_failed; 98 goto dev_create_failed;
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index f3d7fd3406a6..f660ef3e5b29 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -220,22 +220,22 @@ config RTC_DRV_PCF8583
220 will be called rtc-pcf8583. 220 will be called rtc-pcf8583.
221 221
222config RTC_DRV_M41T80 222config RTC_DRV_M41T80
223 tristate "ST M41T80/81/82/83/84/85/87" 223 tristate "ST M41T65/M41T80/81/82/83/84/85/87"
224 help 224 help
225 If you say Y here you will get support for the 225 If you say Y here you will get support for the ST M41T60
226 ST M41T80 RTC chips series. Currently following chips are 226 and M41T80 RTC chips series. Currently, the following chips are
227 supported: M41T80, M41T81, M41T82, M41T83, M41ST84, M41ST85 227 supported: M41T65, M41T80, M41T81, M41T82, M41T83, M41ST84,
228 and M41ST87. 228 M41ST85, and M41ST87.
229 229
230 This driver can also be built as a module. If so, the module 230 This driver can also be built as a module. If so, the module
231 will be called rtc-m41t80. 231 will be called rtc-m41t80.
232 232
233config RTC_DRV_M41T80_WDT 233config RTC_DRV_M41T80_WDT
234 bool "ST M41T80 series RTC watchdog timer" 234 bool "ST M41T65/M41T80 series RTC watchdog timer"
235 depends on RTC_DRV_M41T80 235 depends on RTC_DRV_M41T80
236 help 236 help
237 If you say Y here you will get support for the 237 If you say Y here you will get support for the
238 watchdog timer in ST M41T80 RTC chips series. 238 watchdog timer in the ST M41T60 and M41T80 RTC chips series.
239 239
240config RTC_DRV_TWL92330 240config RTC_DRV_TWL92330
241 boolean "TI TWL92330/Menelaus" 241 boolean "TI TWL92330/Menelaus"
@@ -319,6 +319,15 @@ config RTC_DRV_RS5C348
319 This driver can also be built as a module. If so, the module 319 This driver can also be built as a module. If so, the module
320 will be called rtc-rs5c348. 320 will be called rtc-rs5c348.
321 321
322config RTC_DRV_DS3234
323 tristate "Maxim/Dallas DS3234"
324 help
325 If you say yes here you get support for the
326 Maxim/Dallas DS3234 SPI RTC chip.
327
328 This driver can also be built as a module. If so, the module
329 will be called rtc-ds3234.
330
322endif # SPI_MASTER 331endif # SPI_MASTER
323 332
324comment "Platform RTC drivers" 333comment "Platform RTC drivers"
@@ -603,7 +612,7 @@ config RTC_DRV_RS5C313
603 612
604config RTC_DRV_PPC 613config RTC_DRV_PPC
605 tristate "PowerPC machine dependent RTC support" 614 tristate "PowerPC machine dependent RTC support"
606 depends on PPC_MERGE 615 depends on PPC
607 help 616 help
608 The PowerPC kernel has machine-specific functions for accessing 617 The PowerPC kernel has machine-specific functions for accessing
609 the RTC. This exposes that functionality through the generic RTC 618 the RTC. This exposes that functionality through the generic RTC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 37a71b727262..d05928b3ca94 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_RTC_DRV_DS1511) += rtc-ds1511.o
32obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o 32obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o
33obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o 33obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o
34obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o 34obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
35obj-$(CONFIG_RTC_DRV_DS3234) += rtc-ds3234.o
35obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o 36obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
36obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o 37obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o
37obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o 38obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 4e888cc8be5b..37082616482b 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -29,10 +29,10 @@
29#include <linux/completion.h> 29#include <linux/completion.h>
30 30
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32
32#include <mach/at91_rtc.h> 33#include <mach/at91_rtc.h>
33 34
34 35
35#define AT91_RTC_FREQ 1
36#define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */ 36#define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */
37 37
38static DECLARE_COMPLETION(at91_rtc_updated); 38static DECLARE_COMPLETION(at91_rtc_updated);
@@ -228,8 +228,6 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
228 (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); 228 (imr & AT91_RTC_ACKUPD) ? "yes" : "no");
229 seq_printf(seq, "periodic_IRQ\t: %s\n", 229 seq_printf(seq, "periodic_IRQ\t: %s\n",
230 (imr & AT91_RTC_SECEV) ? "yes" : "no"); 230 (imr & AT91_RTC_SECEV) ? "yes" : "no");
231 seq_printf(seq, "periodic_freq\t: %ld\n",
232 (unsigned long) AT91_RTC_FREQ);
233 231
234 return 0; 232 return 0;
235} 233}
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 52e2743b04ec..079e9ed907e0 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -432,9 +432,15 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
432{ 432{
433 struct rtc_device *rtc = file->private_data; 433 struct rtc_device *rtc = file->private_data;
434 434
435#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 435 /* We shut down the repeating IRQs that userspace enabled,
436 clear_uie(rtc); 436 * since nothing is listening to them.
437#endif 437 * - Update (UIE) ... currently only managed through ioctls
438 * - Periodic (PIE) ... also used through rtc_*() interface calls
439 *
440 * Leave the alarm alone; it may be set to trigger a system wakeup
441 * later, or be used by kernel code, and is a one-shot event anyway.
442 */
443 rtc_dev_ioctl(file, RTC_UIE_OFF, 0);
438 rtc_irq_set_state(rtc, NULL, 0); 444 rtc_irq_set_state(rtc, NULL, 0);
439 445
440 if (rtc->ops->release) 446 if (rtc->ops->release)
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c
index 4b4c1b6a4187..4fcb16bbff4a 100644
--- a/drivers/rtc/rtc-ds1286.c
+++ b/drivers/rtc/rtc-ds1286.c
@@ -17,6 +17,7 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/bcd.h> 18#include <linux/bcd.h>
19#include <linux/ds1286.h> 19#include <linux/ds1286.h>
20#include <linux/io.h>
20 21
21#define DRV_VERSION "1.0" 22#define DRV_VERSION "1.0"
22 23
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bbf97e65202a..4fcf0734a6ef 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -23,10 +23,6 @@
23 * to have set the chip up as a clock (turning on the oscillator and 23 * to have set the chip up as a clock (turning on the oscillator and
24 * setting the date and time), Linux can ignore the non-clock features. 24 * setting the date and time), Linux can ignore the non-clock features.
25 * That's a natural job for a factory or repair bench. 25 * That's a natural job for a factory or repair bench.
26 *
27 * This is currently a simple no-alarms driver. If your board has the
28 * alarm irq wired up on a ds1337 or ds1339, and you want to use that,
29 * then look at the rtc-rs5c372 driver for code to steal...
30 */ 26 */
31enum ds_type { 27enum ds_type {
32 ds_1307, 28 ds_1307,
@@ -67,6 +63,7 @@ enum ds_type {
67# define DS1307_BIT_RS0 0x01 63# define DS1307_BIT_RS0 0x01
68#define DS1337_REG_CONTROL 0x0e 64#define DS1337_REG_CONTROL 0x0e
69# define DS1337_BIT_nEOSC 0x80 65# define DS1337_BIT_nEOSC 0x80
66# define DS1339_BIT_BBSQI 0x20
70# define DS1337_BIT_RS2 0x10 67# define DS1337_BIT_RS2 0x10
71# define DS1337_BIT_RS1 0x08 68# define DS1337_BIT_RS1 0x08
72# define DS1337_BIT_INTCN 0x04 69# define DS1337_BIT_INTCN 0x04
@@ -83,19 +80,22 @@ enum ds_type {
83# define DS1337_BIT_OSF 0x80 80# define DS1337_BIT_OSF 0x80
84# define DS1337_BIT_A2I 0x02 81# define DS1337_BIT_A2I 0x02
85# define DS1337_BIT_A1I 0x01 82# define DS1337_BIT_A1I 0x01
83#define DS1339_REG_ALARM1_SECS 0x07
86#define DS1339_REG_TRICKLE 0x10 84#define DS1339_REG_TRICKLE 0x10
87 85
88 86
89 87
90struct ds1307 { 88struct ds1307 {
91 u8 reg_addr; 89 u8 reg_addr;
92 bool has_nvram; 90 u8 regs[11];
93 u8 regs[8];
94 enum ds_type type; 91 enum ds_type type;
92 unsigned long flags;
93#define HAS_NVRAM 0 /* bit 0 == sysfs file active */
94#define HAS_ALARM 1 /* bit 1 == irq claimed */
95 struct i2c_msg msg[2]; 95 struct i2c_msg msg[2];
96 struct i2c_client *client; 96 struct i2c_client *client;
97 struct i2c_client dev;
98 struct rtc_device *rtc; 97 struct rtc_device *rtc;
98 struct work_struct work;
99}; 99};
100 100
101struct chip_desc { 101struct chip_desc {
@@ -132,12 +132,79 @@ static const struct i2c_device_id ds1307_id[] = {
132}; 132};
133MODULE_DEVICE_TABLE(i2c, ds1307_id); 133MODULE_DEVICE_TABLE(i2c, ds1307_id);
134 134
135/*----------------------------------------------------------------------*/
136
137/*
138 * The IRQ logic includes a "real" handler running in IRQ context just
139 * long enough to schedule this workqueue entry. We need a task context
140 * to talk to the RTC, since I2C I/O calls require that; and disable the
141 * IRQ until we clear its status on the chip, so that this handler can
142 * work with any type of triggering (not just falling edge).
143 *
144 * The ds1337 and ds1339 both have two alarms, but we only use the first
145 * one (with a "seconds" field). For ds1337 we expect nINTA is our alarm
146 * signal; ds1339 chips have only one alarm signal.
147 */
148static void ds1307_work(struct work_struct *work)
149{
150 struct ds1307 *ds1307;
151 struct i2c_client *client;
152 struct mutex *lock;
153 int stat, control;
154
155 ds1307 = container_of(work, struct ds1307, work);
156 client = ds1307->client;
157 lock = &ds1307->rtc->ops_lock;
158
159 mutex_lock(lock);
160 stat = i2c_smbus_read_byte_data(client, DS1337_REG_STATUS);
161 if (stat < 0)
162 goto out;
163
164 if (stat & DS1337_BIT_A1I) {
165 stat &= ~DS1337_BIT_A1I;
166 i2c_smbus_write_byte_data(client, DS1337_REG_STATUS, stat);
167
168 control = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);
169 if (control < 0)
170 goto out;
171
172 control &= ~DS1337_BIT_A1IE;
173 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, control);
174
175 /* rtc_update_irq() assumes that it is called
176 * from IRQ-disabled context.
177 */
178 local_irq_disable();
179 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF);
180 local_irq_enable();
181 }
182
183out:
184 if (test_bit(HAS_ALARM, &ds1307->flags))
185 enable_irq(client->irq);
186 mutex_unlock(lock);
187}
188
189static irqreturn_t ds1307_irq(int irq, void *dev_id)
190{
191 struct i2c_client *client = dev_id;
192 struct ds1307 *ds1307 = i2c_get_clientdata(client);
193
194 disable_irq_nosync(irq);
195 schedule_work(&ds1307->work);
196 return IRQ_HANDLED;
197}
198
199/*----------------------------------------------------------------------*/
200
135static int ds1307_get_time(struct device *dev, struct rtc_time *t) 201static int ds1307_get_time(struct device *dev, struct rtc_time *t)
136{ 202{
137 struct ds1307 *ds1307 = dev_get_drvdata(dev); 203 struct ds1307 *ds1307 = dev_get_drvdata(dev);
138 int tmp; 204 int tmp;
139 205
140 /* read the RTC date and time registers all at once */ 206 /* read the RTC date and time registers all at once */
207 ds1307->reg_addr = 0;
141 ds1307->msg[1].flags = I2C_M_RD; 208 ds1307->msg[1].flags = I2C_M_RD;
142 ds1307->msg[1].len = 7; 209 ds1307->msg[1].len = 7;
143 210
@@ -231,9 +298,186 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
231 return 0; 298 return 0;
232} 299}
233 300
301static int ds1307_read_alarm(struct device *dev, struct rtc_wkalrm *t)
302{
303 struct i2c_client *client = to_i2c_client(dev);
304 struct ds1307 *ds1307 = i2c_get_clientdata(client);
305 int ret;
306
307 if (!test_bit(HAS_ALARM, &ds1307->flags))
308 return -EINVAL;
309
310 /* read all ALARM1, ALARM2, and status registers at once */
311 ds1307->reg_addr = DS1339_REG_ALARM1_SECS;
312 ds1307->msg[1].flags = I2C_M_RD;
313 ds1307->msg[1].len = 9;
314
315 ret = i2c_transfer(to_i2c_adapter(client->dev.parent),
316 ds1307->msg, 2);
317 if (ret != 2) {
318 dev_err(dev, "%s error %d\n", "alarm read", ret);
319 return -EIO;
320 }
321
322 dev_dbg(dev, "%s: %02x %02x %02x %02x, %02x %02x %02x, %02x %02x\n",
323 "alarm read",
324 ds1307->regs[0], ds1307->regs[1],
325 ds1307->regs[2], ds1307->regs[3],
326 ds1307->regs[4], ds1307->regs[5],
327 ds1307->regs[6], ds1307->regs[7],
328 ds1307->regs[8]);
329
330 /* report alarm time (ALARM1); assume 24 hour and day-of-month modes,
331 * and that all four fields are checked matches
332 */
333 t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f);
334 t->time.tm_min = bcd2bin(ds1307->regs[1] & 0x7f);
335 t->time.tm_hour = bcd2bin(ds1307->regs[2] & 0x3f);
336 t->time.tm_mday = bcd2bin(ds1307->regs[3] & 0x3f);
337 t->time.tm_mon = -1;
338 t->time.tm_year = -1;
339 t->time.tm_wday = -1;
340 t->time.tm_yday = -1;
341 t->time.tm_isdst = -1;
342
343 /* ... and status */
344 t->enabled = !!(ds1307->regs[7] & DS1337_BIT_A1IE);
345 t->pending = !!(ds1307->regs[8] & DS1337_BIT_A1I);
346
347 dev_dbg(dev, "%s secs=%d, mins=%d, "
348 "hours=%d, mday=%d, enabled=%d, pending=%d\n",
349 "alarm read", t->time.tm_sec, t->time.tm_min,
350 t->time.tm_hour, t->time.tm_mday,
351 t->enabled, t->pending);
352
353 return 0;
354}
355
356static int ds1307_set_alarm(struct device *dev, struct rtc_wkalrm *t)
357{
358 struct i2c_client *client = to_i2c_client(dev);
359 struct ds1307 *ds1307 = i2c_get_clientdata(client);
360 unsigned char *buf = ds1307->regs;
361 u8 control, status;
362 int ret;
363
364 if (!test_bit(HAS_ALARM, &ds1307->flags))
365 return -EINVAL;
366
367 dev_dbg(dev, "%s secs=%d, mins=%d, "
368 "hours=%d, mday=%d, enabled=%d, pending=%d\n",
369 "alarm set", t->time.tm_sec, t->time.tm_min,
370 t->time.tm_hour, t->time.tm_mday,
371 t->enabled, t->pending);
372
373 /* read current status of both alarms and the chip */
374 ds1307->reg_addr = DS1339_REG_ALARM1_SECS;
375 ds1307->msg[1].flags = I2C_M_RD;
376 ds1307->msg[1].len = 9;
377
378 ret = i2c_transfer(to_i2c_adapter(client->dev.parent),
379 ds1307->msg, 2);
380 if (ret != 2) {
381 dev_err(dev, "%s error %d\n", "alarm write", ret);
382 return -EIO;
383 }
384 control = ds1307->regs[7];
385 status = ds1307->regs[8];
386
387 dev_dbg(dev, "%s: %02x %02x %02x %02x, %02x %02x %02x, %02x %02x\n",
388 "alarm set (old status)",
389 ds1307->regs[0], ds1307->regs[1],
390 ds1307->regs[2], ds1307->regs[3],
391 ds1307->regs[4], ds1307->regs[5],
392 ds1307->regs[6], control, status);
393
394 /* set ALARM1, using 24 hour and day-of-month modes */
395 *buf++ = DS1339_REG_ALARM1_SECS; /* first register addr */
396 buf[0] = bin2bcd(t->time.tm_sec);
397 buf[1] = bin2bcd(t->time.tm_min);
398 buf[2] = bin2bcd(t->time.tm_hour);
399 buf[3] = bin2bcd(t->time.tm_mday);
400
401 /* set ALARM2 to non-garbage */
402 buf[4] = 0;
403 buf[5] = 0;
404 buf[6] = 0;
405
406 /* optionally enable ALARM1 */
407 buf[7] = control & ~(DS1337_BIT_A1IE | DS1337_BIT_A2IE);
408 if (t->enabled) {
409 dev_dbg(dev, "alarm IRQ armed\n");
410 buf[7] |= DS1337_BIT_A1IE; /* only ALARM1 is used */
411 }
412 buf[8] = status & ~(DS1337_BIT_A1I | DS1337_BIT_A2I);
413
414 ds1307->msg[1].flags = 0;
415 ds1307->msg[1].len = 10;
416
417 ret = i2c_transfer(to_i2c_adapter(client->dev.parent),
418 &ds1307->msg[1], 1);
419 if (ret != 1) {
420 dev_err(dev, "can't set alarm time\n");
421 return -EIO;
422 }
423
424 return 0;
425}
426
427static int ds1307_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
428{
429 struct i2c_client *client = to_i2c_client(dev);
430 struct ds1307 *ds1307 = i2c_get_clientdata(client);
431 int ret;
432
433 switch (cmd) {
434 case RTC_AIE_OFF:
435 if (!test_bit(HAS_ALARM, &ds1307->flags))
436 return -ENOTTY;
437
438 ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);
439 if (ret < 0)
440 return ret;
441
442 ret &= ~DS1337_BIT_A1IE;
443
444 ret = i2c_smbus_write_byte_data(client,
445 DS1337_REG_CONTROL, ret);
446 if (ret < 0)
447 return ret;
448
449 break;
450
451 case RTC_AIE_ON:
452 if (!test_bit(HAS_ALARM, &ds1307->flags))
453 return -ENOTTY;
454
455 ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);
456 if (ret < 0)
457 return ret;
458
459 ret |= DS1337_BIT_A1IE;
460
461 ret = i2c_smbus_write_byte_data(client,
462 DS1337_REG_CONTROL, ret);
463 if (ret < 0)
464 return ret;
465
466 break;
467
468 default:
469 return -ENOIOCTLCMD;
470 }
471
472 return 0;
473}
474
234static const struct rtc_class_ops ds13xx_rtc_ops = { 475static const struct rtc_class_ops ds13xx_rtc_ops = {
235 .read_time = ds1307_get_time, 476 .read_time = ds1307_get_time,
236 .set_time = ds1307_set_time, 477 .set_time = ds1307_set_time,
478 .read_alarm = ds1307_read_alarm,
479 .set_alarm = ds1307_set_alarm,
480 .ioctl = ds1307_ioctl,
237}; 481};
238 482
239/*----------------------------------------------------------------------*/ 483/*----------------------------------------------------------------------*/
@@ -327,6 +571,7 @@ static int __devinit ds1307_probe(struct i2c_client *client,
327 int tmp; 571 int tmp;
328 const struct chip_desc *chip = &chips[id->driver_data]; 572 const struct chip_desc *chip = &chips[id->driver_data];
329 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 573 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
574 int want_irq = false;
330 575
331 if (!i2c_check_functionality(adapter, 576 if (!i2c_check_functionality(adapter,
332 I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 577 I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
@@ -353,6 +598,12 @@ static int __devinit ds1307_probe(struct i2c_client *client,
353 switch (ds1307->type) { 598 switch (ds1307->type) {
354 case ds_1337: 599 case ds_1337:
355 case ds_1339: 600 case ds_1339:
601 /* has IRQ? */
602 if (ds1307->client->irq > 0 && chip->alarm) {
603 INIT_WORK(&ds1307->work, ds1307_work);
604 want_irq = true;
605 }
606
356 ds1307->reg_addr = DS1337_REG_CONTROL; 607 ds1307->reg_addr = DS1337_REG_CONTROL;
357 ds1307->msg[1].len = 2; 608 ds1307->msg[1].len = 2;
358 609
@@ -369,8 +620,20 @@ static int __devinit ds1307_probe(struct i2c_client *client,
369 620
370 /* oscillator off? turn it on, so clock can tick. */ 621 /* oscillator off? turn it on, so clock can tick. */
371 if (ds1307->regs[0] & DS1337_BIT_nEOSC) 622 if (ds1307->regs[0] & DS1337_BIT_nEOSC)
372 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, 623 ds1307->regs[0] &= ~DS1337_BIT_nEOSC;
373 ds1307->regs[0] & ~DS1337_BIT_nEOSC); 624
625 /* Using IRQ? Disable the square wave and both alarms.
626 * For ds1339, be sure alarms can trigger when we're
627 * running on Vbackup (BBSQI); we assume ds1337 will
628 * ignore that bit
629 */
630 if (want_irq) {
631 ds1307->regs[0] |= DS1337_BIT_INTCN | DS1339_BIT_BBSQI;
632 ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE);
633 }
634
635 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL,
636 ds1307->regs[0]);
374 637
375 /* oscillator fault? clear flag, and warn */ 638 /* oscillator fault? clear flag, and warn */
376 if (ds1307->regs[1] & DS1337_BIT_OSF) { 639 if (ds1307->regs[1] & DS1337_BIT_OSF) {
@@ -495,10 +758,22 @@ read_rtc:
495 goto exit_free; 758 goto exit_free;
496 } 759 }
497 760
761 if (want_irq) {
762 err = request_irq(client->irq, ds1307_irq, 0,
763 ds1307->rtc->name, client);
764 if (err) {
765 dev_err(&client->dev,
766 "unable to request IRQ!\n");
767 goto exit_irq;
768 }
769 set_bit(HAS_ALARM, &ds1307->flags);
770 dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
771 }
772
498 if (chip->nvram56) { 773 if (chip->nvram56) {
499 err = sysfs_create_bin_file(&client->dev.kobj, &nvram); 774 err = sysfs_create_bin_file(&client->dev.kobj, &nvram);
500 if (err == 0) { 775 if (err == 0) {
501 ds1307->has_nvram = true; 776 set_bit(HAS_NVRAM, &ds1307->flags);
502 dev_info(&client->dev, "56 bytes nvram\n"); 777 dev_info(&client->dev, "56 bytes nvram\n");
503 } 778 }
504 } 779 }
@@ -512,7 +787,9 @@ exit_bad:
512 ds1307->regs[2], ds1307->regs[3], 787 ds1307->regs[2], ds1307->regs[3],
513 ds1307->regs[4], ds1307->regs[5], 788 ds1307->regs[4], ds1307->regs[5],
514 ds1307->regs[6]); 789 ds1307->regs[6]);
515 790exit_irq:
791 if (ds1307->rtc)
792 rtc_device_unregister(ds1307->rtc);
516exit_free: 793exit_free:
517 kfree(ds1307); 794 kfree(ds1307);
518 return err; 795 return err;
@@ -520,9 +797,14 @@ exit_free:
520 797
521static int __devexit ds1307_remove(struct i2c_client *client) 798static int __devexit ds1307_remove(struct i2c_client *client)
522{ 799{
523 struct ds1307 *ds1307 = i2c_get_clientdata(client); 800 struct ds1307 *ds1307 = i2c_get_clientdata(client);
801
802 if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) {
803 free_irq(client->irq, client);
804 cancel_work_sync(&ds1307->work);
805 }
524 806
525 if (ds1307->has_nvram) 807 if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
526 sysfs_remove_bin_file(&client->dev.kobj, &nvram); 808 sysfs_remove_bin_file(&client->dev.kobj, &nvram);
527 809
528 rtc_device_unregister(ds1307->rtc); 810 rtc_device_unregister(ds1307->rtc);
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index a150418fba76..a5b0fc09f0c6 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -429,12 +429,33 @@ static int __devexit ds1374_remove(struct i2c_client *client)
429 return 0; 429 return 0;
430} 430}
431 431
432#ifdef CONFIG_PM
433static int ds1374_suspend(struct i2c_client *client, pm_message_t state)
434{
435 if (client->irq >= 0 && device_may_wakeup(&client->dev))
436 enable_irq_wake(client->irq);
437 return 0;
438}
439
440static int ds1374_resume(struct i2c_client *client)
441{
442 if (client->irq >= 0 && device_may_wakeup(&client->dev))
443 disable_irq_wake(client->irq);
444 return 0;
445}
446#else
447#define ds1374_suspend NULL
448#define ds1374_resume NULL
449#endif
450
432static struct i2c_driver ds1374_driver = { 451static struct i2c_driver ds1374_driver = {
433 .driver = { 452 .driver = {
434 .name = "rtc-ds1374", 453 .name = "rtc-ds1374",
435 .owner = THIS_MODULE, 454 .owner = THIS_MODULE,
436 }, 455 },
437 .probe = ds1374_probe, 456 .probe = ds1374_probe,
457 .suspend = ds1374_suspend,
458 .resume = ds1374_resume,
438 .remove = __devexit_p(ds1374_remove), 459 .remove = __devexit_p(ds1374_remove),
439 .id_table = ds1374_id, 460 .id_table = ds1374_id,
440}; 461};
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 0f0d27d1c4ca..86981d34fbb6 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -379,18 +379,6 @@ ds1511_interrupt(int irq, void *dev_id)
379 return IRQ_HANDLED; 379 return IRQ_HANDLED;
380} 380}
381 381
382 static void
383ds1511_rtc_release(struct device *dev)
384{
385 struct platform_device *pdev = to_platform_device(dev);
386 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
387
388 if (pdata->irq >= 0) {
389 pdata->irqen = 0;
390 ds1511_rtc_update_alarm(pdata);
391 }
392}
393
394 static int 382 static int
395ds1511_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 383ds1511_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
396{ 384{
@@ -428,7 +416,6 @@ static const struct rtc_class_ops ds1511_rtc_ops = {
428 .set_time = ds1511_rtc_set_time, 416 .set_time = ds1511_rtc_set_time,
429 .read_alarm = ds1511_rtc_read_alarm, 417 .read_alarm = ds1511_rtc_read_alarm,
430 .set_alarm = ds1511_rtc_set_alarm, 418 .set_alarm = ds1511_rtc_set_alarm,
431 .release = ds1511_rtc_release,
432 .ioctl = ds1511_rtc_ioctl, 419 .ioctl = ds1511_rtc_ioctl,
433}; 420};
434 421
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index a19f11415540..4ef59285b489 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -207,17 +207,6 @@ static irqreturn_t ds1553_rtc_interrupt(int irq, void *dev_id)
207 return IRQ_HANDLED; 207 return IRQ_HANDLED;
208} 208}
209 209
210static void ds1553_rtc_release(struct device *dev)
211{
212 struct platform_device *pdev = to_platform_device(dev);
213 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
214
215 if (pdata->irq >= 0) {
216 pdata->irqen = 0;
217 ds1553_rtc_update_alarm(pdata);
218 }
219}
220
221static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd, 210static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd,
222 unsigned long arg) 211 unsigned long arg)
223{ 212{
@@ -254,7 +243,6 @@ static const struct rtc_class_ops ds1553_rtc_ops = {
254 .set_time = ds1553_rtc_set_time, 243 .set_time = ds1553_rtc_set_time,
255 .read_alarm = ds1553_rtc_read_alarm, 244 .read_alarm = ds1553_rtc_read_alarm,
256 .set_alarm = ds1553_rtc_set_alarm, 245 .set_alarm = ds1553_rtc_set_alarm,
257 .release = ds1553_rtc_release,
258 .ioctl = ds1553_rtc_ioctl, 246 .ioctl = ds1553_rtc_ioctl,
259}; 247};
260 248
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 6fa4556f5f5c..341d7a5b45a2 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -9,17 +9,10 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#include <linux/module.h>
13#include <linux/i2c.h> 12#include <linux/i2c.h>
14#include <linux/rtc.h> 13#include <linux/rtc.h>
15 14
16#define DRV_VERSION "0.3" 15#define DRV_VERSION "0.4"
17
18/* Addresses to scan: none. This chip cannot be detected. */
19static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
20
21/* Insmod parameters */
22I2C_CLIENT_INSMOD;
23 16
24/* Registers */ 17/* Registers */
25 18
@@ -29,8 +22,7 @@ I2C_CLIENT_INSMOD;
29 22
30#define DS1672_REG_CONTROL_EOSC 0x80 23#define DS1672_REG_CONTROL_EOSC 0x80
31 24
32/* Prototypes */ 25static struct i2c_driver ds1672_driver;
33static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind);
34 26
35/* 27/*
36 * In the routines that deal directly with the ds1672 hardware, we use 28 * In the routines that deal directly with the ds1672 hardware, we use
@@ -44,8 +36,8 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
44 unsigned char buf[4]; 36 unsigned char buf[4];
45 37
46 struct i2c_msg msgs[] = { 38 struct i2c_msg msgs[] = {
47 { client->addr, 0, 1, &addr }, /* setup read ptr */ 39 {client->addr, 0, 1, &addr}, /* setup read ptr */
48 { client->addr, I2C_M_RD, 4, buf }, /* read date */ 40 {client->addr, I2C_M_RD, 4, buf}, /* read date */
49 }; 41 };
50 42
51 /* read date registers */ 43 /* read date registers */
@@ -80,7 +72,7 @@ static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs)
80 buf[2] = (secs & 0x0000FF00) >> 8; 72 buf[2] = (secs & 0x0000FF00) >> 8;
81 buf[3] = (secs & 0x00FF0000) >> 16; 73 buf[3] = (secs & 0x00FF0000) >> 16;
82 buf[4] = (secs & 0xFF000000) >> 24; 74 buf[4] = (secs & 0xFF000000) >> 24;
83 buf[5] = 0; /* set control reg to enable counting */ 75 buf[5] = 0; /* set control reg to enable counting */
84 76
85 xfer = i2c_master_send(client, buf, 6); 77 xfer = i2c_master_send(client, buf, 6);
86 if (xfer != 6) { 78 if (xfer != 6) {
@@ -127,8 +119,8 @@ static int ds1672_get_control(struct i2c_client *client, u8 *status)
127 unsigned char addr = DS1672_REG_CONTROL; 119 unsigned char addr = DS1672_REG_CONTROL;
128 120
129 struct i2c_msg msgs[] = { 121 struct i2c_msg msgs[] = {
130 { client->addr, 0, 1, &addr }, /* setup read ptr */ 122 {client->addr, 0, 1, &addr}, /* setup read ptr */
131 { client->addr, I2C_M_RD, 1, status }, /* read control */ 123 {client->addr, I2C_M_RD, 1, status}, /* read control */
132 }; 124 };
133 125
134 /* read control register */ 126 /* read control register */
@@ -141,7 +133,8 @@ static int ds1672_get_control(struct i2c_client *client, u8 *status)
141} 133}
142 134
143/* following are the sysfs callback functions */ 135/* following are the sysfs callback functions */
144static ssize_t show_control(struct device *dev, struct device_attribute *attr, char *buf) 136static ssize_t show_control(struct device *dev, struct device_attribute *attr,
137 char *buf)
145{ 138{
146 struct i2c_client *client = to_i2c_client(dev); 139 struct i2c_client *client = to_i2c_client(dev);
147 u8 control; 140 u8 control;
@@ -152,85 +145,46 @@ static ssize_t show_control(struct device *dev, struct device_attribute *attr, c
152 return err; 145 return err;
153 146
154 return sprintf(buf, "%s\n", (control & DS1672_REG_CONTROL_EOSC) 147 return sprintf(buf, "%s\n", (control & DS1672_REG_CONTROL_EOSC)
155 ? "disabled" : "enabled"); 148 ? "disabled" : "enabled");
156} 149}
150
157static DEVICE_ATTR(control, S_IRUGO, show_control, NULL); 151static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);
158 152
159static const struct rtc_class_ops ds1672_rtc_ops = { 153static const struct rtc_class_ops ds1672_rtc_ops = {
160 .read_time = ds1672_rtc_read_time, 154 .read_time = ds1672_rtc_read_time,
161 .set_time = ds1672_rtc_set_time, 155 .set_time = ds1672_rtc_set_time,
162 .set_mmss = ds1672_rtc_set_mmss, 156 .set_mmss = ds1672_rtc_set_mmss,
163}; 157};
164 158
165static int ds1672_attach(struct i2c_adapter *adapter) 159static int ds1672_remove(struct i2c_client *client)
166{ 160{
167 return i2c_probe(adapter, &addr_data, ds1672_probe);
168}
169
170static int ds1672_detach(struct i2c_client *client)
171{
172 int err;
173 struct rtc_device *rtc = i2c_get_clientdata(client); 161 struct rtc_device *rtc = i2c_get_clientdata(client);
174 162
175 if (rtc) 163 if (rtc)
176 rtc_device_unregister(rtc); 164 rtc_device_unregister(rtc);
177 165
178 if ((err = i2c_detach_client(client)))
179 return err;
180
181 kfree(client);
182
183 return 0; 166 return 0;
184} 167}
185 168
186static struct i2c_driver ds1672_driver = { 169static int ds1672_probe(struct i2c_client *client,
187 .driver = { 170 const struct i2c_device_id *id)
188 .name = "ds1672",
189 },
190 .id = I2C_DRIVERID_DS1672,
191 .attach_adapter = &ds1672_attach,
192 .detach_client = &ds1672_detach,
193};
194
195static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
196{ 171{
197 int err = 0; 172 int err = 0;
198 u8 control; 173 u8 control;
199 struct i2c_client *client;
200 struct rtc_device *rtc; 174 struct rtc_device *rtc;
201 175
202 dev_dbg(&adapter->dev, "%s\n", __func__); 176 dev_dbg(&client->dev, "%s\n", __func__);
203 177
204 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { 178 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
205 err = -ENODEV; 179 return -ENODEV;
206 goto exit;
207 }
208
209 if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
210 err = -ENOMEM;
211 goto exit;
212 }
213
214 /* I2C client */
215 client->addr = address;
216 client->driver = &ds1672_driver;
217 client->adapter = adapter;
218
219 strlcpy(client->name, ds1672_driver.driver.name, I2C_NAME_SIZE);
220
221 /* Inform the i2c layer */
222 if ((err = i2c_attach_client(client)))
223 goto exit_kfree;
224 180
225 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); 181 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
226 182
227 rtc = rtc_device_register(ds1672_driver.driver.name, &client->dev, 183 rtc = rtc_device_register(ds1672_driver.driver.name, &client->dev,
228 &ds1672_rtc_ops, THIS_MODULE); 184 &ds1672_rtc_ops, THIS_MODULE);
229 185
230 if (IS_ERR(rtc)) { 186 if (IS_ERR(rtc))
231 err = PTR_ERR(rtc); 187 return PTR_ERR(rtc);
232 goto exit_detach;
233 }
234 188
235 i2c_set_clientdata(client, rtc); 189 i2c_set_clientdata(client, rtc);
236 190
@@ -241,7 +195,7 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
241 195
242 if (control & DS1672_REG_CONTROL_EOSC) 196 if (control & DS1672_REG_CONTROL_EOSC)
243 dev_warn(&client->dev, "Oscillator not enabled. " 197 dev_warn(&client->dev, "Oscillator not enabled. "
244 "Set time to enable.\n"); 198 "Set time to enable.\n");
245 199
246 /* Register sysfs hooks */ 200 /* Register sysfs hooks */
247 err = device_create_file(&client->dev, &dev_attr_control); 201 err = device_create_file(&client->dev, &dev_attr_control);
@@ -250,19 +204,19 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
250 204
251 return 0; 205 return 0;
252 206
253exit_devreg: 207 exit_devreg:
254 rtc_device_unregister(rtc); 208 rtc_device_unregister(rtc);
255
256exit_detach:
257 i2c_detach_client(client);
258
259exit_kfree:
260 kfree(client);
261
262exit:
263 return err; 209 return err;
264} 210}
265 211
212static struct i2c_driver ds1672_driver = {
213 .driver = {
214 .name = "rtc-ds1672",
215 },
216 .probe = &ds1672_probe,
217 .remove = &ds1672_remove,
218};
219
266static int __init ds1672_init(void) 220static int __init ds1672_init(void)
267{ 221{
268 return i2c_add_driver(&ds1672_driver); 222 return i2c_add_driver(&ds1672_driver);
diff --git a/drivers/rtc/rtc-ds3234.c b/drivers/rtc/rtc-ds3234.c
new file mode 100644
index 000000000000..37d131d03f33
--- /dev/null
+++ b/drivers/rtc/rtc-ds3234.c
@@ -0,0 +1,290 @@
1/* drivers/rtc/rtc-ds3234.c
2 *
3 * Driver for Dallas Semiconductor (DS3234) SPI RTC with Integrated Crystal
4 * and SRAM.
5 *
6 * Copyright (C) 2008 MIMOMax Wireless Ltd.
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 * Changelog:
13 *
14 * 07-May-2008: Dennis Aberilla <denzzzhome@yahoo.com>
15 * - Created based on the max6902 code. Only implements the
16 * date/time keeping functions; no SRAM yet.
17 */
18
19#include <linux/device.h>
20#include <linux/platform_device.h>
21#include <linux/rtc.h>
22#include <linux/spi/spi.h>
23#include <linux/bcd.h>
24
25#define DS3234_REG_SECONDS 0x00
26#define DS3234_REG_MINUTES 0x01
27#define DS3234_REG_HOURS 0x02
28#define DS3234_REG_DAY 0x03
29#define DS3234_REG_DATE 0x04
30#define DS3234_REG_MONTH 0x05
31#define DS3234_REG_YEAR 0x06
32#define DS3234_REG_CENTURY (1 << 7) /* Bit 7 of the Month register */
33
34#define DS3234_REG_CONTROL 0x0E
35#define DS3234_REG_CONT_STAT 0x0F
36
37#undef DS3234_DEBUG
38
39struct ds3234 {
40 struct rtc_device *rtc;
41 u8 buf[8]; /* Burst read: addr + 7 regs */
42 u8 tx_buf[2];
43 u8 rx_buf[2];
44};
45
46static void ds3234_set_reg(struct device *dev, unsigned char address,
47 unsigned char data)
48{
49 struct spi_device *spi = to_spi_device(dev);
50 unsigned char buf[2];
51
52 /* MSB must be '1' to indicate write */
53 buf[0] = address | 0x80;
54 buf[1] = data;
55
56 spi_write(spi, buf, 2);
57}
58
59static int ds3234_get_reg(struct device *dev, unsigned char address,
60 unsigned char *data)
61{
62 struct spi_device *spi = to_spi_device(dev);
63 struct ds3234 *chip = dev_get_drvdata(dev);
64 struct spi_message message;
65 struct spi_transfer xfer;
66 int status;
67
68 if (!data)
69 return -EINVAL;
70
71 /* Build our spi message */
72 spi_message_init(&message);
73 memset(&xfer, 0, sizeof(xfer));
74
75 /* Address + dummy tx byte */
76 xfer.len = 2;
77 xfer.tx_buf = chip->tx_buf;
78 xfer.rx_buf = chip->rx_buf;
79
80 chip->tx_buf[0] = address;
81 chip->tx_buf[1] = 0xff;
82
83 spi_message_add_tail(&xfer, &message);
84
85 /* do the i/o */
86 status = spi_sync(spi, &message);
87 if (status == 0)
88 status = message.status;
89 else
90 return status;
91
92 *data = chip->rx_buf[1];
93
94 return status;
95}
96
97static int ds3234_get_datetime(struct device *dev, struct rtc_time *dt)
98{
99 struct spi_device *spi = to_spi_device(dev);
100 struct ds3234 *chip = dev_get_drvdata(dev);
101 struct spi_message message;
102 struct spi_transfer xfer;
103 int status;
104
105 /* build the message */
106 spi_message_init(&message);
107 memset(&xfer, 0, sizeof(xfer));
108 xfer.len = 1 + 7; /* Addr + 7 registers */
109 xfer.tx_buf = chip->buf;
110 xfer.rx_buf = chip->buf;
111 chip->buf[0] = 0x00; /* Start address */
112 spi_message_add_tail(&xfer, &message);
113
114 /* do the i/o */
115 status = spi_sync(spi, &message);
116 if (status == 0)
117 status = message.status;
118 else
119 return status;
120
121 /* Seconds, Minutes, Hours, Day, Date, Month, Year */
122 dt->tm_sec = bcd2bin(chip->buf[1]);
123 dt->tm_min = bcd2bin(chip->buf[2]);
124 dt->tm_hour = bcd2bin(chip->buf[3] & 0x3f);
125 dt->tm_wday = bcd2bin(chip->buf[4]) - 1; /* 0 = Sun */
126 dt->tm_mday = bcd2bin(chip->buf[5]);
127 dt->tm_mon = bcd2bin(chip->buf[6] & 0x1f) - 1; /* 0 = Jan */
128 dt->tm_year = bcd2bin(chip->buf[7] & 0xff) + 100; /* Assume 20YY */
129
130#ifdef DS3234_DEBUG
131 dev_dbg(dev, "\n%s : Read RTC values\n", __func__);
132 dev_dbg(dev, "tm_hour: %i\n", dt->tm_hour);
133 dev_dbg(dev, "tm_min : %i\n", dt->tm_min);
134 dev_dbg(dev, "tm_sec : %i\n", dt->tm_sec);
135 dev_dbg(dev, "tm_wday: %i\n", dt->tm_wday);
136 dev_dbg(dev, "tm_mday: %i\n", dt->tm_mday);
137 dev_dbg(dev, "tm_mon : %i\n", dt->tm_mon);
138 dev_dbg(dev, "tm_year: %i\n", dt->tm_year);
139#endif
140
141 return 0;
142}
143
144static int ds3234_set_datetime(struct device *dev, struct rtc_time *dt)
145{
146#ifdef DS3234_DEBUG
147 dev_dbg(dev, "\n%s : Setting RTC values\n", __func__);
148 dev_dbg(dev, "tm_sec : %i\n", dt->tm_sec);
149 dev_dbg(dev, "tm_min : %i\n", dt->tm_min);
150 dev_dbg(dev, "tm_hour: %i\n", dt->tm_hour);
151 dev_dbg(dev, "tm_wday: %i\n", dt->tm_wday);
152 dev_dbg(dev, "tm_mday: %i\n", dt->tm_mday);
153 dev_dbg(dev, "tm_mon : %i\n", dt->tm_mon);
154 dev_dbg(dev, "tm_year: %i\n", dt->tm_year);
155#endif
156
157 ds3234_set_reg(dev, DS3234_REG_SECONDS, bin2bcd(dt->tm_sec));
158 ds3234_set_reg(dev, DS3234_REG_MINUTES, bin2bcd(dt->tm_min));
159 ds3234_set_reg(dev, DS3234_REG_HOURS, bin2bcd(dt->tm_hour) & 0x3f);
160
161 /* 0 = Sun */
162 ds3234_set_reg(dev, DS3234_REG_DAY, bin2bcd(dt->tm_wday + 1));
163 ds3234_set_reg(dev, DS3234_REG_DATE, bin2bcd(dt->tm_mday));
164
165 /* 0 = Jan */
166 ds3234_set_reg(dev, DS3234_REG_MONTH, bin2bcd(dt->tm_mon + 1));
167
168 /* Assume 20YY although we just want to make sure not to go negative. */
169 if (dt->tm_year > 100)
170 dt->tm_year -= 100;
171
172 ds3234_set_reg(dev, DS3234_REG_YEAR, bin2bcd(dt->tm_year));
173
174 return 0;
175}
176
177static int ds3234_read_time(struct device *dev, struct rtc_time *tm)
178{
179 return ds3234_get_datetime(dev, tm);
180}
181
182static int ds3234_set_time(struct device *dev, struct rtc_time *tm)
183{
184 return ds3234_set_datetime(dev, tm);
185}
186
187static const struct rtc_class_ops ds3234_rtc_ops = {
188 .read_time = ds3234_read_time,
189 .set_time = ds3234_set_time,
190};
191
192static int ds3234_probe(struct spi_device *spi)
193{
194 struct rtc_device *rtc;
195 unsigned char tmp;
196 struct ds3234 *chip;
197 int res;
198
199 rtc = rtc_device_register("ds3234",
200 &spi->dev, &ds3234_rtc_ops, THIS_MODULE);
201 if (IS_ERR(rtc))
202 return PTR_ERR(rtc);
203
204 spi->mode = SPI_MODE_3;
205 spi->bits_per_word = 8;
206 spi_setup(spi);
207
208 chip = kzalloc(sizeof(struct ds3234), GFP_KERNEL);
209 if (!chip) {
210 rtc_device_unregister(rtc);
211 return -ENOMEM;
212 }
213 chip->rtc = rtc;
214 dev_set_drvdata(&spi->dev, chip);
215
216 res = ds3234_get_reg(&spi->dev, DS3234_REG_SECONDS, &tmp);
217 if (res) {
218 rtc_device_unregister(rtc);
219 return res;
220 }
221
222 /* Control settings
223 *
224 * CONTROL_REG
225 * BIT 7 6 5 4 3 2 1 0
226 * EOSC BBSQW CONV RS2 RS1 INTCN A2IE A1IE
227 *
228 * 0 0 0 1 1 1 0 0
229 *
230 * CONTROL_STAT_REG
231 * BIT 7 6 5 4 3 2 1 0
232 * OSF BB32kHz CRATE1 CRATE0 EN32kHz BSY A2F A1F
233 *
234 * 1 0 0 0 1 0 0 0
235 */
236 ds3234_get_reg(&spi->dev, DS3234_REG_CONTROL, &tmp);
237 ds3234_set_reg(&spi->dev, DS3234_REG_CONTROL, tmp & 0x1c);
238
239 ds3234_get_reg(&spi->dev, DS3234_REG_CONT_STAT, &tmp);
240 ds3234_set_reg(&spi->dev, DS3234_REG_CONT_STAT, tmp & 0x88);
241
242 /* Print our settings */
243 ds3234_get_reg(&spi->dev, DS3234_REG_CONTROL, &tmp);
244 dev_info(&spi->dev, "Control Reg: 0x%02x\n", tmp);
245
246 ds3234_get_reg(&spi->dev, DS3234_REG_CONT_STAT, &tmp);
247 dev_info(&spi->dev, "Ctrl/Stat Reg: 0x%02x\n", tmp);
248
249 return 0;
250}
251
252static int __exit ds3234_remove(struct spi_device *spi)
253{
254 struct ds3234 *chip = platform_get_drvdata(spi);
255 struct rtc_device *rtc = chip->rtc;
256
257 if (rtc)
258 rtc_device_unregister(rtc);
259
260 kfree(chip);
261
262 return 0;
263}
264
265static struct spi_driver ds3234_driver = {
266 .driver = {
267 .name = "ds3234",
268 .bus = &spi_bus_type,
269 .owner = THIS_MODULE,
270 },
271 .probe = ds3234_probe,
272 .remove = __devexit_p(ds3234_remove),
273};
274
275static __init int ds3234_init(void)
276{
277 printk(KERN_INFO "DS3234 SPI RTC Driver\n");
278 return spi_register_driver(&ds3234_driver);
279}
280module_init(ds3234_init);
281
282static __exit void ds3234_exit(void)
283{
284 spi_unregister_driver(&ds3234_driver);
285}
286module_exit(ds3234_exit);
287
288MODULE_DESCRIPTION("DS3234 SPI RTC driver");
289MODULE_AUTHOR("Dennis Aberilla <denzzzhome@yahoo.com>");
290MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 24bc1689fc74..470fb2d29545 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -56,21 +56,27 @@
56#define M41T80_ALHOUR_HT (1 << 6) /* HT: Halt Update Bit */ 56#define M41T80_ALHOUR_HT (1 << 6) /* HT: Halt Update Bit */
57#define M41T80_FLAGS_AF (1 << 6) /* AF: Alarm Flag Bit */ 57#define M41T80_FLAGS_AF (1 << 6) /* AF: Alarm Flag Bit */
58#define M41T80_FLAGS_BATT_LOW (1 << 4) /* BL: Battery Low Bit */ 58#define M41T80_FLAGS_BATT_LOW (1 << 4) /* BL: Battery Low Bit */
59#define M41T80_WATCHDOG_RB2 (1 << 7) /* RB: Watchdog resolution */
60#define M41T80_WATCHDOG_RB1 (1 << 1) /* RB: Watchdog resolution */
61#define M41T80_WATCHDOG_RB0 (1 << 0) /* RB: Watchdog resolution */
59 62
60#define M41T80_FEATURE_HT (1 << 0) 63#define M41T80_FEATURE_HT (1 << 0) /* Halt feature */
61#define M41T80_FEATURE_BL (1 << 1) 64#define M41T80_FEATURE_BL (1 << 1) /* Battery low indicator */
65#define M41T80_FEATURE_SQ (1 << 2) /* Squarewave feature */
66#define M41T80_FEATURE_WD (1 << 3) /* Extra watchdog resolution */
62 67
63#define DRV_VERSION "0.05" 68#define DRV_VERSION "0.05"
64 69
65static const struct i2c_device_id m41t80_id[] = { 70static const struct i2c_device_id m41t80_id[] = {
66 { "m41t80", 0 }, 71 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD },
67 { "m41t81", M41T80_FEATURE_HT }, 72 { "m41t80", M41T80_FEATURE_SQ },
68 { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 73 { "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
69 { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 74 { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
70 { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 75 { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
71 { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 76 { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
72 { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 77 { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
73 { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 78 { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
79 { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
74 { } 80 { }
75}; 81};
76MODULE_DEVICE_TABLE(i2c, m41t80_id); 82MODULE_DEVICE_TABLE(i2c, m41t80_id);
@@ -386,8 +392,12 @@ static ssize_t m41t80_sysfs_show_sqwfreq(struct device *dev,
386 struct device_attribute *attr, char *buf) 392 struct device_attribute *attr, char *buf)
387{ 393{
388 struct i2c_client *client = to_i2c_client(dev); 394 struct i2c_client *client = to_i2c_client(dev);
395 struct m41t80_data *clientdata = i2c_get_clientdata(client);
389 int val; 396 int val;
390 397
398 if (!(clientdata->features & M41T80_FEATURE_SQ))
399 return -EINVAL;
400
391 val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW); 401 val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW);
392 if (val < 0) 402 if (val < 0)
393 return -EIO; 403 return -EIO;
@@ -408,9 +418,13 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev,
408 const char *buf, size_t count) 418 const char *buf, size_t count)
409{ 419{
410 struct i2c_client *client = to_i2c_client(dev); 420 struct i2c_client *client = to_i2c_client(dev);
421 struct m41t80_data *clientdata = i2c_get_clientdata(client);
411 int almon, sqw; 422 int almon, sqw;
412 int val = simple_strtoul(buf, NULL, 0); 423 int val = simple_strtoul(buf, NULL, 0);
413 424
425 if (!(clientdata->features & M41T80_FEATURE_SQ))
426 return -EINVAL;
427
414 if (val) { 428 if (val) {
415 if (!is_power_of_2(val)) 429 if (!is_power_of_2(val))
416 return -EINVAL; 430 return -EINVAL;
@@ -499,6 +513,8 @@ static void wdt_ping(void)
499 .buf = i2c_data, 513 .buf = i2c_data,
500 }, 514 },
501 }; 515 };
516 struct m41t80_data *clientdata = i2c_get_clientdata(save_client);
517
502 i2c_data[0] = 0x09; /* watchdog register */ 518 i2c_data[0] = 0x09; /* watchdog register */
503 519
504 if (wdt_margin > 31) 520 if (wdt_margin > 31)
@@ -509,6 +525,13 @@ static void wdt_ping(void)
509 */ 525 */
510 i2c_data[1] = wdt_margin<<2 | 0x82; 526 i2c_data[1] = wdt_margin<<2 | 0x82;
511 527
528 /*
529 * M41T65 has three bits for watchdog resolution. Don't set bit 7, as
530 * that would be an invalid resolution.
531 */
532 if (clientdata->features & M41T80_FEATURE_WD)
533 i2c_data[1] &= ~M41T80_WATCHDOG_RB2;
534
512 i2c_transfer(save_client->adapter, msgs1, 1); 535 i2c_transfer(save_client->adapter, msgs1, 1);
513} 536}
514 537
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c
index b9c1fe4a198e..0b2197559940 100644
--- a/drivers/rtc/rtc-m48t35.c
+++ b/drivers/rtc/rtc-m48t35.c
@@ -18,6 +18,7 @@
18#include <linux/rtc.h> 18#include <linux/rtc.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/bcd.h> 20#include <linux/bcd.h>
21#include <linux/io.h>
21 22
22#define DRV_VERSION "1.0" 23#define DRV_VERSION "1.0"
23 24
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c
index ded3c0abad83..12c9cd25cad8 100644
--- a/drivers/rtc/rtc-max6900.c
+++ b/drivers/rtc/rtc-max6900.c
@@ -17,19 +17,18 @@
17#include <linux/rtc.h> 17#include <linux/rtc.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19 19
20#define DRV_NAME "max6900" 20#define DRV_VERSION "0.2"
21#define DRV_VERSION "0.1"
22 21
23/* 22/*
24 * register indices 23 * register indices
25 */ 24 */
26#define MAX6900_REG_SC 0 /* seconds 00-59 */ 25#define MAX6900_REG_SC 0 /* seconds 00-59 */
27#define MAX6900_REG_MN 1 /* minutes 00-59 */ 26#define MAX6900_REG_MN 1 /* minutes 00-59 */
28#define MAX6900_REG_HR 2 /* hours 00-23 */ 27#define MAX6900_REG_HR 2 /* hours 00-23 */
29#define MAX6900_REG_DT 3 /* day of month 00-31 */ 28#define MAX6900_REG_DT 3 /* day of month 00-31 */
30#define MAX6900_REG_MO 4 /* month 01-12 */ 29#define MAX6900_REG_MO 4 /* month 01-12 */
31#define MAX6900_REG_DW 5 /* day of week 1-7 */ 30#define MAX6900_REG_DW 5 /* day of week 1-7 */
32#define MAX6900_REG_YR 6 /* year 00-99 */ 31#define MAX6900_REG_YR 6 /* year 00-99 */
33#define MAX6900_REG_CT 7 /* control */ 32#define MAX6900_REG_CT 7 /* control */
34 /* register 8 is undocumented */ 33 /* register 8 is undocumented */
35#define MAX6900_REG_CENTURY 9 /* century */ 34#define MAX6900_REG_CENTURY 9 /* century */
@@ -39,7 +38,6 @@
39 38
40#define MAX6900_REG_CT_WP (1 << 7) /* Write Protect */ 39#define MAX6900_REG_CT_WP (1 << 7) /* Write Protect */
41 40
42
43/* 41/*
44 * register read/write commands 42 * register read/write commands
45 */ 43 */
@@ -52,16 +50,7 @@
52 50
53#define MAX6900_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */ 51#define MAX6900_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */
54 52
55#define MAX6900_I2C_ADDR 0xa0 53static struct i2c_driver max6900_driver;
56
57static const unsigned short normal_i2c[] = {
58 MAX6900_I2C_ADDR >> 1,
59 I2C_CLIENT_END
60};
61
62I2C_CLIENT_INSMOD; /* defines addr_data */
63
64static int max6900_probe(struct i2c_adapter *adapter, int addr, int kind);
65 54
66static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf) 55static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
67{ 56{
@@ -69,36 +58,35 @@ static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
69 u8 reg_century_read[1] = { MAX6900_REG_CENTURY_READ }; 58 u8 reg_century_read[1] = { MAX6900_REG_CENTURY_READ };
70 struct i2c_msg msgs[4] = { 59 struct i2c_msg msgs[4] = {
71 { 60 {
72 .addr = client->addr, 61 .addr = client->addr,
73 .flags = 0, /* write */ 62 .flags = 0, /* write */
74 .len = sizeof(reg_burst_read), 63 .len = sizeof(reg_burst_read),
75 .buf = reg_burst_read 64 .buf = reg_burst_read}
76 }, 65 ,
77 { 66 {
78 .addr = client->addr, 67 .addr = client->addr,
79 .flags = I2C_M_RD, 68 .flags = I2C_M_RD,
80 .len = MAX6900_BURST_LEN, 69 .len = MAX6900_BURST_LEN,
81 .buf = buf 70 .buf = buf}
82 }, 71 ,
83 { 72 {
84 .addr = client->addr, 73 .addr = client->addr,
85 .flags = 0, /* write */ 74 .flags = 0, /* write */
86 .len = sizeof(reg_century_read), 75 .len = sizeof(reg_century_read),
87 .buf = reg_century_read 76 .buf = reg_century_read}
88 }, 77 ,
89 { 78 {
90 .addr = client->addr, 79 .addr = client->addr,
91 .flags = I2C_M_RD, 80 .flags = I2C_M_RD,
92 .len = sizeof(buf[MAX6900_REG_CENTURY]), 81 .len = sizeof(buf[MAX6900_REG_CENTURY]),
93 .buf = &buf[MAX6900_REG_CENTURY] 82 .buf = &buf[MAX6900_REG_CENTURY]
94 } 83 }
95 }; 84 };
96 int rc; 85 int rc;
97 86
98 rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); 87 rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
99 if (rc != ARRAY_SIZE(msgs)) { 88 if (rc != ARRAY_SIZE(msgs)) {
100 dev_err(&client->dev, "%s: register read failed\n", 89 dev_err(&client->dev, "%s: register read failed\n", __func__);
101 __func__);
102 return -EIO; 90 return -EIO;
103 } 91 }
104 return 0; 92 return 0;
@@ -109,20 +97,18 @@ static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
109 u8 i2c_century_buf[1 + 1] = { MAX6900_REG_CENTURY_WRITE }; 97 u8 i2c_century_buf[1 + 1] = { MAX6900_REG_CENTURY_WRITE };
110 struct i2c_msg century_msgs[1] = { 98 struct i2c_msg century_msgs[1] = {
111 { 99 {
112 .addr = client->addr, 100 .addr = client->addr,
113 .flags = 0, /* write */ 101 .flags = 0, /* write */
114 .len = sizeof(i2c_century_buf), 102 .len = sizeof(i2c_century_buf),
115 .buf = i2c_century_buf 103 .buf = i2c_century_buf}
116 }
117 }; 104 };
118 u8 i2c_burst_buf[MAX6900_BURST_LEN + 1] = { MAX6900_REG_BURST_WRITE }; 105 u8 i2c_burst_buf[MAX6900_BURST_LEN + 1] = { MAX6900_REG_BURST_WRITE };
119 struct i2c_msg burst_msgs[1] = { 106 struct i2c_msg burst_msgs[1] = {
120 { 107 {
121 .addr = client->addr, 108 .addr = client->addr,
122 .flags = 0, /* write */ 109 .flags = 0, /* write */
123 .len = sizeof(i2c_burst_buf), 110 .len = sizeof(i2c_burst_buf),
124 .buf = i2c_burst_buf 111 .buf = i2c_burst_buf}
125 }
126 }; 112 };
127 int rc; 113 int rc;
128 114
@@ -133,10 +119,12 @@ static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
133 * bit as part of the burst write. 119 * bit as part of the burst write.
134 */ 120 */
135 i2c_century_buf[1] = buf[MAX6900_REG_CENTURY]; 121 i2c_century_buf[1] = buf[MAX6900_REG_CENTURY];
122
136 rc = i2c_transfer(client->adapter, century_msgs, 123 rc = i2c_transfer(client->adapter, century_msgs,
137 ARRAY_SIZE(century_msgs)); 124 ARRAY_SIZE(century_msgs));
138 if (rc != ARRAY_SIZE(century_msgs)) 125 if (rc != ARRAY_SIZE(century_msgs))
139 goto write_failed; 126 goto write_failed;
127
140 msleep(MAX6900_IDLE_TIME_AFTER_WRITE); 128 msleep(MAX6900_IDLE_TIME_AFTER_WRITE);
141 129
142 memcpy(&i2c_burst_buf[1], buf, MAX6900_BURST_LEN); 130 memcpy(&i2c_burst_buf[1], buf, MAX6900_BURST_LEN);
@@ -148,45 +136,11 @@ static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
148 136
149 return 0; 137 return 0;
150 138
151write_failed: 139 write_failed:
152 dev_err(&client->dev, "%s: register write failed\n", 140 dev_err(&client->dev, "%s: register write failed\n", __func__);
153 __func__);
154 return -EIO; 141 return -EIO;
155} 142}
156 143
157static int max6900_i2c_validate_client(struct i2c_client *client)
158{
159 u8 regs[MAX6900_REG_LEN];
160 u8 zero_mask[] = {
161 0x80, /* seconds */
162 0x80, /* minutes */
163 0x40, /* hours */
164 0xc0, /* day of month */
165 0xe0, /* month */
166 0xf8, /* day of week */
167 0x00, /* year */
168 0x7f, /* control */
169 };
170 int i;
171 int rc;
172 int reserved;
173
174 reserved = i2c_smbus_read_byte_data(client, MAX6900_REG_RESERVED_READ);
175 if (reserved != 0x07)
176 return -ENODEV;
177
178 rc = max6900_i2c_read_regs(client, regs);
179 if (rc < 0)
180 return rc;
181
182 for (i = 0; i < ARRAY_SIZE(zero_mask); ++i) {
183 if (regs[i] & zero_mask[i])
184 return -ENODEV;
185 }
186
187 return 0;
188}
189
190static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) 144static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
191{ 145{
192 int rc; 146 int rc;
@@ -202,7 +156,7 @@ static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
202 tm->tm_mday = BCD2BIN(regs[MAX6900_REG_DT]); 156 tm->tm_mday = BCD2BIN(regs[MAX6900_REG_DT]);
203 tm->tm_mon = BCD2BIN(regs[MAX6900_REG_MO]) - 1; 157 tm->tm_mon = BCD2BIN(regs[MAX6900_REG_MO]) - 1;
204 tm->tm_year = BCD2BIN(regs[MAX6900_REG_YR]) + 158 tm->tm_year = BCD2BIN(regs[MAX6900_REG_YR]) +
205 BCD2BIN(regs[MAX6900_REG_CENTURY]) * 100 - 1900; 159 BCD2BIN(regs[MAX6900_REG_CENTURY]) * 100 - 1900;
206 tm->tm_wday = BCD2BIN(regs[MAX6900_REG_DW]); 160 tm->tm_wday = BCD2BIN(regs[MAX6900_REG_DW]);
207 161
208 return 0; 162 return 0;
@@ -211,7 +165,7 @@ static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
211static int max6900_i2c_clear_write_protect(struct i2c_client *client) 165static int max6900_i2c_clear_write_protect(struct i2c_client *client)
212{ 166{
213 int rc; 167 int rc;
214 rc = i2c_smbus_write_byte_data (client, MAX6900_REG_CONTROL_WRITE, 0); 168 rc = i2c_smbus_write_byte_data(client, MAX6900_REG_CONTROL_WRITE, 0);
215 if (rc < 0) { 169 if (rc < 0) {
216 dev_err(&client->dev, "%s: control register write failed\n", 170 dev_err(&client->dev, "%s: control register write failed\n",
217 __func__); 171 __func__);
@@ -220,8 +174,8 @@ static int max6900_i2c_clear_write_protect(struct i2c_client *client)
220 return 0; 174 return 0;
221} 175}
222 176
223static int max6900_i2c_set_time(struct i2c_client *client, 177static int
224 struct rtc_time const *tm) 178max6900_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
225{ 179{
226 u8 regs[MAX6900_REG_LEN]; 180 u8 regs[MAX6900_REG_LEN];
227 int rc; 181 int rc;
@@ -258,89 +212,49 @@ static int max6900_rtc_set_time(struct device *dev, struct rtc_time *tm)
258 return max6900_i2c_set_time(to_i2c_client(dev), tm); 212 return max6900_i2c_set_time(to_i2c_client(dev), tm);
259} 213}
260 214
261static int max6900_attach_adapter(struct i2c_adapter *adapter) 215static int max6900_remove(struct i2c_client *client)
262{
263 return i2c_probe(adapter, &addr_data, max6900_probe);
264}
265
266static int max6900_detach_client(struct i2c_client *client)
267{ 216{
268 struct rtc_device *const rtc = i2c_get_clientdata(client); 217 struct rtc_device *rtc = i2c_get_clientdata(client);
269 218
270 if (rtc) 219 if (rtc)
271 rtc_device_unregister(rtc); 220 rtc_device_unregister(rtc);
272 221
273 return i2c_detach_client(client); 222 return 0;
274} 223}
275 224
276static struct i2c_driver max6900_driver = {
277 .driver = {
278 .name = DRV_NAME,
279 },
280 .id = I2C_DRIVERID_MAX6900,
281 .attach_adapter = max6900_attach_adapter,
282 .detach_client = max6900_detach_client,
283};
284
285static const struct rtc_class_ops max6900_rtc_ops = { 225static const struct rtc_class_ops max6900_rtc_ops = {
286 .read_time = max6900_rtc_read_time, 226 .read_time = max6900_rtc_read_time,
287 .set_time = max6900_rtc_set_time, 227 .set_time = max6900_rtc_set_time,
288}; 228};
289 229
290static int max6900_probe(struct i2c_adapter *adapter, int addr, int kind) 230static int
231max6900_probe(struct i2c_client *client, const struct i2c_device_id *id)
291{ 232{
292 int rc = 0; 233 struct rtc_device *rtc;
293 struct i2c_client *client = NULL;
294 struct rtc_device *rtc = NULL;
295
296 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
297 rc = -ENODEV;
298 goto failout;
299 }
300
301 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
302 if (client == NULL) {
303 rc = -ENOMEM;
304 goto failout;
305 }
306
307 client->addr = addr;
308 client->adapter = adapter;
309 client->driver = &max6900_driver;
310 strlcpy(client->name, DRV_NAME, I2C_NAME_SIZE);
311
312 if (kind < 0) {
313 rc = max6900_i2c_validate_client(client);
314 if (rc < 0)
315 goto failout;
316 }
317 234
318 rc = i2c_attach_client(client); 235 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
319 if (rc < 0) 236 return -ENODEV;
320 goto failout;
321 237
322 dev_info(&client->dev, 238 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
323 "chip found, driver version " DRV_VERSION "\n");
324 239
325 rtc = rtc_device_register(max6900_driver.driver.name, 240 rtc = rtc_device_register(max6900_driver.driver.name,
326 &client->dev, 241 &client->dev, &max6900_rtc_ops, THIS_MODULE);
327 &max6900_rtc_ops, THIS_MODULE); 242 if (IS_ERR(rtc))
328 if (IS_ERR(rtc)) { 243 return PTR_ERR(rtc);
329 rc = PTR_ERR(rtc);
330 goto failout_detach;
331 }
332 244
333 i2c_set_clientdata(client, rtc); 245 i2c_set_clientdata(client, rtc);
334 246
335 return 0; 247 return 0;
336
337failout_detach:
338 i2c_detach_client(client);
339failout:
340 kfree(client);
341 return rc;
342} 248}
343 249
250static struct i2c_driver max6900_driver = {
251 .driver = {
252 .name = "rtc-max6900",
253 },
254 .probe = max6900_probe,
255 .remove = max6900_remove,
256};
257
344static int __init max6900_init(void) 258static int __init max6900_init(void)
345{ 259{
346 return i2c_add_driver(&max6900_driver); 260 return i2c_add_driver(&max6900_driver);
@@ -352,6 +266,7 @@ static void __exit max6900_exit(void)
352} 266}
353 267
354MODULE_DESCRIPTION("Maxim MAX6900 RTC driver"); 268MODULE_DESCRIPTION("Maxim MAX6900 RTC driver");
269MODULE_AUTHOR("Dale Farnsworth <dale@farnsworth.org>");
355MODULE_LICENSE("GPL"); 270MODULE_LICENSE("GPL");
356MODULE_VERSION(DRV_VERSION); 271MODULE_VERSION(DRV_VERSION);
357 272
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 748a502a6355..a829f20ad6d6 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -179,58 +179,6 @@ struct pcf8563_limit
179 unsigned char max; 179 unsigned char max;
180}; 180};
181 181
182static int pcf8563_validate_client(struct i2c_client *client)
183{
184 int i;
185
186 static const struct pcf8563_limit pattern[] = {
187 /* register, mask, min, max */
188 { PCF8563_REG_SC, 0x7F, 0, 59 },
189 { PCF8563_REG_MN, 0x7F, 0, 59 },
190 { PCF8563_REG_HR, 0x3F, 0, 23 },
191 { PCF8563_REG_DM, 0x3F, 0, 31 },
192 { PCF8563_REG_MO, 0x1F, 0, 12 },
193 };
194
195 /* check limits (only registers with bcd values) */
196 for (i = 0; i < ARRAY_SIZE(pattern); i++) {
197 int xfer;
198 unsigned char value;
199 unsigned char buf = pattern[i].reg;
200
201 struct i2c_msg msgs[] = {
202 { client->addr, 0, 1, &buf },
203 { client->addr, I2C_M_RD, 1, &buf },
204 };
205
206 xfer = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
207
208 if (xfer != ARRAY_SIZE(msgs)) {
209 dev_err(&client->dev,
210 "%s: could not read register 0x%02X\n",
211 __func__, pattern[i].reg);
212
213 return -EIO;
214 }
215
216 value = BCD2BIN(buf & pattern[i].mask);
217
218 if (value > pattern[i].max ||
219 value < pattern[i].min) {
220 dev_dbg(&client->dev,
221 "%s: pattern=%d, reg=%x, mask=0x%02x, min=%d, "
222 "max=%d, value=%d, raw=0x%02X\n",
223 __func__, i, pattern[i].reg, pattern[i].mask,
224 pattern[i].min, pattern[i].max,
225 value, buf);
226
227 return -ENODEV;
228 }
229 }
230
231 return 0;
232}
233
234static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) 182static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
235{ 183{
236 return pcf8563_get_datetime(to_i2c_client(dev), tm); 184 return pcf8563_get_datetime(to_i2c_client(dev), tm);
@@ -262,12 +210,6 @@ static int pcf8563_probe(struct i2c_client *client,
262 if (!pcf8563) 210 if (!pcf8563)
263 return -ENOMEM; 211 return -ENOMEM;
264 212
265 /* Verify the chip is really an PCF8563 */
266 if (pcf8563_validate_client(client) < 0) {
267 err = -ENODEV;
268 goto exit_kfree;
269 }
270
271 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); 213 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
272 214
273 pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, 215 pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name,
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index 8448eeb9d675..826153552157 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -34,15 +34,6 @@ static irqreturn_t pl030_interrupt(int irq, void *dev_id)
34 return IRQ_HANDLED; 34 return IRQ_HANDLED;
35} 35}
36 36
37static int pl030_open(struct device *dev)
38{
39 return 0;
40}
41
42static void pl030_release(struct device *dev)
43{
44}
45
46static int pl030_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 37static int pl030_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
47{ 38{
48 return -ENOIOCTLCMD; 39 return -ENOIOCTLCMD;
@@ -104,8 +95,6 @@ static int pl030_set_time(struct device *dev, struct rtc_time *tm)
104} 95}
105 96
106static const struct rtc_class_ops pl030_ops = { 97static const struct rtc_class_ops pl030_ops = {
107 .open = pl030_open,
108 .release = pl030_release,
109 .ioctl = pl030_ioctl, 98 .ioctl = pl030_ioctl,
110 .read_time = pl030_read_time, 99 .read_time = pl030_read_time,
111 .set_time = pl030_set_time, 100 .set_time = pl030_set_time,
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 08b4610ec5a6..333eec689d2f 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -45,18 +45,6 @@ static irqreturn_t pl031_interrupt(int irq, void *dev_id)
45 return IRQ_HANDLED; 45 return IRQ_HANDLED;
46} 46}
47 47
48static int pl031_open(struct device *dev)
49{
50 /*
51 * We request IRQ in pl031_probe, so nothing to do here...
52 */
53 return 0;
54}
55
56static void pl031_release(struct device *dev)
57{
58}
59
60static int pl031_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 48static int pl031_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
61{ 49{
62 struct pl031_local *ldata = dev_get_drvdata(dev); 50 struct pl031_local *ldata = dev_get_drvdata(dev);
@@ -118,8 +106,6 @@ static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
118} 106}
119 107
120static const struct rtc_class_ops pl031_ops = { 108static const struct rtc_class_ops pl031_ops = {
121 .open = pl031_open,
122 .release = pl031_release,
123 .ioctl = pl031_ioctl, 109 .ioctl = pl031_ioctl,
124 .read_time = pl031_read_time, 110 .read_time = pl031_read_time,
125 .set_time = pl031_set_time, 111 .set_time = pl031_set_time,
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 56caf6b2c3e5..8b561958fb1e 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * An I2C driver for Ricoh RS5C372 and RV5C38[67] RTCs 2 * An I2C driver for Ricoh RS5C372, R2025S/D and RV5C38[67] RTCs
3 * 3 *
4 * Copyright (C) 2005 Pavel Mironchik <pmironchik@optifacio.net> 4 * Copyright (C) 2005 Pavel Mironchik <pmironchik@optifacio.net>
5 * Copyright (C) 2006 Tower Technologies 5 * Copyright (C) 2006 Tower Technologies
6 * Copyright (C) 2008 Paul Mundt
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License version 2 as
@@ -13,7 +14,7 @@
13#include <linux/rtc.h> 14#include <linux/rtc.h>
14#include <linux/bcd.h> 15#include <linux/bcd.h>
15 16
16#define DRV_VERSION "0.5" 17#define DRV_VERSION "0.6"
17 18
18 19
19/* 20/*
@@ -51,7 +52,8 @@
51# define RS5C_CTRL1_CT4 (4 << 0) /* 1 Hz level irq */ 52# define RS5C_CTRL1_CT4 (4 << 0) /* 1 Hz level irq */
52#define RS5C_REG_CTRL2 15 53#define RS5C_REG_CTRL2 15
53# define RS5C372_CTRL2_24 (1 << 5) 54# define RS5C372_CTRL2_24 (1 << 5)
54# define RS5C_CTRL2_XSTP (1 << 4) 55# define R2025_CTRL2_XST (1 << 5)
56# define RS5C_CTRL2_XSTP (1 << 4) /* only if !R2025S/D */
55# define RS5C_CTRL2_CTFG (1 << 2) 57# define RS5C_CTRL2_CTFG (1 << 2)
56# define RS5C_CTRL2_AAFG (1 << 1) /* or WAFG */ 58# define RS5C_CTRL2_AAFG (1 << 1) /* or WAFG */
57# define RS5C_CTRL2_BAFG (1 << 0) /* or DAFG */ 59# define RS5C_CTRL2_BAFG (1 << 0) /* or DAFG */
@@ -63,6 +65,7 @@
63 65
64enum rtc_type { 66enum rtc_type {
65 rtc_undef = 0, 67 rtc_undef = 0,
68 rtc_r2025sd,
66 rtc_rs5c372a, 69 rtc_rs5c372a,
67 rtc_rs5c372b, 70 rtc_rs5c372b,
68 rtc_rv5c386, 71 rtc_rv5c386,
@@ -70,6 +73,7 @@ enum rtc_type {
70}; 73};
71 74
72static const struct i2c_device_id rs5c372_id[] = { 75static const struct i2c_device_id rs5c372_id[] = {
76 { "r2025sd", rtc_r2025sd },
73 { "rs5c372a", rtc_rs5c372a }, 77 { "rs5c372a", rtc_rs5c372a },
74 { "rs5c372b", rtc_rs5c372b }, 78 { "rs5c372b", rtc_rs5c372b },
75 { "rv5c386", rtc_rv5c386 }, 79 { "rv5c386", rtc_rv5c386 },
@@ -89,6 +93,7 @@ struct rs5c372 {
89 enum rtc_type type; 93 enum rtc_type type;
90 unsigned time24:1; 94 unsigned time24:1;
91 unsigned has_irq:1; 95 unsigned has_irq:1;
96 unsigned smbus:1;
92 char buf[17]; 97 char buf[17];
93 char *regs; 98 char *regs;
94}; 99};
@@ -106,10 +111,25 @@ static int rs5c_get_regs(struct rs5c372 *rs5c)
106 * 111 *
107 * The first method doesn't work with the iop3xx adapter driver, on at 112 * The first method doesn't work with the iop3xx adapter driver, on at
108 * least 80219 chips; this works around that bug. 113 * least 80219 chips; this works around that bug.
114 *
115 * The third method on the other hand doesn't work for the SMBus-only
116 * configurations, so we use the the first method there, stripping off
117 * the extra register in the process.
109 */ 118 */
110 if ((i2c_transfer(client->adapter, msgs, 1)) != 1) { 119 if (rs5c->smbus) {
111 dev_warn(&client->dev, "can't read registers\n"); 120 int addr = RS5C_ADDR(RS5C372_REG_SECS);
112 return -EIO; 121 int size = sizeof(rs5c->buf) - 1;
122
123 if (i2c_smbus_read_i2c_block_data(client, addr, size,
124 rs5c->buf + 1) != size) {
125 dev_warn(&client->dev, "can't read registers\n");
126 return -EIO;
127 }
128 } else {
129 if ((i2c_transfer(client->adapter, msgs, 1)) != 1) {
130 dev_warn(&client->dev, "can't read registers\n");
131 return -EIO;
132 }
113 } 133 }
114 134
115 dev_dbg(&client->dev, 135 dev_dbg(&client->dev,
@@ -187,6 +207,7 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
187{ 207{
188 struct rs5c372 *rs5c = i2c_get_clientdata(client); 208 struct rs5c372 *rs5c = i2c_get_clientdata(client);
189 unsigned char buf[8]; 209 unsigned char buf[8];
210 int addr;
190 211
191 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d " 212 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d "
192 "mday=%d, mon=%d, year=%d, wday=%d\n", 213 "mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -194,16 +215,16 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
194 tm->tm_sec, tm->tm_min, tm->tm_hour, 215 tm->tm_sec, tm->tm_min, tm->tm_hour,
195 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 216 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
196 217
197 buf[0] = RS5C_ADDR(RS5C372_REG_SECS); 218 addr = RS5C_ADDR(RS5C372_REG_SECS);
198 buf[1] = BIN2BCD(tm->tm_sec); 219 buf[0] = BIN2BCD(tm->tm_sec);
199 buf[2] = BIN2BCD(tm->tm_min); 220 buf[1] = BIN2BCD(tm->tm_min);
200 buf[3] = rs5c_hr2reg(rs5c, tm->tm_hour); 221 buf[2] = rs5c_hr2reg(rs5c, tm->tm_hour);
201 buf[4] = BIN2BCD(tm->tm_wday); 222 buf[3] = BIN2BCD(tm->tm_wday);
202 buf[5] = BIN2BCD(tm->tm_mday); 223 buf[4] = BIN2BCD(tm->tm_mday);
203 buf[6] = BIN2BCD(tm->tm_mon + 1); 224 buf[5] = BIN2BCD(tm->tm_mon + 1);
204 buf[7] = BIN2BCD(tm->tm_year - 100); 225 buf[6] = BIN2BCD(tm->tm_year - 100);
205 226
206 if ((i2c_master_send(client, buf, 8)) != 8) { 227 if (i2c_smbus_write_i2c_block_data(client, addr, sizeof(buf), buf) < 0) {
207 dev_err(&client->dev, "%s: write error\n", __func__); 228 dev_err(&client->dev, "%s: write error\n", __func__);
208 return -EIO; 229 return -EIO;
209 } 230 }
@@ -266,16 +287,16 @@ rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
266{ 287{
267 struct i2c_client *client = to_i2c_client(dev); 288 struct i2c_client *client = to_i2c_client(dev);
268 struct rs5c372 *rs5c = i2c_get_clientdata(client); 289 struct rs5c372 *rs5c = i2c_get_clientdata(client);
269 unsigned char buf[2]; 290 unsigned char buf;
270 int status; 291 int status, addr;
271 292
272 buf[1] = rs5c->regs[RS5C_REG_CTRL1]; 293 buf = rs5c->regs[RS5C_REG_CTRL1];
273 switch (cmd) { 294 switch (cmd) {
274 case RTC_UIE_OFF: 295 case RTC_UIE_OFF:
275 case RTC_UIE_ON: 296 case RTC_UIE_ON:
276 /* some 327a modes use a different IRQ pin for 1Hz irqs */ 297 /* some 327a modes use a different IRQ pin for 1Hz irqs */
277 if (rs5c->type == rtc_rs5c372a 298 if (rs5c->type == rtc_rs5c372a
278 && (buf[1] & RS5C372A_CTRL1_SL1)) 299 && (buf & RS5C372A_CTRL1_SL1))
279 return -ENOIOCTLCMD; 300 return -ENOIOCTLCMD;
280 case RTC_AIE_OFF: 301 case RTC_AIE_OFF:
281 case RTC_AIE_ON: 302 case RTC_AIE_ON:
@@ -293,28 +314,30 @@ rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
293 if (status < 0) 314 if (status < 0)
294 return status; 315 return status;
295 316
296 buf[0] = RS5C_ADDR(RS5C_REG_CTRL1); 317 addr = RS5C_ADDR(RS5C_REG_CTRL1);
297 switch (cmd) { 318 switch (cmd) {
298 case RTC_AIE_OFF: /* alarm off */ 319 case RTC_AIE_OFF: /* alarm off */
299 buf[1] &= ~RS5C_CTRL1_AALE; 320 buf &= ~RS5C_CTRL1_AALE;
300 break; 321 break;
301 case RTC_AIE_ON: /* alarm on */ 322 case RTC_AIE_ON: /* alarm on */
302 buf[1] |= RS5C_CTRL1_AALE; 323 buf |= RS5C_CTRL1_AALE;
303 break; 324 break;
304 case RTC_UIE_OFF: /* update off */ 325 case RTC_UIE_OFF: /* update off */
305 buf[1] &= ~RS5C_CTRL1_CT_MASK; 326 buf &= ~RS5C_CTRL1_CT_MASK;
306 break; 327 break;
307 case RTC_UIE_ON: /* update on */ 328 case RTC_UIE_ON: /* update on */
308 buf[1] &= ~RS5C_CTRL1_CT_MASK; 329 buf &= ~RS5C_CTRL1_CT_MASK;
309 buf[1] |= RS5C_CTRL1_CT4; 330 buf |= RS5C_CTRL1_CT4;
310 break; 331 break;
311 } 332 }
312 if ((i2c_master_send(client, buf, 2)) != 2) { 333
334 if (i2c_smbus_write_byte_data(client, addr, buf) < 0) {
313 printk(KERN_WARNING "%s: can't update alarm\n", 335 printk(KERN_WARNING "%s: can't update alarm\n",
314 rs5c->rtc->name); 336 rs5c->rtc->name);
315 status = -EIO; 337 status = -EIO;
316 } else 338 } else
317 rs5c->regs[RS5C_REG_CTRL1] = buf[1]; 339 rs5c->regs[RS5C_REG_CTRL1] = buf;
340
318 return status; 341 return status;
319} 342}
320 343
@@ -364,8 +387,8 @@ static int rs5c_set_alarm(struct device *dev, struct rtc_wkalrm *t)
364{ 387{
365 struct i2c_client *client = to_i2c_client(dev); 388 struct i2c_client *client = to_i2c_client(dev);
366 struct rs5c372 *rs5c = i2c_get_clientdata(client); 389 struct rs5c372 *rs5c = i2c_get_clientdata(client);
367 int status; 390 int status, addr, i;
368 unsigned char buf[4]; 391 unsigned char buf[3];
369 392
370 /* only handle up to 24 hours in the future, like RTC_ALM_SET */ 393 /* only handle up to 24 hours in the future, like RTC_ALM_SET */
371 if (t->time.tm_mday != -1 394 if (t->time.tm_mday != -1
@@ -380,33 +403,36 @@ static int rs5c_set_alarm(struct device *dev, struct rtc_wkalrm *t)
380 if (status < 0) 403 if (status < 0)
381 return status; 404 return status;
382 if (rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE) { 405 if (rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE) {
383 buf[0] = RS5C_ADDR(RS5C_REG_CTRL1); 406 addr = RS5C_ADDR(RS5C_REG_CTRL1);
384 buf[1] = rs5c->regs[RS5C_REG_CTRL1] & ~RS5C_CTRL1_AALE; 407 buf[0] = rs5c->regs[RS5C_REG_CTRL1] & ~RS5C_CTRL1_AALE;
385 if (i2c_master_send(client, buf, 2) != 2) { 408 if (i2c_smbus_write_byte_data(client, addr, buf[0]) < 0) {
386 pr_debug("%s: can't disable alarm\n", rs5c->rtc->name); 409 pr_debug("%s: can't disable alarm\n", rs5c->rtc->name);
387 return -EIO; 410 return -EIO;
388 } 411 }
389 rs5c->regs[RS5C_REG_CTRL1] = buf[1]; 412 rs5c->regs[RS5C_REG_CTRL1] = buf[0];
390 } 413 }
391 414
392 /* set alarm */ 415 /* set alarm */
393 buf[0] = RS5C_ADDR(RS5C_REG_ALARM_A_MIN); 416 buf[0] = BIN2BCD(t->time.tm_min);
394 buf[1] = BIN2BCD(t->time.tm_min); 417 buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour);
395 buf[2] = rs5c_hr2reg(rs5c, t->time.tm_hour); 418 buf[2] = 0x7f; /* any/all days */
396 buf[3] = 0x7f; /* any/all days */ 419
397 if ((i2c_master_send(client, buf, 4)) != 4) { 420 for (i = 0; i < sizeof(buf); i++) {
398 pr_debug("%s: can't set alarm time\n", rs5c->rtc->name); 421 addr = RS5C_ADDR(RS5C_REG_ALARM_A_MIN + i);
399 return -EIO; 422 if (i2c_smbus_write_byte_data(client, addr, buf[i]) < 0) {
423 pr_debug("%s: can't set alarm time\n", rs5c->rtc->name);
424 return -EIO;
425 }
400 } 426 }
401 427
402 /* ... and maybe enable its irq */ 428 /* ... and maybe enable its irq */
403 if (t->enabled) { 429 if (t->enabled) {
404 buf[0] = RS5C_ADDR(RS5C_REG_CTRL1); 430 addr = RS5C_ADDR(RS5C_REG_CTRL1);
405 buf[1] = rs5c->regs[RS5C_REG_CTRL1] | RS5C_CTRL1_AALE; 431 buf[0] = rs5c->regs[RS5C_REG_CTRL1] | RS5C_CTRL1_AALE;
406 if ((i2c_master_send(client, buf, 2)) != 2) 432 if (i2c_smbus_write_byte_data(client, addr, buf[0]) < 0)
407 printk(KERN_WARNING "%s: can't enable alarm\n", 433 printk(KERN_WARNING "%s: can't enable alarm\n",
408 rs5c->rtc->name); 434 rs5c->rtc->name);
409 rs5c->regs[RS5C_REG_CTRL1] = buf[1]; 435 rs5c->regs[RS5C_REG_CTRL1] = buf[0];
410 } 436 }
411 437
412 return 0; 438 return 0;
@@ -503,18 +529,81 @@ static void rs5c_sysfs_unregister(struct device *dev)
503 529
504static struct i2c_driver rs5c372_driver; 530static struct i2c_driver rs5c372_driver;
505 531
532static int rs5c_oscillator_setup(struct rs5c372 *rs5c372)
533{
534 unsigned char buf[2];
535 int addr, i, ret = 0;
536
537 if (rs5c372->type == rtc_r2025sd) {
538 if (!(rs5c372->regs[RS5C_REG_CTRL2] & R2025_CTRL2_XST))
539 return ret;
540 rs5c372->regs[RS5C_REG_CTRL2] &= ~R2025_CTRL2_XST;
541 } else {
542 if (!(rs5c372->regs[RS5C_REG_CTRL2] & RS5C_CTRL2_XSTP))
543 return ret;
544 rs5c372->regs[RS5C_REG_CTRL2] &= ~RS5C_CTRL2_XSTP;
545 }
546
547 addr = RS5C_ADDR(RS5C_REG_CTRL1);
548 buf[0] = rs5c372->regs[RS5C_REG_CTRL1];
549 buf[1] = rs5c372->regs[RS5C_REG_CTRL2];
550
551 /* use 24hr mode */
552 switch (rs5c372->type) {
553 case rtc_rs5c372a:
554 case rtc_rs5c372b:
555 buf[1] |= RS5C372_CTRL2_24;
556 rs5c372->time24 = 1;
557 break;
558 case rtc_r2025sd:
559 case rtc_rv5c386:
560 case rtc_rv5c387a:
561 buf[0] |= RV5C387_CTRL1_24;
562 rs5c372->time24 = 1;
563 break;
564 default:
565 /* impossible */
566 break;
567 }
568
569 for (i = 0; i < sizeof(buf); i++) {
570 addr = RS5C_ADDR(RS5C_REG_CTRL1 + i);
571 ret = i2c_smbus_write_byte_data(rs5c372->client, addr, buf[i]);
572 if (unlikely(ret < 0))
573 return ret;
574 }
575
576 rs5c372->regs[RS5C_REG_CTRL1] = buf[0];
577 rs5c372->regs[RS5C_REG_CTRL2] = buf[1];
578
579 return 0;
580}
581
506static int rs5c372_probe(struct i2c_client *client, 582static int rs5c372_probe(struct i2c_client *client,
507 const struct i2c_device_id *id) 583 const struct i2c_device_id *id)
508{ 584{
509 int err = 0; 585 int err = 0;
586 int smbus_mode = 0;
510 struct rs5c372 *rs5c372; 587 struct rs5c372 *rs5c372;
511 struct rtc_time tm; 588 struct rtc_time tm;
512 589
513 dev_dbg(&client->dev, "%s\n", __func__); 590 dev_dbg(&client->dev, "%s\n", __func__);
514 591
515 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 592 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C |
516 err = -ENODEV; 593 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK)) {
517 goto exit; 594 /*
595 * If we don't have any master mode adapter, try breaking
596 * it down in to the barest of capabilities.
597 */
598 if (i2c_check_functionality(client->adapter,
599 I2C_FUNC_SMBUS_BYTE_DATA |
600 I2C_FUNC_SMBUS_I2C_BLOCK))
601 smbus_mode = 1;
602 else {
603 /* Still no good, give up */
604 err = -ENODEV;
605 goto exit;
606 }
518 } 607 }
519 608
520 if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) { 609 if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) {
@@ -528,6 +617,7 @@ static int rs5c372_probe(struct i2c_client *client,
528 617
529 /* we read registers 0x0f then 0x00-0x0f; skip the first one */ 618 /* we read registers 0x0f then 0x00-0x0f; skip the first one */
530 rs5c372->regs = &rs5c372->buf[1]; 619 rs5c372->regs = &rs5c372->buf[1];
620 rs5c372->smbus = smbus_mode;
531 621
532 err = rs5c_get_regs(rs5c372); 622 err = rs5c_get_regs(rs5c372);
533 if (err < 0) 623 if (err < 0)
@@ -543,6 +633,7 @@ static int rs5c372_probe(struct i2c_client *client,
543 if (rs5c372->regs[RS5C_REG_CTRL2] & RS5C372_CTRL2_24) 633 if (rs5c372->regs[RS5C_REG_CTRL2] & RS5C372_CTRL2_24)
544 rs5c372->time24 = 1; 634 rs5c372->time24 = 1;
545 break; 635 break;
636 case rtc_r2025sd:
546 case rtc_rv5c386: 637 case rtc_rv5c386:
547 case rtc_rv5c387a: 638 case rtc_rv5c387a:
548 if (rs5c372->regs[RS5C_REG_CTRL1] & RV5C387_CTRL1_24) 639 if (rs5c372->regs[RS5C_REG_CTRL1] & RV5C387_CTRL1_24)
@@ -558,39 +649,14 @@ static int rs5c372_probe(struct i2c_client *client,
558 649
559 /* if the oscillator lost power and no other software (like 650 /* if the oscillator lost power and no other software (like
560 * the bootloader) set it up, do it here. 651 * the bootloader) set it up, do it here.
652 *
653 * The R2025S/D does this a little differently than the other
654 * parts, so we special case that..
561 */ 655 */
562 if (rs5c372->regs[RS5C_REG_CTRL2] & RS5C_CTRL2_XSTP) { 656 err = rs5c_oscillator_setup(rs5c372);
563 unsigned char buf[3]; 657 if (unlikely(err < 0)) {
564 658 dev_err(&client->dev, "setup error\n");
565 rs5c372->regs[RS5C_REG_CTRL2] &= ~RS5C_CTRL2_XSTP; 659 goto exit_kfree;
566
567 buf[0] = RS5C_ADDR(RS5C_REG_CTRL1);
568 buf[1] = rs5c372->regs[RS5C_REG_CTRL1];
569 buf[2] = rs5c372->regs[RS5C_REG_CTRL2];
570
571 /* use 24hr mode */
572 switch (rs5c372->type) {
573 case rtc_rs5c372a:
574 case rtc_rs5c372b:
575 buf[2] |= RS5C372_CTRL2_24;
576 rs5c372->time24 = 1;
577 break;
578 case rtc_rv5c386:
579 case rtc_rv5c387a:
580 buf[1] |= RV5C387_CTRL1_24;
581 rs5c372->time24 = 1;
582 break;
583 default:
584 /* impossible */
585 break;
586 }
587
588 if ((i2c_master_send(client, buf, 3)) != 3) {
589 dev_err(&client->dev, "setup error\n");
590 goto exit_kfree;
591 }
592 rs5c372->regs[RS5C_REG_CTRL1] = buf[1];
593 rs5c372->regs[RS5C_REG_CTRL2] = buf[2];
594 } 660 }
595 661
596 if (rs5c372_get_datetime(client, &tm) < 0) 662 if (rs5c372_get_datetime(client, &tm) < 0)
@@ -598,6 +664,7 @@ static int rs5c372_probe(struct i2c_client *client,
598 664
599 dev_info(&client->dev, "%s found, %s, driver version " DRV_VERSION "\n", 665 dev_info(&client->dev, "%s found, %s, driver version " DRV_VERSION "\n",
600 ({ char *s; switch (rs5c372->type) { 666 ({ char *s; switch (rs5c372->type) {
667 case rtc_r2025sd: s = "r2025sd"; break;
601 case rtc_rs5c372a: s = "rs5c372a"; break; 668 case rtc_rs5c372a: s = "rs5c372a"; break;
602 case rtc_rs5c372b: s = "rs5c372b"; break; 669 case rtc_rs5c372b: s = "rs5c372b"; break;
603 case rtc_rv5c386: s = "rv5c386"; break; 670 case rtc_rv5c386: s = "rv5c386"; break;
@@ -667,7 +734,8 @@ module_exit(rs5c372_exit);
667 734
668MODULE_AUTHOR( 735MODULE_AUTHOR(
669 "Pavel Mironchik <pmironchik@optifacio.net>, " 736 "Pavel Mironchik <pmironchik@optifacio.net>, "
670 "Alessandro Zummo <a.zummo@towertech.it>"); 737 "Alessandro Zummo <a.zummo@towertech.it>, "
738 "Paul Mundt <lethal@linux-sh.org>");
671MODULE_DESCRIPTION("Ricoh RS5C372 RTC driver"); 739MODULE_DESCRIPTION("Ricoh RS5C372 RTC driver");
672MODULE_LICENSE("GPL"); 740MODULE_LICENSE("GPL");
673MODULE_VERSION(DRV_VERSION); 741MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 1f88e9e914ec..fcead4c4cd1f 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -257,12 +257,6 @@ static inline void sh_rtc_setaie(struct device *dev, unsigned int enable)
257 spin_unlock_irq(&rtc->lock); 257 spin_unlock_irq(&rtc->lock);
258} 258}
259 259
260static void sh_rtc_release(struct device *dev)
261{
262 sh_rtc_setpie(dev, 0);
263 sh_rtc_setaie(dev, 0);
264}
265
266static int sh_rtc_proc(struct device *dev, struct seq_file *seq) 260static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
267{ 261{
268 struct sh_rtc *rtc = dev_get_drvdata(dev); 262 struct sh_rtc *rtc = dev_get_drvdata(dev);
@@ -559,7 +553,6 @@ static int sh_rtc_irq_set_freq(struct device *dev, int freq)
559} 553}
560 554
561static struct rtc_class_ops sh_rtc_ops = { 555static struct rtc_class_ops sh_rtc_ops = {
562 .release = sh_rtc_release,
563 .ioctl = sh_rtc_ioctl, 556 .ioctl = sh_rtc_ioctl,
564 .read_time = sh_rtc_read_time, 557 .read_time = sh_rtc_read_time,
565 .set_time = sh_rtc_set_time, 558 .set_time = sh_rtc_set_time,
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 31d3c8c28588..9a7e920315fa 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -215,17 +215,6 @@ static irqreturn_t stk17ta8_rtc_interrupt(int irq, void *dev_id)
215 return IRQ_HANDLED; 215 return IRQ_HANDLED;
216} 216}
217 217
218static void stk17ta8_rtc_release(struct device *dev)
219{
220 struct platform_device *pdev = to_platform_device(dev);
221 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
222
223 if (pdata->irq >= 0) {
224 pdata->irqen = 0;
225 stk17ta8_rtc_update_alarm(pdata);
226 }
227}
228
229static int stk17ta8_rtc_ioctl(struct device *dev, unsigned int cmd, 218static int stk17ta8_rtc_ioctl(struct device *dev, unsigned int cmd,
230 unsigned long arg) 219 unsigned long arg)
231{ 220{
@@ -254,7 +243,6 @@ static const struct rtc_class_ops stk17ta8_rtc_ops = {
254 .set_time = stk17ta8_rtc_set_time, 243 .set_time = stk17ta8_rtc_set_time,
255 .read_alarm = stk17ta8_rtc_read_alarm, 244 .read_alarm = stk17ta8_rtc_read_alarm,
256 .set_alarm = stk17ta8_rtc_set_alarm, 245 .set_alarm = stk17ta8_rtc_set_alarm,
257 .release = stk17ta8_rtc_release,
258 .ioctl = stk17ta8_rtc_ioctl, 246 .ioctl = stk17ta8_rtc_ioctl,
259}; 247};
260 248
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 1792b2c0130e..0b15cf107ec9 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -1168,19 +1168,17 @@ static int raw3270_create_attributes(struct raw3270 *rp)
1168 if (rc) 1168 if (rc)
1169 goto out; 1169 goto out;
1170 1170
1171 rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev, 1171 rp->clttydev = device_create(class3270, &rp->cdev->dev,
1172 MKDEV(IBM_TTY3270_MAJOR, rp->minor), 1172 MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL,
1173 NULL, 1173 "tty%s", dev_name(&rp->cdev->dev));
1174 "tty%s", dev_name(&rp->cdev->dev));
1175 if (IS_ERR(rp->clttydev)) { 1174 if (IS_ERR(rp->clttydev)) {
1176 rc = PTR_ERR(rp->clttydev); 1175 rc = PTR_ERR(rp->clttydev);
1177 goto out_ttydev; 1176 goto out_ttydev;
1178 } 1177 }
1179 1178
1180 rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev, 1179 rp->cltubdev = device_create(class3270, &rp->cdev->dev,
1181 MKDEV(IBM_FS3270_MAJOR, rp->minor), 1180 MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL,
1182 NULL, 1181 "tub%s", dev_name(&rp->cdev->dev));
1183 "tub%s", dev_name(&rp->cdev->dev));
1184 if (!IS_ERR(rp->cltubdev)) 1182 if (!IS_ERR(rp->cltubdev))
1185 goto out; 1183 goto out;
1186 1184
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index 12c2a5aaf31b..ddc914ccea8f 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -69,9 +69,9 @@ struct tape_class_device *register_tape_dev(
69 if (rc) 69 if (rc)
70 goto fail_with_cdev; 70 goto fail_with_cdev;
71 71
72 tcd->class_device = device_create_drvdata(tape_class, device, 72 tcd->class_device = device_create(tape_class, device,
73 tcd->char_device->dev, 73 tcd->char_device->dev, NULL,
74 NULL, "%s", tcd->device_name); 74 "%s", tcd->device_name);
75 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0; 75 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0;
76 if (rc) 76 if (rc)
77 goto fail_with_cdev; 77 goto fail_with_cdev;
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 42173cc34610..24762727bc27 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -747,10 +747,10 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
747 device_unregister(dev); 747 device_unregister(dev);
748 return ret; 748 return ret;
749 } 749 }
750 priv->class_device = device_create_drvdata(vmlogrdr_class, dev, 750 priv->class_device = device_create(vmlogrdr_class, dev,
751 MKDEV(vmlogrdr_major, 751 MKDEV(vmlogrdr_major,
752 priv->minor_num), 752 priv->minor_num),
753 priv, "%s", dev_name(dev)); 753 priv, "%s", dev_name(dev));
754 if (IS_ERR(priv->class_device)) { 754 if (IS_ERR(priv->class_device)) {
755 ret = PTR_ERR(priv->class_device); 755 ret = PTR_ERR(priv->class_device);
756 priv->class_device=NULL; 756 priv->class_device=NULL;
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 6fdfa5ddeca8..9020eba620ee 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -896,9 +896,8 @@ static int ur_set_online(struct ccw_device *cdev)
896 goto fail_free_cdev; 896 goto fail_free_cdev;
897 } 897 }
898 898
899 urd->device = device_create_drvdata(vmur_class, NULL, 899 urd->device = device_create(vmur_class, NULL, urd->char_device->dev,
900 urd->char_device->dev, NULL, 900 NULL, "%s", node_id);
901 "%s", node_id);
902 if (IS_ERR(urd->device)) { 901 if (IS_ERR(urd->device)) {
903 rc = PTR_ERR(urd->device); 902 rc = PTR_ERR(urd->device);
904 TRACE("ur_set_online: device_create rc=%d\n", rc); 903 TRACE("ur_set_online: device_create rc=%d\n", rc);
diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c
index cbe470493bf0..19f5d5ed85e0 100644
--- a/drivers/s390/net/ctcm_mpc.c
+++ b/drivers/s390/net/ctcm_mpc.c
@@ -1673,7 +1673,7 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo)
1673 1673
1674done: 1674done:
1675 if (rc) { 1675 if (rc) {
1676 ctcm_pr_info("ctcmpc : %s() failed\n", __FUNCTION__); 1676 ctcm_pr_info("ctcmpc : %s() failed\n", __func__);
1677 priv->xid->xid2_flag2 = 0x40; 1677 priv->xid->xid2_flag2 = 0x40;
1678 grp->saved_xid2->xid2_flag2 = 0x40; 1678 grp->saved_xid2->xid2_flag2 = 0x40;
1679 } 1679 }
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 3c257fe0893e..88ecf94ad979 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -914,9 +914,9 @@ static int ch_probe(struct device *dev)
914 ch->minor = minor; 914 ch->minor = minor;
915 sprintf(ch->name,"ch%d",ch->minor); 915 sprintf(ch->name,"ch%d",ch->minor);
916 916
917 class_dev = device_create_drvdata(ch_sysfs_class, dev, 917 class_dev = device_create(ch_sysfs_class, dev,
918 MKDEV(SCSI_CHANGER_MAJOR, ch->minor), 918 MKDEV(SCSI_CHANGER_MAJOR, ch->minor), ch,
919 ch, "s%s", ch->name); 919 "s%s", ch->name);
920 if (IS_ERR(class_dev)) { 920 if (IS_ERR(class_dev)) {
921 printk(KERN_WARNING "ch%d: device_create failed\n", 921 printk(KERN_WARNING "ch%d: device_create failed\n",
922 ch->minor); 922 ch->minor);
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 1fe0901e8119..8aba4fdfb522 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -271,7 +271,7 @@ rebuild_sys_tab:
271 pHba->initialized = TRUE; 271 pHba->initialized = TRUE;
272 pHba->state &= ~DPTI_STATE_RESET; 272 pHba->state &= ~DPTI_STATE_RESET;
273 if (adpt_sysfs_class) { 273 if (adpt_sysfs_class) {
274 struct device *dev = device_create_drvdata(adpt_sysfs_class, 274 struct device *dev = device_create(adpt_sysfs_class,
275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL, 275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
276 "dpti%d", pHba->unit); 276 "dpti%d", pHba->unit);
277 if (IS_ERR(dev)) { 277 if (IS_ERR(dev)) {
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 1c79f9794f4e..0ea78d9a37db 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5708,7 +5708,8 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S
5708 struct device *osst_member; 5708 struct device *osst_member;
5709 int err; 5709 int err;
5710 5710
5711 osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name); 5711 osst_member = device_create(osst_sysfs_class, device, dev, STp,
5712 "%s", name);
5712 if (IS_ERR(osst_member)) { 5713 if (IS_ERR(osst_member)) {
5713 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5714 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5714 return PTR_ERR(osst_member); 5715 return PTR_ERR(osst_member);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ba9b9bbd4e73..93bd59a1ed79 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1450,12 +1450,10 @@ sg_add(struct device *cl_dev, struct class_interface *cl_intf)
1450 if (sg_sysfs_valid) { 1450 if (sg_sysfs_valid) {
1451 struct device *sg_class_member; 1451 struct device *sg_class_member;
1452 1452
1453 sg_class_member = device_create_drvdata(sg_sysfs_class, 1453 sg_class_member = device_create(sg_sysfs_class, cl_dev->parent,
1454 cl_dev->parent, 1454 MKDEV(SCSI_GENERIC_MAJOR,
1455 MKDEV(SCSI_GENERIC_MAJOR, 1455 sdp->index),
1456 sdp->index), 1456 sdp, "%s", disk->disk_name);
1457 sdp,
1458 "%s", disk->disk_name);
1459 if (IS_ERR(sg_class_member)) { 1457 if (IS_ERR(sg_class_member)) {
1460 printk(KERN_ERR "sg_add: " 1458 printk(KERN_ERR "sg_add: "
1461 "device_create failed\n"); 1459 "device_create failed\n");
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c2bb53e3d941..5c28d08f18f4 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4428,13 +4428,10 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4428 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4428 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4429 STp->disk->disk_name, st_formats[i]); 4429 STp->disk->disk_name, st_formats[i]);
4430 st_class_member = 4430 st_class_member =
4431 device_create_drvdata(st_sysfs_class, 4431 device_create(st_sysfs_class, &STp->device->sdev_gendev,
4432 &STp->device->sdev_gendev, 4432 MKDEV(SCSI_TAPE_MAJOR,
4433 MKDEV(SCSI_TAPE_MAJOR, 4433 TAPE_MINOR(dev_num, mode, rew)),
4434 TAPE_MINOR(dev_num, 4434 &STp->modes[mode], "%s", name);
4435 mode, rew)),
4436 &STp->modes[mode],
4437 "%s", name);
4438 if (IS_ERR(st_class_member)) { 4435 if (IS_ERR(st_class_member)) {
4439 printk(KERN_WARNING "st%d: device_create failed\n", 4436 printk(KERN_WARNING "st%d: device_create failed\n",
4440 dev_num); 4437 dev_num);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index d3ca7d32abe0..1528de23a650 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2223,9 +2223,9 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
2223 serial_outp(up, UART_EFR, efr); 2223 serial_outp(up, UART_EFR, efr);
2224 } 2224 }
2225 2225
2226#ifdef CONFIG_ARCH_OMAP15XX 2226#ifdef CONFIG_ARCH_OMAP
2227 /* Workaround to enable 115200 baud on OMAP1510 internal ports */ 2227 /* Workaround to enable 115200 baud on OMAP1510 internal ports */
2228 if (cpu_is_omap1510() && is_omap_port((unsigned int)up->port.membase)) { 2228 if (cpu_is_omap1510() && is_omap_port(up)) {
2229 if (baud == 115200) { 2229 if (baud == 115200) {
2230 quot = 1; 2230 quot = 1;
2231 serial_out(up, UART_OMAP_OSC_12M_SEL, 1); 2231 serial_out(up, UART_OMAP_OSC_12M_SEL, 1);
@@ -2278,18 +2278,27 @@ serial8250_pm(struct uart_port *port, unsigned int state,
2278 p->pm(port, state, oldstate); 2278 p->pm(port, state, oldstate);
2279} 2279}
2280 2280
2281static unsigned int serial8250_port_size(struct uart_8250_port *pt)
2282{
2283 if (pt->port.iotype == UPIO_AU)
2284 return 0x100000;
2285#ifdef CONFIG_ARCH_OMAP
2286 if (is_omap_port(pt))
2287 return 0x16 << pt->port.regshift;
2288#endif
2289 return 8 << pt->port.regshift;
2290}
2291
2281/* 2292/*
2282 * Resource handling. 2293 * Resource handling.
2283 */ 2294 */
2284static int serial8250_request_std_resource(struct uart_8250_port *up) 2295static int serial8250_request_std_resource(struct uart_8250_port *up)
2285{ 2296{
2286 unsigned int size = 8 << up->port.regshift; 2297 unsigned int size = serial8250_port_size(up);
2287 int ret = 0; 2298 int ret = 0;
2288 2299
2289 switch (up->port.iotype) { 2300 switch (up->port.iotype) {
2290 case UPIO_AU: 2301 case UPIO_AU:
2291 size = 0x100000;
2292 /* fall thru */
2293 case UPIO_TSI: 2302 case UPIO_TSI:
2294 case UPIO_MEM32: 2303 case UPIO_MEM32:
2295 case UPIO_MEM: 2304 case UPIO_MEM:
@@ -2323,12 +2332,10 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
2323 2332
2324static void serial8250_release_std_resource(struct uart_8250_port *up) 2333static void serial8250_release_std_resource(struct uart_8250_port *up)
2325{ 2334{
2326 unsigned int size = 8 << up->port.regshift; 2335 unsigned int size = serial8250_port_size(up);
2327 2336
2328 switch (up->port.iotype) { 2337 switch (up->port.iotype) {
2329 case UPIO_AU: 2338 case UPIO_AU:
2330 size = 0x100000;
2331 /* fall thru */
2332 case UPIO_TSI: 2339 case UPIO_TSI:
2333 case UPIO_MEM32: 2340 case UPIO_MEM32:
2334 case UPIO_MEM: 2341 case UPIO_MEM:
diff --git a/drivers/serial/s3c2400.c b/drivers/serial/s3c2400.c
index c8b4266ac35f..4873f2978bd2 100644
--- a/drivers/serial/s3c2400.c
+++ b/drivers/serial/s3c2400.c
@@ -19,7 +19,7 @@
19 19
20#include <mach/hardware.h> 20#include <mach/hardware.h>
21 21
22#include <asm/plat-s3c/regs-serial.h> 22#include <plat/regs-serial.h>
23#include <mach/regs-gpio.h> 23#include <mach/regs-gpio.h>
24 24
25#include "samsung.h" 25#include "samsung.h"
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 40a2531b5541..87c182ef71b8 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -21,7 +21,7 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23 23
24#include <asm/plat-s3c/regs-serial.h> 24#include <plat/regs-serial.h>
25#include <mach/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include "samsung.h" 27#include "samsung.h"
diff --git a/drivers/serial/s3c2412.c b/drivers/serial/s3c2412.c
index d0170319c729..fd017b375568 100644
--- a/drivers/serial/s3c2412.c
+++ b/drivers/serial/s3c2412.c
@@ -21,7 +21,7 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23 23
24#include <asm/plat-s3c/regs-serial.h> 24#include <plat/regs-serial.h>
25#include <mach/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include "samsung.h" 27#include "samsung.h"
diff --git a/drivers/serial/s3c2440.c b/drivers/serial/s3c2440.c
index d4a2b17b2498..317d239ab740 100644
--- a/drivers/serial/s3c2440.c
+++ b/drivers/serial/s3c2440.c
@@ -21,7 +21,7 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23 23
24#include <asm/plat-s3c/regs-serial.h> 24#include <plat/regs-serial.h>
25#include <mach/regs-gpio.h> 25#include <mach/regs-gpio.h>
26 26
27#include "samsung.h" 27#include "samsung.h"
diff --git a/drivers/serial/samsung.c b/drivers/serial/samsung.c
index 5a88b3f9fe9b..1e219d3d0352 100644
--- a/drivers/serial/samsung.c
+++ b/drivers/serial/samsung.c
@@ -47,7 +47,7 @@
47 47
48#include <mach/hardware.h> 48#include <mach/hardware.h>
49 49
50#include <asm/plat-s3c/regs-serial.h> 50#include <plat/regs-serial.h>
51#include <mach/regs-gpio.h> 51#include <mach/regs-gpio.h>
52 52
53#include "samsung.h" 53#include "samsung.h"
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index cdb3d3191719..0debe11b67b4 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -15,13 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18
19#if defined(CONFIG_PPC_MERGE)
20#include <linux/of_platform.h> 18#include <linux/of_platform.h>
21#else
22#include <linux/platform_device.h>
23#endif
24
25#include <linux/workqueue.h> 19#include <linux/workqueue.h>
26#include <linux/completion.h> 20#include <linux/completion.h>
27#include <linux/io.h> 21#include <linux/io.h>
@@ -471,53 +465,6 @@ static int __exit mpc52xx_psc_spi_do_remove(struct device *dev)
471 return 0; 465 return 0;
472} 466}
473 467
474#if !defined(CONFIG_PPC_MERGE)
475static int __init mpc52xx_psc_spi_probe(struct platform_device *dev)
476{
477 switch(dev->id) {
478 case 1:
479 case 2:
480 case 3:
481 case 6:
482 return mpc52xx_psc_spi_do_probe(&dev->dev,
483 MPC52xx_PA(MPC52xx_PSCx_OFFSET(dev->id)),
484 MPC52xx_PSC_SIZE, platform_get_irq(dev, 0), dev->id);
485 default:
486 return -EINVAL;
487 }
488}
489
490static int __exit mpc52xx_psc_spi_remove(struct platform_device *dev)
491{
492 return mpc52xx_psc_spi_do_remove(&dev->dev);
493}
494
495/* work with hotplug and coldplug */
496MODULE_ALIAS("platform:mpc52xx-psc-spi");
497
498static struct platform_driver mpc52xx_psc_spi_platform_driver = {
499 .remove = __exit_p(mpc52xx_psc_spi_remove),
500 .driver = {
501 .name = "mpc52xx-psc-spi",
502 .owner = THIS_MODULE,
503 },
504};
505
506static int __init mpc52xx_psc_spi_init(void)
507{
508 return platform_driver_probe(&mpc52xx_psc_spi_platform_driver,
509 mpc52xx_psc_spi_probe);
510}
511module_init(mpc52xx_psc_spi_init);
512
513static void __exit mpc52xx_psc_spi_exit(void)
514{
515 platform_driver_unregister(&mpc52xx_psc_spi_platform_driver);
516}
517module_exit(mpc52xx_psc_spi_exit);
518
519#else /* defined(CONFIG_PPC_MERGE) */
520
521static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, 468static int __init mpc52xx_psc_spi_of_probe(struct of_device *op,
522 const struct of_device_id *match) 469 const struct of_device_id *match)
523{ 470{
@@ -586,8 +533,6 @@ static void __exit mpc52xx_psc_spi_exit(void)
586} 533}
587module_exit(mpc52xx_psc_spi_exit); 534module_exit(mpc52xx_psc_spi_exit);
588 535
589#endif /* defined(CONFIG_PPC_MERGE) */
590
591MODULE_AUTHOR("Dragos Carp"); 536MODULE_AUTHOR("Dragos Carp");
592MODULE_DESCRIPTION("MPC52xx PSC SPI Driver"); 537MODULE_DESCRIPTION("MPC52xx PSC SPI Driver");
593MODULE_LICENSE("GPL"); 538MODULE_LICENSE("GPL");
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index 9d2186fd74aa..454a2712e629 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -119,12 +119,14 @@ struct omap2_mcspi {
119 struct clk *fck; 119 struct clk *fck;
120 /* Virtual base address of the controller */ 120 /* Virtual base address of the controller */
121 void __iomem *base; 121 void __iomem *base;
122 unsigned long phys;
122 /* SPI1 has 4 channels, while SPI2 has 2 */ 123 /* SPI1 has 4 channels, while SPI2 has 2 */
123 struct omap2_mcspi_dma *dma_channels; 124 struct omap2_mcspi_dma *dma_channels;
124}; 125};
125 126
126struct omap2_mcspi_cs { 127struct omap2_mcspi_cs {
127 void __iomem *base; 128 void __iomem *base;
129 unsigned long phys;
128 int word_len; 130 int word_len;
129}; 131};
130 132
@@ -233,7 +235,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
233 c = count; 235 c = count;
234 word_len = cs->word_len; 236 word_len = cs->word_len;
235 237
236 base = (unsigned long) io_v2p(cs->base); 238 base = cs->phys;
237 tx_reg = base + OMAP2_MCSPI_TX0; 239 tx_reg = base + OMAP2_MCSPI_TX0;
238 rx_reg = base + OMAP2_MCSPI_RX0; 240 rx_reg = base + OMAP2_MCSPI_RX0;
239 rx = xfer->rx_buf; 241 rx = xfer->rx_buf;
@@ -633,6 +635,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
633 if (!cs) 635 if (!cs)
634 return -ENOMEM; 636 return -ENOMEM;
635 cs->base = mcspi->base + spi->chip_select * 0x14; 637 cs->base = mcspi->base + spi->chip_select * 0x14;
638 cs->phys = mcspi->phys + spi->chip_select * 0x14;
636 spi->controller_state = cs; 639 spi->controller_state = cs;
637 } 640 }
638 641
@@ -1005,7 +1008,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
1005 goto err1; 1008 goto err1;
1006 } 1009 }
1007 1010
1008 mcspi->base = (void __iomem *) io_p2v(r->start); 1011 mcspi->phys = r->start;
1012 mcspi->base = ioremap(r->start, r->end - r->start + 1);
1013 if (!mcspi->base) {
1014 dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
1015 status = -ENOMEM;
1016 goto err1aa;
1017 }
1009 1018
1010 INIT_WORK(&mcspi->work, omap2_mcspi_work); 1019 INIT_WORK(&mcspi->work, omap2_mcspi_work);
1011 1020
@@ -1055,6 +1064,8 @@ err3:
1055err2: 1064err2:
1056 clk_put(mcspi->ick); 1065 clk_put(mcspi->ick);
1057err1a: 1066err1a:
1067 iounmap(mcspi->base);
1068err1aa:
1058 release_mem_region(r->start, (r->end - r->start) + 1); 1069 release_mem_region(r->start, (r->end - r->start) + 1);
1059err1: 1070err1:
1060 spi_master_put(master); 1071 spi_master_put(master);
@@ -1067,6 +1078,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
1067 struct omap2_mcspi *mcspi; 1078 struct omap2_mcspi *mcspi;
1068 struct omap2_mcspi_dma *dma_channels; 1079 struct omap2_mcspi_dma *dma_channels;
1069 struct resource *r; 1080 struct resource *r;
1081 void __iomem *base;
1070 1082
1071 master = dev_get_drvdata(&pdev->dev); 1083 master = dev_get_drvdata(&pdev->dev);
1072 mcspi = spi_master_get_devdata(master); 1084 mcspi = spi_master_get_devdata(master);
@@ -1078,7 +1090,9 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
1078 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1090 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1079 release_mem_region(r->start, (r->end - r->start) + 1); 1091 release_mem_region(r->start, (r->end - r->start) + 1);
1080 1092
1093 base = mcspi->base;
1081 spi_unregister_master(master); 1094 spi_unregister_master(master);
1095 iounmap(base);
1082 kfree(dma_channels); 1096 kfree(dma_channels);
1083 1097
1084 return 0; 1098 return 0;
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c
index 5515eb97d7c5..bab6ff061e91 100644
--- a/drivers/spi/omap_uwire.c
+++ b/drivers/spi/omap_uwire.c
@@ -59,7 +59,6 @@
59 * and irqs should show there too... 59 * and irqs should show there too...
60 */ 60 */
61#define UWIRE_BASE_PHYS 0xFFFB3000 61#define UWIRE_BASE_PHYS 0xFFFB3000
62#define UWIRE_BASE ((void *__iomem)IO_ADDRESS(UWIRE_BASE_PHYS))
63 62
64/* uWire Registers: */ 63/* uWire Registers: */
65#define UWIRE_IO_SIZE 0x20 64#define UWIRE_IO_SIZE 0x20
@@ -103,16 +102,21 @@ struct uwire_state {
103}; 102};
104 103
105/* REVISIT compile time constant for idx_shift? */ 104/* REVISIT compile time constant for idx_shift? */
105/*
106 * Or, put it in a structure which is used throughout the driver;
107 * that avoids having to issue two loads for each bit of static data.
108 */
106static unsigned int uwire_idx_shift; 109static unsigned int uwire_idx_shift;
110static void __iomem *uwire_base;
107 111
108static inline void uwire_write_reg(int idx, u16 val) 112static inline void uwire_write_reg(int idx, u16 val)
109{ 113{
110 __raw_writew(val, UWIRE_BASE + (idx << uwire_idx_shift)); 114 __raw_writew(val, uwire_base + (idx << uwire_idx_shift));
111} 115}
112 116
113static inline u16 uwire_read_reg(int idx) 117static inline u16 uwire_read_reg(int idx)
114{ 118{
115 return __raw_readw(UWIRE_BASE + (idx << uwire_idx_shift)); 119 return __raw_readw(uwire_base + (idx << uwire_idx_shift));
116} 120}
117 121
118static inline void omap_uwire_configure_mode(u8 cs, unsigned long flags) 122static inline void omap_uwire_configure_mode(u8 cs, unsigned long flags)
@@ -492,6 +496,14 @@ static int __init uwire_probe(struct platform_device *pdev)
492 return -ENODEV; 496 return -ENODEV;
493 497
494 uwire = spi_master_get_devdata(master); 498 uwire = spi_master_get_devdata(master);
499
500 uwire_base = ioremap(UWIRE_BASE_PHYS, UWIRE_IO_SIZE);
501 if (!uwire_base) {
502 dev_dbg(&pdev->dev, "can't ioremap UWIRE\n");
503 spi_master_put(master);
504 return -ENOMEM;
505 }
506
495 dev_set_drvdata(&pdev->dev, uwire); 507 dev_set_drvdata(&pdev->dev, uwire);
496 508
497 uwire->ck = clk_get(&pdev->dev, "armxor_ck"); 509 uwire->ck = clk_get(&pdev->dev, "armxor_ck");
@@ -520,8 +532,10 @@ static int __init uwire_probe(struct platform_device *pdev)
520 uwire->bitbang.txrx_bufs = uwire_txrx; 532 uwire->bitbang.txrx_bufs = uwire_txrx;
521 533
522 status = spi_bitbang_start(&uwire->bitbang); 534 status = spi_bitbang_start(&uwire->bitbang);
523 if (status < 0) 535 if (status < 0) {
524 uwire_off(uwire); 536 uwire_off(uwire);
537 iounmap(uwire_base);
538 }
525 return status; 539 return status;
526} 540}
527 541
@@ -534,6 +548,7 @@ static int __exit uwire_remove(struct platform_device *pdev)
534 548
535 status = spi_bitbang_stop(&uwire->bitbang); 549 status = spi_bitbang_stop(&uwire->bitbang);
536 uwire_off(uwire); 550 uwire_off(uwire);
551 iounmap(uwire_base);
537 return status; 552 return status;
538} 553}
539 554
diff --git a/drivers/spi/orion_spi.c b/drivers/spi/orion_spi.c
index b872bfaf4bd2..014becb7d530 100644
--- a/drivers/spi/orion_spi.c
+++ b/drivers/spi/orion_spi.c
@@ -364,6 +364,11 @@ static int orion_spi_setup(struct spi_device *spi)
364 return -EINVAL; 364 return -EINVAL;
365 } 365 }
366 366
367 /* Fix ac timing if required. */
368 if (orion_spi->spi_info->enable_clock_fix)
369 orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG,
370 (1 << 14));
371
367 if (spi->bits_per_word == 0) 372 if (spi->bits_per_word == 0)
368 spi->bits_per_word = 8; 373 spi->bits_per_word = 8;
369 374
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index d47d3636227f..dae87b1a4c6e 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -47,6 +47,10 @@ MODULE_ALIAS("platform:pxa2xx-spi");
47 47
48#define MAX_BUSES 3 48#define MAX_BUSES 3
49 49
50#define RX_THRESH_DFLT 8
51#define TX_THRESH_DFLT 8
52#define TIMOUT_DFLT 1000
53
50#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) 54#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR)
51#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) 55#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK)
52#define IS_DMA_ALIGNED(x) ((((u32)(x)) & 0x07) == 0) 56#define IS_DMA_ALIGNED(x) ((((u32)(x)) & 0x07) == 0)
@@ -1171,6 +1175,8 @@ static int setup(struct spi_device *spi)
1171 struct driver_data *drv_data = spi_master_get_devdata(spi->master); 1175 struct driver_data *drv_data = spi_master_get_devdata(spi->master);
1172 struct ssp_device *ssp = drv_data->ssp; 1176 struct ssp_device *ssp = drv_data->ssp;
1173 unsigned int clk_div; 1177 unsigned int clk_div;
1178 uint tx_thres = TX_THRESH_DFLT;
1179 uint rx_thres = RX_THRESH_DFLT;
1174 1180
1175 if (!spi->bits_per_word) 1181 if (!spi->bits_per_word)
1176 spi->bits_per_word = 8; 1182 spi->bits_per_word = 8;
@@ -1209,8 +1215,7 @@ static int setup(struct spi_device *spi)
1209 1215
1210 chip->cs_control = null_cs_control; 1216 chip->cs_control = null_cs_control;
1211 chip->enable_dma = 0; 1217 chip->enable_dma = 0;
1212 chip->timeout = 1000; 1218 chip->timeout = TIMOUT_DFLT;
1213 chip->threshold = SSCR1_RxTresh(1) | SSCR1_TxTresh(1);
1214 chip->dma_burst_size = drv_data->master_info->enable_dma ? 1219 chip->dma_burst_size = drv_data->master_info->enable_dma ?
1215 DCMD_BURST8 : 0; 1220 DCMD_BURST8 : 0;
1216 } 1221 }
@@ -1224,22 +1229,21 @@ static int setup(struct spi_device *spi)
1224 if (chip_info) { 1229 if (chip_info) {
1225 if (chip_info->cs_control) 1230 if (chip_info->cs_control)
1226 chip->cs_control = chip_info->cs_control; 1231 chip->cs_control = chip_info->cs_control;
1227 1232 if (chip_info->timeout)
1228 chip->timeout = chip_info->timeout; 1233 chip->timeout = chip_info->timeout;
1229 1234 if (chip_info->tx_threshold)
1230 chip->threshold = (SSCR1_RxTresh(chip_info->rx_threshold) & 1235 tx_thres = chip_info->tx_threshold;
1231 SSCR1_RFT) | 1236 if (chip_info->rx_threshold)
1232 (SSCR1_TxTresh(chip_info->tx_threshold) & 1237 rx_thres = chip_info->rx_threshold;
1233 SSCR1_TFT); 1238 chip->enable_dma = drv_data->master_info->enable_dma;
1234
1235 chip->enable_dma = chip_info->dma_burst_size != 0
1236 && drv_data->master_info->enable_dma;
1237 chip->dma_threshold = 0; 1239 chip->dma_threshold = 0;
1238
1239 if (chip_info->enable_loopback) 1240 if (chip_info->enable_loopback)
1240 chip->cr1 = SSCR1_LBM; 1241 chip->cr1 = SSCR1_LBM;
1241 } 1242 }
1242 1243
1244 chip->threshold = (SSCR1_RxTresh(rx_thres) & SSCR1_RFT) |
1245 (SSCR1_TxTresh(tx_thres) & SSCR1_TFT);
1246
1243 /* set dma burst and threshold outside of chip_info path so that if 1247 /* set dma burst and threshold outside of chip_info path so that if
1244 * chip_info goes away after setting chip->enable_dma, the 1248 * chip_info goes away after setting chip->enable_dma, the
1245 * burst and threshold can still respond to changes in bits_per_word */ 1249 * burst and threshold can still respond to changes in bits_per_word */
@@ -1268,17 +1272,19 @@ static int setup(struct spi_device *spi)
1268 1272
1269 /* NOTE: PXA25x_SSP _could_ use external clocking ... */ 1273 /* NOTE: PXA25x_SSP _could_ use external clocking ... */
1270 if (drv_data->ssp_type != PXA25x_SSP) 1274 if (drv_data->ssp_type != PXA25x_SSP)
1271 dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d\n", 1275 dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d, %s\n",
1272 spi->bits_per_word, 1276 spi->bits_per_word,
1273 clk_get_rate(ssp->clk) 1277 clk_get_rate(ssp->clk)
1274 / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), 1278 / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)),
1275 spi->mode & 0x3); 1279 spi->mode & 0x3,
1280 chip->enable_dma ? "DMA" : "PIO");
1276 else 1281 else
1277 dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d\n", 1282 dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d, %s\n",
1278 spi->bits_per_word, 1283 spi->bits_per_word,
1279 clk_get_rate(ssp->clk) 1284 clk_get_rate(ssp->clk) / 2
1280 / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), 1285 / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)),
1281 spi->mode & 0x3); 1286 spi->mode & 0x3,
1287 chip->enable_dma ? "DMA" : "PIO");
1282 1288
1283 if (spi->bits_per_word <= 8) { 1289 if (spi->bits_per_word <= 8) {
1284 chip->n_bytes = 1; 1290 chip->n_bytes = 1;
@@ -1407,9 +1413,9 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1407 struct device *dev = &pdev->dev; 1413 struct device *dev = &pdev->dev;
1408 struct pxa2xx_spi_master *platform_info; 1414 struct pxa2xx_spi_master *platform_info;
1409 struct spi_master *master; 1415 struct spi_master *master;
1410 struct driver_data *drv_data = NULL; 1416 struct driver_data *drv_data;
1411 struct ssp_device *ssp; 1417 struct ssp_device *ssp;
1412 int status = 0; 1418 int status;
1413 1419
1414 platform_info = dev->platform_data; 1420 platform_info = dev->platform_data;
1415 1421
@@ -1422,7 +1428,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1422 /* Allocate master with space for drv_data and null dma buffer */ 1428 /* Allocate master with space for drv_data and null dma buffer */
1423 master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); 1429 master = spi_alloc_master(dev, sizeof(struct driver_data) + 16);
1424 if (!master) { 1430 if (!master) {
1425 dev_err(&pdev->dev, "can not alloc spi_master\n"); 1431 dev_err(&pdev->dev, "cannot alloc spi_master\n");
1426 ssp_free(ssp); 1432 ssp_free(ssp);
1427 return -ENOMEM; 1433 return -ENOMEM;
1428 } 1434 }
@@ -1458,7 +1464,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1458 1464
1459 status = request_irq(ssp->irq, ssp_int, 0, dev->bus_id, drv_data); 1465 status = request_irq(ssp->irq, ssp_int, 0, dev->bus_id, drv_data);
1460 if (status < 0) { 1466 if (status < 0) {
1461 dev_err(&pdev->dev, "can not get IRQ\n"); 1467 dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq);
1462 goto out_error_master_alloc; 1468 goto out_error_master_alloc;
1463 } 1469 }
1464 1470
@@ -1498,7 +1504,9 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1498 1504
1499 /* Load default SSP configuration */ 1505 /* Load default SSP configuration */
1500 write_SSCR0(0, drv_data->ioaddr); 1506 write_SSCR0(0, drv_data->ioaddr);
1501 write_SSCR1(SSCR1_RxTresh(4) | SSCR1_TxTresh(12), drv_data->ioaddr); 1507 write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) |
1508 SSCR1_TxTresh(TX_THRESH_DFLT),
1509 drv_data->ioaddr);
1502 write_SSCR0(SSCR0_SerClkDiv(2) 1510 write_SSCR0(SSCR0_SerClkDiv(2)
1503 | SSCR0_Motorola 1511 | SSCR0_Motorola
1504 | SSCR0_DataSize(8), 1512 | SSCR0_DataSize(8),
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 75e86865234c..3734dc9708e1 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -660,7 +660,7 @@ int spi_write_then_read(struct spi_device *spi,
660 660
661 int status; 661 int status;
662 struct spi_message message; 662 struct spi_message message;
663 struct spi_transfer x[2]; 663 struct spi_transfer x;
664 u8 *local_buf; 664 u8 *local_buf;
665 665
666 /* Use preallocated DMA-safe buffer. We can't avoid copying here, 666 /* Use preallocated DMA-safe buffer. We can't avoid copying here,
@@ -671,15 +671,9 @@ int spi_write_then_read(struct spi_device *spi,
671 return -EINVAL; 671 return -EINVAL;
672 672
673 spi_message_init(&message); 673 spi_message_init(&message);
674 memset(x, 0, sizeof x); 674 memset(&x, 0, sizeof x);
675 if (n_tx) { 675 x.len = n_tx + n_rx;
676 x[0].len = n_tx; 676 spi_message_add_tail(&x, &message);
677 spi_message_add_tail(&x[0], &message);
678 }
679 if (n_rx) {
680 x[1].len = n_rx;
681 spi_message_add_tail(&x[1], &message);
682 }
683 677
684 /* ... unless someone else is using the pre-allocated buffer */ 678 /* ... unless someone else is using the pre-allocated buffer */
685 if (!mutex_trylock(&lock)) { 679 if (!mutex_trylock(&lock)) {
@@ -690,15 +684,15 @@ int spi_write_then_read(struct spi_device *spi,
690 local_buf = buf; 684 local_buf = buf;
691 685
692 memcpy(local_buf, txbuf, n_tx); 686 memcpy(local_buf, txbuf, n_tx);
693 x[0].tx_buf = local_buf; 687 x.tx_buf = local_buf;
694 x[1].rx_buf = local_buf + n_tx; 688 x.rx_buf = local_buf;
695 689
696 /* do the i/o */ 690 /* do the i/o */
697 status = spi_sync(spi, &message); 691 status = spi_sync(spi, &message);
698 if (status == 0) 692 if (status == 0)
699 memcpy(rxbuf, x[1].rx_buf, n_rx); 693 memcpy(rxbuf, x.rx_buf + n_tx, n_rx);
700 694
701 if (x[0].tx_buf == buf) 695 if (x.tx_buf == buf)
702 mutex_unlock(&lock); 696 mutex_unlock(&lock);
703 else 697 else
704 kfree(local_buf); 698 kfree(local_buf);
@@ -744,5 +738,5 @@ err0:
744 * driver registration) _could_ be dynamically linked (modular) ... costs 738 * driver registration) _could_ be dynamically linked (modular) ... costs
745 * include needing to have boardinfo data structures be much more public. 739 * include needing to have boardinfo data structures be much more public.
746 */ 740 */
747subsys_initcall(spi_init); 741postcore_initcall(spi_init);
748 742
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 3eb414b84a9d..c252cbac00f1 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -247,6 +247,9 @@ static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw)
247 writeb(0xff, hw->regs + S3C2410_SPPRE); 247 writeb(0xff, hw->regs + S3C2410_SPPRE);
248 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN); 248 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
249 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON); 249 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
250
251 if (hw->pdata && hw->pdata->gpio_setup)
252 hw->pdata->gpio_setup(hw->pdata, 1);
250} 253}
251 254
252static int __init s3c24xx_spi_probe(struct platform_device *pdev) 255static int __init s3c24xx_spi_probe(struct platform_device *pdev)
@@ -412,6 +415,9 @@ static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg)
412{ 415{
413 struct s3c24xx_spi *hw = platform_get_drvdata(pdev); 416 struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
414 417
418 if (hw->pdata && hw->pdata->gpio_setup)
419 hw->pdata->gpio_setup(hw->pdata, 0);
420
415 clk_disable(hw->clk); 421 clk_disable(hw->clk);
416 return 0; 422 return 0;
417} 423}
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e5e0cfed5e3b..89a43755a453 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -583,10 +583,9 @@ static int spidev_probe(struct spi_device *spi)
583 struct device *dev; 583 struct device *dev;
584 584
585 spidev->devt = MKDEV(SPIDEV_MAJOR, minor); 585 spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
586 dev = device_create_drvdata(spidev_class, &spi->dev, 586 dev = device_create(spidev_class, &spi->dev, spidev->devt,
587 spidev->devt, spidev, 587 spidev, "spidev%d.%d",
588 "spidev%d.%d", 588 spi->master->bus_num, spi->chip_select);
589 spi->master->bus_num, spi->chip_select);
590 status = IS_ERR(dev) ? PTR_ERR(dev) : 0; 589 status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
591 } else { 590 } else {
592 dev_dbg(&spi->dev, "no minor number available!\n"); 591 dev_dbg(&spi->dev, "no minor number available!\n");
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index ec7aeb502d15..41b6530b8f25 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -42,8 +42,6 @@
42 ***************************************************************************/ 42 ***************************************************************************/
43 43
44/* 44/*
45 * $Log: ixj.c,v $
46 *
47 * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci 45 * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci
48 * Audit some copy_*_user and minor cleanup. 46 * Audit some copy_*_user and minor cleanup.
49 * 47 *
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 4190be64917f..04b954cfce76 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -58,4 +58,17 @@ config UIO_SMX
58 58
59 If you compile this as a module, it will be called uio_smx. 59 If you compile this as a module, it will be called uio_smx.
60 60
61config UIO_SERCOS3
62 tristate "Automata Sercos III PCI card driver"
63 default n
64 help
65 Userspace I/O interface for the Sercos III PCI card from
66 Automata GmbH. The userspace part of this driver will be
67 available for download from the Automata GmbH web site.
68
69 Automata GmbH: http://www.automataweb.com
70 Sercos III interface: http://www.sercos.com
71
72 If you compile this as a module, it will be called uio_sercos3.
73
61endif 74endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 8667bbdef904..e69558149859 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o
3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o 3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
4obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o 4obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o
5obj-$(CONFIG_UIO_SMX) += uio_smx.o 5obj-$(CONFIG_UIO_SMX) += uio_smx.o
6obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 3a6934bf7131..5dccf057a7dd 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -67,6 +67,11 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf)
67 return sprintf(buf, "0x%lx\n", mem->size); 67 return sprintf(buf, "0x%lx\n", mem->size);
68} 68}
69 69
70static ssize_t map_offset_show(struct uio_mem *mem, char *buf)
71{
72 return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK);
73}
74
70struct uio_sysfs_entry { 75struct uio_sysfs_entry {
71 struct attribute attr; 76 struct attribute attr;
72 ssize_t (*show)(struct uio_mem *, char *); 77 ssize_t (*show)(struct uio_mem *, char *);
@@ -77,10 +82,13 @@ static struct uio_sysfs_entry addr_attribute =
77 __ATTR(addr, S_IRUGO, map_addr_show, NULL); 82 __ATTR(addr, S_IRUGO, map_addr_show, NULL);
78static struct uio_sysfs_entry size_attribute = 83static struct uio_sysfs_entry size_attribute =
79 __ATTR(size, S_IRUGO, map_size_show, NULL); 84 __ATTR(size, S_IRUGO, map_size_show, NULL);
85static struct uio_sysfs_entry offset_attribute =
86 __ATTR(offset, S_IRUGO, map_offset_show, NULL);
80 87
81static struct attribute *attrs[] = { 88static struct attribute *attrs[] = {
82 &addr_attribute.attr, 89 &addr_attribute.attr,
83 &size_attribute.attr, 90 &size_attribute.attr,
91 &offset_attribute.attr,
84 NULL, /* need to NULL terminate the list of attributes */ 92 NULL, /* need to NULL terminate the list of attributes */
85}; 93};
86 94
@@ -482,15 +490,23 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
482{ 490{
483 struct uio_device *idev = vma->vm_private_data; 491 struct uio_device *idev = vma->vm_private_data;
484 struct page *page; 492 struct page *page;
493 unsigned long offset;
485 494
486 int mi = uio_find_mem_index(vma); 495 int mi = uio_find_mem_index(vma);
487 if (mi < 0) 496 if (mi < 0)
488 return VM_FAULT_SIGBUS; 497 return VM_FAULT_SIGBUS;
489 498
499 /*
500 * We need to subtract mi because userspace uses offset = N*PAGE_SIZE
501 * to use mem[N].
502 */
503 offset = (vmf->pgoff - mi) << PAGE_SHIFT;
504
490 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) 505 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL)
491 page = virt_to_page(idev->info->mem[mi].addr); 506 page = virt_to_page(idev->info->mem[mi].addr + offset);
492 else 507 else
493 page = vmalloc_to_page((void*)idev->info->mem[mi].addr); 508 page = vmalloc_to_page((void *)idev->info->mem[mi].addr
509 + offset);
494 get_page(page); 510 get_page(page);
495 vmf->page = page; 511 vmf->page = page;
496 return 0; 512 return 0;
@@ -682,9 +698,9 @@ int __uio_register_device(struct module *owner,
682 if (ret) 698 if (ret)
683 goto err_get_minor; 699 goto err_get_minor;
684 700
685 idev->dev = device_create_drvdata(uio_class->class, parent, 701 idev->dev = device_create(uio_class->class, parent,
686 MKDEV(uio_major, idev->minor), idev, 702 MKDEV(uio_major, idev->minor), idev,
687 "uio%d", idev->minor); 703 "uio%d", idev->minor);
688 if (IS_ERR(idev->dev)) { 704 if (IS_ERR(idev->dev)) {
689 printk(KERN_ERR "UIO: device register failed\n"); 705 printk(KERN_ERR "UIO: device register failed\n");
690 ret = PTR_ERR(idev->dev); 706 ret = PTR_ERR(idev->dev);
diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c
index 0b4ef39cd85d..d494ce9288c3 100644
--- a/drivers/uio/uio_pdrv.c
+++ b/drivers/uio/uio_pdrv.c
@@ -12,7 +12,7 @@
12#include <linux/uio_driver.h> 12#include <linux/uio_driver.h>
13#include <linux/stringify.h> 13#include <linux/stringify.h>
14 14
15#define DRIVER_NAME "uio" 15#define DRIVER_NAME "uio_pdrv"
16 16
17struct uio_platdata { 17struct uio_platdata {
18 struct uio_info *uioinfo; 18 struct uio_info *uioinfo;
diff --git a/drivers/uio/uio_sercos3.c b/drivers/uio/uio_sercos3.c
new file mode 100644
index 000000000000..a6d1b2bc47f3
--- /dev/null
+++ b/drivers/uio/uio_sercos3.c
@@ -0,0 +1,243 @@
1/* sercos3: UIO driver for the Automata Sercos III PCI card
2
3 Copyright (C) 2008 Linutronix GmbH
4 Author: John Ogness <john.ogness@linutronix.de>
5
6 This is a straight-forward UIO driver, where interrupts are disabled
7 by the interrupt handler and re-enabled via a write to the UIO device
8 by the userspace-part.
9
10 The only part that may seem odd is the use of a logical OR when
11 storing and restoring enabled interrupts. This is done because the
12 userspace-part could directly modify the Interrupt Enable Register
13 at any time. To reduce possible conflicts, the kernel driver uses
14 a logical OR to make more controlled changes (rather than blindly
15 overwriting previous values).
16
17 Race conditions exist if the userspace-part directly modifies the
18 Interrupt Enable Register while in operation. The consequences are
19 that certain interrupts would fail to be enabled or disabled. For
20 this reason, the userspace-part should only directly modify the
21 Interrupt Enable Register at the beginning (to get things going).
22 The userspace-part can safely disable interrupts at any time using
23 a write to the UIO device.
24*/
25
26#include <linux/device.h>
27#include <linux/module.h>
28#include <linux/pci.h>
29#include <linux/uio_driver.h>
30#include <linux/io.h>
31
32/* ID's for SERCOS III PCI card (PLX 9030) */
33#define SERCOS_SUB_VENDOR_ID 0x1971
34#define SERCOS_SUB_SYSID_3530 0x3530
35#define SERCOS_SUB_SYSID_3535 0x3535
36#define SERCOS_SUB_SYSID_3780 0x3780
37
38/* Interrupt Enable Register */
39#define IER0_OFFSET 0x08
40
41/* Interrupt Status Register */
42#define ISR0_OFFSET 0x18
43
44struct sercos3_priv {
45 u32 ier0_cache;
46 spinlock_t ier0_cache_lock;
47};
48
49/* this function assumes ier0_cache_lock is locked! */
50static void sercos3_disable_interrupts(struct uio_info *info,
51 struct sercos3_priv *priv)
52{
53 void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET;
54
55 /* add enabled interrupts to cache */
56 priv->ier0_cache |= ioread32(ier0);
57
58 /* disable interrupts */
59 iowrite32(0, ier0);
60}
61
62/* this function assumes ier0_cache_lock is locked! */
63static void sercos3_enable_interrupts(struct uio_info *info,
64 struct sercos3_priv *priv)
65{
66 void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET;
67
68 /* restore previously enabled interrupts */
69 iowrite32(ioread32(ier0) | priv->ier0_cache, ier0);
70 priv->ier0_cache = 0;
71}
72
73static irqreturn_t sercos3_handler(int irq, struct uio_info *info)
74{
75 struct sercos3_priv *priv = info->priv;
76 void __iomem *isr0 = info->mem[3].internal_addr + ISR0_OFFSET;
77 void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET;
78
79 if (!(ioread32(isr0) & ioread32(ier0)))
80 return IRQ_NONE;
81
82 spin_lock(&priv->ier0_cache_lock);
83 sercos3_disable_interrupts(info, priv);
84 spin_unlock(&priv->ier0_cache_lock);
85
86 return IRQ_HANDLED;
87}
88
89static int sercos3_irqcontrol(struct uio_info *info, s32 irq_on)
90{
91 struct sercos3_priv *priv = info->priv;
92
93 spin_lock_irq(&priv->ier0_cache_lock);
94 if (irq_on)
95 sercos3_enable_interrupts(info, priv);
96 else
97 sercos3_disable_interrupts(info, priv);
98 spin_unlock_irq(&priv->ier0_cache_lock);
99
100 return 0;
101}
102
103static int sercos3_setup_iomem(struct pci_dev *dev, struct uio_info *info,
104 int n, int pci_bar)
105{
106 info->mem[n].addr = pci_resource_start(dev, pci_bar);
107 if (!info->mem[n].addr)
108 return -1;
109 info->mem[n].internal_addr = ioremap(pci_resource_start(dev, pci_bar),
110 pci_resource_len(dev, pci_bar));
111 if (!info->mem[n].internal_addr)
112 return -1;
113 info->mem[n].size = pci_resource_len(dev, pci_bar);
114 info->mem[n].memtype = UIO_MEM_PHYS;
115 return 0;
116}
117
118static int __devinit sercos3_pci_probe(struct pci_dev *dev,
119 const struct pci_device_id *id)
120{
121 struct uio_info *info;
122 struct sercos3_priv *priv;
123 int i;
124
125 info = kzalloc(sizeof(struct uio_info), GFP_KERNEL);
126 if (!info)
127 return -ENOMEM;
128
129 priv = kzalloc(sizeof(struct sercos3_priv), GFP_KERNEL);
130 if (!priv)
131 goto out_free;
132
133 if (pci_enable_device(dev))
134 goto out_free_priv;
135
136 if (pci_request_regions(dev, "sercos3"))
137 goto out_disable;
138
139 /* we only need PCI BAR's 0, 2, 3, 4, 5 */
140 if (sercos3_setup_iomem(dev, info, 0, 0))
141 goto out_unmap;
142 if (sercos3_setup_iomem(dev, info, 1, 2))
143 goto out_unmap;
144 if (sercos3_setup_iomem(dev, info, 2, 3))
145 goto out_unmap;
146 if (sercos3_setup_iomem(dev, info, 3, 4))
147 goto out_unmap;
148 if (sercos3_setup_iomem(dev, info, 4, 5))
149 goto out_unmap;
150
151 spin_lock_init(&priv->ier0_cache_lock);
152 info->priv = priv;
153 info->name = "Sercos_III_PCI";
154 info->version = "0.0.1";
155 info->irq = dev->irq;
156 info->irq_flags = IRQF_DISABLED | IRQF_SHARED;
157 info->handler = sercos3_handler;
158 info->irqcontrol = sercos3_irqcontrol;
159
160 pci_set_drvdata(dev, info);
161
162 if (uio_register_device(&dev->dev, info))
163 goto out_unmap;
164
165 return 0;
166
167out_unmap:
168 for (i = 0; i < 5; i++) {
169 if (info->mem[i].internal_addr)
170 iounmap(info->mem[i].internal_addr);
171 }
172 pci_release_regions(dev);
173out_disable:
174 pci_disable_device(dev);
175out_free_priv:
176 kfree(priv);
177out_free:
178 kfree(info);
179 return -ENODEV;
180}
181
182static void sercos3_pci_remove(struct pci_dev *dev)
183{
184 struct uio_info *info = pci_get_drvdata(dev);
185 int i;
186
187 uio_unregister_device(info);
188 pci_release_regions(dev);
189 pci_disable_device(dev);
190 pci_set_drvdata(dev, NULL);
191 for (i = 0; i < 5; i++) {
192 if (info->mem[i].internal_addr)
193 iounmap(info->mem[i].internal_addr);
194 }
195 kfree(info->priv);
196 kfree(info);
197}
198
199static struct pci_device_id sercos3_pci_ids[] __devinitdata = {
200 {
201 .vendor = PCI_VENDOR_ID_PLX,
202 .device = PCI_DEVICE_ID_PLX_9030,
203 .subvendor = SERCOS_SUB_VENDOR_ID,
204 .subdevice = SERCOS_SUB_SYSID_3530,
205 },
206 {
207 .vendor = PCI_VENDOR_ID_PLX,
208 .device = PCI_DEVICE_ID_PLX_9030,
209 .subvendor = SERCOS_SUB_VENDOR_ID,
210 .subdevice = SERCOS_SUB_SYSID_3535,
211 },
212 {
213 .vendor = PCI_VENDOR_ID_PLX,
214 .device = PCI_DEVICE_ID_PLX_9030,
215 .subvendor = SERCOS_SUB_VENDOR_ID,
216 .subdevice = SERCOS_SUB_SYSID_3780,
217 },
218 { 0, }
219};
220
221static struct pci_driver sercos3_pci_driver = {
222 .name = "sercos3",
223 .id_table = sercos3_pci_ids,
224 .probe = sercos3_pci_probe,
225 .remove = sercos3_pci_remove,
226};
227
228static int __init sercos3_init_module(void)
229{
230 return pci_register_driver(&sercos3_pci_driver);
231}
232
233static void __exit sercos3_exit_module(void)
234{
235 pci_unregister_driver(&sercos3_pci_driver);
236}
237
238module_init(sercos3_init_module);
239module_exit(sercos3_exit_module);
240
241MODULE_DESCRIPTION("UIO driver for the Automata Sercos III PCI card");
242MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>");
243MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 20290c5b1562..7a4fa791dc19 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev)
1729{ 1729{
1730 struct device *cldev; 1730 struct device *cldev;
1731 1731
1732 cldev = device_create_drvdata(usb_classdev_class, &dev->dev, 1732 cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt,
1733 dev->dev.devt, NULL, "usbdev%d.%d", 1733 NULL, "usbdev%d.%d", dev->bus->busnum,
1734 dev->bus->busnum, dev->devnum); 1734 dev->devnum);
1735 if (IS_ERR(cldev)) 1735 if (IS_ERR(cldev))
1736 return PTR_ERR(cldev); 1736 return PTR_ERR(cldev);
1737 dev->usb_classdev = cldev; 1737 dev->usb_classdev = cldev;
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 6b1b229e38cd..55f7f310924b 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -196,9 +196,9 @@ int usb_register_dev(struct usb_interface *intf,
196 ++temp; 196 ++temp;
197 else 197 else
198 temp = name; 198 temp = name;
199 intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev, 199 intf->usb_dev = device_create(usb_class->class, &intf->dev,
200 MKDEV(USB_MAJOR, minor), NULL, 200 MKDEV(USB_MAJOR, minor), NULL,
201 "%s", temp); 201 "%s", temp);
202 if (IS_ERR(intf->usb_dev)) { 202 if (IS_ERR(intf->usb_dev)) {
203 down_write(&minor_rwsem); 203 down_write(&minor_rwsem);
204 usb_minors[intf->minor] = NULL; 204 usb_minors[intf->minor] = NULL;
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8ab389dca2b9..c8035a8216bd 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -818,9 +818,8 @@ static int usb_register_bus(struct usb_bus *bus)
818 set_bit (busnum, busmap.busmap); 818 set_bit (busnum, busmap.busmap);
819 bus->busnum = busnum; 819 bus->busnum = busnum;
820 820
821 bus->dev = device_create_drvdata(usb_host_class, bus->controller, 821 bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0),
822 MKDEV(0, 0), bus, 822 bus, "usb_host%d", busnum);
823 "usb_host%d", busnum);
824 result = PTR_ERR(bus->dev); 823 result = PTR_ERR(bus->dev);
825 if (IS_ERR(bus->dev)) 824 if (IS_ERR(bus->dev))
826 goto error_create_class_dev; 825 goto error_create_class_dev;
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index fcb5cb9094d9..2267fa0b51b2 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -22,24 +22,15 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o
22# 22#
23# USB gadget drivers 23# USB gadget drivers
24# 24#
25C_UTILS = composite.o usbstring.o config.o epautoconf.o 25g_zero-objs := zero.o
26 26g_ether-objs := ether.o
27g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS) 27g_serial-objs := serial.o
28g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS) 28g_midi-objs := gmidi.o
29g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS)
30g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
31gadgetfs-objs := inode.o 29gadgetfs-objs := inode.o
32g_file_storage-objs := file_storage.o usbstring.o config.o \ 30g_file_storage-objs := file_storage.o
33 epautoconf.o 31g_printer-objs := printer.o
34g_printer-objs := printer.o usbstring.o config.o \ 32g_cdc-objs := cdc2.o
35 epautoconf.o
36g_cdc-objs := cdc2.o u_ether.o f_ecm.o \
37 u_serial.o f_acm.o $(C_UTILS)
38 33
39ifeq ($(CONFIG_USB_ETH_RNDIS),y)
40 g_ether-objs += f_rndis.o rndis.o
41endif
42
43obj-$(CONFIG_USB_ZERO) += g_zero.o 34obj-$(CONFIG_USB_ZERO) += g_zero.o
44obj-$(CONFIG_USB_ETH) += g_ether.o 35obj-$(CONFIG_USB_ETH) += g_ether.o
45obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o 36obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index a39a4b940c33..a724fc149850 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -43,6 +43,25 @@
43 43
44/*-------------------------------------------------------------------------*/ 44/*-------------------------------------------------------------------------*/
45 45
46/*
47 * Kbuild is not very cooperative with respect to linking separately
48 * compiled library objects into one module. So for now we won't use
49 * separate compilation ... ensuring init/exit sections work to shrink
50 * the runtime footprint, and giving us at least some parts of what
51 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
52 */
53
54#include "composite.c"
55#include "usbstring.c"
56#include "config.c"
57#include "epautoconf.c"
58#include "u_serial.c"
59#include "f_acm.c"
60#include "f_ecm.c"
61#include "u_ether.c"
62
63/*-------------------------------------------------------------------------*/
64
46static struct usb_device_descriptor device_desc = { 65static struct usb_device_descriptor device_desc = {
47 .bLength = sizeof device_desc, 66 .bLength = sizeof device_desc,
48 .bDescriptorType = USB_DT_DEVICE, 67 .bDescriptorType = USB_DT_DEVICE,
@@ -148,7 +167,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
148 int status; 167 int status;
149 168
150 if (!can_support_ecm(cdev->gadget)) { 169 if (!can_support_ecm(cdev->gadget)) {
151 ERROR(cdev, "controller '%s' not usable\n", gadget->name); 170 dev_err(&gadget->dev, "controller '%s' not usable\n",
171 gadget->name);
152 return -EINVAL; 172 return -EINVAL;
153 } 173 }
154 174
@@ -203,7 +223,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
203 if (status < 0) 223 if (status < 0)
204 goto fail1; 224 goto fail1;
205 225
206 INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); 226 dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
227 DRIVER_DESC);
207 228
208 return 0; 229 return 0;
209 230
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index bcac2e68660d..944c8e889ab4 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -96,6 +96,28 @@ static inline bool has_rndis(void)
96 96
97/*-------------------------------------------------------------------------*/ 97/*-------------------------------------------------------------------------*/
98 98
99/*
100 * Kbuild is not very cooperative with respect to linking separately
101 * compiled library objects into one module. So for now we won't use
102 * separate compilation ... ensuring init/exit sections work to shrink
103 * the runtime footprint, and giving us at least some parts of what
104 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
105 */
106#include "composite.c"
107#include "usbstring.c"
108#include "config.c"
109#include "epautoconf.c"
110
111#include "f_ecm.c"
112#include "f_subset.c"
113#ifdef CONFIG_USB_ETH_RNDIS
114#include "f_rndis.c"
115#include "rndis.c"
116#endif
117#include "u_ether.c"
118
119/*-------------------------------------------------------------------------*/
120
99/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 121/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
100 * Instead: allocate your own, using normal USB-IF procedures. 122 * Instead: allocate your own, using normal USB-IF procedures.
101 */ 123 */
@@ -293,7 +315,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
293 * but if the controller isn't recognized at all then 315 * but if the controller isn't recognized at all then
294 * that assumption is a bit more likely to be wrong. 316 * that assumption is a bit more likely to be wrong.
295 */ 317 */
296 WARNING(cdev, "controller '%s' not recognized; trying %s\n", 318 dev_warn(&gadget->dev,
319 "controller '%s' not recognized; trying %s\n",
297 gadget->name, 320 gadget->name,
298 eth_config_driver.label); 321 eth_config_driver.label);
299 device_desc.bcdDevice = 322 device_desc.bcdDevice =
@@ -332,7 +355,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
332 if (status < 0) 355 if (status < 0)
333 goto fail; 356 goto fail;
334 357
335 INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); 358 dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
359 DRIVER_DESC);
336 360
337 return 0; 361 return 0;
338 362
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index a2b5c092bda0..4ae579948e54 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -83,7 +83,7 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f)
83} 83}
84 84
85/* peak (theoretical) bulk transfer rate in bits-per-second */ 85/* peak (theoretical) bulk transfer rate in bits-per-second */
86static inline unsigned bitrate(struct usb_gadget *g) 86static inline unsigned ecm_bitrate(struct usb_gadget *g)
87{ 87{
88 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) 88 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
89 return 13 * 512 * 8 * 1000 * 8; 89 return 13 * 512 * 8 * 1000 * 8;
@@ -107,7 +107,7 @@ static inline unsigned bitrate(struct usb_gadget *g)
107 */ 107 */
108 108
109#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ 109#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */
110#define STATUS_BYTECOUNT 16 /* 8 byte header + data */ 110#define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */
111 111
112 112
113/* interface descriptor: */ 113/* interface descriptor: */
@@ -125,8 +125,8 @@ static struct usb_interface_descriptor ecm_control_intf __initdata = {
125 /* .iInterface = DYNAMIC */ 125 /* .iInterface = DYNAMIC */
126}; 126};
127 127
128static struct usb_cdc_header_desc header_desc __initdata = { 128static struct usb_cdc_header_desc ecm_header_desc __initdata = {
129 .bLength = sizeof header_desc, 129 .bLength = sizeof ecm_header_desc,
130 .bDescriptorType = USB_DT_CS_INTERFACE, 130 .bDescriptorType = USB_DT_CS_INTERFACE,
131 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 131 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
132 132
@@ -141,8 +141,8 @@ static struct usb_cdc_union_desc ecm_union_desc __initdata = {
141 /* .bSlaveInterface0 = DYNAMIC */ 141 /* .bSlaveInterface0 = DYNAMIC */
142}; 142};
143 143
144static struct usb_cdc_ether_desc ether_desc __initdata = { 144static struct usb_cdc_ether_desc ecm_desc __initdata = {
145 .bLength = sizeof ether_desc, 145 .bLength = sizeof ecm_desc,
146 .bDescriptorType = USB_DT_CS_INTERFACE, 146 .bDescriptorType = USB_DT_CS_INTERFACE,
147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, 147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE,
148 148
@@ -186,17 +186,17 @@ static struct usb_interface_descriptor ecm_data_intf __initdata = {
186 186
187/* full speed support: */ 187/* full speed support: */
188 188
189static struct usb_endpoint_descriptor fs_notify_desc __initdata = { 189static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = {
190 .bLength = USB_DT_ENDPOINT_SIZE, 190 .bLength = USB_DT_ENDPOINT_SIZE,
191 .bDescriptorType = USB_DT_ENDPOINT, 191 .bDescriptorType = USB_DT_ENDPOINT,
192 192
193 .bEndpointAddress = USB_DIR_IN, 193 .bEndpointAddress = USB_DIR_IN,
194 .bmAttributes = USB_ENDPOINT_XFER_INT, 194 .bmAttributes = USB_ENDPOINT_XFER_INT,
195 .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 195 .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT),
196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC,
197}; 197};
198 198
199static struct usb_endpoint_descriptor fs_in_desc __initdata = { 199static struct usb_endpoint_descriptor fs_ecm_in_desc __initdata = {
200 .bLength = USB_DT_ENDPOINT_SIZE, 200 .bLength = USB_DT_ENDPOINT_SIZE,
201 .bDescriptorType = USB_DT_ENDPOINT, 201 .bDescriptorType = USB_DT_ENDPOINT,
202 202
@@ -204,7 +204,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = {
204 .bmAttributes = USB_ENDPOINT_XFER_BULK, 204 .bmAttributes = USB_ENDPOINT_XFER_BULK,
205}; 205};
206 206
207static struct usb_endpoint_descriptor fs_out_desc __initdata = { 207static struct usb_endpoint_descriptor fs_ecm_out_desc __initdata = {
208 .bLength = USB_DT_ENDPOINT_SIZE, 208 .bLength = USB_DT_ENDPOINT_SIZE,
209 .bDescriptorType = USB_DT_ENDPOINT, 209 .bDescriptorType = USB_DT_ENDPOINT,
210 210
@@ -212,34 +212,34 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = {
212 .bmAttributes = USB_ENDPOINT_XFER_BULK, 212 .bmAttributes = USB_ENDPOINT_XFER_BULK,
213}; 213};
214 214
215static struct usb_descriptor_header *eth_fs_function[] __initdata = { 215static struct usb_descriptor_header *ecm_fs_function[] __initdata = {
216 /* CDC ECM control descriptors */ 216 /* CDC ECM control descriptors */
217 (struct usb_descriptor_header *) &ecm_control_intf, 217 (struct usb_descriptor_header *) &ecm_control_intf,
218 (struct usb_descriptor_header *) &header_desc, 218 (struct usb_descriptor_header *) &ecm_header_desc,
219 (struct usb_descriptor_header *) &ecm_union_desc, 219 (struct usb_descriptor_header *) &ecm_union_desc,
220 (struct usb_descriptor_header *) &ether_desc, 220 (struct usb_descriptor_header *) &ecm_desc,
221 /* NOTE: status endpoint might need to be removed */ 221 /* NOTE: status endpoint might need to be removed */
222 (struct usb_descriptor_header *) &fs_notify_desc, 222 (struct usb_descriptor_header *) &fs_ecm_notify_desc,
223 /* data interface, altsettings 0 and 1 */ 223 /* data interface, altsettings 0 and 1 */
224 (struct usb_descriptor_header *) &ecm_data_nop_intf, 224 (struct usb_descriptor_header *) &ecm_data_nop_intf,
225 (struct usb_descriptor_header *) &ecm_data_intf, 225 (struct usb_descriptor_header *) &ecm_data_intf,
226 (struct usb_descriptor_header *) &fs_in_desc, 226 (struct usb_descriptor_header *) &fs_ecm_in_desc,
227 (struct usb_descriptor_header *) &fs_out_desc, 227 (struct usb_descriptor_header *) &fs_ecm_out_desc,
228 NULL, 228 NULL,
229}; 229};
230 230
231/* high speed support: */ 231/* high speed support: */
232 232
233static struct usb_endpoint_descriptor hs_notify_desc __initdata = { 233static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = {
234 .bLength = USB_DT_ENDPOINT_SIZE, 234 .bLength = USB_DT_ENDPOINT_SIZE,
235 .bDescriptorType = USB_DT_ENDPOINT, 235 .bDescriptorType = USB_DT_ENDPOINT,
236 236
237 .bEndpointAddress = USB_DIR_IN, 237 .bEndpointAddress = USB_DIR_IN,
238 .bmAttributes = USB_ENDPOINT_XFER_INT, 238 .bmAttributes = USB_ENDPOINT_XFER_INT,
239 .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 239 .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT),
240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4,
241}; 241};
242static struct usb_endpoint_descriptor hs_in_desc __initdata = { 242static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = {
243 .bLength = USB_DT_ENDPOINT_SIZE, 243 .bLength = USB_DT_ENDPOINT_SIZE,
244 .bDescriptorType = USB_DT_ENDPOINT, 244 .bDescriptorType = USB_DT_ENDPOINT,
245 245
@@ -248,7 +248,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = {
248 .wMaxPacketSize = __constant_cpu_to_le16(512), 248 .wMaxPacketSize = __constant_cpu_to_le16(512),
249}; 249};
250 250
251static struct usb_endpoint_descriptor hs_out_desc __initdata = { 251static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = {
252 .bLength = USB_DT_ENDPOINT_SIZE, 252 .bLength = USB_DT_ENDPOINT_SIZE,
253 .bDescriptorType = USB_DT_ENDPOINT, 253 .bDescriptorType = USB_DT_ENDPOINT,
254 254
@@ -257,19 +257,19 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = {
257 .wMaxPacketSize = __constant_cpu_to_le16(512), 257 .wMaxPacketSize = __constant_cpu_to_le16(512),
258}; 258};
259 259
260static struct usb_descriptor_header *eth_hs_function[] __initdata = { 260static struct usb_descriptor_header *ecm_hs_function[] __initdata = {
261 /* CDC ECM control descriptors */ 261 /* CDC ECM control descriptors */
262 (struct usb_descriptor_header *) &ecm_control_intf, 262 (struct usb_descriptor_header *) &ecm_control_intf,
263 (struct usb_descriptor_header *) &header_desc, 263 (struct usb_descriptor_header *) &ecm_header_desc,
264 (struct usb_descriptor_header *) &ecm_union_desc, 264 (struct usb_descriptor_header *) &ecm_union_desc,
265 (struct usb_descriptor_header *) &ether_desc, 265 (struct usb_descriptor_header *) &ecm_desc,
266 /* NOTE: status endpoint might need to be removed */ 266 /* NOTE: status endpoint might need to be removed */
267 (struct usb_descriptor_header *) &hs_notify_desc, 267 (struct usb_descriptor_header *) &hs_ecm_notify_desc,
268 /* data interface, altsettings 0 and 1 */ 268 /* data interface, altsettings 0 and 1 */
269 (struct usb_descriptor_header *) &ecm_data_nop_intf, 269 (struct usb_descriptor_header *) &ecm_data_nop_intf,
270 (struct usb_descriptor_header *) &ecm_data_intf, 270 (struct usb_descriptor_header *) &ecm_data_intf,
271 (struct usb_descriptor_header *) &hs_in_desc, 271 (struct usb_descriptor_header *) &hs_ecm_in_desc,
272 (struct usb_descriptor_header *) &hs_out_desc, 272 (struct usb_descriptor_header *) &hs_ecm_out_desc,
273 NULL, 273 NULL,
274}; 274};
275 275
@@ -329,14 +329,14 @@ static void ecm_do_notify(struct f_ecm *ecm)
329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE; 329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE;
330 event->wValue = cpu_to_le16(0); 330 event->wValue = cpu_to_le16(0);
331 event->wLength = cpu_to_le16(8); 331 event->wLength = cpu_to_le16(8);
332 req->length = STATUS_BYTECOUNT; 332 req->length = ECM_STATUS_BYTECOUNT;
333 333
334 /* SPEED_CHANGE data is up/down speeds in bits/sec */ 334 /* SPEED_CHANGE data is up/down speeds in bits/sec */
335 data = req->buf + sizeof *event; 335 data = req->buf + sizeof *event;
336 data[0] = cpu_to_le32(bitrate(cdev->gadget)); 336 data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget));
337 data[1] = data[0]; 337 data[1] = data[0];
338 338
339 DBG(cdev, "notify speed %d\n", bitrate(cdev->gadget)); 339 DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget));
340 ecm->notify_state = ECM_NOTIFY_NONE; 340 ecm->notify_state = ECM_NOTIFY_NONE;
341 break; 341 break;
342 } 342 }
@@ -628,13 +628,13 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
628 status = -ENODEV; 628 status = -ENODEV;
629 629
630 /* allocate instance-specific endpoints */ 630 /* allocate instance-specific endpoints */
631 ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); 631 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_in_desc);
632 if (!ep) 632 if (!ep)
633 goto fail; 633 goto fail;
634 ecm->port.in_ep = ep; 634 ecm->port.in_ep = ep;
635 ep->driver_data = cdev; /* claim */ 635 ep->driver_data = cdev; /* claim */
636 636
637 ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); 637 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc);
638 if (!ep) 638 if (!ep)
639 goto fail; 639 goto fail;
640 ecm->port.out_ep = ep; 640 ecm->port.out_ep = ep;
@@ -644,7 +644,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
644 * don't treat it that way. It's simpler, and some newer CDC 644 * don't treat it that way. It's simpler, and some newer CDC
645 * profiles (wireless handsets) no longer treat it as optional. 645 * profiles (wireless handsets) no longer treat it as optional.
646 */ 646 */
647 ep = usb_ep_autoconfig(cdev->gadget, &fs_notify_desc); 647 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc);
648 if (!ep) 648 if (!ep)
649 goto fail; 649 goto fail;
650 ecm->notify = ep; 650 ecm->notify = ep;
@@ -656,47 +656,47 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); 656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL);
657 if (!ecm->notify_req) 657 if (!ecm->notify_req)
658 goto fail; 658 goto fail;
659 ecm->notify_req->buf = kmalloc(STATUS_BYTECOUNT, GFP_KERNEL); 659 ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL);
660 if (!ecm->notify_req->buf) 660 if (!ecm->notify_req->buf)
661 goto fail; 661 goto fail;
662 ecm->notify_req->context = ecm; 662 ecm->notify_req->context = ecm;
663 ecm->notify_req->complete = ecm_notify_complete; 663 ecm->notify_req->complete = ecm_notify_complete;
664 664
665 /* copy descriptors, and track endpoint copies */ 665 /* copy descriptors, and track endpoint copies */
666 f->descriptors = usb_copy_descriptors(eth_fs_function); 666 f->descriptors = usb_copy_descriptors(ecm_fs_function);
667 if (!f->descriptors) 667 if (!f->descriptors)
668 goto fail; 668 goto fail;
669 669
670 ecm->fs.in = usb_find_endpoint(eth_fs_function, 670 ecm->fs.in = usb_find_endpoint(ecm_fs_function,
671 f->descriptors, &fs_in_desc); 671 f->descriptors, &fs_ecm_in_desc);
672 ecm->fs.out = usb_find_endpoint(eth_fs_function, 672 ecm->fs.out = usb_find_endpoint(ecm_fs_function,
673 f->descriptors, &fs_out_desc); 673 f->descriptors, &fs_ecm_out_desc);
674 ecm->fs.notify = usb_find_endpoint(eth_fs_function, 674 ecm->fs.notify = usb_find_endpoint(ecm_fs_function,
675 f->descriptors, &fs_notify_desc); 675 f->descriptors, &fs_ecm_notify_desc);
676 676
677 /* support all relevant hardware speeds... we expect that when 677 /* support all relevant hardware speeds... we expect that when
678 * hardware is dual speed, all bulk-capable endpoints work at 678 * hardware is dual speed, all bulk-capable endpoints work at
679 * both speeds 679 * both speeds
680 */ 680 */
681 if (gadget_is_dualspeed(c->cdev->gadget)) { 681 if (gadget_is_dualspeed(c->cdev->gadget)) {
682 hs_in_desc.bEndpointAddress = 682 hs_ecm_in_desc.bEndpointAddress =
683 fs_in_desc.bEndpointAddress; 683 fs_ecm_in_desc.bEndpointAddress;
684 hs_out_desc.bEndpointAddress = 684 hs_ecm_out_desc.bEndpointAddress =
685 fs_out_desc.bEndpointAddress; 685 fs_ecm_out_desc.bEndpointAddress;
686 hs_notify_desc.bEndpointAddress = 686 hs_ecm_notify_desc.bEndpointAddress =
687 fs_notify_desc.bEndpointAddress; 687 fs_ecm_notify_desc.bEndpointAddress;
688 688
689 /* copy descriptors, and track endpoint copies */ 689 /* copy descriptors, and track endpoint copies */
690 f->hs_descriptors = usb_copy_descriptors(eth_hs_function); 690 f->hs_descriptors = usb_copy_descriptors(ecm_hs_function);
691 if (!f->hs_descriptors) 691 if (!f->hs_descriptors)
692 goto fail; 692 goto fail;
693 693
694 ecm->hs.in = usb_find_endpoint(eth_hs_function, 694 ecm->hs.in = usb_find_endpoint(ecm_hs_function,
695 f->hs_descriptors, &hs_in_desc); 695 f->hs_descriptors, &hs_ecm_in_desc);
696 ecm->hs.out = usb_find_endpoint(eth_hs_function, 696 ecm->hs.out = usb_find_endpoint(ecm_hs_function,
697 f->hs_descriptors, &hs_out_desc); 697 f->hs_descriptors, &hs_ecm_out_desc);
698 ecm->hs.notify = usb_find_endpoint(eth_hs_function, 698 ecm->hs.notify = usb_find_endpoint(ecm_hs_function,
699 f->hs_descriptors, &hs_notify_desc); 699 f->hs_descriptors, &hs_ecm_notify_desc);
700 } 700 }
701 701
702 /* NOTE: all that is done without knowing or caring about 702 /* NOTE: all that is done without knowing or caring about
@@ -795,7 +795,7 @@ int __init ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
795 if (status < 0) 795 if (status < 0)
796 return status; 796 return status;
797 ecm_string_defs[1].id = status; 797 ecm_string_defs[1].id = status;
798 ether_desc.iMACAddress = status; 798 ecm_desc.iMACAddress = status;
799 } 799 }
800 800
801 /* allocate and initialize one new instance */ 801 /* allocate and initialize one new instance */
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index eda4cde72c82..87dde012dacc 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -70,7 +70,7 @@ static struct usb_interface_descriptor loopback_intf = {
70 70
71/* full speed support: */ 71/* full speed support: */
72 72
73static struct usb_endpoint_descriptor fs_source_desc = { 73static struct usb_endpoint_descriptor fs_loop_source_desc = {
74 .bLength = USB_DT_ENDPOINT_SIZE, 74 .bLength = USB_DT_ENDPOINT_SIZE,
75 .bDescriptorType = USB_DT_ENDPOINT, 75 .bDescriptorType = USB_DT_ENDPOINT,
76 76
@@ -78,7 +78,7 @@ static struct usb_endpoint_descriptor fs_source_desc = {
78 .bmAttributes = USB_ENDPOINT_XFER_BULK, 78 .bmAttributes = USB_ENDPOINT_XFER_BULK,
79}; 79};
80 80
81static struct usb_endpoint_descriptor fs_sink_desc = { 81static struct usb_endpoint_descriptor fs_loop_sink_desc = {
82 .bLength = USB_DT_ENDPOINT_SIZE, 82 .bLength = USB_DT_ENDPOINT_SIZE,
83 .bDescriptorType = USB_DT_ENDPOINT, 83 .bDescriptorType = USB_DT_ENDPOINT,
84 84
@@ -88,14 +88,14 @@ static struct usb_endpoint_descriptor fs_sink_desc = {
88 88
89static struct usb_descriptor_header *fs_loopback_descs[] = { 89static struct usb_descriptor_header *fs_loopback_descs[] = {
90 (struct usb_descriptor_header *) &loopback_intf, 90 (struct usb_descriptor_header *) &loopback_intf,
91 (struct usb_descriptor_header *) &fs_sink_desc, 91 (struct usb_descriptor_header *) &fs_loop_sink_desc,
92 (struct usb_descriptor_header *) &fs_source_desc, 92 (struct usb_descriptor_header *) &fs_loop_source_desc,
93 NULL, 93 NULL,
94}; 94};
95 95
96/* high speed support: */ 96/* high speed support: */
97 97
98static struct usb_endpoint_descriptor hs_source_desc = { 98static struct usb_endpoint_descriptor hs_loop_source_desc = {
99 .bLength = USB_DT_ENDPOINT_SIZE, 99 .bLength = USB_DT_ENDPOINT_SIZE,
100 .bDescriptorType = USB_DT_ENDPOINT, 100 .bDescriptorType = USB_DT_ENDPOINT,
101 101
@@ -103,7 +103,7 @@ static struct usb_endpoint_descriptor hs_source_desc = {
103 .wMaxPacketSize = __constant_cpu_to_le16(512), 103 .wMaxPacketSize = __constant_cpu_to_le16(512),
104}; 104};
105 105
106static struct usb_endpoint_descriptor hs_sink_desc = { 106static struct usb_endpoint_descriptor hs_loop_sink_desc = {
107 .bLength = USB_DT_ENDPOINT_SIZE, 107 .bLength = USB_DT_ENDPOINT_SIZE,
108 .bDescriptorType = USB_DT_ENDPOINT, 108 .bDescriptorType = USB_DT_ENDPOINT,
109 109
@@ -113,8 +113,8 @@ static struct usb_endpoint_descriptor hs_sink_desc = {
113 113
114static struct usb_descriptor_header *hs_loopback_descs[] = { 114static struct usb_descriptor_header *hs_loopback_descs[] = {
115 (struct usb_descriptor_header *) &loopback_intf, 115 (struct usb_descriptor_header *) &loopback_intf,
116 (struct usb_descriptor_header *) &hs_source_desc, 116 (struct usb_descriptor_header *) &hs_loop_source_desc,
117 (struct usb_descriptor_header *) &hs_sink_desc, 117 (struct usb_descriptor_header *) &hs_loop_sink_desc,
118 NULL, 118 NULL,
119}; 119};
120 120
@@ -152,7 +152,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f)
152 152
153 /* allocate endpoints */ 153 /* allocate endpoints */
154 154
155 loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); 155 loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_source_desc);
156 if (!loop->in_ep) { 156 if (!loop->in_ep) {
157autoconf_fail: 157autoconf_fail:
158 ERROR(cdev, "%s: can't autoconfigure on %s\n", 158 ERROR(cdev, "%s: can't autoconfigure on %s\n",
@@ -161,17 +161,17 @@ autoconf_fail:
161 } 161 }
162 loop->in_ep->driver_data = cdev; /* claim */ 162 loop->in_ep->driver_data = cdev; /* claim */
163 163
164 loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); 164 loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_sink_desc);
165 if (!loop->out_ep) 165 if (!loop->out_ep)
166 goto autoconf_fail; 166 goto autoconf_fail;
167 loop->out_ep->driver_data = cdev; /* claim */ 167 loop->out_ep->driver_data = cdev; /* claim */
168 168
169 /* support high speed hardware */ 169 /* support high speed hardware */
170 if (gadget_is_dualspeed(c->cdev->gadget)) { 170 if (gadget_is_dualspeed(c->cdev->gadget)) {
171 hs_source_desc.bEndpointAddress = 171 hs_loop_source_desc.bEndpointAddress =
172 fs_source_desc.bEndpointAddress; 172 fs_loop_source_desc.bEndpointAddress;
173 hs_sink_desc.bEndpointAddress = 173 hs_loop_sink_desc.bEndpointAddress =
174 fs_sink_desc.bEndpointAddress; 174 fs_loop_sink_desc.bEndpointAddress;
175 f->hs_descriptors = hs_loopback_descs; 175 f->hs_descriptors = hs_loopback_descs;
176 } 176 }
177 177
@@ -255,8 +255,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop)
255 struct usb_request *req; 255 struct usb_request *req;
256 unsigned i; 256 unsigned i;
257 257
258 src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc); 258 src = ep_choose(cdev->gadget,
259 sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc); 259 &hs_loop_source_desc, &fs_loop_source_desc);
260 sink = ep_choose(cdev->gadget,
261 &hs_loop_sink_desc, &fs_loop_sink_desc);
260 262
261 /* one endpoint writes data back IN to the host */ 263 /* one endpoint writes data back IN to the host */
262 ep = loop->in_ep; 264 ep = loop->in_ep;
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index acb8d233aa1d..fe1832875771 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = {
103 /* .iInterface = DYNAMIC */ 103 /* .iInterface = DYNAMIC */
104}; 104};
105 105
106static struct usb_cdc_header_desc header_desc __initdata = { 106static struct usb_cdc_header_desc mdlm_header_desc __initdata = {
107 .bLength = sizeof header_desc, 107 .bLength = sizeof mdlm_header_desc,
108 .bDescriptorType = USB_DT_CS_INTERFACE, 108 .bDescriptorType = USB_DT_CS_INTERFACE,
109 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 109 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
110 110
@@ -152,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = {
152 152
153/* full speed support: */ 153/* full speed support: */
154 154
155static struct usb_endpoint_descriptor fs_in_desc __initdata = { 155static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = {
156 .bLength = USB_DT_ENDPOINT_SIZE, 156 .bLength = USB_DT_ENDPOINT_SIZE,
157 .bDescriptorType = USB_DT_ENDPOINT, 157 .bDescriptorType = USB_DT_ENDPOINT,
158 158
@@ -160,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = {
160 .bmAttributes = USB_ENDPOINT_XFER_BULK, 160 .bmAttributes = USB_ENDPOINT_XFER_BULK,
161}; 161};
162 162
163static struct usb_endpoint_descriptor fs_out_desc __initdata = { 163static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = {
164 .bLength = USB_DT_ENDPOINT_SIZE, 164 .bLength = USB_DT_ENDPOINT_SIZE,
165 .bDescriptorType = USB_DT_ENDPOINT, 165 .bDescriptorType = USB_DT_ENDPOINT,
166 166
@@ -170,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = {
170 170
171static struct usb_descriptor_header *fs_eth_function[] __initdata = { 171static struct usb_descriptor_header *fs_eth_function[] __initdata = {
172 (struct usb_descriptor_header *) &subset_data_intf, 172 (struct usb_descriptor_header *) &subset_data_intf,
173 (struct usb_descriptor_header *) &header_desc, 173 (struct usb_descriptor_header *) &mdlm_header_desc,
174 (struct usb_descriptor_header *) &mdlm_desc, 174 (struct usb_descriptor_header *) &mdlm_desc,
175 (struct usb_descriptor_header *) &mdlm_detail_desc, 175 (struct usb_descriptor_header *) &mdlm_detail_desc,
176 (struct usb_descriptor_header *) &ether_desc, 176 (struct usb_descriptor_header *) &ether_desc,
177 (struct usb_descriptor_header *) &fs_in_desc, 177 (struct usb_descriptor_header *) &fs_subset_in_desc,
178 (struct usb_descriptor_header *) &fs_out_desc, 178 (struct usb_descriptor_header *) &fs_subset_out_desc,
179 NULL, 179 NULL,
180}; 180};
181 181
182/* high speed support: */ 182/* high speed support: */
183 183
184static struct usb_endpoint_descriptor hs_in_desc __initdata = { 184static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = {
185 .bLength = USB_DT_ENDPOINT_SIZE, 185 .bLength = USB_DT_ENDPOINT_SIZE,
186 .bDescriptorType = USB_DT_ENDPOINT, 186 .bDescriptorType = USB_DT_ENDPOINT,
187 187
@@ -189,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = {
189 .wMaxPacketSize = __constant_cpu_to_le16(512), 189 .wMaxPacketSize = __constant_cpu_to_le16(512),
190}; 190};
191 191
192static struct usb_endpoint_descriptor hs_out_desc __initdata = { 192static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = {
193 .bLength = USB_DT_ENDPOINT_SIZE, 193 .bLength = USB_DT_ENDPOINT_SIZE,
194 .bDescriptorType = USB_DT_ENDPOINT, 194 .bDescriptorType = USB_DT_ENDPOINT,
195 195
@@ -199,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = {
199 199
200static struct usb_descriptor_header *hs_eth_function[] __initdata = { 200static struct usb_descriptor_header *hs_eth_function[] __initdata = {
201 (struct usb_descriptor_header *) &subset_data_intf, 201 (struct usb_descriptor_header *) &subset_data_intf,
202 (struct usb_descriptor_header *) &header_desc, 202 (struct usb_descriptor_header *) &mdlm_header_desc,
203 (struct usb_descriptor_header *) &mdlm_desc, 203 (struct usb_descriptor_header *) &mdlm_desc,
204 (struct usb_descriptor_header *) &mdlm_detail_desc, 204 (struct usb_descriptor_header *) &mdlm_detail_desc,
205 (struct usb_descriptor_header *) &ether_desc, 205 (struct usb_descriptor_header *) &ether_desc,
206 (struct usb_descriptor_header *) &hs_in_desc, 206 (struct usb_descriptor_header *) &hs_subset_in_desc,
207 (struct usb_descriptor_header *) &hs_out_desc, 207 (struct usb_descriptor_header *) &hs_subset_out_desc,
208 NULL, 208 NULL,
209}; 209};
210 210
@@ -281,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
281 status = -ENODEV; 281 status = -ENODEV;
282 282
283 /* allocate instance-specific endpoints */ 283 /* allocate instance-specific endpoints */
284 ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); 284 ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc);
285 if (!ep) 285 if (!ep)
286 goto fail; 286 goto fail;
287 geth->port.in_ep = ep; 287 geth->port.in_ep = ep;
288 ep->driver_data = cdev; /* claim */ 288 ep->driver_data = cdev; /* claim */
289 289
290 ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); 290 ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc);
291 if (!ep) 291 if (!ep)
292 goto fail; 292 goto fail;
293 geth->port.out_ep = ep; 293 geth->port.out_ep = ep;
@@ -297,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
297 f->descriptors = usb_copy_descriptors(fs_eth_function); 297 f->descriptors = usb_copy_descriptors(fs_eth_function);
298 298
299 geth->fs.in = usb_find_endpoint(fs_eth_function, 299 geth->fs.in = usb_find_endpoint(fs_eth_function,
300 f->descriptors, &fs_in_desc); 300 f->descriptors, &fs_subset_in_desc);
301 geth->fs.out = usb_find_endpoint(fs_eth_function, 301 geth->fs.out = usb_find_endpoint(fs_eth_function,
302 f->descriptors, &fs_out_desc); 302 f->descriptors, &fs_subset_out_desc);
303 303
304 304
305 /* support all relevant hardware speeds... we expect that when 305 /* support all relevant hardware speeds... we expect that when
@@ -307,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
307 * both speeds 307 * both speeds
308 */ 308 */
309 if (gadget_is_dualspeed(c->cdev->gadget)) { 309 if (gadget_is_dualspeed(c->cdev->gadget)) {
310 hs_in_desc.bEndpointAddress = 310 hs_subset_in_desc.bEndpointAddress =
311 fs_in_desc.bEndpointAddress; 311 fs_subset_in_desc.bEndpointAddress;
312 hs_out_desc.bEndpointAddress = 312 hs_subset_out_desc.bEndpointAddress =
313 fs_out_desc.bEndpointAddress; 313 fs_subset_out_desc.bEndpointAddress;
314 314
315 /* copy descriptors, and track endpoint copies */ 315 /* copy descriptors, and track endpoint copies */
316 f->hs_descriptors = usb_copy_descriptors(hs_eth_function); 316 f->hs_descriptors = usb_copy_descriptors(hs_eth_function);
317 317
318 geth->hs.in = usb_find_endpoint(hs_eth_function, 318 geth->hs.in = usb_find_endpoint(hs_eth_function,
319 f->hs_descriptors, &hs_in_desc); 319 f->hs_descriptors, &hs_subset_in_desc);
320 geth->hs.out = usb_find_endpoint(hs_eth_function, 320 geth->hs.out = usb_find_endpoint(hs_eth_function,
321 f->hs_descriptors, &hs_out_desc); 321 f->hs_descriptors, &hs_subset_out_desc);
322 } 322 }
323 323
324 /* NOTE: all that is done without knowing or caring about 324 /* NOTE: all that is done without knowing or caring about
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index ea2c31d18080..0c632d22a631 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -245,6 +245,18 @@
245#include "gadget_chips.h" 245#include "gadget_chips.h"
246 246
247 247
248
249/*
250 * Kbuild is not very cooperative with respect to linking separately
251 * compiled library objects into one module. So for now we won't use
252 * separate compilation ... ensuring init/exit sections work to shrink
253 * the runtime footprint, and giving us at least some parts of what
254 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
255 */
256#include "usbstring.c"
257#include "config.c"
258#include "epautoconf.c"
259
248/*-------------------------------------------------------------------------*/ 260/*-------------------------------------------------------------------------*/
249 261
250#define DRIVER_DESC "File-backed Storage Gadget" 262#define DRIVER_DESC "File-backed Storage Gadget"
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index ea8651e3da1a..6eee760410d6 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -35,6 +35,21 @@
35 35
36#include "gadget_chips.h" 36#include "gadget_chips.h"
37 37
38
39/*
40 * Kbuild is not very cooperative with respect to linking separately
41 * compiled library objects into one module. So for now we won't use
42 * separate compilation ... ensuring init/exit sections work to shrink
43 * the runtime footprint, and giving us at least some parts of what
44 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
45 */
46#include "usbstring.c"
47#include "config.c"
48#include "epautoconf.c"
49
50/*-------------------------------------------------------------------------*/
51
52
38MODULE_AUTHOR("Ben Williamson"); 53MODULE_AUTHOR("Ben Williamson");
39MODULE_LICENSE("GPL v2"); 54MODULE_LICENSE("GPL v2");
40 55
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index e0090085b78e..2b3b9e1dd2ee 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -53,6 +53,20 @@
53 53
54#include "gadget_chips.h" 54#include "gadget_chips.h"
55 55
56
57/*
58 * Kbuild is not very cooperative with respect to linking separately
59 * compiled library objects into one module. So for now we won't use
60 * separate compilation ... ensuring init/exit sections work to shrink
61 * the runtime footprint, and giving us at least some parts of what
62 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
63 */
64#include "usbstring.c"
65#include "config.c"
66#include "epautoconf.c"
67
68/*-------------------------------------------------------------------------*/
69
56#define DRIVER_DESC "Printer Gadget" 70#define DRIVER_DESC "Printer Gadget"
57#define DRIVER_VERSION "2007 OCT 06" 71#define DRIVER_VERSION "2007 OCT 06"
58 72
@@ -1360,8 +1374,8 @@ printer_bind(struct usb_gadget *gadget)
1360 1374
1361 1375
1362 /* Setup the sysfs files for the printer gadget. */ 1376 /* Setup the sysfs files for the printer gadget. */
1363 dev->pdev = device_create_drvdata(usb_gadget_class, NULL, 1377 dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno,
1364 g_printer_devno, NULL, "g_printer"); 1378 NULL, "g_printer");
1365 if (IS_ERR(dev->pdev)) { 1379 if (IS_ERR(dev->pdev)) {
1366 ERROR(dev, "Failed to create device: g_printer\n"); 1380 ERROR(dev, "Failed to create device: g_printer\n");
1367 goto fail; 1381 goto fail;
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 7228e8562236..8c26f5ea2b83 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -57,11 +57,6 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging");
57#define rndis_debug 0 57#define rndis_debug 0
58#endif 58#endif
59 59
60#define DBG(str,args...) do { \
61 if (rndis_debug) \
62 pr_debug(str , ## args); \
63 } while (0)
64
65#define RNDIS_MAX_CONFIGS 1 60#define RNDIS_MAX_CONFIGS 1
66 61
67 62
@@ -183,9 +178,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
183 if (!resp) return -ENOMEM; 178 if (!resp) return -ENOMEM;
184 179
185 if (buf_len && rndis_debug > 1) { 180 if (buf_len && rndis_debug > 1) {
186 DBG("query OID %08x value, len %d:\n", OID, buf_len); 181 pr_debug("query OID %08x value, len %d:\n", OID, buf_len);
187 for (i = 0; i < buf_len; i += 16) { 182 for (i = 0; i < buf_len; i += 16) {
188 DBG("%03d: %08x %08x %08x %08x\n", i, 183 pr_debug("%03d: %08x %08x %08x %08x\n", i,
189 get_unaligned_le32(&buf[i]), 184 get_unaligned_le32(&buf[i]),
190 get_unaligned_le32(&buf[i + 4]), 185 get_unaligned_le32(&buf[i + 4]),
191 get_unaligned_le32(&buf[i + 8]), 186 get_unaligned_le32(&buf[i + 8]),
@@ -209,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
209 204
210 /* mandatory */ 205 /* mandatory */
211 case OID_GEN_SUPPORTED_LIST: 206 case OID_GEN_SUPPORTED_LIST:
212 DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__); 207 pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
213 length = sizeof (oid_supported_list); 208 length = sizeof (oid_supported_list);
214 count = length / sizeof (u32); 209 count = length / sizeof (u32);
215 for (i = 0; i < count; i++) 210 for (i = 0; i < count; i++)
@@ -219,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
219 214
220 /* mandatory */ 215 /* mandatory */
221 case OID_GEN_HARDWARE_STATUS: 216 case OID_GEN_HARDWARE_STATUS:
222 DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__); 217 pr_debug("%s: OID_GEN_HARDWARE_STATUS\n", __func__);
223 /* Bogus question! 218 /* Bogus question!
224 * Hardware must be ready to receive high level protocols. 219 * Hardware must be ready to receive high level protocols.
225 * BTW: 220 * BTW:
@@ -232,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
232 227
233 /* mandatory */ 228 /* mandatory */
234 case OID_GEN_MEDIA_SUPPORTED: 229 case OID_GEN_MEDIA_SUPPORTED:
235 DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); 230 pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
236 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 231 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
237 retval = 0; 232 retval = 0;
238 break; 233 break;
239 234
240 /* mandatory */ 235 /* mandatory */
241 case OID_GEN_MEDIA_IN_USE: 236 case OID_GEN_MEDIA_IN_USE:
242 DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__); 237 pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__);
243 /* one medium, one transport... (maybe you do it better) */ 238 /* one medium, one transport... (maybe you do it better) */
244 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 239 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
245 retval = 0; 240 retval = 0;
@@ -247,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
247 242
248 /* mandatory */ 243 /* mandatory */
249 case OID_GEN_MAXIMUM_FRAME_SIZE: 244 case OID_GEN_MAXIMUM_FRAME_SIZE:
250 DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); 245 pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__);
251 if (rndis_per_dev_params [configNr].dev) { 246 if (rndis_per_dev_params [configNr].dev) {
252 *outbuf = cpu_to_le32 ( 247 *outbuf = cpu_to_le32 (
253 rndis_per_dev_params [configNr].dev->mtu); 248 rndis_per_dev_params [configNr].dev->mtu);
@@ -258,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
258 /* mandatory */ 253 /* mandatory */
259 case OID_GEN_LINK_SPEED: 254 case OID_GEN_LINK_SPEED:
260 if (rndis_debug > 1) 255 if (rndis_debug > 1)
261 DBG("%s: OID_GEN_LINK_SPEED\n", __func__); 256 pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__);
262 if (rndis_per_dev_params [configNr].media_state 257 if (rndis_per_dev_params [configNr].media_state
263 == NDIS_MEDIA_STATE_DISCONNECTED) 258 == NDIS_MEDIA_STATE_DISCONNECTED)
264 *outbuf = __constant_cpu_to_le32 (0); 259 *outbuf = __constant_cpu_to_le32 (0);
@@ -270,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
270 265
271 /* mandatory */ 266 /* mandatory */
272 case OID_GEN_TRANSMIT_BLOCK_SIZE: 267 case OID_GEN_TRANSMIT_BLOCK_SIZE:
273 DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); 268 pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__);
274 if (rndis_per_dev_params [configNr].dev) { 269 if (rndis_per_dev_params [configNr].dev) {
275 *outbuf = cpu_to_le32 ( 270 *outbuf = cpu_to_le32 (
276 rndis_per_dev_params [configNr].dev->mtu); 271 rndis_per_dev_params [configNr].dev->mtu);
@@ -280,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
280 275
281 /* mandatory */ 276 /* mandatory */
282 case OID_GEN_RECEIVE_BLOCK_SIZE: 277 case OID_GEN_RECEIVE_BLOCK_SIZE:
283 DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); 278 pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__);
284 if (rndis_per_dev_params [configNr].dev) { 279 if (rndis_per_dev_params [configNr].dev) {
285 *outbuf = cpu_to_le32 ( 280 *outbuf = cpu_to_le32 (
286 rndis_per_dev_params [configNr].dev->mtu); 281 rndis_per_dev_params [configNr].dev->mtu);
@@ -290,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
290 285
291 /* mandatory */ 286 /* mandatory */
292 case OID_GEN_VENDOR_ID: 287 case OID_GEN_VENDOR_ID:
293 DBG("%s: OID_GEN_VENDOR_ID\n", __func__); 288 pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__);
294 *outbuf = cpu_to_le32 ( 289 *outbuf = cpu_to_le32 (
295 rndis_per_dev_params [configNr].vendorID); 290 rndis_per_dev_params [configNr].vendorID);
296 retval = 0; 291 retval = 0;
@@ -298,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
298 293
299 /* mandatory */ 294 /* mandatory */
300 case OID_GEN_VENDOR_DESCRIPTION: 295 case OID_GEN_VENDOR_DESCRIPTION:
301 DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); 296 pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
302 length = strlen (rndis_per_dev_params [configNr].vendorDescr); 297 length = strlen (rndis_per_dev_params [configNr].vendorDescr);
303 memcpy (outbuf, 298 memcpy (outbuf,
304 rndis_per_dev_params [configNr].vendorDescr, length); 299 rndis_per_dev_params [configNr].vendorDescr, length);
@@ -306,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
306 break; 301 break;
307 302
308 case OID_GEN_VENDOR_DRIVER_VERSION: 303 case OID_GEN_VENDOR_DRIVER_VERSION:
309 DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); 304 pr_debug("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__);
310 /* Created as LE */ 305 /* Created as LE */
311 *outbuf = rndis_driver_version; 306 *outbuf = rndis_driver_version;
312 retval = 0; 307 retval = 0;
@@ -314,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
314 309
315 /* mandatory */ 310 /* mandatory */
316 case OID_GEN_CURRENT_PACKET_FILTER: 311 case OID_GEN_CURRENT_PACKET_FILTER:
317 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); 312 pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__);
318 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); 313 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter);
319 retval = 0; 314 retval = 0;
320 break; 315 break;
321 316
322 /* mandatory */ 317 /* mandatory */
323 case OID_GEN_MAXIMUM_TOTAL_SIZE: 318 case OID_GEN_MAXIMUM_TOTAL_SIZE:
324 DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); 319 pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__);
325 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); 320 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE);
326 retval = 0; 321 retval = 0;
327 break; 322 break;
@@ -329,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
329 /* mandatory */ 324 /* mandatory */
330 case OID_GEN_MEDIA_CONNECT_STATUS: 325 case OID_GEN_MEDIA_CONNECT_STATUS:
331 if (rndis_debug > 1) 326 if (rndis_debug > 1)
332 DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); 327 pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__);
333 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 328 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
334 .media_state); 329 .media_state);
335 retval = 0; 330 retval = 0;
336 break; 331 break;
337 332
338 case OID_GEN_PHYSICAL_MEDIUM: 333 case OID_GEN_PHYSICAL_MEDIUM:
339 DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); 334 pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
340 *outbuf = __constant_cpu_to_le32 (0); 335 *outbuf = __constant_cpu_to_le32 (0);
341 retval = 0; 336 retval = 0;
342 break; 337 break;
@@ -346,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
346 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! 341 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE!
347 */ 342 */
348 case OID_GEN_MAC_OPTIONS: /* from WinME */ 343 case OID_GEN_MAC_OPTIONS: /* from WinME */
349 DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__); 344 pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__);
350 *outbuf = __constant_cpu_to_le32( 345 *outbuf = __constant_cpu_to_le32(
351 NDIS_MAC_OPTION_RECEIVE_SERIALIZED 346 NDIS_MAC_OPTION_RECEIVE_SERIALIZED
352 | NDIS_MAC_OPTION_FULL_DUPLEX); 347 | NDIS_MAC_OPTION_FULL_DUPLEX);
@@ -358,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
358 /* mandatory */ 353 /* mandatory */
359 case OID_GEN_XMIT_OK: 354 case OID_GEN_XMIT_OK:
360 if (rndis_debug > 1) 355 if (rndis_debug > 1)
361 DBG("%s: OID_GEN_XMIT_OK\n", __func__); 356 pr_debug("%s: OID_GEN_XMIT_OK\n", __func__);
362 if (stats) { 357 if (stats) {
363 *outbuf = cpu_to_le32(stats->tx_packets 358 *outbuf = cpu_to_le32(stats->tx_packets
364 - stats->tx_errors - stats->tx_dropped); 359 - stats->tx_errors - stats->tx_dropped);
@@ -369,7 +364,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
369 /* mandatory */ 364 /* mandatory */
370 case OID_GEN_RCV_OK: 365 case OID_GEN_RCV_OK:
371 if (rndis_debug > 1) 366 if (rndis_debug > 1)
372 DBG("%s: OID_GEN_RCV_OK\n", __func__); 367 pr_debug("%s: OID_GEN_RCV_OK\n", __func__);
373 if (stats) { 368 if (stats) {
374 *outbuf = cpu_to_le32(stats->rx_packets 369 *outbuf = cpu_to_le32(stats->rx_packets
375 - stats->rx_errors - stats->rx_dropped); 370 - stats->rx_errors - stats->rx_dropped);
@@ -380,7 +375,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
380 /* mandatory */ 375 /* mandatory */
381 case OID_GEN_XMIT_ERROR: 376 case OID_GEN_XMIT_ERROR:
382 if (rndis_debug > 1) 377 if (rndis_debug > 1)
383 DBG("%s: OID_GEN_XMIT_ERROR\n", __func__); 378 pr_debug("%s: OID_GEN_XMIT_ERROR\n", __func__);
384 if (stats) { 379 if (stats) {
385 *outbuf = cpu_to_le32(stats->tx_errors); 380 *outbuf = cpu_to_le32(stats->tx_errors);
386 retval = 0; 381 retval = 0;
@@ -390,7 +385,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
390 /* mandatory */ 385 /* mandatory */
391 case OID_GEN_RCV_ERROR: 386 case OID_GEN_RCV_ERROR:
392 if (rndis_debug > 1) 387 if (rndis_debug > 1)
393 DBG("%s: OID_GEN_RCV_ERROR\n", __func__); 388 pr_debug("%s: OID_GEN_RCV_ERROR\n", __func__);
394 if (stats) { 389 if (stats) {
395 *outbuf = cpu_to_le32(stats->rx_errors); 390 *outbuf = cpu_to_le32(stats->rx_errors);
396 retval = 0; 391 retval = 0;
@@ -399,7 +394,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
399 394
400 /* mandatory */ 395 /* mandatory */
401 case OID_GEN_RCV_NO_BUFFER: 396 case OID_GEN_RCV_NO_BUFFER:
402 DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); 397 pr_debug("%s: OID_GEN_RCV_NO_BUFFER\n", __func__);
403 if (stats) { 398 if (stats) {
404 *outbuf = cpu_to_le32(stats->rx_dropped); 399 *outbuf = cpu_to_le32(stats->rx_dropped);
405 retval = 0; 400 retval = 0;
@@ -410,7 +405,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
410 405
411 /* mandatory */ 406 /* mandatory */
412 case OID_802_3_PERMANENT_ADDRESS: 407 case OID_802_3_PERMANENT_ADDRESS:
413 DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); 408 pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__);
414 if (rndis_per_dev_params [configNr].dev) { 409 if (rndis_per_dev_params [configNr].dev) {
415 length = ETH_ALEN; 410 length = ETH_ALEN;
416 memcpy (outbuf, 411 memcpy (outbuf,
@@ -422,7 +417,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
422 417
423 /* mandatory */ 418 /* mandatory */
424 case OID_802_3_CURRENT_ADDRESS: 419 case OID_802_3_CURRENT_ADDRESS:
425 DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); 420 pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__);
426 if (rndis_per_dev_params [configNr].dev) { 421 if (rndis_per_dev_params [configNr].dev) {
427 length = ETH_ALEN; 422 length = ETH_ALEN;
428 memcpy (outbuf, 423 memcpy (outbuf,
@@ -434,7 +429,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
434 429
435 /* mandatory */ 430 /* mandatory */
436 case OID_802_3_MULTICAST_LIST: 431 case OID_802_3_MULTICAST_LIST:
437 DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); 432 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
438 /* Multicast base address only */ 433 /* Multicast base address only */
439 *outbuf = __constant_cpu_to_le32 (0xE0000000); 434 *outbuf = __constant_cpu_to_le32 (0xE0000000);
440 retval = 0; 435 retval = 0;
@@ -442,21 +437,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
442 437
443 /* mandatory */ 438 /* mandatory */
444 case OID_802_3_MAXIMUM_LIST_SIZE: 439 case OID_802_3_MAXIMUM_LIST_SIZE:
445 DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 440 pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__);
446 /* Multicast base address only */ 441 /* Multicast base address only */
447 *outbuf = __constant_cpu_to_le32 (1); 442 *outbuf = __constant_cpu_to_le32 (1);
448 retval = 0; 443 retval = 0;
449 break; 444 break;
450 445
451 case OID_802_3_MAC_OPTIONS: 446 case OID_802_3_MAC_OPTIONS:
452 DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__); 447 pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__);
453 break; 448 break;
454 449
455 /* ieee802.3 statistics OIDs (table 4-4) */ 450 /* ieee802.3 statistics OIDs (table 4-4) */
456 451
457 /* mandatory */ 452 /* mandatory */
458 case OID_802_3_RCV_ERROR_ALIGNMENT: 453 case OID_802_3_RCV_ERROR_ALIGNMENT:
459 DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); 454 pr_debug("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__);
460 if (stats) { 455 if (stats) {
461 *outbuf = cpu_to_le32(stats->rx_frame_errors); 456 *outbuf = cpu_to_le32(stats->rx_frame_errors);
462 retval = 0; 457 retval = 0;
@@ -465,14 +460,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
465 460
466 /* mandatory */ 461 /* mandatory */
467 case OID_802_3_XMIT_ONE_COLLISION: 462 case OID_802_3_XMIT_ONE_COLLISION:
468 DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); 463 pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__);
469 *outbuf = __constant_cpu_to_le32 (0); 464 *outbuf = __constant_cpu_to_le32 (0);
470 retval = 0; 465 retval = 0;
471 break; 466 break;
472 467
473 /* mandatory */ 468 /* mandatory */
474 case OID_802_3_XMIT_MORE_COLLISIONS: 469 case OID_802_3_XMIT_MORE_COLLISIONS:
475 DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 470 pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__);
476 *outbuf = __constant_cpu_to_le32 (0); 471 *outbuf = __constant_cpu_to_le32 (0);
477 retval = 0; 472 retval = 0;
478 break; 473 break;
@@ -504,9 +499,9 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
504 return -ENOMEM; 499 return -ENOMEM;
505 500
506 if (buf_len && rndis_debug > 1) { 501 if (buf_len && rndis_debug > 1) {
507 DBG("set OID %08x value, len %d:\n", OID, buf_len); 502 pr_debug("set OID %08x value, len %d:\n", OID, buf_len);
508 for (i = 0; i < buf_len; i += 16) { 503 for (i = 0; i < buf_len; i += 16) {
509 DBG("%03d: %08x %08x %08x %08x\n", i, 504 pr_debug("%03d: %08x %08x %08x %08x\n", i,
510 get_unaligned_le32(&buf[i]), 505 get_unaligned_le32(&buf[i]),
511 get_unaligned_le32(&buf[i + 4]), 506 get_unaligned_le32(&buf[i + 4]),
512 get_unaligned_le32(&buf[i + 8]), 507 get_unaligned_le32(&buf[i + 8]),
@@ -525,7 +520,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
525 * MULTICAST, ALL_MULTICAST, BROADCAST 520 * MULTICAST, ALL_MULTICAST, BROADCAST
526 */ 521 */
527 *params->filter = (u16)get_unaligned_le32(buf); 522 *params->filter = (u16)get_unaligned_le32(buf);
528 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 523 pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n",
529 __func__, *params->filter); 524 __func__, *params->filter);
530 525
531 /* this call has a significant side effect: it's 526 /* this call has a significant side effect: it's
@@ -547,7 +542,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
547 542
548 case OID_802_3_MULTICAST_LIST: 543 case OID_802_3_MULTICAST_LIST:
549 /* I think we can ignore this */ 544 /* I think we can ignore this */
550 DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); 545 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
551 retval = 0; 546 retval = 0;
552 break; 547 break;
553 548
@@ -606,7 +601,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
606 rndis_resp_t *r; 601 rndis_resp_t *r;
607 struct rndis_params *params = rndis_per_dev_params + configNr; 602 struct rndis_params *params = rndis_per_dev_params + configNr;
608 603
609 // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); 604 /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */
610 if (!params->dev) 605 if (!params->dev)
611 return -ENOTSUPP; 606 return -ENOTSUPP;
612 607
@@ -659,15 +654,15 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
659 BufOffset = le32_to_cpu (buf->InformationBufferOffset); 654 BufOffset = le32_to_cpu (buf->InformationBufferOffset);
660 655
661#ifdef VERBOSE_DEBUG 656#ifdef VERBOSE_DEBUG
662 DBG("%s: Length: %d\n", __func__, BufLength); 657 pr_debug("%s: Length: %d\n", __func__, BufLength);
663 DBG("%s: Offset: %d\n", __func__, BufOffset); 658 pr_debug("%s: Offset: %d\n", __func__, BufOffset);
664 DBG("%s: InfoBuffer: ", __func__); 659 pr_debug("%s: InfoBuffer: ", __func__);
665 660
666 for (i = 0; i < BufLength; i++) { 661 for (i = 0; i < BufLength; i++) {
667 DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); 662 pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset));
668 } 663 }
669 664
670 DBG("\n"); 665 pr_debug("\n");
671#endif 666#endif
672 667
673 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); 668 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT);
@@ -821,14 +816,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
821 /* For USB: responses may take up to 10 seconds */ 816 /* For USB: responses may take up to 10 seconds */
822 switch (MsgType) { 817 switch (MsgType) {
823 case REMOTE_NDIS_INITIALIZE_MSG: 818 case REMOTE_NDIS_INITIALIZE_MSG:
824 DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", 819 pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
825 __func__ ); 820 __func__ );
826 params->state = RNDIS_INITIALIZED; 821 params->state = RNDIS_INITIALIZED;
827 return rndis_init_response (configNr, 822 return rndis_init_response (configNr,
828 (rndis_init_msg_type *) buf); 823 (rndis_init_msg_type *) buf);
829 824
830 case REMOTE_NDIS_HALT_MSG: 825 case REMOTE_NDIS_HALT_MSG:
831 DBG("%s: REMOTE_NDIS_HALT_MSG\n", 826 pr_debug("%s: REMOTE_NDIS_HALT_MSG\n",
832 __func__ ); 827 __func__ );
833 params->state = RNDIS_UNINITIALIZED; 828 params->state = RNDIS_UNINITIALIZED;
834 if (params->dev) { 829 if (params->dev) {
@@ -846,7 +841,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
846 (rndis_set_msg_type *) buf); 841 (rndis_set_msg_type *) buf);
847 842
848 case REMOTE_NDIS_RESET_MSG: 843 case REMOTE_NDIS_RESET_MSG:
849 DBG("%s: REMOTE_NDIS_RESET_MSG\n", 844 pr_debug("%s: REMOTE_NDIS_RESET_MSG\n",
850 __func__ ); 845 __func__ );
851 return rndis_reset_response (configNr, 846 return rndis_reset_response (configNr,
852 (rndis_reset_msg_type *) buf); 847 (rndis_reset_msg_type *) buf);
@@ -854,7 +849,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
854 case REMOTE_NDIS_KEEPALIVE_MSG: 849 case REMOTE_NDIS_KEEPALIVE_MSG:
855 /* For USB: host does this every 5 seconds */ 850 /* For USB: host does this every 5 seconds */
856 if (rndis_debug > 1) 851 if (rndis_debug > 1)
857 DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", 852 pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
858 __func__ ); 853 __func__ );
859 return rndis_keepalive_response (configNr, 854 return rndis_keepalive_response (configNr,
860 (rndis_keepalive_msg_type *) 855 (rndis_keepalive_msg_type *)
@@ -870,7 +865,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
870 { 865 {
871 unsigned i; 866 unsigned i;
872 for (i = 0; i < MsgLength; i += 16) { 867 for (i = 0; i < MsgLength; i += 16) {
873 DBG("%03d: " 868 pr_debug("%03d: "
874 " %02x %02x %02x %02x" 869 " %02x %02x %02x %02x"
875 " %02x %02x %02x %02x" 870 " %02x %02x %02x %02x"
876 " %02x %02x %02x %02x" 871 " %02x %02x %02x %02x"
@@ -905,18 +900,18 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
905 rndis_per_dev_params [i].used = 1; 900 rndis_per_dev_params [i].used = 1;
906 rndis_per_dev_params [i].resp_avail = resp_avail; 901 rndis_per_dev_params [i].resp_avail = resp_avail;
907 rndis_per_dev_params [i].v = v; 902 rndis_per_dev_params [i].v = v;
908 DBG("%s: configNr = %d\n", __func__, i); 903 pr_debug("%s: configNr = %d\n", __func__, i);
909 return i; 904 return i;
910 } 905 }
911 } 906 }
912 DBG("failed\n"); 907 pr_debug("failed\n");
913 908
914 return -ENODEV; 909 return -ENODEV;
915} 910}
916 911
917void rndis_deregister (int configNr) 912void rndis_deregister (int configNr)
918{ 913{
919 DBG("%s: \n", __func__ ); 914 pr_debug("%s: \n", __func__);
920 915
921 if (configNr >= RNDIS_MAX_CONFIGS) return; 916 if (configNr >= RNDIS_MAX_CONFIGS) return;
922 rndis_per_dev_params [configNr].used = 0; 917 rndis_per_dev_params [configNr].used = 0;
@@ -926,7 +921,7 @@ void rndis_deregister (int configNr)
926 921
927int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) 922int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
928{ 923{
929 DBG("%s:\n", __func__ ); 924 pr_debug("%s:\n", __func__);
930 if (!dev) 925 if (!dev)
931 return -EINVAL; 926 return -EINVAL;
932 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 927 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
@@ -939,7 +934,7 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
939 934
940int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) 935int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
941{ 936{
942 DBG("%s:\n", __func__ ); 937 pr_debug("%s:\n", __func__);
943 if (!vendorDescr) return -1; 938 if (!vendorDescr) return -1;
944 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 939 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
945 940
@@ -951,7 +946,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
951 946
952int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) 947int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed)
953{ 948{
954 DBG("%s: %u %u\n", __func__, medium, speed); 949 pr_debug("%s: %u %u\n", __func__, medium, speed);
955 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 950 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
956 951
957 rndis_per_dev_params [configNr].medium = medium; 952 rndis_per_dev_params [configNr].medium = medium;
@@ -1114,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
1114 break; 1109 break;
1115 default: 1110 default:
1116 if (fl_speed) p->speed = speed; 1111 if (fl_speed) p->speed = speed;
1117 else DBG("%c is not valid\n", c); 1112 else pr_debug("%c is not valid\n", c);
1118 break; 1113 break;
1119 } 1114 }
1120 1115
@@ -1159,12 +1154,12 @@ int __init rndis_init (void)
1159 &rndis_proc_fops, 1154 &rndis_proc_fops,
1160 (void *)(rndis_per_dev_params + i)))) 1155 (void *)(rndis_per_dev_params + i))))
1161 { 1156 {
1162 DBG("%s :remove entries", __func__); 1157 pr_debug("%s :remove entries", __func__);
1163 while (i) { 1158 while (i) {
1164 sprintf (name, NAME_TEMPLATE, --i); 1159 sprintf (name, NAME_TEMPLATE, --i);
1165 remove_proc_entry (name, NULL); 1160 remove_proc_entry (name, NULL);
1166 } 1161 }
1167 DBG("\n"); 1162 pr_debug("\n");
1168 return -EIO; 1163 return -EIO;
1169 } 1164 }
1170#endif 1165#endif
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index b3699afff002..3faa7a7022df 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -30,6 +30,24 @@
30 30
31/*-------------------------------------------------------------------------*/ 31/*-------------------------------------------------------------------------*/
32 32
33/*
34 * Kbuild is not very cooperative with respect to linking separately
35 * compiled library objects into one module. So for now we won't use
36 * separate compilation ... ensuring init/exit sections work to shrink
37 * the runtime footprint, and giving us at least some parts of what
38 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
39 */
40#include "composite.c"
41#include "usbstring.c"
42#include "config.c"
43#include "epautoconf.c"
44
45#include "f_acm.c"
46#include "f_serial.c"
47#include "u_serial.c"
48
49/*-------------------------------------------------------------------------*/
50
33/* Thanks to NetChip Technologies for donating this product ID. 51/* Thanks to NetChip Technologies for donating this product ID.
34* 52*
35* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 53* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 3791e6271903..dbd575a194f3 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -52,7 +52,7 @@
52 * this single "physical" link to be used by multiple virtual links.) 52 * this single "physical" link to be used by multiple virtual links.)
53 */ 53 */
54 54
55#define DRIVER_VERSION "29-May-2008" 55#define UETH__VERSION "29-May-2008"
56 56
57struct eth_dev { 57struct eth_dev {
58 /* lock is held while accessing port_usb 58 /* lock is held while accessing port_usb
@@ -170,7 +170,7 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)
170 struct eth_dev *dev = netdev_priv(net); 170 struct eth_dev *dev = netdev_priv(net);
171 171
172 strlcpy(p->driver, "g_ether", sizeof p->driver); 172 strlcpy(p->driver, "g_ether", sizeof p->driver);
173 strlcpy(p->version, DRIVER_VERSION, sizeof p->version); 173 strlcpy(p->version, UETH__VERSION, sizeof p->version);
174 strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version); 174 strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version);
175 strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info); 175 strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info);
176} 176}
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index aa0bd4f126a1..361d9659ac48 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -59,6 +59,23 @@
59 59
60/*-------------------------------------------------------------------------*/ 60/*-------------------------------------------------------------------------*/
61 61
62/*
63 * Kbuild is not very cooperative with respect to linking separately
64 * compiled library objects into one module. So for now we won't use
65 * separate compilation ... ensuring init/exit sections work to shrink
66 * the runtime footprint, and giving us at least some parts of what
67 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
68 */
69#include "composite.c"
70#include "usbstring.c"
71#include "config.c"
72#include "epautoconf.c"
73
74#include "f_sourcesink.c"
75#include "f_loopback.c"
76
77/*-------------------------------------------------------------------------*/
78
62#define DRIVER_VERSION "Cinco de Mayo 2008" 79#define DRIVER_VERSION "Cinco de Mayo 2008"
63 80
64static const char longname[] = "Gadget Zero"; 81static const char longname[] = "Gadget Zero";
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 95b3ec89c126..522185629624 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -344,7 +344,12 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
344 goto err1; 344 goto err1;
345 } 345 }
346 346
347 hcd->regs = (void __iomem *) (int) IO_ADDRESS(hcd->rsrc_start); 347 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
348 if (!hcd->regs) {
349 dev_err(&pdev->dev, "can't ioremap OHCI HCD\n");
350 retval = -ENOMEM;
351 goto err2;
352 }
348 353
349 ohci = hcd_to_ohci(hcd); 354 ohci = hcd_to_ohci(hcd);
350 ohci_hcd_init(ohci); 355 ohci_hcd_init(ohci);
@@ -355,11 +360,11 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
355 irq = platform_get_irq(pdev, 0); 360 irq = platform_get_irq(pdev, 0);
356 if (irq < 0) { 361 if (irq < 0) {
357 retval = -ENXIO; 362 retval = -ENXIO;
358 goto err2; 363 goto err3;
359 } 364 }
360 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); 365 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
361 if (retval) 366 if (retval)
362 goto err2; 367 goto err3;
363 368
364 host_initialized = 1; 369 host_initialized = 1;
365 370
@@ -367,6 +372,8 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
367 omap_ohci_clock_power(0); 372 omap_ohci_clock_power(0);
368 373
369 return 0; 374 return 0;
375err3:
376 iounmap(hcd->regs);
370err2: 377err2:
371 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 378 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
372err1: 379err1:
@@ -401,6 +408,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
401 } 408 }
402 if (machine_is_omap_osk()) 409 if (machine_is_omap_osk())
403 omap_free_gpio(9); 410 omap_free_gpio(9);
411 iounmap(hcd->regs);
404 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 412 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
405 usb_put_hcd(hcd); 413 usb_put_hcd(hcd);
406 clk_put(usb_dc_ck); 414 clk_put(usb_dc_ck);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index db645936eedd..1f0c2cf26e5d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -123,14 +123,10 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
123 123
124static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) 124static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
125{ 125{
126 if (!list_empty(&td->list)) { 126 if (!list_empty(&td->list))
127 dev_warn(uhci_dev(uhci), "td %p still in list!\n", td); 127 dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td);
128 WARN_ON(1); 128 if (!list_empty(&td->fl_list))
129 } 129 dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td);
130 if (!list_empty(&td->fl_list)) {
131 dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td);
132 WARN_ON(1);
133 }
134 130
135 dma_pool_free(uhci->td_pool, td, td->dma_handle); 131 dma_pool_free(uhci->td_pool, td, td->dma_handle);
136} 132}
@@ -295,10 +291,8 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
295static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) 291static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
296{ 292{
297 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); 293 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev);
298 if (!list_empty(&qh->queue)) { 294 if (!list_empty(&qh->queue))
299 dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh); 295 dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh);
300 WARN_ON(1);
301 }
302 296
303 list_del(&qh->node); 297 list_del(&qh->node);
304 if (qh->udev) { 298 if (qh->udev) {
@@ -746,11 +740,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci,
746{ 740{
747 struct uhci_td *td, *tmp; 741 struct uhci_td *td, *tmp;
748 742
749 if (!list_empty(&urbp->node)) { 743 if (!list_empty(&urbp->node))
750 dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n", 744 dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n",
751 urbp->urb); 745 urbp->urb);
752 WARN_ON(1);
753 }
754 746
755 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { 747 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
756 uhci_remove_td_from_urbp(td); 748 uhci_remove_td_from_urbp(td);
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 4cfa25b0f44e..cc8e0a926f99 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -595,9 +595,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
595 } while(value); 595 } while(value);
596 kit->dev_no = bit; 596 kit->dev_no = bit;
597 597
598 kit->dev = device_create_drvdata(phidget_class, &kit->udev->dev, 598 kit->dev = device_create(phidget_class, &kit->udev->dev, MKDEV(0, 0),
599 MKDEV(0, 0), kit, 599 kit, "interfacekit%d", kit->dev_no);
600 "interfacekit%d", kit->dev_no);
601 if (IS_ERR(kit->dev)) { 600 if (IS_ERR(kit->dev)) {
602 rc = PTR_ERR(kit->dev); 601 rc = PTR_ERR(kit->dev);
603 kit->dev = NULL; 602 kit->dev = NULL;
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 9b4696f21b22..38088b44349e 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -365,9 +365,8 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
365 } while(value); 365 } while(value);
366 mc->dev_no = bit; 366 mc->dev_no = bit;
367 367
368 mc->dev = device_create_drvdata(phidget_class, &mc->udev->dev, 368 mc->dev = device_create(phidget_class, &mc->udev->dev, MKDEV(0, 0), mc,
369 MKDEV(0, 0), mc, 369 "motorcontrol%d", mc->dev_no);
370 "motorcontrol%d", mc->dev_no);
371 if (IS_ERR(mc->dev)) { 370 if (IS_ERR(mc->dev)) {
372 rc = PTR_ERR(mc->dev); 371 rc = PTR_ERR(mc->dev);
373 mc->dev = NULL; 372 mc->dev = NULL;
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index 1ca7ddb41d4d..bef6fe16364b 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -275,9 +275,8 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
275 } while (value); 275 } while (value);
276 dev->dev_no = bit; 276 dev->dev_no = bit;
277 277
278 dev->dev = device_create_drvdata(phidget_class, &dev->udev->dev, 278 dev->dev = device_create(phidget_class, &dev->udev->dev, MKDEV(0, 0),
279 MKDEV(0, 0), dev, 279 dev, "servo%d", dev->dev_no);
280 "servo%d", dev->dev_no);
281 if (IS_ERR(dev->dev)) { 280 if (IS_ERR(dev->dev)) {
282 rc = PTR_ERR(dev->dev); 281 rc = PTR_ERR(dev->dev);
283 dev->dev = NULL; 282 dev->dev = NULL;
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 6566fc0a3228..c9de3f027aab 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1162,9 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus)
1162 if (minor >= MON_BIN_MAX_MINOR) 1162 if (minor >= MON_BIN_MAX_MINOR)
1163 return 0; 1163 return 0;
1164 1164
1165 dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL, 1165 dev = device_create(mon_bin_class, ubus ? ubus->controller : NULL,
1166 MKDEV(MAJOR(mon_bin_dev0), minor), NULL, 1166 MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
1167 "usbmon%d", minor); 1167 "usbmon%d", minor);
1168 if (IS_ERR(dev)) 1168 if (IS_ERR(dev))
1169 return 0; 1169 return 0;
1170 1170
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index f79c2040758b..0f13448c6f79 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -76,6 +76,14 @@ config FB_DDC
76 select I2C 76 select I2C
77 default n 77 default n
78 78
79config FB_BOOT_VESA_SUPPORT
80 bool
81 depends on FB
82 default n
83 ---help---
84 If true, at least one selected framebuffer driver can take advantage
85 of VESA video modes set at an early boot stage via the vga= parameter.
86
79config FB_CFB_FILLRECT 87config FB_CFB_FILLRECT
80 tristate 88 tristate
81 depends on FB 89 depends on FB
@@ -254,16 +262,24 @@ config FB_PM2
254 select FB_CFB_COPYAREA 262 select FB_CFB_COPYAREA
255 select FB_CFB_IMAGEBLIT 263 select FB_CFB_IMAGEBLIT
256 help 264 help
257 This is the frame buffer device driver for the Permedia2 AGP frame 265 This is the frame buffer device driver for cards based on
258 buffer card from ASK, aka `Graphic Blaster Exxtreme'. There is a 266 the 3D Labs Permedia, Permedia 2 and Permedia 2V chips.
259 product page at 267 The driver was tested on the following cards:
260 <http://www.ask.com.hk/product/Permedia%202/permedia2.htm>. 268 Diamond FireGL 1000 PRO AGP
269 ELSA Gloria Synergy PCI
270 Appian Jeronimo PRO (both heads) PCI
271 3DLabs Oxygen ACX aka EONtronics Picasso P2 PCI
272 Techsource Raptor GFX-8P (aka Sun PGX-32) on SPARC
273 ASK Graphic Blaster Exxtreme AGP
274
275 To compile this driver as a module, choose M here: the
276 module will be called pm2fb.
261 277
262config FB_PM2_FIFO_DISCONNECT 278config FB_PM2_FIFO_DISCONNECT
263 bool "enable FIFO disconnect feature" 279 bool "enable FIFO disconnect feature"
264 depends on FB_PM2 && PCI 280 depends on FB_PM2 && PCI
265 help 281 help
266 Support the Permedia2 FIFO disconnect feature (see CONFIG_FB_PM2). 282 Support the Permedia2 FIFO disconnect feature.
267 283
268config FB_ARMCLCD 284config FB_ARMCLCD
269 tristate "ARM PrimeCell PL110 support" 285 tristate "ARM PrimeCell PL110 support"
@@ -673,6 +689,7 @@ config FB_VESA
673 select FB_CFB_FILLRECT 689 select FB_CFB_FILLRECT
674 select FB_CFB_COPYAREA 690 select FB_CFB_COPYAREA
675 select FB_CFB_IMAGEBLIT 691 select FB_CFB_IMAGEBLIT
692 select FB_BOOT_VESA_SUPPORT
676 help 693 help
677 This is the frame buffer device driver for generic VESA 2.0 694 This is the frame buffer device driver for generic VESA 2.0
678 compliant graphic cards. The older VESA 1.2 cards are not supported. 695 compliant graphic cards. The older VESA 1.2 cards are not supported.
@@ -681,23 +698,14 @@ config FB_VESA
681 698
682config FB_EFI 699config FB_EFI
683 bool "EFI-based Framebuffer Support" 700 bool "EFI-based Framebuffer Support"
684 depends on (FB = y) && X86
685 select FB_CFB_FILLRECT
686 select FB_CFB_COPYAREA
687 select FB_CFB_IMAGEBLIT
688 help
689 This is the EFI frame buffer device driver. If the firmware on
690 your platform is UEFI2.0, select Y to add support for
691 Graphics Output Protocol for early console messages to appear.
692
693config FB_IMAC
694 bool "Intel-based Macintosh Framebuffer Support"
695 depends on (FB = y) && X86 && EFI 701 depends on (FB = y) && X86 && EFI
696 select FB_CFB_FILLRECT 702 select FB_CFB_FILLRECT
697 select FB_CFB_COPYAREA 703 select FB_CFB_COPYAREA
698 select FB_CFB_IMAGEBLIT 704 select FB_CFB_IMAGEBLIT
699 help 705 help
700 This is the frame buffer device driver for the Intel-based Macintosh 706 This is the EFI frame buffer device driver. If the firmware on
707 your platform is EFI 1.10 or UEFI 2.0, select Y to add support for
708 using the EFI framebuffer as your console.
701 709
702config FB_N411 710config FB_N411
703 tristate "N411 Apollo/Hecuba devkit support" 711 tristate "N411 Apollo/Hecuba devkit support"
@@ -1118,6 +1126,7 @@ config FB_INTEL
1118 select FB_CFB_FILLRECT 1126 select FB_CFB_FILLRECT
1119 select FB_CFB_COPYAREA 1127 select FB_CFB_COPYAREA
1120 select FB_CFB_IMAGEBLIT 1128 select FB_CFB_IMAGEBLIT
1129 select FB_BOOT_VESA_SUPPORT
1121 help 1130 help
1122 This driver supports the on-board graphics built in to the Intel 1131 This driver supports the on-board graphics built in to the Intel
1123 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM chipsets. 1132 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM chipsets.
@@ -1470,6 +1479,7 @@ config FB_SIS
1470 select FB_CFB_FILLRECT 1479 select FB_CFB_FILLRECT
1471 select FB_CFB_COPYAREA 1480 select FB_CFB_COPYAREA
1472 select FB_CFB_IMAGEBLIT 1481 select FB_CFB_IMAGEBLIT
1482 select FB_BOOT_VESA_SUPPORT
1473 help 1483 help
1474 This is the frame buffer device driver for the SiS 300, 315, 330 1484 This is the frame buffer device driver for the SiS 300, 315, 330
1475 and 340 series as well as XGI V3XT, V5, V8, Z7 graphics chipsets. 1485 and 340 series as well as XGI V3XT, V5, V8, Z7 graphics chipsets.
@@ -1492,6 +1502,24 @@ config FB_SIS_315
1492 (315/H/PRO, 55x, 650, 651, 740, 330, 661, 741, 760, 761) as well 1502 (315/H/PRO, 55x, 650, 651, 740, 330, 661, 741, 760, 761) as well
1493 as XGI V3XT, V5, V8 and Z7. 1503 as XGI V3XT, V5, V8 and Z7.
1494 1504
1505config FB_VIA
1506 tristate "VIA UniChrome (Pro) and Chrome9 display support"
1507 depends on FB && PCI
1508 select FB_CFB_FILLRECT
1509 select FB_CFB_COPYAREA
1510 select FB_CFB_IMAGEBLIT
1511 select FB_SOFT_CURSOR
1512 select I2C_ALGOBIT
1513 select I2C
1514 help
1515 This is the frame buffer device driver for Graphics chips of VIA
1516 UniChrome (Pro) Family (CLE266,PM800/CN400,P4M800CE/P4M800Pro/
1517 CN700/VN800,CX700/VX700,P4M890) and Chrome9 Family (K8M890,CN896
1518 /P4M900,VX800)
1519 Say Y if you have a VIA UniChrome graphics board.
1520
1521 To compile this driver as a module, choose M here: the
1522 module will be called viafb.
1495config FB_NEOMAGIC 1523config FB_NEOMAGIC
1496 tristate "NeoMagic display support" 1524 tristate "NeoMagic display support"
1497 depends on FB && PCI 1525 depends on FB && PCI
@@ -1521,25 +1549,25 @@ config FB_KYRO
1521 module will be called kyrofb. 1549 module will be called kyrofb.
1522 1550
1523config FB_3DFX 1551config FB_3DFX
1524 tristate "3Dfx Banshee/Voodoo3 display support" 1552 tristate "3Dfx Banshee/Voodoo3/Voodoo5 display support"
1525 depends on FB && PCI 1553 depends on FB && PCI
1526 select FB_CFB_IMAGEBLIT 1554 select FB_CFB_IMAGEBLIT
1527 select FB_CFB_FILLRECT 1555 select FB_CFB_FILLRECT
1528 select FB_CFB_COPYAREA 1556 select FB_CFB_COPYAREA
1529 help 1557 help
1530 This driver supports graphics boards with the 3Dfx Banshee/Voodoo3 1558 This driver supports graphics boards with the 3Dfx Banshee,
1531 chips. Say Y if you have such a graphics board. 1559 Voodoo3 or VSA-100 (aka Voodoo4/5) chips. Say Y if you have
1560 such a graphics board.
1532 1561
1533 To compile this driver as a module, choose M here: the 1562 To compile this driver as a module, choose M here: the
1534 module will be called tdfxfb. 1563 module will be called tdfxfb.
1535 1564
1536config FB_3DFX_ACCEL 1565config FB_3DFX_ACCEL
1537 bool "3Dfx Banshee/Voodoo3 Acceleration functions (EXPERIMENTAL)" 1566 bool "3Dfx Acceleration functions (EXPERIMENTAL)"
1538 depends on FB_3DFX && EXPERIMENTAL 1567 depends on FB_3DFX && EXPERIMENTAL
1539 ---help--- 1568 ---help---
1540 This will compile the 3Dfx Banshee/Voodoo3 frame buffer device 1569 This will compile the 3Dfx Banshee/Voodoo3/VSA-100 frame buffer
1541 with acceleration functions. 1570 device driver with acceleration functions.
1542
1543 1571
1544config FB_VOODOO1 1572config FB_VOODOO1
1545 tristate "3Dfx Voodoo Graphics (sst1) support" 1573 tristate "3Dfx Voodoo Graphics (sst1) support"
@@ -1604,17 +1632,16 @@ config FB_TRIDENT
1604 select FB_CFB_COPYAREA 1632 select FB_CFB_COPYAREA
1605 select FB_CFB_IMAGEBLIT 1633 select FB_CFB_IMAGEBLIT
1606 ---help--- 1634 ---help---
1607 This driver is supposed to support graphics boards with the 1635 This is the frame buffer device driver for Trident PCI/AGP chipsets.
1608 Trident CyberXXXX/Image/CyberBlade chips mostly found in laptops 1636 Supported chipset families are TGUI 9440/96XX, 3DImage, Blade3D
1637 and Blade XP.
1638 There are also integrated versions of these chips called CyberXXXX,
1639 CyberImage or CyberBlade. These chips are mostly found in laptops
1609 but also on some motherboards. For more information, read 1640 but also on some motherboards. For more information, read
1610 <file:Documentation/fb/tridentfb.txt> 1641 <file:Documentation/fb/tridentfb.txt>
1611 1642
1612 Cyberblade/i1 support will be removed soon, use the cyblafb driver
1613 instead.
1614
1615 Say Y if you have such a graphics board. 1643 Say Y if you have such a graphics board.
1616 1644
1617
1618 To compile this driver as a module, choose M here: the 1645 To compile this driver as a module, choose M here: the
1619 module will be called tridentfb. 1646 module will be called tridentfb.
1620 1647
@@ -1869,6 +1896,28 @@ config FB_SH_MOBILE_LCDC
1869 ---help--- 1896 ---help---
1870 Frame buffer driver for the on-chip SH-Mobile LCD controller. 1897 Frame buffer driver for the on-chip SH-Mobile LCD controller.
1871 1898
1899config FB_TMIO
1900 tristate "Toshiba Mobile IO FrameBuffer support"
1901 depends on FB && MFD_CORE
1902 select FB_CFB_FILLRECT
1903 select FB_CFB_COPYAREA
1904 select FB_CFB_IMAGEBLIT
1905 ---help---
1906 Frame buffer driver for the Toshiba Mobile IO integrated as found
1907 on the Sharp SL-6000 series
1908
1909 This driver is also available as a module ( = code which can be
1910 inserted and removed from the running kernel whenever you want). The
1911 module will be called tmiofb. If you want to compile it as a module,
1912 say M here and read <file:Documentation/kbuild/modules.txt>.
1913
1914 If unsure, say N.
1915
1916config FB_TMIO_ACCELL
1917 bool "tmiofb acceleration"
1918 depends on FB_TMIO
1919 default y
1920
1872config FB_S3C2410 1921config FB_S3C2410
1873 tristate "S3C2410 LCD framebuffer support" 1922 tristate "S3C2410 LCD framebuffer support"
1874 depends on FB && ARCH_S3C2410 1923 depends on FB && ARCH_S3C2410
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index ad0330bf9be3..248bddc8d0b0 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_FB_ATY) += aty/ macmodes.o
42obj-$(CONFIG_FB_ATY128) += aty/ macmodes.o 42obj-$(CONFIG_FB_ATY128) += aty/ macmodes.o
43obj-$(CONFIG_FB_RADEON) += aty/ 43obj-$(CONFIG_FB_RADEON) += aty/
44obj-$(CONFIG_FB_SIS) += sis/ 44obj-$(CONFIG_FB_SIS) += sis/
45obj-$(CONFIG_FB_VIA) += via/
45obj-$(CONFIG_FB_KYRO) += kyro/ 46obj-$(CONFIG_FB_KYRO) += kyro/
46obj-$(CONFIG_FB_SAVAGE) += savage/ 47obj-$(CONFIG_FB_SAVAGE) += savage/
47obj-$(CONFIG_FB_GEODE) += geode/ 48obj-$(CONFIG_FB_GEODE) += geode/
@@ -97,6 +98,7 @@ obj-$(CONFIG_FB_CIRRUS) += cirrusfb.o
97obj-$(CONFIG_FB_ASILIANT) += asiliantfb.o 98obj-$(CONFIG_FB_ASILIANT) += asiliantfb.o
98obj-$(CONFIG_FB_PXA) += pxafb.o 99obj-$(CONFIG_FB_PXA) += pxafb.o
99obj-$(CONFIG_FB_W100) += w100fb.o 100obj-$(CONFIG_FB_W100) += w100fb.o
101obj-$(CONFIG_FB_TMIO) += tmiofb.o
100obj-$(CONFIG_FB_AU1100) += au1100fb.o 102obj-$(CONFIG_FB_AU1100) += au1100fb.o
101obj-$(CONFIG_FB_AU1200) += au1200fb.o 103obj-$(CONFIG_FB_AU1200) += au1200fb.o
102obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o 104obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o
@@ -124,7 +126,6 @@ obj-$(CONFIG_FB_CARMINE) += carminefb.o
124# Platform or fallback drivers go here 126# Platform or fallback drivers go here
125obj-$(CONFIG_FB_UVESA) += uvesafb.o 127obj-$(CONFIG_FB_UVESA) += uvesafb.o
126obj-$(CONFIG_FB_VESA) += vesafb.o 128obj-$(CONFIG_FB_VESA) += vesafb.o
127obj-$(CONFIG_FB_IMAC) += imacfb.o
128obj-$(CONFIG_FB_EFI) += efifb.o 129obj-$(CONFIG_FB_EFI) += efifb.o
129obj-$(CONFIG_FB_VGA16) += vga16fb.o 130obj-$(CONFIG_FB_VGA16) += vga16fb.o
130obj-$(CONFIG_FB_OF) += offb.o 131obj-$(CONFIG_FB_OF) += offb.o
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index d38fd5217422..f8d0a57a07cb 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -372,6 +372,13 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
372 var->transp.offset = var->transp.length = 0; 372 var->transp.offset = var->transp.length = 0;
373 var->xoffset = var->yoffset = 0; 373 var->xoffset = var->yoffset = 0;
374 374
375 if (info->fix.smem_len) {
376 unsigned int smem_len = (var->xres_virtual * var->yres_virtual
377 * ((var->bits_per_pixel + 7) / 8));
378 if (smem_len > info->fix.smem_len)
379 return -EINVAL;
380 }
381
375 /* Saturate vertical and horizontal timings at maximum values */ 382 /* Saturate vertical and horizontal timings at maximum values */
376 var->vsync_len = min_t(u32, var->vsync_len, 383 var->vsync_len = min_t(u32, var->vsync_len,
377 (ATMEL_LCDC_VPW >> ATMEL_LCDC_VPW_OFFSET) + 1); 384 (ATMEL_LCDC_VPW >> ATMEL_LCDC_VPW_OFFSET) + 1);
diff --git a/drivers/video/aty/radeon_accel.c b/drivers/video/aty/radeon_accel.c
index aa95f8350242..8718f7349d6b 100644
--- a/drivers/video/aty/radeon_accel.c
+++ b/drivers/video/aty/radeon_accel.c
@@ -5,61 +5,61 @@
5 * --dte 5 * --dte
6 */ 6 */
7 7
8static void radeon_fixup_offset(struct radeonfb_info *rinfo) 8#define FLUSH_CACHE_WORKAROUND 1
9
10void radeon_fifo_update_and_wait(struct radeonfb_info *rinfo, int entries)
9{ 11{
10 u32 local_base; 12 int i;
11
12 /* *** Ugly workaround *** */
13 /*
14 * On some platforms, the video memory is mapped at 0 in radeon chip space
15 * (like PPCs) by the firmware. X will always move it up so that it's seen
16 * by the chip to be at the same address as the PCI BAR.
17 * That means that when switching back from X, there is a mismatch between
18 * the offsets programmed into the engine. This means that potentially,
19 * accel operations done before radeonfb has a chance to re-init the engine
20 * will have incorrect offsets, and potentially trash system memory !
21 *
22 * The correct fix is for fbcon to never call any accel op before the engine
23 * has properly been re-initialized (by a call to set_var), but this is a
24 * complex fix. This workaround in the meantime, called before every accel
25 * operation, makes sure the offsets are in sync.
26 */
27 13
28 radeon_fifo_wait (1); 14 for (i=0; i<2000000; i++) {
29 local_base = INREG(MC_FB_LOCATION) << 16; 15 rinfo->fifo_free = INREG(RBBM_STATUS) & 0x7f;
30 if (local_base == rinfo->fb_local_base) 16 if (rinfo->fifo_free >= entries)
31 return; 17 return;
18 udelay(10);
19 }
20 printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
21 /* XXX Todo: attempt to reset the engine */
22}
32 23
33 rinfo->fb_local_base = local_base; 24static inline void radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
25{
26 if (entries <= rinfo->fifo_free)
27 rinfo->fifo_free -= entries;
28 else
29 radeon_fifo_update_and_wait(rinfo, entries);
30}
34 31
35 radeon_fifo_wait (3); 32static inline void radeonfb_set_creg(struct radeonfb_info *rinfo, u32 reg,
36 OUTREG(DEFAULT_PITCH_OFFSET, (rinfo->pitch << 0x16) | 33 u32 *cache, u32 new_val)
37 (rinfo->fb_local_base >> 10)); 34{
38 OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10)); 35 if (new_val == *cache)
39 OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10)); 36 return;
37 *cache = new_val;
38 radeon_fifo_wait(rinfo, 1);
39 OUTREG(reg, new_val);
40} 40}
41 41
42static void radeonfb_prim_fillrect(struct radeonfb_info *rinfo, 42static void radeonfb_prim_fillrect(struct radeonfb_info *rinfo,
43 const struct fb_fillrect *region) 43 const struct fb_fillrect *region)
44{ 44{
45 radeon_fifo_wait(4); 45 radeonfb_set_creg(rinfo, DP_GUI_MASTER_CNTL, &rinfo->dp_gui_mc_cache,
46 46 rinfo->dp_gui_mc_base | GMC_BRUSH_SOLID_COLOR | ROP3_P);
47 OUTREG(DP_GUI_MASTER_CNTL, 47 radeonfb_set_creg(rinfo, DP_CNTL, &rinfo->dp_cntl_cache,
48 rinfo->dp_gui_master_cntl /* contains, like GMC_DST_32BPP */ 48 DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM);
49 | GMC_BRUSH_SOLID_COLOR 49 radeonfb_set_creg(rinfo, DP_BRUSH_FRGD_CLR, &rinfo->dp_brush_fg_cache,
50 | ROP3_P); 50 region->color);
51 if (radeon_get_dstbpp(rinfo->depth) != DST_8BPP) 51
52 OUTREG(DP_BRUSH_FRGD_CLR, rinfo->pseudo_palette[region->color]); 52 /* Ensure the dst cache is flushed and the engine idle before
53 else 53 * issuing the operation.
54 OUTREG(DP_BRUSH_FRGD_CLR, region->color); 54 *
55 OUTREG(DP_WRITE_MSK, 0xffffffff); 55 * This works around engine lockups on some cards
56 OUTREG(DP_CNTL, (DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM)); 56 */
57 57#if FLUSH_CACHE_WORKAROUND
58 radeon_fifo_wait(2); 58 radeon_fifo_wait(rinfo, 2);
59 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL); 59 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
60 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE)); 60 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
61 61#endif
62 radeon_fifo_wait(2); 62 radeon_fifo_wait(rinfo, 2);
63 OUTREG(DST_Y_X, (region->dy << 16) | region->dx); 63 OUTREG(DST_Y_X, (region->dy << 16) | region->dx);
64 OUTREG(DST_WIDTH_HEIGHT, (region->width << 16) | region->height); 64 OUTREG(DST_WIDTH_HEIGHT, (region->width << 16) | region->height);
65} 65}
@@ -70,15 +70,14 @@ void radeonfb_fillrect(struct fb_info *info, const struct fb_fillrect *region)
70 struct fb_fillrect modded; 70 struct fb_fillrect modded;
71 int vxres, vyres; 71 int vxres, vyres;
72 72
73 if (info->state != FBINFO_STATE_RUNNING) 73 WARN_ON(rinfo->gfx_mode);
74 if (info->state != FBINFO_STATE_RUNNING || rinfo->gfx_mode)
74 return; 75 return;
75 if (info->flags & FBINFO_HWACCEL_DISABLED) { 76 if (info->flags & FBINFO_HWACCEL_DISABLED) {
76 cfb_fillrect(info, region); 77 cfb_fillrect(info, region);
77 return; 78 return;
78 } 79 }
79 80
80 radeon_fixup_offset(rinfo);
81
82 vxres = info->var.xres_virtual; 81 vxres = info->var.xres_virtual;
83 vyres = info->var.yres_virtual; 82 vyres = info->var.yres_virtual;
84 83
@@ -91,6 +90,10 @@ void radeonfb_fillrect(struct fb_info *info, const struct fb_fillrect *region)
91 if(modded.dx + modded.width > vxres) modded.width = vxres - modded.dx; 90 if(modded.dx + modded.width > vxres) modded.width = vxres - modded.dx;
92 if(modded.dy + modded.height > vyres) modded.height = vyres - modded.dy; 91 if(modded.dy + modded.height > vyres) modded.height = vyres - modded.dy;
93 92
93 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
94 info->fix.visual == FB_VISUAL_DIRECTCOLOR )
95 modded.color = ((u32 *) (info->pseudo_palette))[region->color];
96
94 radeonfb_prim_fillrect(rinfo, &modded); 97 radeonfb_prim_fillrect(rinfo, &modded);
95} 98}
96 99
@@ -109,22 +112,22 @@ static void radeonfb_prim_copyarea(struct radeonfb_info *rinfo,
109 if ( xdir < 0 ) { sx += w-1; dx += w-1; } 112 if ( xdir < 0 ) { sx += w-1; dx += w-1; }
110 if ( ydir < 0 ) { sy += h-1; dy += h-1; } 113 if ( ydir < 0 ) { sy += h-1; dy += h-1; }
111 114
112 radeon_fifo_wait(3); 115 radeonfb_set_creg(rinfo, DP_GUI_MASTER_CNTL, &rinfo->dp_gui_mc_cache,
113 OUTREG(DP_GUI_MASTER_CNTL, 116 rinfo->dp_gui_mc_base |
114 rinfo->dp_gui_master_cntl /* i.e. GMC_DST_32BPP */ 117 GMC_BRUSH_NONE |
115 | GMC_BRUSH_NONE 118 GMC_SRC_DATATYPE_COLOR |
116 | GMC_SRC_DSTCOLOR 119 ROP3_S |
117 | ROP3_S 120 DP_SRC_SOURCE_MEMORY);
118 | DP_SRC_SOURCE_MEMORY ); 121 radeonfb_set_creg(rinfo, DP_CNTL, &rinfo->dp_cntl_cache,
119 OUTREG(DP_WRITE_MSK, 0xffffffff); 122 (xdir>=0 ? DST_X_LEFT_TO_RIGHT : 0) |
120 OUTREG(DP_CNTL, (xdir>=0 ? DST_X_LEFT_TO_RIGHT : 0) 123 (ydir>=0 ? DST_Y_TOP_TO_BOTTOM : 0));
121 | (ydir>=0 ? DST_Y_TOP_TO_BOTTOM : 0)); 124
122 125#if FLUSH_CACHE_WORKAROUND
123 radeon_fifo_wait(2); 126 radeon_fifo_wait(rinfo, 2);
124 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL); 127 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
125 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE)); 128 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
126 129#endif
127 radeon_fifo_wait(3); 130 radeon_fifo_wait(rinfo, 3);
128 OUTREG(SRC_Y_X, (sy << 16) | sx); 131 OUTREG(SRC_Y_X, (sy << 16) | sx);
129 OUTREG(DST_Y_X, (dy << 16) | dx); 132 OUTREG(DST_Y_X, (dy << 16) | dx);
130 OUTREG(DST_HEIGHT_WIDTH, (h << 16) | w); 133 OUTREG(DST_HEIGHT_WIDTH, (h << 16) | w);
@@ -143,15 +146,14 @@ void radeonfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
143 modded.width = area->width; 146 modded.width = area->width;
144 modded.height = area->height; 147 modded.height = area->height;
145 148
146 if (info->state != FBINFO_STATE_RUNNING) 149 WARN_ON(rinfo->gfx_mode);
150 if (info->state != FBINFO_STATE_RUNNING || rinfo->gfx_mode)
147 return; 151 return;
148 if (info->flags & FBINFO_HWACCEL_DISABLED) { 152 if (info->flags & FBINFO_HWACCEL_DISABLED) {
149 cfb_copyarea(info, area); 153 cfb_copyarea(info, area);
150 return; 154 return;
151 } 155 }
152 156
153 radeon_fixup_offset(rinfo);
154
155 vxres = info->var.xres_virtual; 157 vxres = info->var.xres_virtual;
156 vyres = info->var.yres_virtual; 158 vyres = info->var.yres_virtual;
157 159
@@ -168,13 +170,112 @@ void radeonfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
168 radeonfb_prim_copyarea(rinfo, &modded); 170 radeonfb_prim_copyarea(rinfo, &modded);
169} 171}
170 172
173static void radeonfb_prim_imageblit(struct radeonfb_info *rinfo,
174 const struct fb_image *image,
175 u32 fg, u32 bg)
176{
177 unsigned int src_bytes, dwords;
178 u32 *bits;
179
180 radeonfb_set_creg(rinfo, DP_GUI_MASTER_CNTL, &rinfo->dp_gui_mc_cache,
181 rinfo->dp_gui_mc_base |
182 GMC_BRUSH_NONE |
183 GMC_SRC_DATATYPE_MONO_FG_BG |
184 ROP3_S |
185 GMC_BYTE_ORDER_MSB_TO_LSB |
186 DP_SRC_SOURCE_HOST_DATA);
187 radeonfb_set_creg(rinfo, DP_CNTL, &rinfo->dp_cntl_cache,
188 DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM);
189 radeonfb_set_creg(rinfo, DP_SRC_FRGD_CLR, &rinfo->dp_src_fg_cache, fg);
190 radeonfb_set_creg(rinfo, DP_SRC_BKGD_CLR, &rinfo->dp_src_bg_cache, bg);
191
192 radeon_fifo_wait(rinfo, 1);
193 OUTREG(DST_Y_X, (image->dy << 16) | image->dx);
194
195 /* Ensure the dst cache is flushed and the engine idle before
196 * issuing the operation.
197 *
198 * This works around engine lockups on some cards
199 */
200#if FLUSH_CACHE_WORKAROUND
201 radeon_fifo_wait(rinfo, 2);
202 OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
203 OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
204#endif
205
206 /* X here pads width to a multiple of 32 and uses the clipper to
207 * adjust the result. Is that really necessary ? Things seem to
208 * work ok for me without that and the doco doesn't seem to imply
209 * there is such a restriction.
210 */
211 OUTREG(DST_WIDTH_HEIGHT, (image->width << 16) | image->height);
212
213 src_bytes = (((image->width * image->depth) + 7) / 8) * image->height;
214 dwords = (src_bytes + 3) / 4;
215 bits = (u32*)(image->data);
216
217 while(dwords >= 8) {
218 radeon_fifo_wait(rinfo, 8);
219#if BITS_PER_LONG == 64
220 __raw_writeq(*((u64 *)(bits)), rinfo->mmio_base + HOST_DATA0);
221 __raw_writeq(*((u64 *)(bits+2)), rinfo->mmio_base + HOST_DATA2);
222 __raw_writeq(*((u64 *)(bits+4)), rinfo->mmio_base + HOST_DATA4);
223 __raw_writeq(*((u64 *)(bits+6)), rinfo->mmio_base + HOST_DATA6);
224 bits += 8;
225#else
226 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA0);
227 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA1);
228 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA2);
229 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA3);
230 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA4);
231 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA5);
232 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA6);
233 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA7);
234#endif
235 dwords -= 8;
236 }
237 while(dwords--) {
238 radeon_fifo_wait(rinfo, 1);
239 __raw_writel(*(bits++), rinfo->mmio_base + HOST_DATA0);
240 }
241}
242
171void radeonfb_imageblit(struct fb_info *info, const struct fb_image *image) 243void radeonfb_imageblit(struct fb_info *info, const struct fb_image *image)
172{ 244{
173 struct radeonfb_info *rinfo = info->par; 245 struct radeonfb_info *rinfo = info->par;
246 u32 fg, bg;
174 247
175 if (info->state != FBINFO_STATE_RUNNING) 248 WARN_ON(rinfo->gfx_mode);
249 if (info->state != FBINFO_STATE_RUNNING || rinfo->gfx_mode)
250 return;
251
252 if (!image->width || !image->height)
176 return; 253 return;
177 radeon_engine_idle(); 254
255 /* We only do 1 bpp color expansion for now */
256 if (info->flags & FBINFO_HWACCEL_DISABLED || image->depth != 1)
257 goto fallback;
258
259 /* Fallback if running out of the screen. We may do clipping
260 * in the future */
261 if ((image->dx + image->width) > info->var.xres_virtual ||
262 (image->dy + image->height) > info->var.yres_virtual)
263 goto fallback;
264
265 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
266 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
267 fg = ((u32*)(info->pseudo_palette))[image->fg_color];
268 bg = ((u32*)(info->pseudo_palette))[image->bg_color];
269 } else {
270 fg = image->fg_color;
271 bg = image->bg_color;
272 }
273
274 radeonfb_prim_imageblit(rinfo, image, fg, bg);
275 return;
276
277 fallback:
278 radeon_engine_idle(rinfo);
178 279
179 cfb_imageblit(info, image); 280 cfb_imageblit(info, image);
180} 281}
@@ -185,7 +286,8 @@ int radeonfb_sync(struct fb_info *info)
185 286
186 if (info->state != FBINFO_STATE_RUNNING) 287 if (info->state != FBINFO_STATE_RUNNING)
187 return 0; 288 return 0;
188 radeon_engine_idle(); 289
290 radeon_engine_idle(rinfo);
189 291
190 return 0; 292 return 0;
191} 293}
@@ -211,9 +313,7 @@ void radeonfb_engine_reset(struct radeonfb_info *rinfo)
211 host_path_cntl = INREG(HOST_PATH_CNTL); 313 host_path_cntl = INREG(HOST_PATH_CNTL);
212 rbbm_soft_reset = INREG(RBBM_SOFT_RESET); 314 rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
213 315
214 if (rinfo->family == CHIP_FAMILY_R300 || 316 if (IS_R300_VARIANT(rinfo)) {
215 rinfo->family == CHIP_FAMILY_R350 ||
216 rinfo->family == CHIP_FAMILY_RV350) {
217 u32 tmp; 317 u32 tmp;
218 318
219 OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset | 319 OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
@@ -249,9 +349,7 @@ void radeonfb_engine_reset(struct radeonfb_info *rinfo)
249 INREG(HOST_PATH_CNTL); 349 INREG(HOST_PATH_CNTL);
250 OUTREG(HOST_PATH_CNTL, host_path_cntl); 350 OUTREG(HOST_PATH_CNTL, host_path_cntl);
251 351
252 if (rinfo->family != CHIP_FAMILY_R300 && 352 if (!IS_R300_VARIANT(rinfo))
253 rinfo->family != CHIP_FAMILY_R350 &&
254 rinfo->family != CHIP_FAMILY_RV350)
255 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset); 353 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
256 354
257 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index); 355 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
@@ -265,15 +363,24 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
265 /* disable 3D engine */ 363 /* disable 3D engine */
266 OUTREG(RB3D_CNTL, 0); 364 OUTREG(RB3D_CNTL, 0);
267 365
366 rinfo->fifo_free = 0;
268 radeonfb_engine_reset(rinfo); 367 radeonfb_engine_reset(rinfo);
269 368
270 radeon_fifo_wait (1); 369 radeon_fifo_wait(rinfo, 1);
271 if ((rinfo->family != CHIP_FAMILY_R300) && 370 if (IS_R300_VARIANT(rinfo)) {
272 (rinfo->family != CHIP_FAMILY_R350) && 371 OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) |
273 (rinfo->family != CHIP_FAMILY_RV350)) 372 RB2D_DC_AUTOFLUSH_ENABLE |
373 RB2D_DC_DC_DISABLE_IGNORE_PE);
374 } else {
375 /* This needs to be double checked with ATI. Latest X driver
376 * completely "forgets" to set this register on < r3xx, and
377 * we used to just write 0 there... I'll keep the 0 and update
378 * that when we have sorted things out on X side.
379 */
274 OUTREG(RB2D_DSTCACHE_MODE, 0); 380 OUTREG(RB2D_DSTCACHE_MODE, 0);
381 }
275 382
276 radeon_fifo_wait (3); 383 radeon_fifo_wait(rinfo, 3);
277 /* We re-read MC_FB_LOCATION from card as it can have been 384 /* We re-read MC_FB_LOCATION from card as it can have been
278 * modified by XFree drivers (ouch !) 385 * modified by XFree drivers (ouch !)
279 */ 386 */
@@ -284,41 +391,57 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
284 OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10)); 391 OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
285 OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10)); 392 OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
286 393
287 radeon_fifo_wait (1); 394 radeon_fifo_wait(rinfo, 1);
288#if defined(__BIG_ENDIAN) 395#ifdef __BIG_ENDIAN
289 OUTREGP(DP_DATATYPE, HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN); 396 OUTREGP(DP_DATATYPE, HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN);
290#else 397#else
291 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN); 398 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN);
292#endif 399#endif
293 radeon_fifo_wait (2); 400 radeon_fifo_wait(rinfo, 2);
294 OUTREG(DEFAULT_SC_TOP_LEFT, 0); 401 OUTREG(DEFAULT_SC_TOP_LEFT, 0);
295 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX | 402 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX |
296 DEFAULT_SC_BOTTOM_MAX)); 403 DEFAULT_SC_BOTTOM_MAX));
297 404
405 /* set default DP_GUI_MASTER_CNTL */
298 temp = radeon_get_dstbpp(rinfo->depth); 406 temp = radeon_get_dstbpp(rinfo->depth);
299 rinfo->dp_gui_master_cntl = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS); 407 rinfo->dp_gui_mc_base = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS);
300 408
301 radeon_fifo_wait (1); 409 rinfo->dp_gui_mc_cache = rinfo->dp_gui_mc_base |
302 OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl | 410 GMC_BRUSH_SOLID_COLOR |
303 GMC_BRUSH_SOLID_COLOR | 411 GMC_SRC_DATATYPE_COLOR;
304 GMC_SRC_DATATYPE_COLOR)); 412 radeon_fifo_wait(rinfo, 1);
413 OUTREG(DP_GUI_MASTER_CNTL, rinfo->dp_gui_mc_cache);
305 414
306 radeon_fifo_wait (7);
307 415
308 /* clear line drawing regs */ 416 /* clear line drawing regs */
417 radeon_fifo_wait(rinfo, 2);
309 OUTREG(DST_LINE_START, 0); 418 OUTREG(DST_LINE_START, 0);
310 OUTREG(DST_LINE_END, 0); 419 OUTREG(DST_LINE_END, 0);
311 420
312 /* set brush color regs */ 421 /* set brush and source color regs */
313 OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff); 422 rinfo->dp_brush_fg_cache = 0xffffffff;
314 OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000); 423 rinfo->dp_brush_bg_cache = 0x00000000;
315 424 rinfo->dp_src_fg_cache = 0xffffffff;
316 /* set source color regs */ 425 rinfo->dp_src_bg_cache = 0x00000000;
317 OUTREG(DP_SRC_FRGD_CLR, 0xffffffff); 426 radeon_fifo_wait(rinfo, 4);
318 OUTREG(DP_SRC_BKGD_CLR, 0x00000000); 427 OUTREG(DP_BRUSH_FRGD_CLR, rinfo->dp_brush_fg_cache);
428 OUTREG(DP_BRUSH_BKGD_CLR, rinfo->dp_brush_bg_cache);
429 OUTREG(DP_SRC_FRGD_CLR, rinfo->dp_src_fg_cache);
430 OUTREG(DP_SRC_BKGD_CLR, rinfo->dp_src_bg_cache);
431
432 /* Default direction */
433 rinfo->dp_cntl_cache = DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM;
434 radeon_fifo_wait(rinfo, 1);
435 OUTREG(DP_CNTL, rinfo->dp_cntl_cache);
319 436
320 /* default write mask */ 437 /* default write mask */
438 radeon_fifo_wait(rinfo, 1);
321 OUTREG(DP_WRITE_MSK, 0xffffffff); 439 OUTREG(DP_WRITE_MSK, 0xffffffff);
322 440
323 radeon_engine_idle (); 441 /* Default to no swapping of host data */
442 radeon_fifo_wait(rinfo, 1);
443 OUTREG(RBBM_GUICNTL, RBBM_GUICNTL_HOST_DATA_SWAP_NONE);
444
445 /* Make sure it's settled */
446 radeon_engine_idle(rinfo);
324} 447}
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index 1a056adb61c8..f343ba83f0ae 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -66,7 +66,7 @@ static int radeon_bl_update_status(struct backlight_device *bd)
66 level = bd->props.brightness; 66 level = bd->props.brightness;
67 67
68 del_timer_sync(&rinfo->lvds_timer); 68 del_timer_sync(&rinfo->lvds_timer);
69 radeon_engine_idle(); 69 radeon_engine_idle(rinfo);
70 70
71 lvds_gen_cntl = INREG(LVDS_GEN_CNTL); 71 lvds_gen_cntl = INREG(LVDS_GEN_CNTL);
72 if (level > 0) { 72 if (level > 0) {
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 652273e9f5f9..9a5821c65ebf 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -852,7 +852,6 @@ static int radeonfb_pan_display (struct fb_var_screeninfo *var,
852 if (rinfo->asleep) 852 if (rinfo->asleep)
853 return 0; 853 return 0;
854 854
855 radeon_fifo_wait(2);
856 OUTREG(CRTC_OFFSET, ((var->yoffset * var->xres_virtual + var->xoffset) 855 OUTREG(CRTC_OFFSET, ((var->yoffset * var->xres_virtual + var->xoffset)
857 * var->bits_per_pixel / 8) & ~7); 856 * var->bits_per_pixel / 8) & ~7);
858 return 0; 857 return 0;
@@ -882,7 +881,6 @@ static int radeonfb_ioctl (struct fb_info *info, unsigned int cmd,
882 if (rc) 881 if (rc)
883 return rc; 882 return rc;
884 883
885 radeon_fifo_wait(2);
886 if (value & 0x01) { 884 if (value & 0x01) {
887 tmp = INREG(LVDS_GEN_CNTL); 885 tmp = INREG(LVDS_GEN_CNTL);
888 886
@@ -940,7 +938,7 @@ int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch)
940 if (rinfo->lock_blank) 938 if (rinfo->lock_blank)
941 return 0; 939 return 0;
942 940
943 radeon_engine_idle(); 941 radeon_engine_idle(rinfo);
944 942
945 val = INREG(CRTC_EXT_CNTL); 943 val = INREG(CRTC_EXT_CNTL);
946 val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | 944 val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS |
@@ -1048,7 +1046,7 @@ static int radeonfb_blank (int blank, struct fb_info *info)
1048 1046
1049 if (rinfo->asleep) 1047 if (rinfo->asleep)
1050 return 0; 1048 return 0;
1051 1049
1052 return radeon_screen_blank(rinfo, blank, 0); 1050 return radeon_screen_blank(rinfo, blank, 0);
1053} 1051}
1054 1052
@@ -1074,8 +1072,6 @@ static int radeon_setcolreg (unsigned regno, unsigned red, unsigned green,
1074 pindex = regno; 1072 pindex = regno;
1075 1073
1076 if (!rinfo->asleep) { 1074 if (!rinfo->asleep) {
1077 radeon_fifo_wait(9);
1078
1079 if (rinfo->bpp == 16) { 1075 if (rinfo->bpp == 16) {
1080 pindex = regno * 8; 1076 pindex = regno * 8;
1081 1077
@@ -1244,8 +1240,6 @@ static void radeon_write_pll_regs(struct radeonfb_info *rinfo, struct radeon_reg
1244{ 1240{
1245 int i; 1241 int i;
1246 1242
1247 radeon_fifo_wait(20);
1248
1249 /* Workaround from XFree */ 1243 /* Workaround from XFree */
1250 if (rinfo->is_mobility) { 1244 if (rinfo->is_mobility) {
1251 /* A temporal workaround for the occational blanking on certain laptop 1245 /* A temporal workaround for the occational blanking on certain laptop
@@ -1286,11 +1280,10 @@ static void radeon_write_pll_regs(struct radeonfb_info *rinfo, struct radeon_reg
1286 radeon_pll_errata_after_data(rinfo); 1280 radeon_pll_errata_after_data(rinfo);
1287 1281
1288 /* Set PPLL ref. div */ 1282 /* Set PPLL ref. div */
1289 if (rinfo->family == CHIP_FAMILY_R300 || 1283 if (IS_R300_VARIANT(rinfo) ||
1290 rinfo->family == CHIP_FAMILY_RS300 || 1284 rinfo->family == CHIP_FAMILY_RS300 ||
1291 rinfo->family == CHIP_FAMILY_R350 || 1285 rinfo->family == CHIP_FAMILY_RS400 ||
1292 rinfo->family == CHIP_FAMILY_RV350 || 1286 rinfo->family == CHIP_FAMILY_RS480) {
1293 rinfo->family == CHIP_FAMILY_RV380 ) {
1294 if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) { 1287 if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) {
1295 /* When restoring console mode, use saved PPLL_REF_DIV 1288 /* When restoring console mode, use saved PPLL_REF_DIV
1296 * setting. 1289 * setting.
@@ -1342,7 +1335,7 @@ static void radeon_lvds_timer_func(unsigned long data)
1342{ 1335{
1343 struct radeonfb_info *rinfo = (struct radeonfb_info *)data; 1336 struct radeonfb_info *rinfo = (struct radeonfb_info *)data;
1344 1337
1345 radeon_engine_idle(); 1338 radeon_engine_idle(rinfo);
1346 1339
1347 OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl); 1340 OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl);
1348} 1341}
@@ -1360,10 +1353,11 @@ void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode,
1360 if (nomodeset) 1353 if (nomodeset)
1361 return; 1354 return;
1362 1355
1356 radeon_engine_idle(rinfo);
1357
1363 if (!regs_only) 1358 if (!regs_only)
1364 radeon_screen_blank(rinfo, FB_BLANK_NORMAL, 0); 1359 radeon_screen_blank(rinfo, FB_BLANK_NORMAL, 0);
1365 1360
1366 radeon_fifo_wait(31);
1367 for (i=0; i<10; i++) 1361 for (i=0; i<10; i++)
1368 OUTREG(common_regs[i].reg, common_regs[i].val); 1362 OUTREG(common_regs[i].reg, common_regs[i].val);
1369 1363
@@ -1391,7 +1385,6 @@ void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode,
1391 radeon_write_pll_regs(rinfo, mode); 1385 radeon_write_pll_regs(rinfo, mode);
1392 1386
1393 if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { 1387 if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) {
1394 radeon_fifo_wait(10);
1395 OUTREG(FP_CRTC_H_TOTAL_DISP, mode->fp_crtc_h_total_disp); 1388 OUTREG(FP_CRTC_H_TOTAL_DISP, mode->fp_crtc_h_total_disp);
1396 OUTREG(FP_CRTC_V_TOTAL_DISP, mode->fp_crtc_v_total_disp); 1389 OUTREG(FP_CRTC_V_TOTAL_DISP, mode->fp_crtc_v_total_disp);
1397 OUTREG(FP_H_SYNC_STRT_WID, mode->fp_h_sync_strt_wid); 1390 OUTREG(FP_H_SYNC_STRT_WID, mode->fp_h_sync_strt_wid);
@@ -1406,7 +1399,6 @@ void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode,
1406 if (!regs_only) 1399 if (!regs_only)
1407 radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 0); 1400 radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 0);
1408 1401
1409 radeon_fifo_wait(2);
1410 OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl); 1402 OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl);
1411 1403
1412 return; 1404 return;
@@ -1461,10 +1453,7 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
1461 /* Not all chip revs have the same format for this register, 1453 /* Not all chip revs have the same format for this register,
1462 * extract the source selection 1454 * extract the source selection
1463 */ 1455 */
1464 if (rinfo->family == CHIP_FAMILY_R200 || 1456 if (rinfo->family == CHIP_FAMILY_R200 || IS_R300_VARIANT(rinfo)) {
1465 rinfo->family == CHIP_FAMILY_R300 ||
1466 rinfo->family == CHIP_FAMILY_R350 ||
1467 rinfo->family == CHIP_FAMILY_RV350) {
1468 source = (fp2_gen_cntl >> 10) & 0x3; 1457 source = (fp2_gen_cntl >> 10) & 0x3;
1469 /* sourced from transform unit, check for transform unit 1458 /* sourced from transform unit, check for transform unit
1470 * own source 1459 * own source
@@ -1560,7 +1549,7 @@ static int radeonfb_set_par(struct fb_info *info)
1560 /* We always want engine to be idle on a mode switch, even 1549 /* We always want engine to be idle on a mode switch, even
1561 * if we won't actually change the mode 1550 * if we won't actually change the mode
1562 */ 1551 */
1563 radeon_engine_idle(); 1552 radeon_engine_idle(rinfo);
1564 1553
1565 hSyncStart = mode->xres + mode->right_margin; 1554 hSyncStart = mode->xres + mode->right_margin;
1566 hSyncEnd = hSyncStart + mode->hsync_len; 1555 hSyncEnd = hSyncStart + mode->hsync_len;
@@ -1855,7 +1844,6 @@ static int radeonfb_set_par(struct fb_info *info)
1855 return 0; 1844 return 0;
1856} 1845}
1857 1846
1858
1859static struct fb_ops radeonfb_ops = { 1847static struct fb_ops radeonfb_ops = {
1860 .owner = THIS_MODULE, 1848 .owner = THIS_MODULE,
1861 .fb_check_var = radeonfb_check_var, 1849 .fb_check_var = radeonfb_check_var,
@@ -1879,6 +1867,7 @@ static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo)
1879 info->par = rinfo; 1867 info->par = rinfo;
1880 info->pseudo_palette = rinfo->pseudo_palette; 1868 info->pseudo_palette = rinfo->pseudo_palette;
1881 info->flags = FBINFO_DEFAULT 1869 info->flags = FBINFO_DEFAULT
1870 | FBINFO_HWACCEL_IMAGEBLIT
1882 | FBINFO_HWACCEL_COPYAREA 1871 | FBINFO_HWACCEL_COPYAREA
1883 | FBINFO_HWACCEL_FILLRECT 1872 | FBINFO_HWACCEL_FILLRECT
1884 | FBINFO_HWACCEL_XPAN 1873 | FBINFO_HWACCEL_XPAN
@@ -2005,11 +1994,11 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
2005 (rinfo->family == CHIP_FAMILY_RS200) || 1994 (rinfo->family == CHIP_FAMILY_RS200) ||
2006 (rinfo->family == CHIP_FAMILY_RS300) || 1995 (rinfo->family == CHIP_FAMILY_RS300) ||
2007 (rinfo->family == CHIP_FAMILY_RC410) || 1996 (rinfo->family == CHIP_FAMILY_RC410) ||
1997 (rinfo->family == CHIP_FAMILY_RS400) ||
2008 (rinfo->family == CHIP_FAMILY_RS480) ) { 1998 (rinfo->family == CHIP_FAMILY_RS480) ) {
2009 u32 tom = INREG(NB_TOM); 1999 u32 tom = INREG(NB_TOM);
2010 tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024); 2000 tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
2011 2001
2012 radeon_fifo_wait(6);
2013 OUTREG(MC_FB_LOCATION, tom); 2002 OUTREG(MC_FB_LOCATION, tom);
2014 OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); 2003 OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
2015 OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); 2004 OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 8c8fa35f1b7c..2c5567175dca 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -139,12 +139,8 @@ void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, 139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn,
140 u8 **out_edid) 140 u8 **out_edid)
141{ 141{
142 u32 reg = rinfo->i2c[conn-1].ddc_reg;
143 u8 *edid; 142 u8 *edid;
144 143
145 OUTREG(reg, INREG(reg) &
146 ~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
147
148 edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter); 144 edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter);
149 145
150 if (out_edid) 146 if (out_edid)
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 675abdafc2d8..3df5015f1d13 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2653,9 +2653,9 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2653 2653
2654 if (!(info->flags & FBINFO_HWACCEL_DISABLED)) { 2654 if (!(info->flags & FBINFO_HWACCEL_DISABLED)) {
2655 /* Make sure engine is reset */ 2655 /* Make sure engine is reset */
2656 radeon_engine_idle(); 2656 radeon_engine_idle(rinfo);
2657 radeonfb_engine_reset(rinfo); 2657 radeonfb_engine_reset(rinfo);
2658 radeon_engine_idle(); 2658 radeon_engine_idle(rinfo);
2659 } 2659 }
2660 2660
2661 /* Blank display and LCD */ 2661 /* Blank display and LCD */
@@ -2767,7 +2767,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2767 2767
2768 rinfo->asleep = 0; 2768 rinfo->asleep = 0;
2769 } else 2769 } else
2770 radeon_engine_idle(); 2770 radeon_engine_idle(rinfo);
2771 2771
2772 /* Restore display & engine */ 2772 /* Restore display & engine */
2773 radeon_write_mode (rinfo, &rinfo->state, 1); 2773 radeon_write_mode (rinfo, &rinfo->state, 1);
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index ccbfffd12805..ea0b5b47acaf 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -53,6 +53,7 @@ enum radeon_family {
53 CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */ 53 CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */
54 CHIP_FAMILY_R420, /* R420/R423/M18 */ 54 CHIP_FAMILY_R420, /* R420/R423/M18 */
55 CHIP_FAMILY_RC410, 55 CHIP_FAMILY_RC410,
56 CHIP_FAMILY_RS400,
56 CHIP_FAMILY_RS480, 57 CHIP_FAMILY_RS480,
57 CHIP_FAMILY_LAST, 58 CHIP_FAMILY_LAST,
58}; 59};
@@ -335,7 +336,15 @@ struct radeonfb_info {
335 int mon2_type; 336 int mon2_type;
336 u8 *mon2_EDID; 337 u8 *mon2_EDID;
337 338
338 u32 dp_gui_master_cntl; 339 /* accel bits */
340 u32 dp_gui_mc_base;
341 u32 dp_gui_mc_cache;
342 u32 dp_cntl_cache;
343 u32 dp_brush_fg_cache;
344 u32 dp_brush_bg_cache;
345 u32 dp_src_fg_cache;
346 u32 dp_src_bg_cache;
347 u32 fifo_free;
339 348
340 struct pll_info pll; 349 struct pll_info pll;
341 350
@@ -347,6 +356,7 @@ struct radeonfb_info {
347 int lock_blank; 356 int lock_blank;
348 int dynclk; 357 int dynclk;
349 int no_schedule; 358 int no_schedule;
359 int gfx_mode;
350 enum radeon_pm_mode pm_mode; 360 enum radeon_pm_mode pm_mode;
351 reinit_function_ptr reinit_func; 361 reinit_function_ptr reinit_func;
352 362
@@ -391,8 +401,14 @@ static inline void _radeon_msleep(struct radeonfb_info *rinfo, unsigned long ms)
391#define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr) 401#define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr)
392#define INREG16(addr) readw((rinfo->mmio_base)+addr) 402#define INREG16(addr) readw((rinfo->mmio_base)+addr)
393#define OUTREG16(addr,val) writew(val, (rinfo->mmio_base)+addr) 403#define OUTREG16(addr,val) writew(val, (rinfo->mmio_base)+addr)
404
405#ifdef CONFIG_PPC
406#define INREG(addr) ({ eieio(); ld_le32(rinfo->mmio_base+(addr)); })
407#define OUTREG(addr,val) do { eieio(); st_le32(rinfo->mmio_base+(addr),(val)); } while(0)
408#else
394#define INREG(addr) readl((rinfo->mmio_base)+addr) 409#define INREG(addr) readl((rinfo->mmio_base)+addr)
395#define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr) 410#define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr)
411#endif
396 412
397static inline void _OUTREGP(struct radeonfb_info *rinfo, u32 addr, 413static inline void _OUTREGP(struct radeonfb_info *rinfo, u32 addr,
398 u32 val, u32 mask) 414 u32 val, u32 mask)
@@ -533,16 +549,25 @@ static inline u32 radeon_get_dstbpp(u16 depth)
533/* 549/*
534 * 2D Engine helper routines 550 * 2D Engine helper routines
535 */ 551 */
552
553extern void radeon_fifo_update_and_wait(struct radeonfb_info *rinfo, int entries);
554
536static inline void radeon_engine_flush (struct radeonfb_info *rinfo) 555static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
537{ 556{
538 int i; 557 int i;
539 558
540 /* initiate flush */ 559 /* Initiate flush */
541 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL, 560 OUTREGP(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
542 ~RB2D_DC_FLUSH_ALL); 561 ~RB2D_DC_FLUSH_ALL);
543 562
563 /* Ensure FIFO is empty, ie, make sure the flush commands
564 * has reached the cache
565 */
566 radeon_fifo_update_and_wait(rinfo, 64);
567
568 /* Wait for the flush to complete */
544 for (i=0; i < 2000000; i++) { 569 for (i=0; i < 2000000; i++) {
545 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY)) 570 if (!(INREG(DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
546 return; 571 return;
547 udelay(1); 572 udelay(1);
548 } 573 }
@@ -550,25 +575,12 @@ static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
550} 575}
551 576
552 577
553static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries) 578static inline void radeon_engine_idle(struct radeonfb_info *rinfo)
554{
555 int i;
556
557 for (i=0; i<2000000; i++) {
558 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
559 return;
560 udelay(1);
561 }
562 printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
563}
564
565
566static inline void _radeon_engine_idle(struct radeonfb_info *rinfo)
567{ 579{
568 int i; 580 int i;
569 581
570 /* ensure FIFO is empty before waiting for idle */ 582 /* ensure FIFO is empty before waiting for idle */
571 _radeon_fifo_wait (rinfo, 64); 583 radeon_fifo_update_and_wait (rinfo, 64);
572 584
573 for (i=0; i<2000000; i++) { 585 for (i=0; i<2000000; i++) {
574 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) { 586 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) {
@@ -581,8 +593,6 @@ static inline void _radeon_engine_idle(struct radeonfb_info *rinfo)
581} 593}
582 594
583 595
584#define radeon_engine_idle() _radeon_engine_idle(rinfo)
585#define radeon_fifo_wait(entries) _radeon_fifo_wait(rinfo,entries)
586#define radeon_msleep(ms) _radeon_msleep(rinfo,ms) 596#define radeon_msleep(ms) _radeon_msleep(rinfo,ms)
587 597
588 598
@@ -612,6 +622,7 @@ extern void radeonfb_imageblit(struct fb_info *p, const struct fb_image *image);
612extern int radeonfb_sync(struct fb_info *info); 622extern int radeonfb_sync(struct fb_info *info);
613extern void radeonfb_engine_init (struct radeonfb_info *rinfo); 623extern void radeonfb_engine_init (struct radeonfb_info *rinfo);
614extern void radeonfb_engine_reset(struct radeonfb_info *rinfo); 624extern void radeonfb_engine_reset(struct radeonfb_info *rinfo);
625extern void radeon_fixup_mem_offset(struct radeonfb_info *rinfo);
615 626
616/* Other functions */ 627/* Other functions */
617extern int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch); 628extern int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch);
diff --git a/drivers/video/carminefb.c b/drivers/video/carminefb.c
index e15bb447440a..c9b191319a9a 100644
--- a/drivers/video/carminefb.c
+++ b/drivers/video/carminefb.c
@@ -535,7 +535,7 @@ static struct fb_ops carminefb_ops = {
535 .fb_setcolreg = carmine_setcolreg, 535 .fb_setcolreg = carmine_setcolreg,
536}; 536};
537 537
538static int alloc_carmine_fb(void __iomem *regs, void __iomem *smem_base, 538static int __devinit alloc_carmine_fb(void __iomem *regs, void __iomem *smem_base,
539 int smem_offset, struct device *device, struct fb_info **rinfo) 539 int smem_offset, struct device *device, struct fb_info **rinfo)
540{ 540{
541 int ret; 541 int ret;
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index e729fb279645..048b139f0e50 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -327,29 +327,7 @@ static const struct {
327#endif /* CONFIG_ZORRO */ 327#endif /* CONFIG_ZORRO */
328 328
329struct cirrusfb_regs { 329struct cirrusfb_regs {
330 long freq; 330 int multiplexing;
331 long nom;
332 long den;
333 long div;
334 long multiplexing;
335 long mclk;
336 long divMCLK;
337
338 long HorizRes; /* The x resolution in pixel */
339 long HorizTotal;
340 long HorizDispEnd;
341 long HorizBlankStart;
342 long HorizBlankEnd;
343 long HorizSyncStart;
344 long HorizSyncEnd;
345
346 long VertRes; /* the physical y resolution in scanlines */
347 long VertTotal;
348 long VertDispEnd;
349 long VertSyncStart;
350 long VertSyncEnd;
351 long VertBlankStart;
352 long VertBlankEnd;
353}; 331};
354 332
355#ifdef CIRRUSFB_DEBUG 333#ifdef CIRRUSFB_DEBUG
@@ -367,110 +345,13 @@ struct cirrusfb_info {
367 345
368 struct cirrusfb_regs currentmode; 346 struct cirrusfb_regs currentmode;
369 int blank_mode; 347 int blank_mode;
348 u32 pseudo_palette[16];
370 349
371 u32 pseudo_palette[16];
372
373#ifdef CONFIG_ZORRO
374 struct zorro_dev *zdev;
375#endif
376#ifdef CONFIG_PCI
377 struct pci_dev *pdev;
378#endif
379 void (*unmap)(struct fb_info *info); 350 void (*unmap)(struct fb_info *info);
380}; 351};
381 352
382static unsigned cirrusfb_def_mode = 1; 353static int noaccel __devinitdata;
383static int noaccel; 354static char *mode_option __devinitdata = "640x480@60";
384
385/*
386 * Predefined Video Modes
387 */
388
389static const struct {
390 const char *name;
391 struct fb_var_screeninfo var;
392} cirrusfb_predefined[] = {
393 {
394 /* autodetect mode */
395 .name = "Autodetect",
396 }, {
397 /* 640x480, 31.25 kHz, 60 Hz, 25 MHz PixClock */
398 .name = "640x480",
399 .var = {
400 .xres = 640,
401 .yres = 480,
402 .xres_virtual = 640,
403 .yres_virtual = 480,
404 .bits_per_pixel = 8,
405 .red = { .length = 8 },
406 .green = { .length = 8 },
407 .blue = { .length = 8 },
408 .width = -1,
409 .height = -1,
410 .pixclock = 40000,
411 .left_margin = 48,
412 .right_margin = 16,
413 .upper_margin = 32,
414 .lower_margin = 8,
415 .hsync_len = 96,
416 .vsync_len = 4,
417 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
418 .vmode = FB_VMODE_NONINTERLACED
419 }
420 }, {
421 /* 800x600, 48 kHz, 76 Hz, 50 MHz PixClock */
422 .name = "800x600",
423 .var = {
424 .xres = 800,
425 .yres = 600,
426 .xres_virtual = 800,
427 .yres_virtual = 600,
428 .bits_per_pixel = 8,
429 .red = { .length = 8 },
430 .green = { .length = 8 },
431 .blue = { .length = 8 },
432 .width = -1,
433 .height = -1,
434 .pixclock = 20000,
435 .left_margin = 128,
436 .right_margin = 16,
437 .upper_margin = 24,
438 .lower_margin = 2,
439 .hsync_len = 96,
440 .vsync_len = 6,
441 .vmode = FB_VMODE_NONINTERLACED
442 }
443 }, {
444 /*
445 * Modeline from XF86Config:
446 * Mode "1024x768" 80 1024 1136 1340 1432 768 770 774 805
447 */
448 /* 1024x768, 55.8 kHz, 70 Hz, 80 MHz PixClock */
449 .name = "1024x768",
450 .var = {
451 .xres = 1024,
452 .yres = 768,
453 .xres_virtual = 1024,
454 .yres_virtual = 768,
455 .bits_per_pixel = 8,
456 .red = { .length = 8 },
457 .green = { .length = 8 },
458 .blue = { .length = 8 },
459 .width = -1,
460 .height = -1,
461 .pixclock = 12500,
462 .left_margin = 144,
463 .right_margin = 32,
464 .upper_margin = 30,
465 .lower_margin = 2,
466 .hsync_len = 192,
467 .vsync_len = 6,
468 .vmode = FB_VMODE_NONINTERLACED
469 }
470 }
471};
472
473#define NUM_TOTAL_MODES ARRAY_SIZE(cirrusfb_predefined)
474 355
475/****************************************************************************/ 356/****************************************************************************/
476/**** BEGIN PROTOTYPES ******************************************************/ 357/**** BEGIN PROTOTYPES ******************************************************/
@@ -514,10 +395,6 @@ static struct fb_ops cirrusfb_ops = {
514 .fb_imageblit = cirrusfb_imageblit, 395 .fb_imageblit = cirrusfb_imageblit,
515}; 396};
516 397
517/*--- Hardware Specific Routines -------------------------------------------*/
518static int cirrusfb_decode_var(const struct fb_var_screeninfo *var,
519 struct cirrusfb_regs *regs,
520 struct fb_info *info);
521/*--- Internal routines ----------------------------------------------------*/ 398/*--- Internal routines ----------------------------------------------------*/
522static void init_vgachip(struct fb_info *info); 399static void init_vgachip(struct fb_info *info);
523static void switch_monitor(struct cirrusfb_info *cinfo, int on); 400static void switch_monitor(struct cirrusfb_info *cinfo, int on);
@@ -546,9 +423,7 @@ static void cirrusfb_RectFill(u8 __iomem *regbase, int bits_per_pixel,
546 u_short width, u_short height, 423 u_short width, u_short height,
547 u_char color, u_short line_length); 424 u_char color, u_short line_length);
548 425
549static void bestclock(long freq, long *best, 426static void bestclock(long freq, int *nom, int *den, int *div);
550 long *nom, long *den,
551 long *div, long maxfreq);
552 427
553#ifdef CIRRUSFB_DEBUG 428#ifdef CIRRUSFB_DEBUG
554static void cirrusfb_dump(void); 429static void cirrusfb_dump(void);
@@ -584,45 +459,28 @@ static int cirrusfb_release(struct fb_info *info, int user)
584/****************************************************************************/ 459/****************************************************************************/
585/**** BEGIN Hardware specific Routines **************************************/ 460/**** BEGIN Hardware specific Routines **************************************/
586 461
587/* Get a good MCLK value */ 462/* Check if the MCLK is not a better clock source */
588static long cirrusfb_get_mclk(long freq, int bpp, long *div) 463static int cirrusfb_check_mclk(struct cirrusfb_info *cinfo, long freq)
589{ 464{
590 long mclk; 465 long mclk = vga_rseq(cinfo->regbase, CL_SEQR1F) & 0x3f;
591 466
592 assert(div != NULL); 467 /* Read MCLK value */
593 468 mclk = (14318 * mclk) >> 3;
594 /* Calculate MCLK, in case VCLK is high enough to require > 50MHz. 469 DPRINTK("Read MCLK of %ld kHz\n", mclk);
595 * Assume a 64-bit data path for now. The formula is:
596 * ((B * PCLK * 2)/W) * 1.2
597 * B = bytes per pixel, PCLK = pixclock, W = data width in bytes */
598 mclk = ((bpp / 8) * freq * 2) / 4;
599 mclk = (mclk * 12) / 10;
600 if (mclk < 50000)
601 mclk = 50000;
602 DPRINTK("Use MCLK of %ld kHz\n", mclk);
603
604 /* Calculate value for SR1F. Multiply by 2 so we can round up. */
605 mclk = ((mclk * 16) / 14318);
606 mclk = (mclk + 1) / 2;
607 DPRINTK("Set SR1F[5:0] to 0x%lx\n", mclk);
608 470
609 /* Determine if we should use MCLK instead of VCLK, and if so, what we 471 /* Determine if we should use MCLK instead of VCLK, and if so, what we
610 * should divide it by to get VCLK */ 472 * should divide it by to get VCLK
611 switch (freq) { 473 */
612 case 24751 ... 25249: 474
613 *div = 2; 475 if (abs(freq - mclk) < 250) {
614 DPRINTK("Using VCLK = MCLK/2\n");
615 break;
616 case 49501 ... 50499:
617 *div = 1;
618 DPRINTK("Using VCLK = MCLK\n"); 476 DPRINTK("Using VCLK = MCLK\n");
619 break; 477 return 1;
620 default: 478 } else if (abs(freq - (mclk / 2)) < 250) {
621 *div = 0; 479 DPRINTK("Using VCLK = MCLK/2\n");
622 break; 480 return 2;
623 } 481 }
624 482
625 return mclk; 483 return 0;
626} 484}
627 485
628static int cirrusfb_check_var(struct fb_var_screeninfo *var, 486static int cirrusfb_check_var(struct fb_var_screeninfo *var,
@@ -638,7 +496,6 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var,
638 break; /* 8 pixel per byte, only 1/4th of mem usable */ 496 break; /* 8 pixel per byte, only 1/4th of mem usable */
639 case 8: 497 case 8:
640 case 16: 498 case 16:
641 case 24:
642 case 32: 499 case 32:
643 break; /* 1 pixel == 1 byte */ 500 break; /* 1 pixel == 1 byte */
644 default: 501 default:
@@ -713,7 +570,6 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var,
713 var->blue.length = 5; 570 var->blue.length = 5;
714 break; 571 break;
715 572
716 case 24:
717 case 32: 573 case 32:
718 if (isPReP) { 574 if (isPReP) {
719 var->red.offset = 8; 575 var->red.offset = 8;
@@ -767,8 +623,6 @@ static int cirrusfb_decode_var(const struct fb_var_screeninfo *var,
767 long maxclock; 623 long maxclock;
768 int maxclockidx = var->bits_per_pixel >> 3; 624 int maxclockidx = var->bits_per_pixel >> 3;
769 struct cirrusfb_info *cinfo = info->par; 625 struct cirrusfb_info *cinfo = info->par;
770 int xres, hfront, hsync, hback;
771 int yres, vfront, vsync, vback;
772 626
773 switch (var->bits_per_pixel) { 627 switch (var->bits_per_pixel) {
774 case 1: 628 case 1:
@@ -782,10 +636,9 @@ static int cirrusfb_decode_var(const struct fb_var_screeninfo *var,
782 break; 636 break;
783 637
784 case 16: 638 case 16:
785 case 24:
786 case 32: 639 case 32:
787 info->fix.line_length = var->xres_virtual * maxclockidx; 640 info->fix.line_length = var->xres_virtual * maxclockidx;
788 info->fix.visual = FB_VISUAL_DIRECTCOLOR; 641 info->fix.visual = FB_VISUAL_TRUECOLOR;
789 break; 642 break;
790 643
791 default: 644 default:
@@ -827,90 +680,33 @@ static int cirrusfb_decode_var(const struct fb_var_screeninfo *var,
827 switch (var->bits_per_pixel) { 680 switch (var->bits_per_pixel) {
828 case 16: 681 case 16:
829 case 32: 682 case 32:
830 if (regs->HorizRes <= 800) 683 if (var->xres <= 800)
831 /* Xbh has this type of clock for 32-bit */ 684 /* Xbh has this type of clock for 32-bit */
832 freq /= 2; 685 freq /= 2;
833 break; 686 break;
834 } 687 }
835#endif 688#endif
836
837 bestclock(freq, &regs->freq, &regs->nom, &regs->den, &regs->div,
838 maxclock);
839 regs->mclk = cirrusfb_get_mclk(freq, var->bits_per_pixel,
840 &regs->divMCLK);
841
842 xres = var->xres;
843 hfront = var->right_margin;
844 hsync = var->hsync_len;
845 hback = var->left_margin;
846
847 yres = var->yres;
848 vfront = var->lower_margin;
849 vsync = var->vsync_len;
850 vback = var->upper_margin;
851
852 if (var->vmode & FB_VMODE_DOUBLE) {
853 yres *= 2;
854 vfront *= 2;
855 vsync *= 2;
856 vback *= 2;
857 } else if (var->vmode & FB_VMODE_INTERLACED) {
858 yres = (yres + 1) / 2;
859 vfront = (vfront + 1) / 2;
860 vsync = (vsync + 1) / 2;
861 vback = (vback + 1) / 2;
862 }
863 regs->HorizRes = xres;
864 regs->HorizTotal = (xres + hfront + hsync + hback) / 8 - 5;
865 regs->HorizDispEnd = xres / 8 - 1;
866 regs->HorizBlankStart = xres / 8;
867 /* does not count with "-5" */
868 regs->HorizBlankEnd = regs->HorizTotal + 5;
869 regs->HorizSyncStart = (xres + hfront) / 8 + 1;
870 regs->HorizSyncEnd = (xres + hfront + hsync) / 8 + 1;
871
872 regs->VertRes = yres;
873 regs->VertTotal = yres + vfront + vsync + vback - 2;
874 regs->VertDispEnd = yres - 1;
875 regs->VertBlankStart = yres;
876 regs->VertBlankEnd = regs->VertTotal;
877 regs->VertSyncStart = yres + vfront - 1;
878 regs->VertSyncEnd = yres + vfront + vsync - 1;
879
880 if (regs->VertRes >= 1024) {
881 regs->VertTotal /= 2;
882 regs->VertSyncStart /= 2;
883 regs->VertSyncEnd /= 2;
884 regs->VertDispEnd /= 2;
885 }
886 if (regs->multiplexing) {
887 regs->HorizTotal /= 2;
888 regs->HorizSyncStart /= 2;
889 regs->HorizSyncEnd /= 2;
890 regs->HorizDispEnd /= 2;
891 }
892
893 return 0; 689 return 0;
894} 690}
895 691
896static void cirrusfb_set_mclk(const struct cirrusfb_info *cinfo, int val, 692static void cirrusfb_set_mclk_as_source(const struct cirrusfb_info *cinfo,
897 int div) 693 int div)
898{ 694{
695 unsigned char old1f, old1e;
899 assert(cinfo != NULL); 696 assert(cinfo != NULL);
697 old1f = vga_rseq(cinfo->regbase, CL_SEQR1F) & ~0x40;
900 698
901 if (div == 2) { 699 if (div) {
902 /* VCLK = MCLK/2 */ 700 DPRINTK("Set %s as pixclock source.\n",
903 unsigned char old = vga_rseq(cinfo->regbase, CL_SEQR1E); 701 (div == 2) ? "MCLK/2" : "MCLK");
904 vga_wseq(cinfo->regbase, CL_SEQR1E, old | 0x1); 702 old1f |= 0x40;
905 vga_wseq(cinfo->regbase, CL_SEQR1F, 0x40 | (val & 0x3f)); 703 old1e = vga_rseq(cinfo->regbase, CL_SEQR1E) & ~0x1;
906 } else if (div == 1) { 704 if (div == 2)
907 /* VCLK = MCLK */ 705 old1e |= 1;
908 unsigned char old = vga_rseq(cinfo->regbase, CL_SEQR1E); 706
909 vga_wseq(cinfo->regbase, CL_SEQR1E, old & ~0x1); 707 vga_wseq(cinfo->regbase, CL_SEQR1E, old1e);
910 vga_wseq(cinfo->regbase, CL_SEQR1F, 0x40 | (val & 0x3f));
911 } else {
912 vga_wseq(cinfo->regbase, CL_SEQR1F, val & 0x3f);
913 } 708 }
709 vga_wseq(cinfo->regbase, CL_SEQR1F, old1f);
914} 710}
915 711
916/************************************************************************* 712/*************************************************************************
@@ -927,6 +723,10 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
927 unsigned char tmp; 723 unsigned char tmp;
928 int offset = 0, err; 724 int offset = 0, err;
929 const struct cirrusfb_board_info_rec *bi; 725 const struct cirrusfb_board_info_rec *bi;
726 int hdispend, hsyncstart, hsyncend, htotal;
727 int yres, vdispend, vsyncstart, vsyncend, vtotal;
728 long freq;
729 int nom, den, div;
930 730
931 DPRINTK("ENTER\n"); 731 DPRINTK("ENTER\n");
932 DPRINTK("Requested mode: %dx%dx%d\n", 732 DPRINTK("Requested mode: %dx%dx%d\n",
@@ -944,76 +744,117 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
944 744
945 bi = &cirrusfb_board_info[cinfo->btype]; 745 bi = &cirrusfb_board_info[cinfo->btype];
946 746
747 hsyncstart = var->xres + var->right_margin;
748 hsyncend = hsyncstart + var->hsync_len;
749 htotal = (hsyncend + var->left_margin) / 8 - 5;
750 hdispend = var->xres / 8 - 1;
751 hsyncstart = hsyncstart / 8 + 1;
752 hsyncend = hsyncend / 8 + 1;
753
754 yres = var->yres;
755 vsyncstart = yres + var->lower_margin;
756 vsyncend = vsyncstart + var->vsync_len;
757 vtotal = vsyncend + var->upper_margin;
758 vdispend = yres - 1;
759
760 if (var->vmode & FB_VMODE_DOUBLE) {
761 yres *= 2;
762 vsyncstart *= 2;
763 vsyncend *= 2;
764 vtotal *= 2;
765 } else if (var->vmode & FB_VMODE_INTERLACED) {
766 yres = (yres + 1) / 2;
767 vsyncstart = (vsyncstart + 1) / 2;
768 vsyncend = (vsyncend + 1) / 2;
769 vtotal = (vtotal + 1) / 2;
770 }
771
772 vtotal -= 2;
773 vsyncstart -= 1;
774 vsyncend -= 1;
775
776 if (yres >= 1024) {
777 vtotal /= 2;
778 vsyncstart /= 2;
779 vsyncend /= 2;
780 vdispend /= 2;
781 }
782 if (regs.multiplexing) {
783 htotal /= 2;
784 hsyncstart /= 2;
785 hsyncend /= 2;
786 hdispend /= 2;
787 }
947 /* unlock register VGA_CRTC_H_TOTAL..CRT7 */ 788 /* unlock register VGA_CRTC_H_TOTAL..CRT7 */
948 vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, 0x20); /* previously: 0x00) */ 789 vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, 0x20); /* previously: 0x00) */
949 790
950 /* if debugging is enabled, all parameters get output before writing */ 791 /* if debugging is enabled, all parameters get output before writing */
951 DPRINTK("CRT0: %ld\n", regs.HorizTotal); 792 DPRINTK("CRT0: %d\n", htotal);
952 vga_wcrt(regbase, VGA_CRTC_H_TOTAL, regs.HorizTotal); 793 vga_wcrt(regbase, VGA_CRTC_H_TOTAL, htotal);
953 794
954 DPRINTK("CRT1: %ld\n", regs.HorizDispEnd); 795 DPRINTK("CRT1: %d\n", hdispend);
955 vga_wcrt(regbase, VGA_CRTC_H_DISP, regs.HorizDispEnd); 796 vga_wcrt(regbase, VGA_CRTC_H_DISP, hdispend);
956 797
957 DPRINTK("CRT2: %ld\n", regs.HorizBlankStart); 798 DPRINTK("CRT2: %d\n", var->xres / 8);
958 vga_wcrt(regbase, VGA_CRTC_H_BLANK_START, regs.HorizBlankStart); 799 vga_wcrt(regbase, VGA_CRTC_H_BLANK_START, var->xres / 8);
959 800
960 /* + 128: Compatible read */ 801 /* + 128: Compatible read */
961 DPRINTK("CRT3: 128+%ld\n", regs.HorizBlankEnd % 32); 802 DPRINTK("CRT3: 128+%d\n", (htotal + 5) % 32);
962 vga_wcrt(regbase, VGA_CRTC_H_BLANK_END, 803 vga_wcrt(regbase, VGA_CRTC_H_BLANK_END,
963 128 + (regs.HorizBlankEnd % 32)); 804 128 + ((htotal + 5) % 32));
964 805
965 DPRINTK("CRT4: %ld\n", regs.HorizSyncStart); 806 DPRINTK("CRT4: %d\n", hsyncstart);
966 vga_wcrt(regbase, VGA_CRTC_H_SYNC_START, regs.HorizSyncStart); 807 vga_wcrt(regbase, VGA_CRTC_H_SYNC_START, hsyncstart);
967 808
968 tmp = regs.HorizSyncEnd % 32; 809 tmp = hsyncend % 32;
969 if (regs.HorizBlankEnd & 32) 810 if ((htotal + 5) & 32)
970 tmp += 128; 811 tmp += 128;
971 DPRINTK("CRT5: %d\n", tmp); 812 DPRINTK("CRT5: %d\n", tmp);
972 vga_wcrt(regbase, VGA_CRTC_H_SYNC_END, tmp); 813 vga_wcrt(regbase, VGA_CRTC_H_SYNC_END, tmp);
973 814
974 DPRINTK("CRT6: %ld\n", regs.VertTotal & 0xff); 815 DPRINTK("CRT6: %d\n", vtotal & 0xff);
975 vga_wcrt(regbase, VGA_CRTC_V_TOTAL, (regs.VertTotal & 0xff)); 816 vga_wcrt(regbase, VGA_CRTC_V_TOTAL, vtotal & 0xff);
976 817
977 tmp = 16; /* LineCompare bit #9 */ 818 tmp = 16; /* LineCompare bit #9 */
978 if (regs.VertTotal & 256) 819 if (vtotal & 256)
979 tmp |= 1; 820 tmp |= 1;
980 if (regs.VertDispEnd & 256) 821 if (vdispend & 256)
981 tmp |= 2; 822 tmp |= 2;
982 if (regs.VertSyncStart & 256) 823 if (vsyncstart & 256)
983 tmp |= 4; 824 tmp |= 4;
984 if (regs.VertBlankStart & 256) 825 if ((vdispend + 1) & 256)
985 tmp |= 8; 826 tmp |= 8;
986 if (regs.VertTotal & 512) 827 if (vtotal & 512)
987 tmp |= 32; 828 tmp |= 32;
988 if (regs.VertDispEnd & 512) 829 if (vdispend & 512)
989 tmp |= 64; 830 tmp |= 64;
990 if (regs.VertSyncStart & 512) 831 if (vsyncstart & 512)
991 tmp |= 128; 832 tmp |= 128;
992 DPRINTK("CRT7: %d\n", tmp); 833 DPRINTK("CRT7: %d\n", tmp);
993 vga_wcrt(regbase, VGA_CRTC_OVERFLOW, tmp); 834 vga_wcrt(regbase, VGA_CRTC_OVERFLOW, tmp);
994 835
995 tmp = 0x40; /* LineCompare bit #8 */ 836 tmp = 0x40; /* LineCompare bit #8 */
996 if (regs.VertBlankStart & 512) 837 if ((vdispend + 1) & 512)
997 tmp |= 0x20; 838 tmp |= 0x20;
998 if (var->vmode & FB_VMODE_DOUBLE) 839 if (var->vmode & FB_VMODE_DOUBLE)
999 tmp |= 0x80; 840 tmp |= 0x80;
1000 DPRINTK("CRT9: %d\n", tmp); 841 DPRINTK("CRT9: %d\n", tmp);
1001 vga_wcrt(regbase, VGA_CRTC_MAX_SCAN, tmp); 842 vga_wcrt(regbase, VGA_CRTC_MAX_SCAN, tmp);
1002 843
1003 DPRINTK("CRT10: %ld\n", regs.VertSyncStart & 0xff); 844 DPRINTK("CRT10: %d\n", vsyncstart & 0xff);
1004 vga_wcrt(regbase, VGA_CRTC_V_SYNC_START, regs.VertSyncStart & 0xff); 845 vga_wcrt(regbase, VGA_CRTC_V_SYNC_START, vsyncstart & 0xff);
1005 846
1006 DPRINTK("CRT11: 64+32+%ld\n", regs.VertSyncEnd % 16); 847 DPRINTK("CRT11: 64+32+%d\n", vsyncend % 16);
1007 vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, regs.VertSyncEnd % 16 + 64 + 32); 848 vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, vsyncend % 16 + 64 + 32);
1008 849
1009 DPRINTK("CRT12: %ld\n", regs.VertDispEnd & 0xff); 850 DPRINTK("CRT12: %d\n", vdispend & 0xff);
1010 vga_wcrt(regbase, VGA_CRTC_V_DISP_END, regs.VertDispEnd & 0xff); 851 vga_wcrt(regbase, VGA_CRTC_V_DISP_END, vdispend & 0xff);
1011 852
1012 DPRINTK("CRT15: %ld\n", regs.VertBlankStart & 0xff); 853 DPRINTK("CRT15: %d\n", (vdispend + 1) & 0xff);
1013 vga_wcrt(regbase, VGA_CRTC_V_BLANK_START, regs.VertBlankStart & 0xff); 854 vga_wcrt(regbase, VGA_CRTC_V_BLANK_START, (vdispend + 1) & 0xff);
1014 855
1015 DPRINTK("CRT16: %ld\n", regs.VertBlankEnd & 0xff); 856 DPRINTK("CRT16: %d\n", vtotal & 0xff);
1016 vga_wcrt(regbase, VGA_CRTC_V_BLANK_END, regs.VertBlankEnd & 0xff); 857 vga_wcrt(regbase, VGA_CRTC_V_BLANK_END, vtotal & 0xff);
1017 858
1018 DPRINTK("CRT18: 0xff\n"); 859 DPRINTK("CRT18: 0xff\n");
1019 vga_wcrt(regbase, VGA_CRTC_LINE_COMPARE, 0xff); 860 vga_wcrt(regbase, VGA_CRTC_LINE_COMPARE, 0xff);
@@ -1021,38 +862,53 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
1021 tmp = 0; 862 tmp = 0;
1022 if (var->vmode & FB_VMODE_INTERLACED) 863 if (var->vmode & FB_VMODE_INTERLACED)
1023 tmp |= 1; 864 tmp |= 1;
1024 if (regs.HorizBlankEnd & 64) 865 if ((htotal + 5) & 64)
1025 tmp |= 16; 866 tmp |= 16;
1026 if (regs.HorizBlankEnd & 128) 867 if ((htotal + 5) & 128)
1027 tmp |= 32; 868 tmp |= 32;
1028 if (regs.VertBlankEnd & 256) 869 if (vtotal & 256)
1029 tmp |= 64; 870 tmp |= 64;
1030 if (regs.VertBlankEnd & 512) 871 if (vtotal & 512)
1031 tmp |= 128; 872 tmp |= 128;
1032 873
1033 DPRINTK("CRT1a: %d\n", tmp); 874 DPRINTK("CRT1a: %d\n", tmp);
1034 vga_wcrt(regbase, CL_CRT1A, tmp); 875 vga_wcrt(regbase, CL_CRT1A, tmp);
1035 876
877 freq = PICOS2KHZ(var->pixclock);
878 bestclock(freq, &nom, &den, &div);
879
1036 /* set VCLK0 */ 880 /* set VCLK0 */
1037 /* hardware RefClock: 14.31818 MHz */ 881 /* hardware RefClock: 14.31818 MHz */
1038 /* formula: VClk = (OSC * N) / (D * (1+P)) */ 882 /* formula: VClk = (OSC * N) / (D * (1+P)) */
1039 /* Example: VClk = (14.31818 * 91) / (23 * (1+1)) = 28.325 MHz */ 883 /* Example: VClk = (14.31818 * 91) / (23 * (1+1)) = 28.325 MHz */
1040 884
1041 vga_wseq(regbase, CL_SEQRB, regs.nom); 885 if (cinfo->btype == BT_ALPINE) {
1042 tmp = regs.den << 1; 886 /* if freq is close to mclk or mclk/2 select mclk
1043 if (regs.div != 0) 887 * as clock source
1044 tmp |= 1; 888 */
889 int divMCLK = cirrusfb_check_mclk(cinfo, freq);
890 if (divMCLK) {
891 nom = 0;
892 cirrusfb_set_mclk_as_source(cinfo, divMCLK);
893 }
894 }
895 if (nom) {
896 vga_wseq(regbase, CL_SEQRB, nom);
897 tmp = den << 1;
898 if (div != 0)
899 tmp |= 1;
1045 900
1046 /* 6 bit denom; ONLY 5434!!! (bugged me 10 days) */ 901 /* 6 bit denom; ONLY 5434!!! (bugged me 10 days) */
1047 if ((cinfo->btype == BT_SD64) || 902 if ((cinfo->btype == BT_SD64) ||
1048 (cinfo->btype == BT_ALPINE) || 903 (cinfo->btype == BT_ALPINE) ||
1049 (cinfo->btype == BT_GD5480)) 904 (cinfo->btype == BT_GD5480))
1050 tmp |= 0x80; 905 tmp |= 0x80;
1051 906
1052 DPRINTK("CL_SEQR1B: %ld\n", (long) tmp); 907 DPRINTK("CL_SEQR1B: %ld\n", (long) tmp);
1053 vga_wseq(regbase, CL_SEQR1B, tmp); 908 vga_wseq(regbase, CL_SEQR1B, tmp);
909 }
1054 910
1055 if (regs.VertRes >= 1024) 911 if (yres >= 1024)
1056 /* 1280x1024 */ 912 /* 1280x1024 */
1057 vga_wcrt(regbase, VGA_CRTC_MODE, 0xc7); 913 vga_wcrt(regbase, VGA_CRTC_MODE, 0xc7);
1058 else 914 else
@@ -1066,7 +922,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
1066 /* don't know if it would hurt to also program this if no interlaced */ 922 /* don't know if it would hurt to also program this if no interlaced */
1067 /* mode is used, but I feel better this way.. :-) */ 923 /* mode is used, but I feel better this way.. :-) */
1068 if (var->vmode & FB_VMODE_INTERLACED) 924 if (var->vmode & FB_VMODE_INTERLACED)
1069 vga_wcrt(regbase, VGA_CRTC_REGS, regs.HorizTotal / 2); 925 vga_wcrt(regbase, VGA_CRTC_REGS, htotal / 2);
1070 else 926 else
1071 vga_wcrt(regbase, VGA_CRTC_REGS, 0x00); /* interlace control */ 927 vga_wcrt(regbase, VGA_CRTC_REGS, 0x00); /* interlace control */
1072 928
@@ -1240,7 +1096,6 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
1240 1096
1241 case BT_ALPINE: 1097 case BT_ALPINE:
1242 DPRINTK(" (for GD543x)\n"); 1098 DPRINTK(" (for GD543x)\n");
1243 cirrusfb_set_mclk(cinfo, regs.mclk, regs.divMCLK);
1244 /* We already set SRF and SR1F */ 1099 /* We already set SRF and SR1F */
1245 break; 1100 break;
1246 1101
@@ -1312,11 +1167,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
1312 1167
1313 case BT_ALPINE: 1168 case BT_ALPINE:
1314 DPRINTK(" (for GD543x)\n"); 1169 DPRINTK(" (for GD543x)\n");
1315 if (regs.HorizRes >= 1024) 1170 vga_wseq(regbase, CL_SEQR7, 0xa7);
1316 vga_wseq(regbase, CL_SEQR7, 0xa7);
1317 else
1318 vga_wseq(regbase, CL_SEQR7, 0xa3);
1319 cirrusfb_set_mclk(cinfo, regs.mclk, regs.divMCLK);
1320 break; 1171 break;
1321 1172
1322 case BT_GD5480: 1173 case BT_GD5480:
@@ -1360,7 +1211,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
1360 */ 1211 */
1361 1212
1362 else if (var->bits_per_pixel == 32) { 1213 else if (var->bits_per_pixel == 32) {
1363 DPRINTK("cirrusfb: preparing for 24/32 bit deep display\n"); 1214 DPRINTK("cirrusfb: preparing for 32 bit deep display\n");
1364 switch (cinfo->btype) { 1215 switch (cinfo->btype) {
1365 case BT_SD64: 1216 case BT_SD64:
1366 /* Extended Sequencer Mode: 256c col. mode */ 1217 /* Extended Sequencer Mode: 256c col. mode */
@@ -1394,7 +1245,6 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
1394 case BT_ALPINE: 1245 case BT_ALPINE:
1395 DPRINTK(" (for GD543x)\n"); 1246 DPRINTK(" (for GD543x)\n");
1396 vga_wseq(regbase, CL_SEQR7, 0xa9); 1247 vga_wseq(regbase, CL_SEQR7, 0xa9);
1397 cirrusfb_set_mclk(cinfo, regs.mclk, regs.divMCLK);
1398 break; 1248 break;
1399 1249
1400 case BT_GD5480: 1250 case BT_GD5480:
@@ -1949,8 +1799,6 @@ static void init_vgachip(struct fb_info *info)
1949 /* misc... */ 1799 /* misc... */
1950 WHDR(cinfo, 0); /* Hidden DAC register: - */ 1800 WHDR(cinfo, 0); /* Hidden DAC register: - */
1951 1801
1952 printk(KERN_DEBUG "cirrusfb: This board has %ld bytes of DRAM memory\n",
1953 info->screen_size);
1954 DPRINTK("EXIT\n"); 1802 DPRINTK("EXIT\n");
1955 return; 1803 return;
1956} 1804}
@@ -2122,7 +1970,7 @@ static int release_io_ports;
2122 * based on the DRAM bandwidth bit and DRAM bank switching bit. This 1970 * based on the DRAM bandwidth bit and DRAM bank switching bit. This
2123 * works with 1MB, 2MB and 4MB configurations (which the Motorola boards 1971 * works with 1MB, 2MB and 4MB configurations (which the Motorola boards
2124 * seem to have. */ 1972 * seem to have. */
2125static unsigned int cirrusfb_get_memsize(u8 __iomem *regbase) 1973static unsigned int __devinit cirrusfb_get_memsize(u8 __iomem *regbase)
2126{ 1974{
2127 unsigned long mem; 1975 unsigned long mem;
2128 unsigned char SRF; 1976 unsigned char SRF;
@@ -2188,8 +2036,7 @@ static void get_pci_addrs(const struct pci_dev *pdev,
2188 2036
2189static void cirrusfb_pci_unmap(struct fb_info *info) 2037static void cirrusfb_pci_unmap(struct fb_info *info)
2190{ 2038{
2191 struct cirrusfb_info *cinfo = info->par; 2039 struct pci_dev *pdev = to_pci_dev(info->device);
2192 struct pci_dev *pdev = cinfo->pdev;
2193 2040
2194 iounmap(info->screen_base); 2041 iounmap(info->screen_base);
2195#if 0 /* if system didn't claim this region, we would... */ 2042#if 0 /* if system didn't claim this region, we would... */
@@ -2205,20 +2052,22 @@ static void cirrusfb_pci_unmap(struct fb_info *info)
2205static void __devexit cirrusfb_zorro_unmap(struct fb_info *info) 2052static void __devexit cirrusfb_zorro_unmap(struct fb_info *info)
2206{ 2053{
2207 struct cirrusfb_info *cinfo = info->par; 2054 struct cirrusfb_info *cinfo = info->par;
2208 zorro_release_device(cinfo->zdev); 2055 struct zorro_dev *zdev = to_zorro_dev(info->device);
2056
2057 zorro_release_device(zdev);
2209 2058
2210 if (cinfo->btype == BT_PICASSO4) { 2059 if (cinfo->btype == BT_PICASSO4) {
2211 cinfo->regbase -= 0x600000; 2060 cinfo->regbase -= 0x600000;
2212 iounmap((void *)cinfo->regbase); 2061 iounmap((void *)cinfo->regbase);
2213 iounmap(info->screen_base); 2062 iounmap(info->screen_base);
2214 } else { 2063 } else {
2215 if (zorro_resource_start(cinfo->zdev) > 0x01000000) 2064 if (zorro_resource_start(zdev) > 0x01000000)
2216 iounmap(info->screen_base); 2065 iounmap(info->screen_base);
2217 } 2066 }
2218} 2067}
2219#endif /* CONFIG_ZORRO */ 2068#endif /* CONFIG_ZORRO */
2220 2069
2221static int cirrusfb_set_fbinfo(struct fb_info *info) 2070static int __devinit cirrusfb_set_fbinfo(struct fb_info *info)
2222{ 2071{
2223 struct cirrusfb_info *cinfo = info->par; 2072 struct cirrusfb_info *cinfo = info->par;
2224 struct fb_var_screeninfo *var = &info->var; 2073 struct fb_var_screeninfo *var = &info->var;
@@ -2235,7 +2084,7 @@ static int cirrusfb_set_fbinfo(struct fb_info *info)
2235 if (cinfo->btype == BT_GD5480) { 2084 if (cinfo->btype == BT_GD5480) {
2236 if (var->bits_per_pixel == 16) 2085 if (var->bits_per_pixel == 16)
2237 info->screen_base += 1 * MB_; 2086 info->screen_base += 1 * MB_;
2238 if (var->bits_per_pixel == 24 || var->bits_per_pixel == 32) 2087 if (var->bits_per_pixel == 32)
2239 info->screen_base += 2 * MB_; 2088 info->screen_base += 2 * MB_;
2240 } 2089 }
2241 2090
@@ -2262,7 +2111,7 @@ static int cirrusfb_set_fbinfo(struct fb_info *info)
2262 return 0; 2111 return 0;
2263} 2112}
2264 2113
2265static int cirrusfb_register(struct fb_info *info) 2114static int __devinit cirrusfb_register(struct fb_info *info)
2266{ 2115{
2267 struct cirrusfb_info *cinfo = info->par; 2116 struct cirrusfb_info *cinfo = info->par;
2268 int err; 2117 int err;
@@ -2278,23 +2127,27 @@ static int cirrusfb_register(struct fb_info *info)
2278 /* sanity checks */ 2127 /* sanity checks */
2279 assert(btype != BT_NONE); 2128 assert(btype != BT_NONE);
2280 2129
2130 /* set all the vital stuff */
2131 cirrusfb_set_fbinfo(info);
2132
2281 DPRINTK("cirrusfb: (RAM start set to: 0x%p)\n", info->screen_base); 2133 DPRINTK("cirrusfb: (RAM start set to: 0x%p)\n", info->screen_base);
2282 2134
2283 /* Make pretend we've set the var so our structures are in a "good" */ 2135 err = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
2284 /* state, even though we haven't written the mode to the hw yet... */ 2136 if (!err) {
2285 info->var = cirrusfb_predefined[cirrusfb_def_mode].var; 2137 DPRINTK("wrong initial video mode\n");
2138 err = -EINVAL;
2139 goto err_dealloc_cmap;
2140 }
2141
2286 info->var.activate = FB_ACTIVATE_NOW; 2142 info->var.activate = FB_ACTIVATE_NOW;
2287 2143
2288 err = cirrusfb_decode_var(&info->var, &cinfo->currentmode, info); 2144 err = cirrusfb_decode_var(&info->var, &cinfo->currentmode, info);
2289 if (err < 0) { 2145 if (err < 0) {
2290 /* should never happen */ 2146 /* should never happen */
2291 DPRINTK("choking on default var... umm, no good.\n"); 2147 DPRINTK("choking on default var... umm, no good.\n");
2292 goto err_unmap_cirrusfb; 2148 goto err_dealloc_cmap;
2293 } 2149 }
2294 2150
2295 /* set all the vital stuff */
2296 cirrusfb_set_fbinfo(info);
2297
2298 err = register_framebuffer(info); 2151 err = register_framebuffer(info);
2299 if (err < 0) { 2152 if (err < 0) {
2300 printk(KERN_ERR "cirrusfb: could not register " 2153 printk(KERN_ERR "cirrusfb: could not register "
@@ -2307,7 +2160,6 @@ static int cirrusfb_register(struct fb_info *info)
2307 2160
2308err_dealloc_cmap: 2161err_dealloc_cmap:
2309 fb_dealloc_cmap(&info->cmap); 2162 fb_dealloc_cmap(&info->cmap);
2310err_unmap_cirrusfb:
2311 cinfo->unmap(info); 2163 cinfo->unmap(info);
2312 framebuffer_release(info); 2164 framebuffer_release(info);
2313 return err; 2165 return err;
@@ -2330,8 +2182,8 @@ static void __devexit cirrusfb_cleanup(struct fb_info *info)
2330} 2182}
2331 2183
2332#ifdef CONFIG_PCI 2184#ifdef CONFIG_PCI
2333static int cirrusfb_pci_register(struct pci_dev *pdev, 2185static int __devinit cirrusfb_pci_register(struct pci_dev *pdev,
2334 const struct pci_device_id *ent) 2186 const struct pci_device_id *ent)
2335{ 2187{
2336 struct cirrusfb_info *cinfo; 2188 struct cirrusfb_info *cinfo;
2337 struct fb_info *info; 2189 struct fb_info *info;
@@ -2353,7 +2205,6 @@ static int cirrusfb_pci_register(struct pci_dev *pdev,
2353 } 2205 }
2354 2206
2355 cinfo = info->par; 2207 cinfo = info->par;
2356 cinfo->pdev = pdev;
2357 cinfo->btype = btype = (enum cirrus_board) ent->driver_data; 2208 cinfo->btype = btype = (enum cirrus_board) ent->driver_data;
2358 2209
2359 DPRINTK(" Found PCI device, base address 0 is 0x%x, btype set to %d\n", 2210 DPRINTK(" Found PCI device, base address 0 is 0x%x, btype set to %d\n",
@@ -2459,8 +2310,8 @@ static struct pci_driver cirrusfb_pci_driver = {
2459#endif /* CONFIG_PCI */ 2310#endif /* CONFIG_PCI */
2460 2311
2461#ifdef CONFIG_ZORRO 2312#ifdef CONFIG_ZORRO
2462static int cirrusfb_zorro_register(struct zorro_dev *z, 2313static int __devinit cirrusfb_zorro_register(struct zorro_dev *z,
2463 const struct zorro_device_id *ent) 2314 const struct zorro_device_id *ent)
2464{ 2315{
2465 struct cirrusfb_info *cinfo; 2316 struct cirrusfb_info *cinfo;
2466 struct fb_info *info; 2317 struct fb_info *info;
@@ -2489,7 +2340,6 @@ static int cirrusfb_zorro_register(struct zorro_dev *z,
2489 assert(z); 2340 assert(z);
2490 assert(btype != BT_NONE); 2341 assert(btype != BT_NONE);
2491 2342
2492 cinfo->zdev = z;
2493 board_addr = zorro_resource_start(z); 2343 board_addr = zorro_resource_start(z);
2494 board_size = zorro_resource_len(z); 2344 board_size = zorro_resource_len(z);
2495 info->screen_size = size; 2345 info->screen_size = size;
@@ -2621,17 +2471,17 @@ static int __init cirrusfb_setup(char *options) {
2621 return 0; 2471 return 0;
2622 2472
2623 while ((this_opt = strsep(&options, ",")) != NULL) { 2473 while ((this_opt = strsep(&options, ",")) != NULL) {
2624 if (!*this_opt) continue; 2474 if (!*this_opt)
2475 continue;
2625 2476
2626 DPRINTK("cirrusfb_setup: option '%s'\n", this_opt); 2477 DPRINTK("cirrusfb_setup: option '%s'\n", this_opt);
2627 2478
2628 for (i = 0; i < NUM_TOTAL_MODES; i++) {
2629 sprintf(s, "mode:%s", cirrusfb_predefined[i].name);
2630 if (strcmp(this_opt, s) == 0)
2631 cirrusfb_def_mode = i;
2632 }
2633 if (!strcmp(this_opt, "noaccel")) 2479 if (!strcmp(this_opt, "noaccel"))
2634 noaccel = 1; 2480 noaccel = 1;
2481 else if (!strncmp(this_opt, "mode:", 5))
2482 mode_option = this_opt + 5;
2483 else
2484 mode_option = this_opt;
2635 } 2485 }
2636 return 0; 2486 return 0;
2637} 2487}
@@ -2657,6 +2507,11 @@ static void __exit cirrusfb_exit(void)
2657 2507
2658module_init(cirrusfb_init); 2508module_init(cirrusfb_init);
2659 2509
2510module_param(mode_option, charp, 0);
2511MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");
2512module_param(noaccel, bool, 0);
2513MODULE_PARM_DESC(noaccel, "Disable acceleration");
2514
2660#ifdef MODULE 2515#ifdef MODULE
2661module_exit(cirrusfb_exit); 2516module_exit(cirrusfb_exit);
2662#endif 2517#endif
@@ -3050,16 +2905,14 @@ static void cirrusfb_RectFill(u8 __iomem *regbase, int bits_per_pixel,
3050 * bestclock() - determine closest possible clock lower(?) than the 2905 * bestclock() - determine closest possible clock lower(?) than the
3051 * desired pixel clock 2906 * desired pixel clock
3052 **************************************************************************/ 2907 **************************************************************************/
3053static void bestclock(long freq, long *best, long *nom, 2908static void bestclock(long freq, int *nom, int *den, int *div)
3054 long *den, long *div, long maxfreq)
3055{ 2909{
3056 long n, h, d, f; 2910 int n, d;
2911 long h, diff;
3057 2912
3058 assert(best != NULL);
3059 assert(nom != NULL); 2913 assert(nom != NULL);
3060 assert(den != NULL); 2914 assert(den != NULL);
3061 assert(div != NULL); 2915 assert(div != NULL);
3062 assert(maxfreq > 0);
3063 2916
3064 *nom = 0; 2917 *nom = 0;
3065 *den = 0; 2918 *den = 0;
@@ -3070,51 +2923,47 @@ static void bestclock(long freq, long *best, long *nom,
3070 if (freq < 8000) 2923 if (freq < 8000)
3071 freq = 8000; 2924 freq = 8000;
3072 2925
3073 if (freq > maxfreq) 2926 diff = freq;
3074 freq = maxfreq;
3075
3076 *best = 0;
3077 f = freq * 10;
3078 2927
3079 for (n = 32; n < 128; n++) { 2928 for (n = 32; n < 128; n++) {
3080 d = (143181 * n) / f; 2929 int s = 0;
2930
2931 d = (14318 * n) / freq;
3081 if ((d >= 7) && (d <= 63)) { 2932 if ((d >= 7) && (d <= 63)) {
3082 if (d > 31) 2933 int temp = d;
3083 d = (d / 2) * 2; 2934
3084 h = (14318 * n) / d; 2935 if (temp > 31) {
3085 if (abs(h - freq) < abs(*best - freq)) { 2936 s = 1;
3086 *best = h; 2937 temp >>= 1;
2938 }
2939 h = ((14318 * n) / temp) >> s;
2940 h = h > freq ? h - freq : freq - h;
2941 if (h < diff) {
2942 diff = h;
3087 *nom = n; 2943 *nom = n;
3088 if (d < 32) { 2944 *den = temp;
3089 *den = d; 2945 *div = s;
3090 *div = 0;
3091 } else {
3092 *den = d / 2;
3093 *div = 1;
3094 }
3095 } 2946 }
3096 } 2947 }
3097 d = DIV_ROUND_UP(143181 * n, f); 2948 d++;
3098 if ((d >= 7) && (d <= 63)) { 2949 if ((d >= 7) && (d <= 63)) {
3099 if (d > 31) 2950 if (d > 31) {
3100 d = (d / 2) * 2; 2951 s = 1;
3101 h = (14318 * n) / d; 2952 d >>= 1;
3102 if (abs(h - freq) < abs(*best - freq)) { 2953 }
3103 *best = h; 2954 h = ((14318 * n) / d) >> s;
2955 h = h > freq ? h - freq : freq - h;
2956 if (h < diff) {
2957 diff = h;
3104 *nom = n; 2958 *nom = n;
3105 if (d < 32) { 2959 *den = d;
3106 *den = d; 2960 *div = s;
3107 *div = 0;
3108 } else {
3109 *den = d / 2;
3110 *div = 1;
3111 }
3112 } 2961 }
3113 } 2962 }
3114 } 2963 }
3115 2964
3116 DPRINTK("Best possible values for given frequency:\n"); 2965 DPRINTK("Best possible values for given frequency:\n");
3117 DPRINTK(" best: %ld kHz nom: %ld den: %ld div: %ld\n", 2966 DPRINTK(" freq: %ld kHz nom: %d den: %d div: %d\n",
3118 freq, *nom, *den, *div); 2967 freq, *nom, *den, *div);
3119 2968
3120 DPRINTK("EXIT\n"); 2969 DPRINTK("EXIT\n");
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index da91bb16da8a..64b3d30027b8 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2977,8 +2977,8 @@ static void fbcon_set_all_vcs(struct fb_info *info)
2977 p = &fb_display[vc->vc_num]; 2977 p = &fb_display[vc->vc_num];
2978 set_blitting_type(vc, info); 2978 set_blitting_type(vc, info);
2979 var_to_display(p, &info->var, info); 2979 var_to_display(p, &info->var, info);
2980 cols = FBCON_SWAP(p->rotate, info->var.xres, info->var.yres); 2980 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2981 rows = FBCON_SWAP(p->rotate, info->var.yres, info->var.xres); 2981 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2982 cols /= vc->vc_font.width; 2982 cols /= vc->vc_font.width;
2983 rows /= vc->vc_font.height; 2983 rows /= vc->vc_font.height;
2984 vc_resize(vc, cols, rows); 2984 vc_resize(vc, cols, rows);
@@ -3573,8 +3573,8 @@ static int __init fb_console_init(void)
3573 3573
3574 acquire_console_sem(); 3574 acquire_console_sem();
3575 fb_register_client(&fbcon_event_notifier); 3575 fb_register_client(&fbcon_event_notifier);
3576 fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0), 3576 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3577 NULL, "fbcon"); 3577 "fbcon");
3578 3578
3579 if (IS_ERR(fbcon_device)) { 3579 if (IS_ERR(fbcon_device)) {
3580 printk(KERN_WARNING "Unable to create device " 3580 printk(KERN_WARNING "Unable to create device "
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 6df29a62d720..448d209a0bf2 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -239,8 +239,7 @@ static void vgacon_restore_screen(struct vc_data *c)
239 239
240static int vgacon_scrolldelta(struct vc_data *c, int lines) 240static int vgacon_scrolldelta(struct vc_data *c, int lines)
241{ 241{
242 int start, end, count, soff, diff; 242 int start, end, count, soff;
243 void *d, *s;
244 243
245 if (!lines) { 244 if (!lines) {
246 c->vc_visible_origin = c->vc_origin; 245 c->vc_visible_origin = c->vc_origin;
@@ -287,29 +286,29 @@ static int vgacon_scrolldelta(struct vc_data *c, int lines)
287 if (count > c->vc_rows) 286 if (count > c->vc_rows)
288 count = c->vc_rows; 287 count = c->vc_rows;
289 288
290 diff = c->vc_rows - count; 289 if (count) {
290 int copysize;
291 291
292 d = (void *) c->vc_origin; 292 int diff = c->vc_rows - count;
293 s = (void *) c->vc_screenbuf; 293 void *d = (void *) c->vc_origin;
294 void *s = (void *) c->vc_screenbuf;
294 295
295 while (count--) { 296 count *= c->vc_size_row;
296 scr_memcpyw(d, vgacon_scrollback + soff, c->vc_size_row); 297 /* how much memory to end of buffer left? */
297 d += c->vc_size_row; 298 copysize = min(count, vgacon_scrollback_size - soff);
298 soff += c->vc_size_row; 299 scr_memcpyw(d, vgacon_scrollback + soff, copysize);
300 d += copysize;
301 count -= copysize;
299 302
300 if (soff >= vgacon_scrollback_size) 303 if (count) {
301 soff = 0; 304 scr_memcpyw(d, vgacon_scrollback, count);
302 } 305 d += count;
306 }
303 307
304 if (diff == c->vc_rows) { 308 if (diff)
309 scr_memcpyw(d, s, diff * c->vc_size_row);
310 } else
305 vgacon_cursor(c, CM_MOVE); 311 vgacon_cursor(c, CM_MOVE);
306 } else {
307 while (diff--) {
308 scr_memcpyw(d, s, c->vc_size_row);
309 d += c->vc_size_row;
310 s += c->vc_size_row;
311 }
312 }
313 312
314 return 1; 313 return 1;
315} 314}
diff --git a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c
index 6ef800bdf482..4830b1bf51e5 100644
--- a/drivers/video/display/display-sysfs.c
+++ b/drivers/video/display/display-sysfs.c
@@ -153,12 +153,9 @@ struct display_device *display_device_register(struct display_driver *driver,
153 mutex_unlock(&allocated_dsp_lock); 153 mutex_unlock(&allocated_dsp_lock);
154 154
155 if (!ret) { 155 if (!ret) {
156 new_dev->dev = device_create_drvdata(display_class, 156 new_dev->dev = device_create(display_class, parent,
157 parent, 157 MKDEV(0, 0), new_dev,
158 MKDEV(0,0), 158 "display%d", new_dev->idx);
159 new_dev,
160 "display%d",
161 new_dev->idx);
162 if (!IS_ERR(new_dev->dev)) { 159 if (!IS_ERR(new_dev->dev)) {
163 new_dev->parent = parent; 160 new_dev->parent = parent;
164 new_dev->driver = driver; 161 new_dev->driver = driver;
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index bd779ae44b1e..daf9b81878a4 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -12,6 +12,7 @@
12#include <linux/fb.h> 12#include <linux/fb.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/screen_info.h> 14#include <linux/screen_info.h>
15#include <linux/dmi.h>
15 16
16#include <video/vga.h> 17#include <video/vga.h>
17 18
@@ -33,6 +34,105 @@ static struct fb_fix_screeninfo efifb_fix __initdata = {
33 .visual = FB_VISUAL_TRUECOLOR, 34 .visual = FB_VISUAL_TRUECOLOR,
34}; 35};
35 36
37enum {
38 M_I17, /* 17-Inch iMac */
39 M_I20, /* 20-Inch iMac */
40 M_I20_SR, /* 20-Inch iMac (Santa Rosa) */
41 M_I24, /* 24-Inch iMac */
42 M_MINI, /* Mac Mini */
43 M_MB, /* MacBook */
44 M_MB_2, /* MacBook, 2nd rev. */
45 M_MB_3, /* MacBook, 3rd rev. */
46 M_MB_SR, /* MacBook, 2nd gen, (Santa Rosa) */
47 M_MBA, /* MacBook Air */
48 M_MBP, /* MacBook Pro */
49 M_MBP_2, /* MacBook Pro 2nd gen */
50 M_MBP_SR, /* MacBook Pro (Santa Rosa) */
51 M_MBP_4, /* MacBook Pro, 4th gen */
52 M_UNKNOWN /* placeholder */
53};
54
55static struct efifb_dmi_info {
56 char *optname;
57 unsigned long base;
58 int stride;
59 int width;
60 int height;
61} dmi_list[] = {
62 [M_I17] = { "i17", 0x80010000, 1472 * 4, 1440, 900 },
63 [M_I20] = { "i20", 0x80010000, 1728 * 4, 1680, 1050 }, /* guess */
64 [M_I20_SR] = { "imac7", 0x40010000, 1728 * 4, 1680, 1050 },
65 [M_I24] = { "i24", 0x80010000, 2048 * 4, 1920, 1200 }, /* guess */
66 [M_MINI]= { "mini", 0x80000000, 2048 * 4, 1024, 768 },
67 [M_MB] = { "macbook", 0x80000000, 2048 * 4, 1280, 800 },
68 [M_MBA] = { "mba", 0x80000000, 2048 * 4, 1280, 800 },
69 [M_MBP] = { "mbp", 0x80010000, 1472 * 4, 1440, 900 },
70 [M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */
71 [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 },
72 [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200 },
73 [M_UNKNOWN] = { NULL, 0, 0, 0, 0 }
74};
75
76static int set_system(const struct dmi_system_id *id);
77
78#define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \
79 { set_system, name, { \
80 DMI_MATCH(DMI_BIOS_VENDOR, vendor), \
81 DMI_MATCH(DMI_PRODUCT_NAME, name) }, \
82 &dmi_list[enumid] }
83
84static struct dmi_system_id __initdata dmi_system_table[] = {
85 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17),
86 /* At least one of these two will be right; maybe both? */
87 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac5,1", M_I20),
88 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac5,1", M_I20),
89 /* At least one of these two will be right; maybe both? */
90 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac6,1", M_I24),
91 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac6,1", M_I24),
92 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac7,1", M_I20_SR),
93 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "Macmini1,1", M_MINI),
94 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook1,1", M_MB),
95 /* At least one of these two will be right; maybe both? */
96 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook2,1", M_MB),
97 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook2,1", M_MB),
98 /* At least one of these two will be right; maybe both? */
99 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook3,1", M_MB),
100 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook3,1", M_MB),
101 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook4,1", M_MB),
102 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir1,1", M_MBA),
103 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro1,1", M_MBP),
104 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,1", M_MBP_2),
105 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro2,1", M_MBP_2),
106 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR),
107 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR),
108 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4),
109 {},
110};
111
112static int set_system(const struct dmi_system_id *id)
113{
114 struct efifb_dmi_info *info = id->driver_data;
115 if (info->base == 0)
116 return -ENODEV;
117
118 printk(KERN_INFO "efifb: dmi detected %s - framebuffer at %p "
119 "(%dx%d, stride %d)\n", id->ident,
120 (void *)info->base, info->width, info->height,
121 info->stride);
122
123 /* Trust the bootloader over the DMI tables */
124 if (screen_info.lfb_base == 0)
125 screen_info.lfb_base = info->base;
126 if (screen_info.lfb_linelength == 0)
127 screen_info.lfb_linelength = info->stride;
128 if (screen_info.lfb_width == 0)
129 screen_info.lfb_width = info->width;
130 if (screen_info.lfb_height == 0)
131 screen_info.lfb_height = info->height;
132
133 return 0;
134}
135
36static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green, 136static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
37 unsigned blue, unsigned transp, 137 unsigned blue, unsigned transp,
38 struct fb_info *info) 138 struct fb_info *info)
@@ -67,6 +167,38 @@ static struct fb_ops efifb_ops = {
67 .fb_imageblit = cfb_imageblit, 167 .fb_imageblit = cfb_imageblit,
68}; 168};
69 169
170static int __init efifb_setup(char *options)
171{
172 char *this_opt;
173 int i;
174
175 if (!options || !*options)
176 return 0;
177
178 while ((this_opt = strsep(&options, ",")) != NULL) {
179 if (!*this_opt) continue;
180
181 for (i = 0; i < M_UNKNOWN; i++) {
182 if (!strcmp(this_opt, dmi_list[i].optname) &&
183 dmi_list[i].base != 0) {
184 screen_info.lfb_base = dmi_list[i].base;
185 screen_info.lfb_linelength = dmi_list[i].stride;
186 screen_info.lfb_width = dmi_list[i].width;
187 screen_info.lfb_height = dmi_list[i].height;
188 }
189 }
190 if (!strncmp(this_opt, "base:", 5))
191 screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
192 else if (!strncmp(this_opt, "stride:", 7))
193 screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
194 else if (!strncmp(this_opt, "height:", 7))
195 screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
196 else if (!strncmp(this_opt, "width:", 6))
197 screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
198 }
199 return 0;
200}
201
70static int __init efifb_probe(struct platform_device *dev) 202static int __init efifb_probe(struct platform_device *dev)
71{ 203{
72 struct fb_info *info; 204 struct fb_info *info;
@@ -74,6 +206,26 @@ static int __init efifb_probe(struct platform_device *dev)
74 unsigned int size_vmode; 206 unsigned int size_vmode;
75 unsigned int size_remap; 207 unsigned int size_remap;
76 unsigned int size_total; 208 unsigned int size_total;
209 int request_succeeded = 0;
210
211 printk(KERN_INFO "efifb: probing for efifb\n");
212
213 if (!screen_info.lfb_depth)
214 screen_info.lfb_depth = 32;
215 if (!screen_info.pages)
216 screen_info.pages = 1;
217
218 /* just assume they're all unset if any are */
219 if (!screen_info.blue_size) {
220 screen_info.blue_size = 8;
221 screen_info.blue_pos = 0;
222 screen_info.green_size = 8;
223 screen_info.green_pos = 8;
224 screen_info.red_size = 8;
225 screen_info.red_pos = 16;
226 screen_info.rsvd_size = 8;
227 screen_info.rsvd_pos = 24;
228 }
77 229
78 efifb_fix.smem_start = screen_info.lfb_base; 230 efifb_fix.smem_start = screen_info.lfb_base;
79 efifb_defined.bits_per_pixel = screen_info.lfb_depth; 231 efifb_defined.bits_per_pixel = screen_info.lfb_depth;
@@ -98,21 +250,25 @@ static int __init efifb_probe(struct platform_device *dev)
98 * option to simply use size_total as that 250 * option to simply use size_total as that
99 * wastes plenty of kernel address space. */ 251 * wastes plenty of kernel address space. */
100 size_remap = size_vmode * 2; 252 size_remap = size_vmode * 2;
101 if (size_remap < size_vmode)
102 size_remap = size_vmode;
103 if (size_remap > size_total) 253 if (size_remap > size_total)
104 size_remap = size_total; 254 size_remap = size_total;
255 if (size_remap % PAGE_SIZE)
256 size_remap += PAGE_SIZE - (size_remap % PAGE_SIZE);
105 efifb_fix.smem_len = size_remap; 257 efifb_fix.smem_len = size_remap;
106 258
107 if (!request_mem_region(efifb_fix.smem_start, size_total, "efifb")) 259 if (request_mem_region(efifb_fix.smem_start, size_remap, "efifb")) {
260 request_succeeded = 1;
261 } else {
108 /* We cannot make this fatal. Sometimes this comes from magic 262 /* We cannot make this fatal. Sometimes this comes from magic
109 spaces our resource handlers simply don't know about */ 263 spaces our resource handlers simply don't know about */
110 printk(KERN_WARNING 264 printk(KERN_WARNING
111 "efifb: cannot reserve video memory at 0x%lx\n", 265 "efifb: cannot reserve video memory at 0x%lx\n",
112 efifb_fix.smem_start); 266 efifb_fix.smem_start);
267 }
113 268
114 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev); 269 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
115 if (!info) { 270 if (!info) {
271 printk(KERN_ERR "efifb: cannot allocate framebuffer\n");
116 err = -ENOMEM; 272 err = -ENOMEM;
117 goto err_release_mem; 273 goto err_release_mem;
118 } 274 }
@@ -125,7 +281,7 @@ static int __init efifb_probe(struct platform_device *dev)
125 "0x%x @ 0x%lx\n", 281 "0x%x @ 0x%lx\n",
126 efifb_fix.smem_len, efifb_fix.smem_start); 282 efifb_fix.smem_len, efifb_fix.smem_start);
127 err = -EIO; 283 err = -EIO;
128 goto err_unmap; 284 goto err_release_fb;
129 } 285 }
130 286
131 printk(KERN_INFO "efifb: framebuffer at 0x%lx, mapped to 0x%p, " 287 printk(KERN_INFO "efifb: framebuffer at 0x%lx, mapped to 0x%p, "
@@ -178,25 +334,27 @@ static int __init efifb_probe(struct platform_device *dev)
178 info->fix = efifb_fix; 334 info->fix = efifb_fix;
179 info->flags = FBINFO_FLAG_DEFAULT; 335 info->flags = FBINFO_FLAG_DEFAULT;
180 336
181 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 337 if ((err = fb_alloc_cmap(&info->cmap, 256, 0)) < 0) {
182 err = -ENOMEM; 338 printk(KERN_ERR "efifb: cannot allocate colormap\n");
183 goto err_unmap; 339 goto err_unmap;
184 } 340 }
185 if (register_framebuffer(info) < 0) { 341 if ((err = register_framebuffer(info)) < 0) {
186 err = -EINVAL; 342 printk(KERN_ERR "efifb: cannot register framebuffer\n");
187 goto err_fb_dealoc; 343 goto err_fb_dealoc;
188 } 344 }
189 printk(KERN_INFO "fb%d: %s frame buffer device\n", 345 printk(KERN_INFO "fb%d: %s frame buffer device\n",
190 info->node, info->fix.id); 346 info->node, info->fix.id);
191 return 0; 347 return 0;
192 348
193err_fb_dealoc: 349err_fb_dealoc:
194 fb_dealloc_cmap(&info->cmap); 350 fb_dealloc_cmap(&info->cmap);
195err_unmap: 351err_unmap:
196 iounmap(info->screen_base); 352 iounmap(info->screen_base);
353err_release_fb:
197 framebuffer_release(info); 354 framebuffer_release(info);
198err_release_mem: 355err_release_mem:
199 release_mem_region(efifb_fix.smem_start, size_total); 356 if (request_succeeded)
357 release_mem_region(efifb_fix.smem_start, size_total);
200 return err; 358 return err;
201} 359}
202 360
@@ -214,9 +372,22 @@ static struct platform_device efifb_device = {
214static int __init efifb_init(void) 372static int __init efifb_init(void)
215{ 373{
216 int ret; 374 int ret;
375 char *option = NULL;
217 376
218 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) 377 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
219 return -ENODEV; 378 return -ENODEV;
379 dmi_check_system(dmi_system_table);
380
381 if (fb_get_options("efifb", &option))
382 return -ENODEV;
383 efifb_setup(option);
384
385 /* We don't get linelength from UGA Draw Protocol, only from
386 * EFI Graphics Protocol. So if it's not in DMI, and it's not
387 * passed in from the user, we really can't use the framebuffer.
388 */
389 if (!screen_info.lfb_linelength)
390 return -ENODEV;
220 391
221 ret = platform_driver_register(&efifb_driver); 392 ret = platform_driver_register(&efifb_driver);
222 393
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 0737570030f5..217c5118ae9e 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -28,9 +28,7 @@
28#include <linux/proc_fs.h> 28#include <linux/proc_fs.h>
29#include <linux/seq_file.h> 29#include <linux/seq_file.h>
30#include <linux/console.h> 30#include <linux/console.h>
31#ifdef CONFIG_KMOD
32#include <linux/kmod.h> 31#include <linux/kmod.h>
33#endif
34#include <linux/err.h> 32#include <linux/err.h>
35#include <linux/device.h> 33#include <linux/device.h>
36#include <linux/efi.h> 34#include <linux/efi.h>
@@ -837,13 +835,6 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
837 return (cnt) ? cnt : err; 835 return (cnt) ? cnt : err;
838} 836}
839 837
840#ifdef CONFIG_KMOD
841static void try_to_load(int fb)
842{
843 request_module("fb%d", fb);
844}
845#endif /* CONFIG_KMOD */
846
847int 838int
848fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var) 839fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
849{ 840{
@@ -1086,10 +1077,8 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
1086 return -EINVAL; 1077 return -EINVAL;
1087 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) 1078 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
1088 return -EINVAL; 1079 return -EINVAL;
1089#ifdef CONFIG_KMOD
1090 if (!registered_fb[con2fb.framebuffer]) 1080 if (!registered_fb[con2fb.framebuffer])
1091 try_to_load(con2fb.framebuffer); 1081 request_module("fb%d", con2fb.framebuffer);
1092#endif /* CONFIG_KMOD */
1093 if (!registered_fb[con2fb.framebuffer]) 1082 if (!registered_fb[con2fb.framebuffer])
1094 return -EINVAL; 1083 return -EINVAL;
1095 event.info = info; 1084 event.info = info;
@@ -1327,10 +1316,8 @@ fb_open(struct inode *inode, struct file *file)
1327 if (fbidx >= FB_MAX) 1316 if (fbidx >= FB_MAX)
1328 return -ENODEV; 1317 return -ENODEV;
1329 lock_kernel(); 1318 lock_kernel();
1330#ifdef CONFIG_KMOD
1331 if (!(info = registered_fb[fbidx])) 1319 if (!(info = registered_fb[fbidx]))
1332 try_to_load(fbidx); 1320 request_module("fb%d", fbidx);
1333#endif /* CONFIG_KMOD */
1334 if (!(info = registered_fb[fbidx])) { 1321 if (!(info = registered_fb[fbidx])) {
1335 res = -ENODEV; 1322 res = -ENODEV;
1336 goto out; 1323 goto out;
@@ -1443,9 +1430,8 @@ register_framebuffer(struct fb_info *fb_info)
1443 break; 1430 break;
1444 fb_info->node = i; 1431 fb_info->node = i;
1445 1432
1446 fb_info->dev = device_create_drvdata(fb_class, fb_info->device, 1433 fb_info->dev = device_create(fb_class, fb_info->device,
1447 MKDEV(FB_MAJOR, i), NULL, 1434 MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
1448 "fb%d", i);
1449 if (IS_ERR(fb_info->dev)) { 1435 if (IS_ERR(fb_info->dev)) {
1450 /* Not fatal */ 1436 /* Not fatal */
1451 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev)); 1437 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 6a0aa180c266..5c1a2c01778f 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -564,7 +564,13 @@ static void get_detailed_timing(unsigned char *block,
564 mode->sync |= FB_SYNC_VERT_HIGH_ACT; 564 mode->sync |= FB_SYNC_VERT_HIGH_ACT;
565 mode->refresh = PIXEL_CLOCK/((H_ACTIVE + H_BLANKING) * 565 mode->refresh = PIXEL_CLOCK/((H_ACTIVE + H_BLANKING) *
566 (V_ACTIVE + V_BLANKING)); 566 (V_ACTIVE + V_BLANKING));
567 mode->vmode = 0; 567 if (INTERLACED) {
568 mode->yres *= 2;
569 mode->upper_margin *= 2;
570 mode->lower_margin *= 2;
571 mode->vsync_len *= 2;
572 mode->vmode |= FB_VMODE_INTERLACED;
573 }
568 mode->flag = FB_MODE_IS_DETAILED; 574 mode->flag = FB_MODE_IS_DETAILED;
569 575
570 DPRINTK(" %d MHz ", PIXEL_CLOCK/1000000); 576 DPRINTK(" %d MHz ", PIXEL_CLOCK/1000000);
diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c
index 9366ef2bb5f7..e69de29bb2d1 100644
--- a/drivers/video/imacfb.c
+++ b/drivers/video/imacfb.c
@@ -1,376 +0,0 @@
1/*
2 * framebuffer driver for Intel Based Mac's
3 *
4 * (c) 2006 Edgar Hucek <gimli@dark-green.com>
5 * Original imac driver written by Gerd Knorr <kraxel@goldbach.in-berlin.de>
6 *
7 */
8
9#include <linux/delay.h>
10#include <linux/errno.h>
11#include <linux/fb.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/mm.h>
16#include <linux/module.h>
17#include <linux/platform_device.h>
18#include <linux/screen_info.h>
19#include <linux/slab.h>
20#include <linux/string.h>
21#include <linux/dmi.h>
22#include <linux/efi.h>
23
24#include <asm/io.h>
25
26#include <video/vga.h>
27
28typedef enum _MAC_TYPE {
29 M_I17,
30 M_I20,
31 M_MINI,
32 M_MACBOOK,
33 M_UNKNOWN
34} MAC_TYPE;
35
36/* --------------------------------------------------------------------- */
37
38static struct fb_var_screeninfo imacfb_defined __initdata = {
39 .activate = FB_ACTIVATE_NOW,
40 .height = -1,
41 .width = -1,
42 .right_margin = 32,
43 .upper_margin = 16,
44 .lower_margin = 4,
45 .vsync_len = 4,
46 .vmode = FB_VMODE_NONINTERLACED,
47};
48
49static struct fb_fix_screeninfo imacfb_fix __initdata = {
50 .id = "IMAC VGA",
51 .type = FB_TYPE_PACKED_PIXELS,
52 .accel = FB_ACCEL_NONE,
53 .visual = FB_VISUAL_TRUECOLOR,
54};
55
56static int inverse;
57static int model = M_UNKNOWN;
58static int manual_height;
59static int manual_width;
60
61static int set_system(const struct dmi_system_id *id)
62{
63 printk(KERN_INFO "imacfb: %s detected - set system to %ld\n",
64 id->ident, (long)id->driver_data);
65
66 model = (long)id->driver_data;
67
68 return 0;
69}
70
71static struct dmi_system_id __initdata dmi_system_table[] = {
72 { set_system, "iMac4,1", {
73 DMI_MATCH(DMI_BIOS_VENDOR,"Apple Computer, Inc."),
74 DMI_MATCH(DMI_PRODUCT_NAME,"iMac4,1") }, (void*)M_I17},
75 { set_system, "MacBookPro1,1", {
76 DMI_MATCH(DMI_BIOS_VENDOR,"Apple Computer, Inc."),
77 DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro1,1") }, (void*)M_I17},
78 { set_system, "MacBook1,1", {
79 DMI_MATCH(DMI_BIOS_VENDOR,"Apple Computer, Inc."),
80 DMI_MATCH(DMI_PRODUCT_NAME,"MacBook1,1")}, (void *)M_MACBOOK},
81 { set_system, "Macmini1,1", {
82 DMI_MATCH(DMI_BIOS_VENDOR,"Apple Computer, Inc."),
83 DMI_MATCH(DMI_PRODUCT_NAME,"Macmini1,1")}, (void *)M_MINI},
84 {},
85};
86
87#define DEFAULT_FB_MEM 1024*1024*16
88
89/* --------------------------------------------------------------------- */
90
91static int imacfb_setcolreg(unsigned regno, unsigned red, unsigned green,
92 unsigned blue, unsigned transp,
93 struct fb_info *info)
94{
95 /*
96 * Set a single color register. The values supplied are
97 * already rounded down to the hardware's capabilities
98 * (according to the entries in the `var' structure). Return
99 * != 0 for invalid regno.
100 */
101
102 if (regno >= info->cmap.len)
103 return 1;
104
105 if (regno < 16) {
106 red >>= 8;
107 green >>= 8;
108 blue >>= 8;
109 ((u32 *)(info->pseudo_palette))[regno] =
110 (red << info->var.red.offset) |
111 (green << info->var.green.offset) |
112 (blue << info->var.blue.offset);
113 }
114 return 0;
115}
116
117static struct fb_ops imacfb_ops = {
118 .owner = THIS_MODULE,
119 .fb_setcolreg = imacfb_setcolreg,
120 .fb_fillrect = cfb_fillrect,
121 .fb_copyarea = cfb_copyarea,
122 .fb_imageblit = cfb_imageblit,
123};
124
125static int __init imacfb_setup(char *options)
126{
127 char *this_opt;
128
129 if (!options || !*options)
130 return 0;
131
132 while ((this_opt = strsep(&options, ",")) != NULL) {
133 if (!*this_opt) continue;
134
135 if (!strcmp(this_opt, "inverse"))
136 inverse = 1;
137 else if (!strcmp(this_opt, "i17"))
138 model = M_I17;
139 else if (!strcmp(this_opt, "i20"))
140 model = M_I20;
141 else if (!strcmp(this_opt, "mini"))
142 model = M_MINI;
143 else if (!strcmp(this_opt, "macbook"))
144 model = M_MACBOOK;
145 else if (!strncmp(this_opt, "height:", 7))
146 manual_height = simple_strtoul(this_opt+7, NULL, 0);
147 else if (!strncmp(this_opt, "width:", 6))
148 manual_width = simple_strtoul(this_opt+6, NULL, 0);
149 }
150 return 0;
151}
152
153static int __init imacfb_probe(struct platform_device *dev)
154{
155 struct fb_info *info;
156 int err;
157 unsigned int size_vmode;
158 unsigned int size_remap;
159 unsigned int size_total;
160
161 screen_info.lfb_depth = 32;
162 screen_info.lfb_size = DEFAULT_FB_MEM / 0x10000;
163 screen_info.pages=1;
164 screen_info.blue_size = 8;
165 screen_info.blue_pos = 0;
166 screen_info.green_size = 8;
167 screen_info.green_pos = 8;
168 screen_info.red_size = 8;
169 screen_info.red_pos = 16;
170 screen_info.rsvd_size = 8;
171 screen_info.rsvd_pos = 24;
172
173 switch (model) {
174 case M_I17:
175 screen_info.lfb_width = 1440;
176 screen_info.lfb_height = 900;
177 screen_info.lfb_linelength = 1472 * 4;
178 screen_info.lfb_base = 0x80010000;
179 break;
180 case M_I20:
181 screen_info.lfb_width = 1680;
182 screen_info.lfb_height = 1050;
183 screen_info.lfb_linelength = 1728 * 4;
184 screen_info.lfb_base = 0x80010000;
185 break;
186 case M_MINI:
187 screen_info.lfb_width = 1024;
188 screen_info.lfb_height = 768;
189 screen_info.lfb_linelength = 2048 * 4;
190 screen_info.lfb_base = 0x80000000;
191 break;
192 case M_MACBOOK:
193 screen_info.lfb_width = 1280;
194 screen_info.lfb_height = 800;
195 screen_info.lfb_linelength = 2048 * 4;
196 screen_info.lfb_base = 0x80000000;
197 break;
198 }
199
200 /* if the user wants to manually specify height/width,
201 we will override the defaults */
202 /* TODO: eventually get auto-detection working */
203 if (manual_height > 0)
204 screen_info.lfb_height = manual_height;
205 if (manual_width > 0)
206 screen_info.lfb_width = manual_width;
207
208 imacfb_fix.smem_start = screen_info.lfb_base;
209 imacfb_defined.bits_per_pixel = screen_info.lfb_depth;
210 imacfb_defined.xres = screen_info.lfb_width;
211 imacfb_defined.yres = screen_info.lfb_height;
212 imacfb_fix.line_length = screen_info.lfb_linelength;
213
214 /* size_vmode -- that is the amount of memory needed for the
215 * used video mode, i.e. the minimum amount of
216 * memory we need. */
217 size_vmode = imacfb_defined.yres * imacfb_fix.line_length;
218
219 /* size_total -- all video memory we have. Used for
220 * entries, ressource allocation and bounds
221 * checking. */
222 size_total = screen_info.lfb_size * 65536;
223 if (size_total < size_vmode)
224 size_total = size_vmode;
225
226 /* size_remap -- the amount of video memory we are going to
227 * use for imacfb. With modern cards it is no
228 * option to simply use size_total as that
229 * wastes plenty of kernel address space. */
230 size_remap = size_vmode * 2;
231 if (size_remap < size_vmode)
232 size_remap = size_vmode;
233 if (size_remap > size_total)
234 size_remap = size_total;
235 imacfb_fix.smem_len = size_remap;
236
237 if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) {
238 printk(KERN_WARNING
239 "imacfb: cannot reserve video memory at 0x%lx\n",
240 imacfb_fix.smem_start);
241 /* We cannot make this fatal. Sometimes this comes from magic
242 spaces our resource handlers simply don't know about */
243 }
244
245 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
246 if (!info) {
247 err = -ENOMEM;
248 goto err_release_mem;
249 }
250 info->pseudo_palette = info->par;
251 info->par = NULL;
252
253 info->screen_base = ioremap(imacfb_fix.smem_start, imacfb_fix.smem_len);
254 if (!info->screen_base) {
255 printk(KERN_ERR "imacfb: abort, cannot ioremap video memory "
256 "0x%x @ 0x%lx\n",
257 imacfb_fix.smem_len, imacfb_fix.smem_start);
258 err = -EIO;
259 goto err_unmap;
260 }
261
262 printk(KERN_INFO "imacfb: framebuffer at 0x%lx, mapped to 0x%p, "
263 "using %dk, total %dk\n",
264 imacfb_fix.smem_start, info->screen_base,
265 size_remap/1024, size_total/1024);
266 printk(KERN_INFO "imacfb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
267 imacfb_defined.xres, imacfb_defined.yres,
268 imacfb_defined.bits_per_pixel, imacfb_fix.line_length,
269 screen_info.pages);
270
271 imacfb_defined.xres_virtual = imacfb_defined.xres;
272 imacfb_defined.yres_virtual = imacfb_fix.smem_len /
273 imacfb_fix.line_length;
274 printk(KERN_INFO "imacfb: scrolling: redraw\n");
275 imacfb_defined.yres_virtual = imacfb_defined.yres;
276
277 /* some dummy values for timing to make fbset happy */
278 imacfb_defined.pixclock = 10000000 / imacfb_defined.xres *
279 1000 / imacfb_defined.yres;
280 imacfb_defined.left_margin = (imacfb_defined.xres / 8) & 0xf8;
281 imacfb_defined.hsync_len = (imacfb_defined.xres / 8) & 0xf8;
282
283 imacfb_defined.red.offset = screen_info.red_pos;
284 imacfb_defined.red.length = screen_info.red_size;
285 imacfb_defined.green.offset = screen_info.green_pos;
286 imacfb_defined.green.length = screen_info.green_size;
287 imacfb_defined.blue.offset = screen_info.blue_pos;
288 imacfb_defined.blue.length = screen_info.blue_size;
289 imacfb_defined.transp.offset = screen_info.rsvd_pos;
290 imacfb_defined.transp.length = screen_info.rsvd_size;
291
292 printk(KERN_INFO "imacfb: %s: "
293 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
294 "Truecolor",
295 screen_info.rsvd_size,
296 screen_info.red_size,
297 screen_info.green_size,
298 screen_info.blue_size,
299 screen_info.rsvd_pos,
300 screen_info.red_pos,
301 screen_info.green_pos,
302 screen_info.blue_pos);
303
304 imacfb_fix.ypanstep = 0;
305 imacfb_fix.ywrapstep = 0;
306
307 /* request failure does not faze us, as vgacon probably has this
308 * region already (FIXME) */
309 request_region(0x3c0, 32, "imacfb");
310
311 info->fbops = &imacfb_ops;
312 info->var = imacfb_defined;
313 info->fix = imacfb_fix;
314 info->flags = FBINFO_FLAG_DEFAULT;
315
316 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
317 err = -ENOMEM;
318 goto err_unmap;
319 }
320 if (register_framebuffer(info)<0) {
321 err = -EINVAL;
322 goto err_fb_dealoc;
323 }
324 printk(KERN_INFO "fb%d: %s frame buffer device\n",
325 info->node, info->fix.id);
326 return 0;
327
328err_fb_dealoc:
329 fb_dealloc_cmap(&info->cmap);
330err_unmap:
331 iounmap(info->screen_base);
332 framebuffer_release(info);
333err_release_mem:
334 release_mem_region(imacfb_fix.smem_start, size_total);
335 return err;
336}
337
338static struct platform_driver imacfb_driver = {
339 .probe = imacfb_probe,
340 .driver = {
341 .name = "imacfb",
342 },
343};
344
345static struct platform_device imacfb_device = {
346 .name = "imacfb",
347};
348
349static int __init imacfb_init(void)
350{
351 int ret;
352 char *option = NULL;
353
354 if (!efi_enabled)
355 return -ENODEV;
356 if (!dmi_check_system(dmi_system_table))
357 return -ENODEV;
358 if (model == M_UNKNOWN)
359 return -ENODEV;
360
361 if (fb_get_options("imacfb", &option))
362 return -ENODEV;
363
364 imacfb_setup(option);
365 ret = platform_driver_register(&imacfb_driver);
366
367 if (!ret) {
368 ret = platform_device_register(&imacfb_device);
369 if (ret)
370 platform_driver_unregister(&imacfb_driver);
371 }
372 return ret;
373}
374module_init(imacfb_init);
375
376MODULE_LICENSE("GPL");
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
index 3325fbd68ab3..a50bea614804 100644
--- a/drivers/video/intelfb/intelfb.h
+++ b/drivers/video/intelfb/intelfb.h
@@ -12,9 +12,9 @@
12#endif 12#endif
13 13
14/*** Version/name ***/ 14/*** Version/name ***/
15#define INTELFB_VERSION "0.9.5" 15#define INTELFB_VERSION "0.9.6"
16#define INTELFB_MODULE_NAME "intelfb" 16#define INTELFB_MODULE_NAME "intelfb"
17#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM" 17#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/945GME/965G/965GM"
18 18
19 19
20/*** Debug/feature defines ***/ 20/*** Debug/feature defines ***/
@@ -58,6 +58,7 @@
58#define PCI_DEVICE_ID_INTEL_915GM 0x2592 58#define PCI_DEVICE_ID_INTEL_915GM 0x2592
59#define PCI_DEVICE_ID_INTEL_945G 0x2772 59#define PCI_DEVICE_ID_INTEL_945G 0x2772
60#define PCI_DEVICE_ID_INTEL_945GM 0x27A2 60#define PCI_DEVICE_ID_INTEL_945GM 0x27A2
61#define PCI_DEVICE_ID_INTEL_945GME 0x27AE
61#define PCI_DEVICE_ID_INTEL_965G 0x29A2 62#define PCI_DEVICE_ID_INTEL_965G 0x29A2
62#define PCI_DEVICE_ID_INTEL_965GM 0x2A02 63#define PCI_DEVICE_ID_INTEL_965GM 0x2A02
63 64
@@ -160,6 +161,7 @@ enum intel_chips {
160 INTEL_915GM, 161 INTEL_915GM,
161 INTEL_945G, 162 INTEL_945G,
162 INTEL_945GM, 163 INTEL_945GM,
164 INTEL_945GME,
163 INTEL_965G, 165 INTEL_965G,
164 INTEL_965GM, 166 INTEL_965GM,
165}; 167};
@@ -363,6 +365,7 @@ struct intelfb_info {
363 ((dinfo)->chipset == INTEL_915GM) || \ 365 ((dinfo)->chipset == INTEL_915GM) || \
364 ((dinfo)->chipset == INTEL_945G) || \ 366 ((dinfo)->chipset == INTEL_945G) || \
365 ((dinfo)->chipset == INTEL_945GM) || \ 367 ((dinfo)->chipset == INTEL_945GM) || \
368 ((dinfo)->chipset == INTEL_945GME) || \
366 ((dinfo)->chipset == INTEL_965G) || \ 369 ((dinfo)->chipset == INTEL_965G) || \
367 ((dinfo)->chipset == INTEL_965GM)) 370 ((dinfo)->chipset == INTEL_965GM))
368 371
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c
index fcf9fadbf572..5d896b81f4e0 100644
--- a/drivers/video/intelfb/intelfb_i2c.c
+++ b/drivers/video/intelfb/intelfb_i2c.c
@@ -171,6 +171,7 @@ void intelfb_create_i2c_busses(struct intelfb_info *dinfo)
171 /* has some LVDS + tv-out */ 171 /* has some LVDS + tv-out */
172 case INTEL_945G: 172 case INTEL_945G:
173 case INTEL_945GM: 173 case INTEL_945GM:
174 case INTEL_945GME:
174 case INTEL_965G: 175 case INTEL_965G:
175 case INTEL_965GM: 176 case INTEL_965GM:
176 /* SDVO ports have a single control bus - 2 devices */ 177 /* SDVO ports have a single control bus - 2 devices */
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index e44303f9bc52..a09e23649357 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -2,7 +2,7 @@
2 * intelfb 2 * intelfb
3 * 3 *
4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/ 4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/
5 * 945G/945GM/965G/965GM integrated graphics chips. 5 * 945G/945GM/945GME/965G/965GM integrated graphics chips.
6 * 6 *
7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org> 7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
8 * 2004 Sylvain Meyer 8 * 2004 Sylvain Meyer
@@ -102,6 +102,9 @@
102 * 102 *
103 * 04/2008 - Version 0.9.5 103 * 04/2008 - Version 0.9.5
104 * Add support for 965G/965GM. (Maik Broemme <mbroemme@plusserver.de>) 104 * Add support for 965G/965GM. (Maik Broemme <mbroemme@plusserver.de>)
105 *
106 * 08/2008 - Version 0.9.6
107 * Add support for 945GME. (Phil Endecott <spam_from_intelfb@chezphil.org>)
105 */ 108 */
106 109
107#include <linux/module.h> 110#include <linux/module.h>
@@ -183,6 +186,7 @@ static struct pci_device_id intelfb_pci_table[] __devinitdata = {
183 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM }, 186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM },
184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G }, 187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G },
185 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM }, 188 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM },
189 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GME, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GME },
186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965G }, 190 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965G },
187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965GM }, 191 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965GM },
188 { 0, } 192 { 0, }
@@ -555,6 +559,7 @@ static int __devinit intelfb_pci_register(struct pci_dev *pdev,
555 (ent->device == PCI_DEVICE_ID_INTEL_915GM) || 559 (ent->device == PCI_DEVICE_ID_INTEL_915GM) ||
556 (ent->device == PCI_DEVICE_ID_INTEL_945G) || 560 (ent->device == PCI_DEVICE_ID_INTEL_945G) ||
557 (ent->device == PCI_DEVICE_ID_INTEL_945GM) || 561 (ent->device == PCI_DEVICE_ID_INTEL_945GM) ||
562 (ent->device == PCI_DEVICE_ID_INTEL_945GME) ||
558 (ent->device == PCI_DEVICE_ID_INTEL_965G) || 563 (ent->device == PCI_DEVICE_ID_INTEL_965G) ||
559 (ent->device == PCI_DEVICE_ID_INTEL_965GM)) { 564 (ent->device == PCI_DEVICE_ID_INTEL_965GM)) {
560 565
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index 8e6d6a4db0ad..8b26b27c2db6 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -143,6 +143,12 @@ int intelfbhw_get_chipset(struct pci_dev *pdev, struct intelfb_info *dinfo)
143 dinfo->mobile = 1; 143 dinfo->mobile = 1;
144 dinfo->pll_index = PLLS_I9xx; 144 dinfo->pll_index = PLLS_I9xx;
145 return 0; 145 return 0;
146 case PCI_DEVICE_ID_INTEL_945GME:
147 dinfo->name = "Intel(R) 945GME";
148 dinfo->chipset = INTEL_945GME;
149 dinfo->mobile = 1;
150 dinfo->pll_index = PLLS_I9xx;
151 return 0;
146 case PCI_DEVICE_ID_INTEL_965G: 152 case PCI_DEVICE_ID_INTEL_965G:
147 dinfo->name = "Intel(R) 965G"; 153 dinfo->name = "Intel(R) 965G";
148 dinfo->chipset = INTEL_965G; 154 dinfo->chipset = INTEL_965G;
@@ -186,6 +192,7 @@ int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
186 case PCI_DEVICE_ID_INTEL_915GM: 192 case PCI_DEVICE_ID_INTEL_915GM:
187 case PCI_DEVICE_ID_INTEL_945G: 193 case PCI_DEVICE_ID_INTEL_945G:
188 case PCI_DEVICE_ID_INTEL_945GM: 194 case PCI_DEVICE_ID_INTEL_945GM:
195 case PCI_DEVICE_ID_INTEL_945GME:
189 case PCI_DEVICE_ID_INTEL_965G: 196 case PCI_DEVICE_ID_INTEL_965G:
190 case PCI_DEVICE_ID_INTEL_965GM: 197 case PCI_DEVICE_ID_INTEL_965GM:
191 /* 915, 945 and 965 chipsets support a 256MB aperture. 198 /* 915, 945 and 965 chipsets support a 256MB aperture.
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index c02136202792..8e7a275df50c 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -1453,6 +1453,13 @@ static struct board {
1453 MGA_G100, 1453 MGA_G100,
1454 &vbG100, 1454 &vbG100,
1455 "MGA-G100 (AGP)"}, 1455 "MGA-G100 (AGP)"},
1456 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200EV_PCI, 0xFF,
1457 0, 0,
1458 DEVF_G200,
1459 230000,
1460 MGA_G200,
1461 &vbG200,
1462 "MGA-G200eV (PCI)"},
1456 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, 0xFF, 1463 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, 0xFF,
1457 0, 0, 1464 0, 0,
1458 DEVF_G200, 1465 DEVF_G200,
@@ -2118,6 +2125,8 @@ static struct pci_device_id matroxfb_devices[] = {
2118 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2125 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2119 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_AGP, 2126 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_AGP,
2120 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2127 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2128 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200EV_PCI,
2129 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2121 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, 2130 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI,
2122 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2131 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2123 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, 2132 {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP,
diff --git a/drivers/video/neofb.c b/drivers/video/neofb.c
index 25172b2a2a94..bfb802d26d5a 100644
--- a/drivers/video/neofb.c
+++ b/drivers/video/neofb.c
@@ -426,11 +426,11 @@ static void vgaHWProtect(int on)
426{ 426{
427 unsigned char tmp; 427 unsigned char tmp;
428 428
429 tmp = vga_rseq(NULL, 0x01);
429 if (on) { 430 if (on) {
430 /* 431 /*
431 * Turn off screen and disable sequencer. 432 * Turn off screen and disable sequencer.
432 */ 433 */
433 tmp = vga_rseq(NULL, 0x01);
434 vga_wseq(NULL, 0x00, 0x01); /* Synchronous Reset */ 434 vga_wseq(NULL, 0x00, 0x01); /* Synchronous Reset */
435 vga_wseq(NULL, 0x01, tmp | 0x20); /* disable the display */ 435 vga_wseq(NULL, 0x01, tmp | 0x20); /* disable the display */
436 436
@@ -439,7 +439,6 @@ static void vgaHWProtect(int on)
439 /* 439 /*
440 * Reenable sequencer, then turn on screen. 440 * Reenable sequencer, then turn on screen.
441 */ 441 */
442 tmp = vga_rseq(NULL, 0x01);
443 vga_wseq(NULL, 0x01, tmp & ~0x20); /* reenable display */ 442 vga_wseq(NULL, 0x01, tmp & ~0x20); /* reenable display */
444 vga_wseq(NULL, 0x00, 0x03); /* clear synchronousreset */ 443 vga_wseq(NULL, 0x00, 0x03); /* clear synchronousreset */
445 444
@@ -558,14 +557,12 @@ neofb_open(struct fb_info *info, int user)
558{ 557{
559 struct neofb_par *par = info->par; 558 struct neofb_par *par = info->par;
560 559
561 mutex_lock(&par->open_lock);
562 if (!par->ref_count) { 560 if (!par->ref_count) {
563 memset(&par->state, 0, sizeof(struct vgastate)); 561 memset(&par->state, 0, sizeof(struct vgastate));
564 par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS; 562 par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS;
565 save_vga(&par->state); 563 save_vga(&par->state);
566 } 564 }
567 par->ref_count++; 565 par->ref_count++;
568 mutex_unlock(&par->open_lock);
569 566
570 return 0; 567 return 0;
571} 568}
@@ -575,16 +572,13 @@ neofb_release(struct fb_info *info, int user)
575{ 572{
576 struct neofb_par *par = info->par; 573 struct neofb_par *par = info->par;
577 574
578 mutex_lock(&par->open_lock); 575 if (!par->ref_count)
579 if (!par->ref_count) {
580 mutex_unlock(&par->open_lock);
581 return -EINVAL; 576 return -EINVAL;
582 } 577
583 if (par->ref_count == 1) { 578 if (par->ref_count == 1) {
584 restore_vga(&par->state); 579 restore_vga(&par->state);
585 } 580 }
586 par->ref_count--; 581 par->ref_count--;
587 mutex_unlock(&par->open_lock);
588 582
589 return 0; 583 return 0;
590} 584}
@@ -648,10 +642,10 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
648 var->blue.msb_right = 0; 642 var->blue.msb_right = 0;
649 var->transp.msb_right = 0; 643 var->transp.msb_right = 0;
650 644
645 var->transp.offset = 0;
646 var->transp.length = 0;
651 switch (var->bits_per_pixel) { 647 switch (var->bits_per_pixel) {
652 case 8: /* PSEUDOCOLOUR, 256 */ 648 case 8: /* PSEUDOCOLOUR, 256 */
653 var->transp.offset = 0;
654 var->transp.length = 0;
655 var->red.offset = 0; 649 var->red.offset = 0;
656 var->red.length = 8; 650 var->red.length = 8;
657 var->green.offset = 0; 651 var->green.offset = 0;
@@ -661,8 +655,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
661 break; 655 break;
662 656
663 case 16: /* DIRECTCOLOUR, 64k */ 657 case 16: /* DIRECTCOLOUR, 64k */
664 var->transp.offset = 0;
665 var->transp.length = 0;
666 var->red.offset = 11; 658 var->red.offset = 11;
667 var->red.length = 5; 659 var->red.length = 5;
668 var->green.offset = 5; 660 var->green.offset = 5;
@@ -672,8 +664,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
672 break; 664 break;
673 665
674 case 24: /* TRUECOLOUR, 16m */ 666 case 24: /* TRUECOLOUR, 16m */
675 var->transp.offset = 0;
676 var->transp.length = 0;
677 var->red.offset = 16; 667 var->red.offset = 16;
678 var->red.length = 8; 668 var->red.length = 8;
679 var->green.offset = 8; 669 var->green.offset = 8;
@@ -704,8 +694,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
704 if (vramlen > 4 * 1024 * 1024) 694 if (vramlen > 4 * 1024 * 1024)
705 vramlen = 4 * 1024 * 1024; 695 vramlen = 4 * 1024 * 1024;
706 696
707 if (var->yres_virtual < var->yres)
708 var->yres_virtual = var->yres;
709 if (var->xres_virtual < var->xres) 697 if (var->xres_virtual < var->xres)
710 var->xres_virtual = var->xres; 698 var->xres_virtual = var->xres;
711 699
@@ -722,8 +710,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
722 if it was possible. We should return -EINVAL, but I disagree */ 710 if it was possible. We should return -EINVAL, but I disagree */
723 if (var->yres_virtual < var->yres) 711 if (var->yres_virtual < var->yres)
724 var->yres = var->yres_virtual; 712 var->yres = var->yres_virtual;
725 if (var->xres_virtual < var->xres)
726 var->xres = var->xres_virtual;
727 if (var->xoffset + var->xres > var->xres_virtual) 713 if (var->xoffset + var->xres > var->xres_virtual)
728 var->xoffset = var->xres_virtual - var->xres; 714 var->xoffset = var->xres_virtual - var->xres;
729 if (var->yoffset + var->yres > var->yres_virtual) 715 if (var->yoffset + var->yres > var->yres_virtual)
@@ -1186,8 +1172,11 @@ static int neofb_set_par(struct fb_info *info)
1186 return 0; 1172 return 0;
1187} 1173}
1188 1174
1189static void neofb_update_start(struct fb_info *info, 1175/*
1190 struct fb_var_screeninfo *var) 1176 * Pan or Wrap the Display
1177 */
1178static int neofb_pan_display(struct fb_var_screeninfo *var,
1179 struct fb_info *info)
1191{ 1180{
1192 struct neofb_par *par = info->par; 1181 struct neofb_par *par = info->par;
1193 struct vgastate *state = &par->state; 1182 struct vgastate *state = &par->state;
@@ -1216,35 +1205,7 @@ static void neofb_update_start(struct fb_info *info,
1216 vga_wgfx(state->vgabase, 0x0E, (((Base >> 16) & 0x0f) | (oldExtCRTDispAddr & 0xf0))); 1205 vga_wgfx(state->vgabase, 0x0E, (((Base >> 16) & 0x0f) | (oldExtCRTDispAddr & 0xf0)));
1217 1206
1218 neoLock(state); 1207 neoLock(state);
1219}
1220
1221/*
1222 * Pan or Wrap the Display
1223 */
1224static int neofb_pan_display(struct fb_var_screeninfo *var,
1225 struct fb_info *info)
1226{
1227 u_int y_bottom;
1228
1229 y_bottom = var->yoffset;
1230
1231 if (!(var->vmode & FB_VMODE_YWRAP))
1232 y_bottom += var->yres;
1233 1208
1234 if (var->xoffset > (var->xres_virtual - var->xres))
1235 return -EINVAL;
1236 if (y_bottom > info->var.yres_virtual)
1237 return -EINVAL;
1238
1239 neofb_update_start(info, var);
1240
1241 info->var.xoffset = var->xoffset;
1242 info->var.yoffset = var->yoffset;
1243
1244 if (var->vmode & FB_VMODE_YWRAP)
1245 info->var.vmode |= FB_VMODE_YWRAP;
1246 else
1247 info->var.vmode &= ~FB_VMODE_YWRAP;
1248 return 0; 1209 return 0;
1249} 1210}
1250 1211
@@ -1992,7 +1953,6 @@ static struct fb_info *__devinit neo_alloc_fb_info(struct pci_dev *dev, const st
1992 1953
1993 info->fix.accel = id->driver_data; 1954 info->fix.accel = id->driver_data;
1994 1955
1995 mutex_init(&par->open_lock);
1996 par->pci_burst = !nopciburst; 1956 par->pci_burst = !nopciburst;
1997 par->lcd_stretch = !nostretch; 1957 par->lcd_stretch = !nostretch;
1998 par->libretto = libretto; 1958 par->libretto = libretto;
diff --git a/drivers/video/omap/dispc.c b/drivers/video/omap/dispc.c
index 6efcf89e7fbe..dfb72f5e4c96 100644
--- a/drivers/video/omap/dispc.c
+++ b/drivers/video/omap/dispc.c
@@ -156,7 +156,7 @@ struct resmap {
156}; 156};
157 157
158static struct { 158static struct {
159 u32 base; 159 void __iomem *base;
160 160
161 struct omapfb_mem_desc mem_desc; 161 struct omapfb_mem_desc mem_desc;
162 struct resmap *res_map[DISPC_MEMTYPE_NUM]; 162 struct resmap *res_map[DISPC_MEMTYPE_NUM];
@@ -212,9 +212,9 @@ static void enable_rfbi_mode(int enable)
212 dispc_write_reg(DISPC_CONTROL, l); 212 dispc_write_reg(DISPC_CONTROL, l);
213 213
214 /* Set bypass mode in RFBI module */ 214 /* Set bypass mode in RFBI module */
215 l = __raw_readl(io_p2v(RFBI_CONTROL)); 215 l = __raw_readl(IO_ADDRESS(RFBI_CONTROL));
216 l |= enable ? 0 : (1 << 1); 216 l |= enable ? 0 : (1 << 1);
217 __raw_writel(l, io_p2v(RFBI_CONTROL)); 217 __raw_writel(l, IO_ADDRESS(RFBI_CONTROL));
218} 218}
219 219
220static void set_lcd_data_lines(int data_lines) 220static void set_lcd_data_lines(int data_lines)
@@ -1349,14 +1349,19 @@ static int omap_dispc_init(struct omapfb_device *fbdev, int ext_mode,
1349 1349
1350 memset(&dispc, 0, sizeof(dispc)); 1350 memset(&dispc, 0, sizeof(dispc));
1351 1351
1352 dispc.base = io_p2v(DISPC_BASE); 1352 dispc.base = ioremap(DISPC_BASE, SZ_1K);
1353 if (!dispc.base) {
1354 dev_err(fbdev->dev, "can't ioremap DISPC\n");
1355 return -ENOMEM;
1356 }
1357
1353 dispc.fbdev = fbdev; 1358 dispc.fbdev = fbdev;
1354 dispc.ext_mode = ext_mode; 1359 dispc.ext_mode = ext_mode;
1355 1360
1356 init_completion(&dispc.frame_done); 1361 init_completion(&dispc.frame_done);
1357 1362
1358 if ((r = get_dss_clocks()) < 0) 1363 if ((r = get_dss_clocks()) < 0)
1359 return r; 1364 goto fail0;
1360 1365
1361 enable_interface_clocks(1); 1366 enable_interface_clocks(1);
1362 enable_lcd_clocks(1); 1367 enable_lcd_clocks(1);
@@ -1414,7 +1419,7 @@ static int omap_dispc_init(struct omapfb_device *fbdev, int ext_mode,
1414 } 1419 }
1415 1420
1416 /* L3 firewall setting: enable access to OCM RAM */ 1421 /* L3 firewall setting: enable access to OCM RAM */
1417 __raw_writel(0x402000b0, io_p2v(0x680050a0)); 1422 __raw_writel(0x402000b0, IO_ADDRESS(0x680050a0));
1418 1423
1419 if ((r = alloc_palette_ram()) < 0) 1424 if ((r = alloc_palette_ram()) < 0)
1420 goto fail2; 1425 goto fail2;
@@ -1464,7 +1469,8 @@ fail1:
1464 enable_lcd_clocks(0); 1469 enable_lcd_clocks(0);
1465 enable_interface_clocks(0); 1470 enable_interface_clocks(0);
1466 put_dss_clocks(); 1471 put_dss_clocks();
1467 1472fail0:
1473 iounmap(dispc.base);
1468 return r; 1474 return r;
1469} 1475}
1470 1476
@@ -1481,6 +1487,7 @@ static void omap_dispc_cleanup(void)
1481 free_irq(INT_24XX_DSS_IRQ, dispc.fbdev); 1487 free_irq(INT_24XX_DSS_IRQ, dispc.fbdev);
1482 enable_interface_clocks(0); 1488 enable_interface_clocks(0);
1483 put_dss_clocks(); 1489 put_dss_clocks();
1490 iounmap(dispc.base);
1484} 1491}
1485 1492
1486const struct lcd_ctrl omap2_int_ctrl = { 1493const struct lcd_ctrl omap2_int_ctrl = {
diff --git a/drivers/video/omap/dispc.h b/drivers/video/omap/dispc.h
index eb1512b56ce8..ef720a78f6d5 100644
--- a/drivers/video/omap/dispc.h
+++ b/drivers/video/omap/dispc.h
@@ -40,4 +40,6 @@ extern void omap_dispc_enable_digit_out(int enable);
40extern int omap_dispc_request_irq(void (*callback)(void *data), void *data); 40extern int omap_dispc_request_irq(void (*callback)(void *data), void *data);
41extern void omap_dispc_free_irq(void); 41extern void omap_dispc_free_irq(void);
42 42
43extern const struct lcd_ctrl omap2_int_ctrl;
44
43#endif 45#endif
diff --git a/drivers/video/omap/lcd_h4.c b/drivers/video/omap/lcd_h4.c
index 88c19d424ef7..6ff56430341b 100644
--- a/drivers/video/omap/lcd_h4.c
+++ b/drivers/video/omap/lcd_h4.c
@@ -47,7 +47,7 @@ static unsigned long h4_panel_get_caps(struct lcd_panel *panel)
47 return 0; 47 return 0;
48} 48}
49 49
50struct lcd_panel h4_panel = { 50static struct lcd_panel h4_panel = {
51 .name = "h4", 51 .name = "h4",
52 .config = OMAP_LCDC_PANEL_TFT, 52 .config = OMAP_LCDC_PANEL_TFT,
53 53
@@ -91,7 +91,7 @@ static int h4_panel_resume(struct platform_device *pdev)
91 return 0; 91 return 0;
92} 92}
93 93
94struct platform_driver h4_panel_driver = { 94static struct platform_driver h4_panel_driver = {
95 .probe = h4_panel_probe, 95 .probe = h4_panel_probe,
96 .remove = h4_panel_remove, 96 .remove = h4_panel_remove,
97 .suspend = h4_panel_suspend, 97 .suspend = h4_panel_suspend,
diff --git a/drivers/video/omap/lcd_inn1610.c b/drivers/video/omap/lcd_inn1610.c
index 6a42c6a0cd99..4c4f7ee6d733 100644
--- a/drivers/video/omap/lcd_inn1610.c
+++ b/drivers/video/omap/lcd_inn1610.c
@@ -32,43 +32,43 @@ static int innovator1610_panel_init(struct lcd_panel *panel,
32{ 32{
33 int r = 0; 33 int r = 0;
34 34
35 if (omap_request_gpio(14)) { 35 if (gpio_request(14, "lcd_en0")) {
36 pr_err(MODULE_NAME ": can't request GPIO 14\n"); 36 pr_err(MODULE_NAME ": can't request GPIO 14\n");
37 r = -1; 37 r = -1;
38 goto exit; 38 goto exit;
39 } 39 }
40 if (omap_request_gpio(15)) { 40 if (gpio_request(15, "lcd_en1")) {
41 pr_err(MODULE_NAME ": can't request GPIO 15\n"); 41 pr_err(MODULE_NAME ": can't request GPIO 15\n");
42 omap_free_gpio(14); 42 gpio_free(14);
43 r = -1; 43 r = -1;
44 goto exit; 44 goto exit;
45 } 45 }
46 /* configure GPIO(14, 15) as outputs */ 46 /* configure GPIO(14, 15) as outputs */
47 omap_set_gpio_direction(14, 0); 47 gpio_direction_output(14, 0);
48 omap_set_gpio_direction(15, 0); 48 gpio_direction_output(15, 0);
49exit: 49exit:
50 return r; 50 return r;
51} 51}
52 52
53static void innovator1610_panel_cleanup(struct lcd_panel *panel) 53static void innovator1610_panel_cleanup(struct lcd_panel *panel)
54{ 54{
55 omap_free_gpio(15); 55 gpio_free(15);
56 omap_free_gpio(14); 56 gpio_free(14);
57} 57}
58 58
59static int innovator1610_panel_enable(struct lcd_panel *panel) 59static int innovator1610_panel_enable(struct lcd_panel *panel)
60{ 60{
61 /* set GPIO14 and GPIO15 high */ 61 /* set GPIO14 and GPIO15 high */
62 omap_set_gpio_dataout(14, 1); 62 gpio_set_value(14, 1);
63 omap_set_gpio_dataout(15, 1); 63 gpio_set_value(15, 1);
64 return 0; 64 return 0;
65} 65}
66 66
67static void innovator1610_panel_disable(struct lcd_panel *panel) 67static void innovator1610_panel_disable(struct lcd_panel *panel)
68{ 68{
69 /* set GPIO13, GPIO14 and GPIO15 low */ 69 /* set GPIO13, GPIO14 and GPIO15 low */
70 omap_set_gpio_dataout(14, 0); 70 gpio_set_value(14, 0);
71 omap_set_gpio_dataout(15, 0); 71 gpio_set_value(15, 0);
72} 72}
73 73
74static unsigned long innovator1610_panel_get_caps(struct lcd_panel *panel) 74static unsigned long innovator1610_panel_get_caps(struct lcd_panel *panel)
diff --git a/drivers/video/omap/lcd_osk.c b/drivers/video/omap/lcd_osk.c
index a4a725f427a4..379c96d36da5 100644
--- a/drivers/video/omap/lcd_osk.c
+++ b/drivers/video/omap/lcd_osk.c
@@ -29,6 +29,7 @@
29 29
30static int osk_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev) 30static int osk_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
31{ 31{
32 /* gpio2 was allocated in board init */
32 return 0; 33 return 0;
33} 34}
34 35
@@ -47,11 +48,8 @@ static int osk_panel_enable(struct lcd_panel *panel)
47 /* Set PWL level */ 48 /* Set PWL level */
48 omap_writeb(0xFF, OMAP_PWL_ENABLE); 49 omap_writeb(0xFF, OMAP_PWL_ENABLE);
49 50
50 /* configure GPIO2 as output */ 51 /* set GPIO2 high (lcd power enabled) */
51 omap_set_gpio_direction(2, 0); 52 gpio_set_value(2, 1);
52
53 /* set GPIO2 high */
54 omap_set_gpio_dataout(2, 1);
55 53
56 return 0; 54 return 0;
57} 55}
@@ -65,7 +63,7 @@ static void osk_panel_disable(struct lcd_panel *panel)
65 omap_writeb(0x00, OMAP_PWL_CLK_ENABLE); 63 omap_writeb(0x00, OMAP_PWL_CLK_ENABLE);
66 64
67 /* set GPIO2 low */ 65 /* set GPIO2 low */
68 omap_set_gpio_dataout(2, 0); 66 gpio_set_value(2, 0);
69} 67}
70 68
71static unsigned long osk_panel_get_caps(struct lcd_panel *panel) 69static unsigned long osk_panel_get_caps(struct lcd_panel *panel)
diff --git a/drivers/video/omap/lcd_sx1.c b/drivers/video/omap/lcd_sx1.c
index caa6a896cb8b..e55de201b8ff 100644
--- a/drivers/video/omap/lcd_sx1.c
+++ b/drivers/video/omap/lcd_sx1.c
@@ -81,21 +81,21 @@ static void epson_sendbyte(int flag, unsigned char byte)
81 int i, shifter = 0x80; 81 int i, shifter = 0x80;
82 82
83 if (!flag) 83 if (!flag)
84 omap_set_gpio_dataout(_A_LCD_SSC_A0, 0); 84 gpio_set_value(_A_LCD_SSC_A0, 0);
85 mdelay(2); 85 mdelay(2);
86 omap_set_gpio_dataout(A_LCD_SSC_RD, 1); 86 gpio_set_value(A_LCD_SSC_RD, 1);
87 87
88 omap_set_gpio_dataout(A_LCD_SSC_SD, flag); 88 gpio_set_value(A_LCD_SSC_SD, flag);
89 89
90 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200); 90 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200);
91 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202); 91 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202);
92 for (i = 0; i < 8; i++) { 92 for (i = 0; i < 8; i++) {
93 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200); 93 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2200);
94 omap_set_gpio_dataout(A_LCD_SSC_SD, shifter & byte); 94 gpio_set_value(A_LCD_SSC_SD, shifter & byte);
95 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202); 95 OMAP_MCBSP_WRITE(OMAP1510_MCBSP3_BASE, PCR0, 0x2202);
96 shifter >>= 1; 96 shifter >>= 1;
97 } 97 }
98 omap_set_gpio_dataout(_A_LCD_SSC_A0, 1); 98 gpio_set_value(_A_LCD_SSC_A0, 1);
99} 99}
100 100
101static void init_system(void) 101static void init_system(void)
@@ -107,25 +107,18 @@ static void init_system(void)
107static void setup_GPIO(void) 107static void setup_GPIO(void)
108{ 108{
109 /* new wave */ 109 /* new wave */
110 omap_request_gpio(A_LCD_SSC_RD); 110 gpio_request(A_LCD_SSC_RD, "lcd_ssc_rd");
111 omap_request_gpio(A_LCD_SSC_SD); 111 gpio_request(A_LCD_SSC_SD, "lcd_ssc_sd");
112 omap_request_gpio(_A_LCD_RESET); 112 gpio_request(_A_LCD_RESET, "lcd_reset");
113 omap_request_gpio(_A_LCD_SSC_CS); 113 gpio_request(_A_LCD_SSC_CS, "lcd_ssc_cs");
114 omap_request_gpio(_A_LCD_SSC_A0); 114 gpio_request(_A_LCD_SSC_A0, "lcd_ssc_a0");
115 115
116 /* set all GPIOs to output */ 116 /* set GPIOs to output, with initial data */
117 omap_set_gpio_direction(A_LCD_SSC_RD, 0); 117 gpio_direction_output(A_LCD_SSC_RD, 1);
118 omap_set_gpio_direction(A_LCD_SSC_SD, 0); 118 gpio_direction_output(A_LCD_SSC_SD, 0);
119 omap_set_gpio_direction(_A_LCD_RESET, 0); 119 gpio_direction_output(_A_LCD_RESET, 0);
120 omap_set_gpio_direction(_A_LCD_SSC_CS, 0); 120 gpio_direction_output(_A_LCD_SSC_CS, 1);
121 omap_set_gpio_direction(_A_LCD_SSC_A0, 0); 121 gpio_direction_output(_A_LCD_SSC_A0, 1);
122
123 /* set GPIO data */
124 omap_set_gpio_dataout(A_LCD_SSC_RD, 1);
125 omap_set_gpio_dataout(A_LCD_SSC_SD, 0);
126 omap_set_gpio_dataout(_A_LCD_RESET, 0);
127 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1);
128 omap_set_gpio_dataout(_A_LCD_SSC_A0, 1);
129} 122}
130 123
131static void display_init(void) 124static void display_init(void)
@@ -139,61 +132,61 @@ static void display_init(void)
139 mdelay(2); 132 mdelay(2);
140 133
141 /* reset LCD */ 134 /* reset LCD */
142 omap_set_gpio_dataout(A_LCD_SSC_SD, 1); 135 gpio_set_value(A_LCD_SSC_SD, 1);
143 epson_sendbyte(0, 0x25); 136 epson_sendbyte(0, 0x25);
144 137
145 omap_set_gpio_dataout(_A_LCD_RESET, 0); 138 gpio_set_value(_A_LCD_RESET, 0);
146 mdelay(10); 139 mdelay(10);
147 omap_set_gpio_dataout(_A_LCD_RESET, 1); 140 gpio_set_value(_A_LCD_RESET, 1);
148 141
149 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 142 gpio_set_value(_A_LCD_SSC_CS, 1);
150 mdelay(2); 143 mdelay(2);
151 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 144 gpio_set_value(_A_LCD_SSC_CS, 0);
152 145
153 /* init LCD, phase 1 */ 146 /* init LCD, phase 1 */
154 epson_sendbyte(0, 0xCA); 147 epson_sendbyte(0, 0xCA);
155 for (i = 0; i < 10; i++) 148 for (i = 0; i < 10; i++)
156 epson_sendbyte(1, INIT_1[i]); 149 epson_sendbyte(1, INIT_1[i]);
157 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 150 gpio_set_value(_A_LCD_SSC_CS, 1);
158 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 151 gpio_set_value(_A_LCD_SSC_CS, 0);
159 152
160 /* init LCD phase 2 */ 153 /* init LCD phase 2 */
161 epson_sendbyte(0, 0xCB); 154 epson_sendbyte(0, 0xCB);
162 for (i = 0; i < 125; i++) 155 for (i = 0; i < 125; i++)
163 epson_sendbyte(1, INIT_2[i]); 156 epson_sendbyte(1, INIT_2[i]);
164 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 157 gpio_set_value(_A_LCD_SSC_CS, 1);
165 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 158 gpio_set_value(_A_LCD_SSC_CS, 0);
166 159
167 /* init LCD phase 2a */ 160 /* init LCD phase 2a */
168 epson_sendbyte(0, 0xCC); 161 epson_sendbyte(0, 0xCC);
169 for (i = 0; i < 14; i++) 162 for (i = 0; i < 14; i++)
170 epson_sendbyte(1, INIT_3[i]); 163 epson_sendbyte(1, INIT_3[i]);
171 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 164 gpio_set_value(_A_LCD_SSC_CS, 1);
172 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 165 gpio_set_value(_A_LCD_SSC_CS, 0);
173 166
174 /* init LCD phase 3 */ 167 /* init LCD phase 3 */
175 epson_sendbyte(0, 0xBC); 168 epson_sendbyte(0, 0xBC);
176 epson_sendbyte(1, 0x08); 169 epson_sendbyte(1, 0x08);
177 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 170 gpio_set_value(_A_LCD_SSC_CS, 1);
178 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 171 gpio_set_value(_A_LCD_SSC_CS, 0);
179 172
180 /* init LCD phase 4 */ 173 /* init LCD phase 4 */
181 epson_sendbyte(0, 0x07); 174 epson_sendbyte(0, 0x07);
182 epson_sendbyte(1, 0x05); 175 epson_sendbyte(1, 0x05);
183 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 176 gpio_set_value(_A_LCD_SSC_CS, 1);
184 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 177 gpio_set_value(_A_LCD_SSC_CS, 0);
185 178
186 /* init LCD phase 5 */ 179 /* init LCD phase 5 */
187 epson_sendbyte(0, 0x94); 180 epson_sendbyte(0, 0x94);
188 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 181 gpio_set_value(_A_LCD_SSC_CS, 1);
189 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 182 gpio_set_value(_A_LCD_SSC_CS, 0);
190 183
191 /* init LCD phase 6 */ 184 /* init LCD phase 6 */
192 epson_sendbyte(0, 0xC6); 185 epson_sendbyte(0, 0xC6);
193 epson_sendbyte(1, 0x80); 186 epson_sendbyte(1, 0x80);
194 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 187 gpio_set_value(_A_LCD_SSC_CS, 1);
195 mdelay(100); /* used to be 1000 */ 188 mdelay(100); /* used to be 1000 */
196 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 189 gpio_set_value(_A_LCD_SSC_CS, 0);
197 190
198 /* init LCD phase 7 */ 191 /* init LCD phase 7 */
199 epson_sendbyte(0, 0x16); 192 epson_sendbyte(0, 0x16);
@@ -201,8 +194,8 @@ static void display_init(void)
201 epson_sendbyte(1, 0x00); 194 epson_sendbyte(1, 0x00);
202 epson_sendbyte(1, 0xB1); 195 epson_sendbyte(1, 0xB1);
203 epson_sendbyte(1, 0x00); 196 epson_sendbyte(1, 0x00);
204 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 197 gpio_set_value(_A_LCD_SSC_CS, 1);
205 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 198 gpio_set_value(_A_LCD_SSC_CS, 0);
206 199
207 /* init LCD phase 8 */ 200 /* init LCD phase 8 */
208 epson_sendbyte(0, 0x76); 201 epson_sendbyte(0, 0x76);
@@ -210,12 +203,12 @@ static void display_init(void)
210 epson_sendbyte(1, 0x00); 203 epson_sendbyte(1, 0x00);
211 epson_sendbyte(1, 0xDB); 204 epson_sendbyte(1, 0xDB);
212 epson_sendbyte(1, 0x00); 205 epson_sendbyte(1, 0x00);
213 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 206 gpio_set_value(_A_LCD_SSC_CS, 1);
214 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 207 gpio_set_value(_A_LCD_SSC_CS, 0);
215 208
216 /* init LCD phase 9 */ 209 /* init LCD phase 9 */
217 epson_sendbyte(0, 0xAF); 210 epson_sendbyte(0, 0xAF);
218 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 211 gpio_set_value(_A_LCD_SSC_CS, 1);
219} 212}
220 213
221static int sx1_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev) 214static int sx1_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
@@ -231,18 +224,18 @@ static void sx1_panel_disable(struct lcd_panel *panel)
231{ 224{
232 printk(KERN_INFO "SX1: LCD panel disable\n"); 225 printk(KERN_INFO "SX1: LCD panel disable\n");
233 sx1_setmmipower(0); 226 sx1_setmmipower(0);
234 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 227 gpio_set_value(_A_LCD_SSC_CS, 1);
235 228
236 epson_sendbyte(0, 0x25); 229 epson_sendbyte(0, 0x25);
237 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 230 gpio_set_value(_A_LCD_SSC_CS, 0);
238 231
239 epson_sendbyte(0, 0xAE); 232 epson_sendbyte(0, 0xAE);
240 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 233 gpio_set_value(_A_LCD_SSC_CS, 1);
241 mdelay(100); 234 mdelay(100);
242 omap_set_gpio_dataout(_A_LCD_SSC_CS, 0); 235 gpio_set_value(_A_LCD_SSC_CS, 0);
243 236
244 epson_sendbyte(0, 0x95); 237 epson_sendbyte(0, 0x95);
245 omap_set_gpio_dataout(_A_LCD_SSC_CS, 1); 238 gpio_set_value(_A_LCD_SSC_CS, 1);
246} 239}
247 240
248static int sx1_panel_enable(struct lcd_panel *panel) 241static int sx1_panel_enable(struct lcd_panel *panel)
diff --git a/drivers/video/omap/lcdc.c b/drivers/video/omap/lcdc.c
index 83514f066712..6e2ea7518761 100644
--- a/drivers/video/omap/lcdc.c
+++ b/drivers/video/omap/lcdc.c
@@ -34,6 +34,8 @@
34 34
35#include <asm/mach-types.h> 35#include <asm/mach-types.h>
36 36
37#include "lcdc.h"
38
37#define MODULE_NAME "lcdc" 39#define MODULE_NAME "lcdc"
38 40
39#define OMAP_LCDC_BASE 0xfffec000 41#define OMAP_LCDC_BASE 0xfffec000
diff --git a/drivers/video/omap/lcdc.h b/drivers/video/omap/lcdc.h
index adb731e5314a..845222270db3 100644
--- a/drivers/video/omap/lcdc.h
+++ b/drivers/video/omap/lcdc.h
@@ -4,4 +4,6 @@
4int omap_lcdc_set_dma_callback(void (*callback)(void *data), void *data); 4int omap_lcdc_set_dma_callback(void (*callback)(void *data), void *data);
5void omap_lcdc_free_dma_callback(void); 5void omap_lcdc_free_dma_callback(void);
6 6
7extern const struct lcd_ctrl omap1_int_ctrl;
8
7#endif 9#endif
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 51a138bd113c..5a5e407dc45f 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -31,11 +31,14 @@
31#include <mach/dma.h> 31#include <mach/dma.h>
32#include <mach/omapfb.h> 32#include <mach/omapfb.h>
33 33
34#include "lcdc.h"
35#include "dispc.h"
36
34#define MODULE_NAME "omapfb" 37#define MODULE_NAME "omapfb"
35 38
36static unsigned int def_accel; 39static unsigned int def_accel;
37static unsigned long def_vram[OMAPFB_PLANE_NUM]; 40static unsigned long def_vram[OMAPFB_PLANE_NUM];
38static int def_vram_cnt; 41static unsigned int def_vram_cnt;
39static unsigned long def_vxres; 42static unsigned long def_vxres;
40static unsigned long def_vyres; 43static unsigned long def_vyres;
41static unsigned int def_rotate; 44static unsigned int def_rotate;
@@ -84,12 +87,10 @@ static struct caps_table_struct color_caps[] = {
84 * LCD panel 87 * LCD panel
85 * --------------------------------------------------------------------------- 88 * ---------------------------------------------------------------------------
86 */ 89 */
87extern struct lcd_ctrl omap1_int_ctrl;
88extern struct lcd_ctrl omap2_int_ctrl;
89extern struct lcd_ctrl hwa742_ctrl; 90extern struct lcd_ctrl hwa742_ctrl;
90extern struct lcd_ctrl blizzard_ctrl; 91extern struct lcd_ctrl blizzard_ctrl;
91 92
92static struct lcd_ctrl *ctrls[] = { 93static const struct lcd_ctrl *ctrls[] = {
93#ifdef CONFIG_ARCH_OMAP1 94#ifdef CONFIG_ARCH_OMAP1
94 &omap1_int_ctrl, 95 &omap1_int_ctrl,
95#else 96#else
@@ -740,7 +741,7 @@ static int omapfb_update_win(struct fb_info *fbi,
740 int ret; 741 int ret;
741 742
742 omapfb_rqueue_lock(plane->fbdev); 743 omapfb_rqueue_lock(plane->fbdev);
743 ret = omapfb_update_window_async(fbi, win, NULL, 0); 744 ret = omapfb_update_window_async(fbi, win, NULL, NULL);
744 omapfb_rqueue_unlock(plane->fbdev); 745 omapfb_rqueue_unlock(plane->fbdev);
745 746
746 return ret; 747 return ret;
@@ -768,7 +769,7 @@ static int omapfb_update_full_screen(struct fb_info *fbi)
768 win.format = 0; 769 win.format = 0;
769 770
770 omapfb_rqueue_lock(fbdev); 771 omapfb_rqueue_lock(fbdev);
771 r = fbdev->ctrl->update_window(fbi, &win, NULL, 0); 772 r = fbdev->ctrl->update_window(fbi, &win, NULL, NULL);
772 omapfb_rqueue_unlock(fbdev); 773 omapfb_rqueue_unlock(fbdev);
773 774
774 return r; 775 return r;
@@ -1047,7 +1048,7 @@ void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval)
1047 win.height = 2; 1048 win.height = 2;
1048 win.out_width = 2; 1049 win.out_width = 2;
1049 win.out_height = 2; 1050 win.out_height = 2;
1050 fbdev->ctrl->update_window(fbdev->fb_info[0], &win, NULL, 0); 1051 fbdev->ctrl->update_window(fbdev->fb_info[0], &win, NULL, NULL);
1051 } 1052 }
1052 omapfb_rqueue_unlock(fbdev); 1053 omapfb_rqueue_unlock(fbdev);
1053} 1054}
diff --git a/drivers/video/omap/rfbi.c b/drivers/video/omap/rfbi.c
index 4a6f13d3facf..a13c8dcad2a8 100644
--- a/drivers/video/omap/rfbi.c
+++ b/drivers/video/omap/rfbi.c
@@ -59,7 +59,7 @@
59#define DISPC_CONTROL 0x0040 59#define DISPC_CONTROL 0x0040
60 60
61static struct { 61static struct {
62 u32 base; 62 void __iomem *base;
63 void (*lcdc_callback)(void *data); 63 void (*lcdc_callback)(void *data);
64 void *lcdc_callback_data; 64 void *lcdc_callback_data;
65 unsigned long l4_khz; 65 unsigned long l4_khz;
@@ -518,7 +518,11 @@ static int rfbi_init(struct omapfb_device *fbdev)
518 int r; 518 int r;
519 519
520 rfbi.fbdev = fbdev; 520 rfbi.fbdev = fbdev;
521 rfbi.base = io_p2v(RFBI_BASE); 521 rfbi.base = ioremap(RFBI_BASE, SZ_1K);
522 if (!rfbi.base) {
523 dev_err(fbdev->dev, "can't ioremap RFBI\n");
524 return -ENOMEM;
525 }
522 526
523 if ((r = rfbi_get_clocks()) < 0) 527 if ((r = rfbi_get_clocks()) < 0)
524 return r; 528 return r;
@@ -566,6 +570,7 @@ static void rfbi_cleanup(void)
566{ 570{
567 omap_dispc_free_irq(); 571 omap_dispc_free_irq();
568 rfbi_put_clocks(); 572 rfbi_put_clocks();
573 iounmap(rfbi.base);
569} 574}
570 575
571const struct lcd_ctrl_extif omap2_ext_if = { 576const struct lcd_ctrl_extif omap2_ext_if = {
diff --git a/drivers/video/omap/sossi.c b/drivers/video/omap/sossi.c
index 6359353c2c67..a76946220249 100644
--- a/drivers/video/omap/sossi.c
+++ b/drivers/video/omap/sossi.c
@@ -574,7 +574,12 @@ static int sossi_init(struct omapfb_device *fbdev)
574 struct clk *dpll1out_ck; 574 struct clk *dpll1out_ck;
575 int r; 575 int r;
576 576
577 sossi.base = (void __iomem *)IO_ADDRESS(OMAP_SOSSI_BASE); 577 sossi.base = ioremap(OMAP_SOSSI_BASE, SZ_1K);
578 if (!sossi.base) {
579 dev_err(fbdev->dev, "can't ioremap SoSSI\n");
580 return -ENOMEM;
581 }
582
578 sossi.fbdev = fbdev; 583 sossi.fbdev = fbdev;
579 spin_lock_init(&sossi.lock); 584 spin_lock_init(&sossi.lock);
580 585
@@ -665,6 +670,7 @@ static void sossi_cleanup(void)
665{ 670{
666 omap_lcdc_free_dma_callback(); 671 omap_lcdc_free_dma_callback();
667 clk_put(sossi.fck); 672 clk_put(sossi.fck);
673 iounmap(sossi.base);
668} 674}
669 675
670struct lcd_ctrl_extif omap1_ext_if = { 676struct lcd_ctrl_extif omap1_ext_if = {
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index b829dc7c5edf..a7b01d2724b5 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -50,6 +50,11 @@
50#define dbg(fmt, args...) do { } while (0) 50#define dbg(fmt, args...) do { } while (0)
51#endif 51#endif
52 52
53static const int __devinitconst s1d13xxxfb_revisions[] = {
54 S1D13506_CHIP_REV, /* Rev.4 on HP Jornada 7xx S1D13506 */
55 S1D13806_CHIP_REV, /* Rev.7 on .. */
56};
57
53/* 58/*
54 * Here we define the default struct fb_fix_screeninfo 59 * Here we define the default struct fb_fix_screeninfo
55 */ 60 */
@@ -538,6 +543,7 @@ s1d13xxxfb_probe(struct platform_device *pdev)
538 struct fb_info *info; 543 struct fb_info *info;
539 struct s1d13xxxfb_pdata *pdata = NULL; 544 struct s1d13xxxfb_pdata *pdata = NULL;
540 int ret = 0; 545 int ret = 0;
546 int i;
541 u8 revision; 547 u8 revision;
542 548
543 dbg("probe called: device is %p\n", pdev); 549 dbg("probe called: device is %p\n", pdev);
@@ -607,10 +613,19 @@ s1d13xxxfb_probe(struct platform_device *pdev)
607 goto bail; 613 goto bail;
608 } 614 }
609 615
610 revision = s1d13xxxfb_readreg(default_par, S1DREG_REV_CODE); 616 revision = s1d13xxxfb_readreg(default_par, S1DREG_REV_CODE) >> 2;
611 if ((revision >> 2) != S1D_CHIP_REV) { 617
612 printk(KERN_INFO PFX "chip not found: %i\n", (revision >> 2)); 618 ret = -ENODEV;
613 ret = -ENODEV; 619
620 for (i = 0; i < ARRAY_SIZE(s1d13xxxfb_revisions); i++) {
621 if (revision == s1d13xxxfb_revisions[i])
622 ret = 0;
623 }
624
625 if (!ret)
626 printk(KERN_INFO PFX "chip revision %i\n", revision);
627 else {
628 printk(KERN_INFO PFX "unknown chip revision %i\n", revision);
614 goto bail; 629 goto bail;
615 } 630 }
616 631
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 4599a4385bc9..14bd3f3680b8 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -1195,57 +1195,58 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
1195 return -ENOMEM; 1195 return -ENOMEM;
1196 1196
1197 default_par = info->par; 1197 default_par = info->par;
1198 info->fix = tdfx_fix;
1198 1199
1199 /* Configure the default fb_fix_screeninfo first */ 1200 /* Configure the default fb_fix_screeninfo first */
1200 switch (pdev->device) { 1201 switch (pdev->device) {
1201 case PCI_DEVICE_ID_3DFX_BANSHEE: 1202 case PCI_DEVICE_ID_3DFX_BANSHEE:
1202 strcpy(tdfx_fix.id, "3Dfx Banshee"); 1203 strcpy(info->fix.id, "3Dfx Banshee");
1203 default_par->max_pixclock = BANSHEE_MAX_PIXCLOCK; 1204 default_par->max_pixclock = BANSHEE_MAX_PIXCLOCK;
1204 break; 1205 break;
1205 case PCI_DEVICE_ID_3DFX_VOODOO3: 1206 case PCI_DEVICE_ID_3DFX_VOODOO3:
1206 strcpy(tdfx_fix.id, "3Dfx Voodoo3"); 1207 strcpy(info->fix.id, "3Dfx Voodoo3");
1207 default_par->max_pixclock = VOODOO3_MAX_PIXCLOCK; 1208 default_par->max_pixclock = VOODOO3_MAX_PIXCLOCK;
1208 break; 1209 break;
1209 case PCI_DEVICE_ID_3DFX_VOODOO5: 1210 case PCI_DEVICE_ID_3DFX_VOODOO5:
1210 strcpy(tdfx_fix.id, "3Dfx Voodoo5"); 1211 strcpy(info->fix.id, "3Dfx Voodoo5");
1211 default_par->max_pixclock = VOODOO5_MAX_PIXCLOCK; 1212 default_par->max_pixclock = VOODOO5_MAX_PIXCLOCK;
1212 break; 1213 break;
1213 } 1214 }
1214 1215
1215 tdfx_fix.mmio_start = pci_resource_start(pdev, 0); 1216 info->fix.mmio_start = pci_resource_start(pdev, 0);
1216 tdfx_fix.mmio_len = pci_resource_len(pdev, 0); 1217 info->fix.mmio_len = pci_resource_len(pdev, 0);
1217 if (!request_mem_region(tdfx_fix.mmio_start, tdfx_fix.mmio_len, 1218 if (!request_mem_region(info->fix.mmio_start, info->fix.mmio_len,
1218 "tdfx regbase")) { 1219 "tdfx regbase")) {
1219 printk(KERN_ERR "tdfxfb: Can't reserve regbase\n"); 1220 printk(KERN_ERR "tdfxfb: Can't reserve regbase\n");
1220 goto out_err; 1221 goto out_err;
1221 } 1222 }
1222 1223
1223 default_par->regbase_virt = 1224 default_par->regbase_virt =
1224 ioremap_nocache(tdfx_fix.mmio_start, tdfx_fix.mmio_len); 1225 ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
1225 if (!default_par->regbase_virt) { 1226 if (!default_par->regbase_virt) {
1226 printk(KERN_ERR "fb: Can't remap %s register area.\n", 1227 printk(KERN_ERR "fb: Can't remap %s register area.\n",
1227 tdfx_fix.id); 1228 info->fix.id);
1228 goto out_err_regbase; 1229 goto out_err_regbase;
1229 } 1230 }
1230 1231
1231 tdfx_fix.smem_start = pci_resource_start(pdev, 1); 1232 info->fix.smem_start = pci_resource_start(pdev, 1);
1232 tdfx_fix.smem_len = do_lfb_size(default_par, pdev->device); 1233 info->fix.smem_len = do_lfb_size(default_par, pdev->device);
1233 if (!tdfx_fix.smem_len) { 1234 if (!info->fix.smem_len) {
1234 printk(KERN_ERR "fb: Can't count %s memory.\n", tdfx_fix.id); 1235 printk(KERN_ERR "fb: Can't count %s memory.\n", info->fix.id);
1235 goto out_err_regbase; 1236 goto out_err_regbase;
1236 } 1237 }
1237 1238
1238 if (!request_mem_region(tdfx_fix.smem_start, 1239 if (!request_mem_region(info->fix.smem_start,
1239 pci_resource_len(pdev, 1), "tdfx smem")) { 1240 pci_resource_len(pdev, 1), "tdfx smem")) {
1240 printk(KERN_ERR "tdfxfb: Can't reserve smem\n"); 1241 printk(KERN_ERR "tdfxfb: Can't reserve smem\n");
1241 goto out_err_regbase; 1242 goto out_err_regbase;
1242 } 1243 }
1243 1244
1244 info->screen_base = ioremap_nocache(tdfx_fix.smem_start, 1245 info->screen_base = ioremap_nocache(info->fix.smem_start,
1245 tdfx_fix.smem_len); 1246 info->fix.smem_len);
1246 if (!info->screen_base) { 1247 if (!info->screen_base) {
1247 printk(KERN_ERR "fb: Can't remap %s framebuffer.\n", 1248 printk(KERN_ERR "fb: Can't remap %s framebuffer.\n",
1248 tdfx_fix.id); 1249 info->fix.id);
1249 goto out_err_screenbase; 1250 goto out_err_screenbase;
1250 } 1251 }
1251 1252
@@ -1257,20 +1258,19 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
1257 goto out_err_screenbase; 1258 goto out_err_screenbase;
1258 } 1259 }
1259 1260
1260 printk(KERN_INFO "fb: %s memory = %dK\n", tdfx_fix.id, 1261 printk(KERN_INFO "fb: %s memory = %dK\n", info->fix.id,
1261 tdfx_fix.smem_len >> 10); 1262 info->fix.smem_len >> 10);
1262 1263
1263 default_par->mtrr_handle = -1; 1264 default_par->mtrr_handle = -1;
1264 if (!nomtrr) 1265 if (!nomtrr)
1265 default_par->mtrr_handle = 1266 default_par->mtrr_handle =
1266 mtrr_add(tdfx_fix.smem_start, tdfx_fix.smem_len, 1267 mtrr_add(info->fix.smem_start, info->fix.smem_len,
1267 MTRR_TYPE_WRCOMB, 1); 1268 MTRR_TYPE_WRCOMB, 1);
1268 1269
1269 tdfx_fix.ypanstep = nopan ? 0 : 1; 1270 info->fix.ypanstep = nopan ? 0 : 1;
1270 tdfx_fix.ywrapstep = nowrap ? 0 : 1; 1271 info->fix.ywrapstep = nowrap ? 0 : 1;
1271 1272
1272 info->fbops = &tdfxfb_ops; 1273 info->fbops = &tdfxfb_ops;
1273 info->fix = tdfx_fix;
1274 info->pseudo_palette = default_par->palette; 1274 info->pseudo_palette = default_par->palette;
1275 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 1275 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1276#ifdef CONFIG_FB_3DFX_ACCEL 1276#ifdef CONFIG_FB_3DFX_ACCEL
@@ -1323,14 +1323,14 @@ out_err_iobase:
1323out_err_screenbase: 1323out_err_screenbase:
1324 if (info->screen_base) 1324 if (info->screen_base)
1325 iounmap(info->screen_base); 1325 iounmap(info->screen_base);
1326 release_mem_region(tdfx_fix.smem_start, pci_resource_len(pdev, 1)); 1326 release_mem_region(info->fix.smem_start, pci_resource_len(pdev, 1));
1327out_err_regbase: 1327out_err_regbase:
1328 /* 1328 /*
1329 * Cleanup after anything that was remapped/allocated. 1329 * Cleanup after anything that was remapped/allocated.
1330 */ 1330 */
1331 if (default_par->regbase_virt) 1331 if (default_par->regbase_virt)
1332 iounmap(default_par->regbase_virt); 1332 iounmap(default_par->regbase_virt);
1333 release_mem_region(tdfx_fix.mmio_start, tdfx_fix.mmio_len); 1333 release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
1334out_err: 1334out_err:
1335 framebuffer_release(info); 1335 framebuffer_release(info);
1336 return -ENXIO; 1336 return -ENXIO;
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
new file mode 100644
index 000000000000..2a380011e9ba
--- /dev/null
+++ b/drivers/video/tmiofb.c
@@ -0,0 +1,1050 @@
1/*
2 * Frame Buffer Device for Toshiba Mobile IO(TMIO) controller
3 *
4 * Copyright(C) 2005-2006 Chris Humbert
5 * Copyright(C) 2005 Dirk Opfer
6 * Copytight(C) 2007,2008 Dmitry Baryshkov
7 *
8 * Based on:
9 * drivers/video/w100fb.c
10 * code written by Sharp/Lineo for 2.4 kernels
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
14 * as published by the Free Software Foundation;
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25#include <linux/fb.h>
26#include <linux/interrupt.h>
27#include <linux/delay.h>
28/* Why should fb driver call console functions? because acquire_console_sem() */
29#include <linux/console.h>
30#include <linux/mfd/core.h>
31#include <linux/mfd/tmio.h>
32#include <linux/uaccess.h>
33
34/*
35 * accelerator commands
36 */
37#define TMIOFB_ACC_CSADR(x) (0x00000000 | ((x) & 0x001ffffe))
38#define TMIOFB_ACC_CHPIX(x) (0x01000000 | ((x) & 0x000003ff))
39#define TMIOFB_ACC_CVPIX(x) (0x02000000 | ((x) & 0x000003ff))
40#define TMIOFB_ACC_PSADR(x) (0x03000000 | ((x) & 0x00fffffe))
41#define TMIOFB_ACC_PHPIX(x) (0x04000000 | ((x) & 0x000003ff))
42#define TMIOFB_ACC_PVPIX(x) (0x05000000 | ((x) & 0x000003ff))
43#define TMIOFB_ACC_PHOFS(x) (0x06000000 | ((x) & 0x000003ff))
44#define TMIOFB_ACC_PVOFS(x) (0x07000000 | ((x) & 0x000003ff))
45#define TMIOFB_ACC_POADR(x) (0x08000000 | ((x) & 0x00fffffe))
46#define TMIOFB_ACC_RSTR(x) (0x09000000 | ((x) & 0x000000ff))
47#define TMIOFB_ACC_TCLOR(x) (0x0A000000 | ((x) & 0x0000ffff))
48#define TMIOFB_ACC_FILL(x) (0x0B000000 | ((x) & 0x0000ffff))
49#define TMIOFB_ACC_DSADR(x) (0x0C000000 | ((x) & 0x00fffffe))
50#define TMIOFB_ACC_SSADR(x) (0x0D000000 | ((x) & 0x00fffffe))
51#define TMIOFB_ACC_DHPIX(x) (0x0E000000 | ((x) & 0x000003ff))
52#define TMIOFB_ACC_DVPIX(x) (0x0F000000 | ((x) & 0x000003ff))
53#define TMIOFB_ACC_SHPIX(x) (0x10000000 | ((x) & 0x000003ff))
54#define TMIOFB_ACC_SVPIX(x) (0x11000000 | ((x) & 0x000003ff))
55#define TMIOFB_ACC_LBINI(x) (0x12000000 | ((x) & 0x0000ffff))
56#define TMIOFB_ACC_LBK2(x) (0x13000000 | ((x) & 0x0000ffff))
57#define TMIOFB_ACC_SHBINI(x) (0x14000000 | ((x) & 0x0000ffff))
58#define TMIOFB_ACC_SHBK2(x) (0x15000000 | ((x) & 0x0000ffff))
59#define TMIOFB_ACC_SVBINI(x) (0x16000000 | ((x) & 0x0000ffff))
60#define TMIOFB_ACC_SVBK2(x) (0x17000000 | ((x) & 0x0000ffff))
61
62#define TMIOFB_ACC_CMGO 0x20000000
63#define TMIOFB_ACC_CMGO_CEND 0x00000001
64#define TMIOFB_ACC_CMGO_INT 0x00000002
65#define TMIOFB_ACC_CMGO_CMOD 0x00000010
66#define TMIOFB_ACC_CMGO_CDVRV 0x00000020
67#define TMIOFB_ACC_CMGO_CDHRV 0x00000040
68#define TMIOFB_ACC_CMGO_RUND 0x00008000
69#define TMIOFB_ACC_SCGO 0x21000000
70#define TMIOFB_ACC_SCGO_CEND 0x00000001
71#define TMIOFB_ACC_SCGO_INT 0x00000002
72#define TMIOFB_ACC_SCGO_ROP3 0x00000004
73#define TMIOFB_ACC_SCGO_TRNS 0x00000008
74#define TMIOFB_ACC_SCGO_DVRV 0x00000010
75#define TMIOFB_ACC_SCGO_DHRV 0x00000020
76#define TMIOFB_ACC_SCGO_SVRV 0x00000040
77#define TMIOFB_ACC_SCGO_SHRV 0x00000080
78#define TMIOFB_ACC_SCGO_DSTXY 0x00008000
79#define TMIOFB_ACC_SBGO 0x22000000
80#define TMIOFB_ACC_SBGO_CEND 0x00000001
81#define TMIOFB_ACC_SBGO_INT 0x00000002
82#define TMIOFB_ACC_SBGO_DVRV 0x00000010
83#define TMIOFB_ACC_SBGO_DHRV 0x00000020
84#define TMIOFB_ACC_SBGO_SVRV 0x00000040
85#define TMIOFB_ACC_SBGO_SHRV 0x00000080
86#define TMIOFB_ACC_SBGO_SBMD 0x00000100
87#define TMIOFB_ACC_FLGO 0x23000000
88#define TMIOFB_ACC_FLGO_CEND 0x00000001
89#define TMIOFB_ACC_FLGO_INT 0x00000002
90#define TMIOFB_ACC_FLGO_ROP3 0x00000004
91#define TMIOFB_ACC_LDGO 0x24000000
92#define TMIOFB_ACC_LDGO_CEND 0x00000001
93#define TMIOFB_ACC_LDGO_INT 0x00000002
94#define TMIOFB_ACC_LDGO_ROP3 0x00000004
95#define TMIOFB_ACC_LDGO_ENDPX 0x00000008
96#define TMIOFB_ACC_LDGO_LVRV 0x00000010
97#define TMIOFB_ACC_LDGO_LHRV 0x00000020
98#define TMIOFB_ACC_LDGO_LDMOD 0x00000040
99
100/* a FIFO is always allocated, even if acceleration is not used */
101#define TMIOFB_FIFO_SIZE 512
102
103/*
104 * LCD Host Controller Configuration Register
105 *
106 * This iomem area supports only 16-bit IO.
107 */
108#define CCR_CMD 0x04 /* Command */
109#define CCR_REVID 0x08 /* Revision ID */
110#define CCR_BASEL 0x10 /* LCD Control Reg Base Addr Low */
111#define CCR_BASEH 0x12 /* LCD Control Reg Base Addr High */
112#define CCR_UGCC 0x40 /* Unified Gated Clock Control */
113#define CCR_GCC 0x42 /* Gated Clock Control */
114#define CCR_USC 0x50 /* Unified Software Clear */
115#define CCR_VRAMRTC 0x60 /* VRAM Timing Control */
116 /* 0x61 VRAM Refresh Control */
117#define CCR_VRAMSAC 0x62 /* VRAM Access Control */
118 /* 0x63 VRAM Status */
119#define CCR_VRAMBC 0x64 /* VRAM Block Control */
120
121/*
122 * LCD Control Register
123 *
124 * This iomem area supports only 16-bit IO.
125 */
126#define LCR_UIS 0x000 /* Unified Interrupt Status */
127#define LCR_VHPN 0x008 /* VRAM Horizontal Pixel Number */
128#define LCR_CFSAL 0x00a /* Command FIFO Start Address Low */
129#define LCR_CFSAH 0x00c /* Command FIFO Start Address High */
130#define LCR_CFS 0x00e /* Command FIFO Size */
131#define LCR_CFWS 0x010 /* Command FIFO Writeable Size */
132#define LCR_BBIE 0x012 /* BitBLT Interrupt Enable */
133#define LCR_BBISC 0x014 /* BitBLT Interrupt Status and Clear */
134#define LCR_CCS 0x016 /* Command Count Status */
135#define LCR_BBES 0x018 /* BitBLT Execution Status */
136#define LCR_CMDL 0x01c /* Command Low */
137#define LCR_CMDH 0x01e /* Command High */
138#define LCR_CFC 0x022 /* Command FIFO Clear */
139#define LCR_CCIFC 0x024 /* CMOS Camera IF Control */
140#define LCR_HWT 0x026 /* Hardware Test */
141#define LCR_LCDCCRC 0x100 /* LCDC Clock and Reset Control */
142#define LCR_LCDCC 0x102 /* LCDC Control */
143#define LCR_LCDCOPC 0x104 /* LCDC Output Pin Control */
144#define LCR_LCDIS 0x108 /* LCD Interrupt Status */
145#define LCR_LCDIM 0x10a /* LCD Interrupt Mask */
146#define LCR_LCDIE 0x10c /* LCD Interrupt Enable */
147#define LCR_GDSAL 0x122 /* Graphics Display Start Address Low */
148#define LCR_GDSAH 0x124 /* Graphics Display Start Address High */
149#define LCR_VHPCL 0x12a /* VRAM Horizontal Pixel Count Low */
150#define LCR_VHPCH 0x12c /* VRAM Horizontal Pixel Count High */
151#define LCR_GM 0x12e /* Graphic Mode(VRAM access enable) */
152#define LCR_HT 0x140 /* Horizontal Total */
153#define LCR_HDS 0x142 /* Horizontal Display Start */
154#define LCR_HSS 0x144 /* H-Sync Start */
155#define LCR_HSE 0x146 /* H-Sync End */
156#define LCR_HNP 0x14c /* Horizontal Number of Pixels */
157#define LCR_VT 0x150 /* Vertical Total */
158#define LCR_VDS 0x152 /* Vertical Display Start */
159#define LCR_VSS 0x154 /* V-Sync Start */
160#define LCR_VSE 0x156 /* V-Sync End */
161#define LCR_CDLN 0x160 /* Current Display Line Number */
162#define LCR_ILN 0x162 /* Interrupt Line Number */
163#define LCR_SP 0x164 /* Sync Polarity */
164#define LCR_MISC 0x166 /* MISC(RGB565 mode) */
165#define LCR_VIHSS 0x16a /* Video Interface H-Sync Start */
166#define LCR_VIVS 0x16c /* Video Interface Vertical Start */
167#define LCR_VIVE 0x16e /* Video Interface Vertical End */
168#define LCR_VIVSS 0x170 /* Video Interface V-Sync Start */
169#define LCR_VCCIS 0x17e /* Video / CMOS Camera Interface Select */
170#define LCR_VIDWSAL 0x180 /* VI Data Write Start Address Low */
171#define LCR_VIDWSAH 0x182 /* VI Data Write Start Address High */
172#define LCR_VIDRSAL 0x184 /* VI Data Read Start Address Low */
173#define LCR_VIDRSAH 0x186 /* VI Data Read Start Address High */
174#define LCR_VIPDDST 0x188 /* VI Picture Data Display Start Timing */
175#define LCR_VIPDDET 0x186 /* VI Picture Data Display End Timing */
176#define LCR_VIE 0x18c /* Video Interface Enable */
177#define LCR_VCS 0x18e /* Video/Camera Select */
178#define LCR_VPHWC 0x194 /* Video Picture Horizontal Wait Count */
179#define LCR_VPHS 0x196 /* Video Picture Horizontal Size */
180#define LCR_VPVWC 0x198 /* Video Picture Vertical Wait Count */
181#define LCR_VPVS 0x19a /* Video Picture Vertical Size */
182#define LCR_PLHPIX 0x1a0 /* PLHPIX */
183#define LCR_XS 0x1a2 /* XStart */
184#define LCR_XCKHW 0x1a4 /* XCK High Width */
185#define LCR_STHS 0x1a8 /* STH Start */
186#define LCR_VT2 0x1aa /* Vertical Total */
187#define LCR_YCKSW 0x1ac /* YCK Start Wait */
188#define LCR_YSTS 0x1ae /* YST Start */
189#define LCR_PPOLS 0x1b0 /* #PPOL Start */
190#define LCR_PRECW 0x1b2 /* PREC Width */
191#define LCR_VCLKHW 0x1b4 /* VCLK High Width */
192#define LCR_OC 0x1b6 /* Output Control */
193
194static char *mode_option __devinitdata;
195
196struct tmiofb_par {
197 u32 pseudo_palette[16];
198
199#ifdef CONFIG_FB_TMIO_ACCELL
200 wait_queue_head_t wait_acc;
201 bool use_polling;
202#endif
203
204 void __iomem *ccr;
205 void __iomem *lcr;
206};
207
208/*--------------------------------------------------------------------------*/
209
210/*
211 * reasons for an interrupt:
212 * uis bbisc lcdis
213 * 0100 0001 accelerator command completed
214 * 2000 0001 vsync start
215 * 2000 0002 display start
216 * 2000 0004 line number match(0x1ff mask???)
217 */
218static irqreturn_t tmiofb_irq(int irq, void *__info)
219{
220 struct fb_info *info = __info;
221 struct tmiofb_par *par = info->par;
222 unsigned int bbisc = tmio_ioread16(par->lcr + LCR_BBISC);
223
224
225 /*
226 * We were in polling mode and now we got correct irq.
227 * Switch back to IRQ-based sync of command FIFO
228 */
229 if (unlikely(par->use_polling && irq != -1)) {
230 printk(KERN_INFO "tmiofb: switching to waitq\n");
231 par->use_polling = false;
232 }
233
234 tmio_iowrite16(bbisc, par->lcr + LCR_BBISC);
235
236#ifdef CONFIG_FB_TMIO_ACCELL
237 if (bbisc & 1)
238 wake_up(&par->wait_acc);
239#endif
240
241 return IRQ_HANDLED;
242}
243
244
245/*--------------------------------------------------------------------------*/
246
247
248/*
249 * Turns off the LCD controller and LCD host controller.
250 */
251static int tmiofb_hw_stop(struct platform_device *dev)
252{
253 struct mfd_cell *cell = dev->dev.platform_data;
254 struct tmio_fb_data *data = cell->driver_data;
255 struct fb_info *info = platform_get_drvdata(dev);
256 struct tmiofb_par *par = info->par;
257
258 tmio_iowrite16(0, par->ccr + CCR_UGCC);
259 tmio_iowrite16(0, par->lcr + LCR_GM);
260 data->lcd_set_power(dev, 0);
261 tmio_iowrite16(0x0010, par->lcr + LCR_LCDCCRC);
262
263 return 0;
264}
265
266/*
267 * Initializes the LCD host controller.
268 */
269static int tmiofb_hw_init(struct platform_device *dev)
270{
271 struct mfd_cell *cell = dev->dev.platform_data;
272 struct fb_info *info = platform_get_drvdata(dev);
273 struct tmiofb_par *par = info->par;
274 const struct resource *nlcr = &cell->resources[0];
275 const struct resource *vram = &cell->resources[2];
276 unsigned long base;
277
278 if (nlcr == NULL || vram == NULL)
279 return -EINVAL;
280
281 base = nlcr->start;
282
283 tmio_iowrite16(0x003a, par->ccr + CCR_UGCC);
284 tmio_iowrite16(0x003a, par->ccr + CCR_GCC);
285 tmio_iowrite16(0x3f00, par->ccr + CCR_USC);
286
287 msleep(2); /* wait for device to settle */
288
289 tmio_iowrite16(0x0000, par->ccr + CCR_USC);
290 tmio_iowrite16(base >> 16, par->ccr + CCR_BASEH);
291 tmio_iowrite16(base, par->ccr + CCR_BASEL);
292 tmio_iowrite16(0x0002, par->ccr + CCR_CMD); /* base address enable */
293 tmio_iowrite16(0x40a8, par->ccr + CCR_VRAMRTC); /* VRAMRC, VRAMTC */
294 tmio_iowrite16(0x0018, par->ccr + CCR_VRAMSAC); /* VRAMSTS, VRAMAC */
295 tmio_iowrite16(0x0002, par->ccr + CCR_VRAMBC);
296 msleep(2); /* wait for device to settle */
297 tmio_iowrite16(0x000b, par->ccr + CCR_VRAMBC);
298
299 base = vram->start + info->screen_size;
300 tmio_iowrite16(base >> 16, par->lcr + LCR_CFSAH);
301 tmio_iowrite16(base, par->lcr + LCR_CFSAL);
302 tmio_iowrite16(TMIOFB_FIFO_SIZE - 1, par->lcr + LCR_CFS);
303 tmio_iowrite16(1, par->lcr + LCR_CFC);
304 tmio_iowrite16(1, par->lcr + LCR_BBIE);
305 tmio_iowrite16(0, par->lcr + LCR_CFWS);
306
307 return 0;
308}
309
310/*
311 * Sets the LCD controller's output resolution and pixel clock
312 */
313static void tmiofb_hw_mode(struct platform_device *dev)
314{
315 struct mfd_cell *cell = dev->dev.platform_data;
316 struct tmio_fb_data *data = cell->driver_data;
317 struct fb_info *info = platform_get_drvdata(dev);
318 struct fb_videomode *mode = info->mode;
319 struct tmiofb_par *par = info->par;
320 unsigned int i;
321
322 tmio_iowrite16(0, par->lcr + LCR_GM);
323 data->lcd_set_power(dev, 0);
324 tmio_iowrite16(0x0010, par->lcr + LCR_LCDCCRC);
325 data->lcd_mode(dev, mode);
326 data->lcd_set_power(dev, 1);
327
328 tmio_iowrite16(info->fix.line_length, par->lcr + LCR_VHPN);
329 tmio_iowrite16(0, par->lcr + LCR_GDSAH);
330 tmio_iowrite16(0, par->lcr + LCR_GDSAL);
331 tmio_iowrite16(info->fix.line_length >> 16, par->lcr + LCR_VHPCH);
332 tmio_iowrite16(info->fix.line_length, par->lcr + LCR_VHPCL);
333 tmio_iowrite16(i = 0, par->lcr + LCR_HSS);
334 tmio_iowrite16(i += mode->hsync_len, par->lcr + LCR_HSE);
335 tmio_iowrite16(i += mode->left_margin, par->lcr + LCR_HDS);
336 tmio_iowrite16(i += mode->xres + mode->right_margin, par->lcr + LCR_HT);
337 tmio_iowrite16(mode->xres, par->lcr + LCR_HNP);
338 tmio_iowrite16(i = 0, par->lcr + LCR_VSS);
339 tmio_iowrite16(i += mode->vsync_len, par->lcr + LCR_VSE);
340 tmio_iowrite16(i += mode->upper_margin, par->lcr + LCR_VDS);
341 tmio_iowrite16(i += mode->yres, par->lcr + LCR_ILN);
342 tmio_iowrite16(i += mode->lower_margin, par->lcr + LCR_VT);
343 tmio_iowrite16(3, par->lcr + LCR_MISC); /* RGB565 mode */
344 tmio_iowrite16(1, par->lcr + LCR_GM); /* VRAM enable */
345 tmio_iowrite16(0x4007, par->lcr + LCR_LCDCC);
346 tmio_iowrite16(3, par->lcr + LCR_SP); /* sync polarity */
347
348 tmio_iowrite16(0x0010, par->lcr + LCR_LCDCCRC);
349 msleep(5); /* wait for device to settle */
350 tmio_iowrite16(0x0014, par->lcr + LCR_LCDCCRC); /* STOP_CKP */
351 msleep(5); /* wait for device to settle */
352 tmio_iowrite16(0x0015, par->lcr + LCR_LCDCCRC); /* STOP_CKP|SOFT_RESET*/
353 tmio_iowrite16(0xfffa, par->lcr + LCR_VCS);
354}
355
356/*--------------------------------------------------------------------------*/
357
358#ifdef CONFIG_FB_TMIO_ACCELL
359static int __must_check
360tmiofb_acc_wait(struct fb_info *info, unsigned int ccs)
361{
362 struct tmiofb_par *par = info->par;
363 /*
364 * This code can be called whith interrupts disabled.
365 * So instead of relaying on irq to trigger the event,
366 * poll the state till the necessary command is executed.
367 */
368 if (irqs_disabled() || par->use_polling) {
369 int i = 0;
370 while (tmio_ioread16(par->lcr + LCR_CCS) > ccs) {
371 udelay(1);
372 i++;
373 if (i > 10000) {
374 pr_err("tmiofb: timeout waiting for %d\n",
375 ccs);
376 return -ETIMEDOUT;
377 }
378 tmiofb_irq(-1, info);
379 }
380 } else {
381 if (!wait_event_interruptible_timeout(par->wait_acc,
382 tmio_ioread16(par->lcr + LCR_CCS) <= ccs,
383 1000)) {
384 pr_err("tmiofb: timeout waiting for %d\n", ccs);
385 return -ETIMEDOUT;
386 }
387 }
388
389 return 0;
390}
391
392/*
393 * Writes an accelerator command to the accelerator's FIFO.
394 */
395static int
396tmiofb_acc_write(struct fb_info *info, const u32 *cmd, unsigned int count)
397{
398 struct tmiofb_par *par = info->par;
399 int ret;
400
401 ret = tmiofb_acc_wait(info, TMIOFB_FIFO_SIZE - count);
402 if (ret)
403 return ret;
404
405 for (; count; count--, cmd++) {
406 tmio_iowrite16(*cmd >> 16, par->lcr + LCR_CMDH);
407 tmio_iowrite16(*cmd, par->lcr + LCR_CMDL);
408 }
409
410 return ret;
411}
412
413/*
414 * Wait for the accelerator to finish its operations before writing
415 * to the framebuffer for consistent display output.
416 */
417static int tmiofb_sync(struct fb_info *fbi)
418{
419 struct tmiofb_par *par = fbi->par;
420
421 int ret;
422 int i = 0;
423
424 ret = tmiofb_acc_wait(fbi, 0);
425
426 while (tmio_ioread16(par->lcr + LCR_BBES) & 2) { /* blit active */
427 udelay(1);
428 i++ ;
429 if (i > 10000) {
430 printk(KERN_ERR "timeout waiting for blit to end!\n");
431 return -ETIMEDOUT;
432 }
433 }
434
435 return ret;
436}
437
438static void
439tmiofb_fillrect(struct fb_info *fbi, const struct fb_fillrect *rect)
440{
441 const u32 cmd[] = {
442 TMIOFB_ACC_DSADR((rect->dy * fbi->mode->xres + rect->dx) * 2),
443 TMIOFB_ACC_DHPIX(rect->width - 1),
444 TMIOFB_ACC_DVPIX(rect->height - 1),
445 TMIOFB_ACC_FILL(rect->color),
446 TMIOFB_ACC_FLGO,
447 };
448
449 if (fbi->state != FBINFO_STATE_RUNNING ||
450 fbi->flags & FBINFO_HWACCEL_DISABLED) {
451 cfb_fillrect(fbi, rect);
452 return;
453 }
454
455 tmiofb_acc_write(fbi, cmd, ARRAY_SIZE(cmd));
456}
457
458static void
459tmiofb_copyarea(struct fb_info *fbi, const struct fb_copyarea *area)
460{
461 const u32 cmd[] = {
462 TMIOFB_ACC_DSADR((area->dy * fbi->mode->xres + area->dx) * 2),
463 TMIOFB_ACC_DHPIX(area->width - 1),
464 TMIOFB_ACC_DVPIX(area->height - 1),
465 TMIOFB_ACC_SSADR((area->sy * fbi->mode->xres + area->sx) * 2),
466 TMIOFB_ACC_SCGO,
467 };
468
469 if (fbi->state != FBINFO_STATE_RUNNING ||
470 fbi->flags & FBINFO_HWACCEL_DISABLED) {
471 cfb_copyarea(fbi, area);
472 return;
473 }
474
475 tmiofb_acc_write(fbi, cmd, ARRAY_SIZE(cmd));
476}
477#endif
478
479static void tmiofb_clearscreen(struct fb_info *info)
480{
481 const struct fb_fillrect rect = {
482 .dx = 0,
483 .dy = 0,
484 .width = info->mode->xres,
485 .height = info->mode->yres,
486 .color = 0,
487 .rop = ROP_COPY,
488 };
489
490 info->fbops->fb_fillrect(info, &rect);
491}
492
493static int tmiofb_vblank(struct fb_info *fbi, struct fb_vblank *vblank)
494{
495 struct tmiofb_par *par = fbi->par;
496 struct fb_videomode *mode = fbi->mode;
497 unsigned int vcount = tmio_ioread16(par->lcr + LCR_CDLN);
498 unsigned int vds = mode->vsync_len + mode->upper_margin;
499
500 vblank->vcount = vcount;
501 vblank->flags = FB_VBLANK_HAVE_VBLANK | FB_VBLANK_HAVE_VCOUNT
502 | FB_VBLANK_HAVE_VSYNC;
503
504 if (vcount < mode->vsync_len)
505 vblank->flags |= FB_VBLANK_VSYNCING;
506
507 if (vcount < vds || vcount > vds + mode->yres)
508 vblank->flags |= FB_VBLANK_VBLANKING;
509
510 return 0;
511}
512
513
514static int tmiofb_ioctl(struct fb_info *fbi,
515 unsigned int cmd, unsigned long arg)
516{
517 switch (cmd) {
518 case FBIOGET_VBLANK: {
519 struct fb_vblank vblank = {0};
520 void __user *argp = (void __user *) arg;
521
522 tmiofb_vblank(fbi, &vblank);
523 if (copy_to_user(argp, &vblank, sizeof vblank))
524 return -EFAULT;
525 return 0;
526 }
527
528#ifdef CONFIG_FB_TMIO_ACCELL
529 case FBIO_TMIO_ACC_SYNC:
530 tmiofb_sync(fbi);
531 return 0;
532
533 case FBIO_TMIO_ACC_WRITE: {
534 u32 __user *argp = (void __user *) arg;
535 u32 len;
536 u32 acc[16];
537
538 if (get_user(len, argp))
539 return -EFAULT;
540 if (len > ARRAY_SIZE(acc))
541 return -EINVAL;
542 if (copy_from_user(acc, argp + 1, sizeof(u32) * len))
543 return -EFAULT;
544
545 return tmiofb_acc_write(fbi, acc, len);
546 }
547#endif
548 }
549
550 return -ENOTTY;
551}
552
553/*--------------------------------------------------------------------------*/
554
555/* Select the smallest mode that allows the desired resolution to be
556 * displayed. If desired, the x and y parameters can be rounded up to
557 * match the selected mode.
558 */
559static struct fb_videomode *
560tmiofb_find_mode(struct fb_info *info, struct fb_var_screeninfo *var)
561{
562 struct mfd_cell *cell =
563 info->device->platform_data;
564 struct tmio_fb_data *data = cell->driver_data;
565 struct fb_videomode *best = NULL;
566 int i;
567
568 for (i = 0; i < data->num_modes; i++) {
569 struct fb_videomode *mode = data->modes + i;
570
571 if (mode->xres >= var->xres && mode->yres >= var->yres
572 && (!best || (mode->xres < best->xres
573 && mode->yres < best->yres)))
574 best = mode;
575 }
576
577 return best;
578}
579
580static int tmiofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
581{
582
583 struct fb_videomode *mode;
584 struct mfd_cell *cell =
585 info->device->platform_data;
586 struct tmio_fb_data *data = cell->driver_data;
587
588 mode = tmiofb_find_mode(info, var);
589 if (!mode || var->bits_per_pixel > 16)
590 return -EINVAL;
591
592 fb_videomode_to_var(var, mode);
593
594 var->xres_virtual = mode->xres;
595 var->yres_virtual = info->screen_size / (mode->xres * 2);
596
597 if (var->yres_virtual < var->yres)
598 return -EINVAL;
599
600 var->xoffset = 0;
601 var->yoffset = 0;
602 var->bits_per_pixel = 16;
603 var->grayscale = 0;
604 var->red.offset = 11;
605 var->red.length = 5;
606 var->green.offset = 5;
607 var->green.length = 6;
608 var->blue.offset = 0;
609 var->blue.length = 5;
610 var->transp.offset = 0;
611 var->transp.length = 0;
612 var->nonstd = 0;
613 var->height = data->height; /* mm */
614 var->width = data->width; /* mm */
615 var->rotate = 0;
616 return 0;
617}
618
619static int tmiofb_set_par(struct fb_info *info)
620{
621 struct fb_var_screeninfo *var = &info->var;
622 struct fb_videomode *mode;
623
624 mode = tmiofb_find_mode(info, var);
625 if (!mode)
626 return -EINVAL;
627
628 info->mode = mode;
629 info->fix.line_length = info->mode->xres *
630 var->bits_per_pixel / 8;
631
632 tmiofb_hw_mode(to_platform_device(info->device));
633 tmiofb_clearscreen(info);
634 return 0;
635}
636
637static int tmiofb_setcolreg(unsigned regno, unsigned red, unsigned green,
638 unsigned blue, unsigned transp,
639 struct fb_info *info)
640{
641 struct tmiofb_par *par = info->par;
642
643 if (regno < ARRAY_SIZE(par->pseudo_palette)) {
644 par->pseudo_palette[regno] =
645 ((red & 0xf800)) |
646 ((green & 0xfc00) >> 5) |
647 ((blue & 0xf800) >> 11);
648 return 0;
649 }
650
651 return -EINVAL;
652}
653
654static int tmiofb_blank(int blank, struct fb_info *info)
655{
656 /*
657 * everything is done in lcd/bl drivers.
658 * this is purely to make sysfs happy and work.
659 */
660 return 0;
661}
662
663static struct fb_ops tmiofb_ops = {
664 .owner = THIS_MODULE,
665
666 .fb_ioctl = tmiofb_ioctl,
667 .fb_check_var = tmiofb_check_var,
668 .fb_set_par = tmiofb_set_par,
669 .fb_setcolreg = tmiofb_setcolreg,
670 .fb_blank = tmiofb_blank,
671 .fb_imageblit = cfb_imageblit,
672#ifdef CONFIG_FB_TMIO_ACCELL
673 .fb_sync = tmiofb_sync,
674 .fb_fillrect = tmiofb_fillrect,
675 .fb_copyarea = tmiofb_copyarea,
676#else
677 .fb_fillrect = cfb_fillrect,
678 .fb_copyarea = cfb_copyarea,
679#endif
680};
681
682/*--------------------------------------------------------------------------*/
683
684static int __devinit tmiofb_probe(struct platform_device *dev)
685{
686 struct mfd_cell *cell = dev->dev.platform_data;
687 struct tmio_fb_data *data = cell->driver_data;
688 struct resource *ccr = platform_get_resource(dev, IORESOURCE_MEM, 1);
689 struct resource *lcr = platform_get_resource(dev, IORESOURCE_MEM, 0);
690 struct resource *vram = platform_get_resource(dev, IORESOURCE_MEM, 2);
691 int irq = platform_get_irq(dev, 0);
692 struct fb_info *info;
693 struct tmiofb_par *par;
694 int retval;
695
696 /*
697 * This is the only way ATM to disable the fb
698 */
699 if (data == NULL) {
700 dev_err(&dev->dev, "NULL platform data!\n");
701 return -EINVAL;
702 }
703
704 info = framebuffer_alloc(sizeof(struct tmiofb_par), &dev->dev);
705
706 if (!info)
707 return -ENOMEM;
708
709 par = info->par;
710
711#ifdef CONFIG_FB_TMIO_ACCELL
712 init_waitqueue_head(&par->wait_acc);
713
714 par->use_polling = true;
715
716 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA
717 | FBINFO_HWACCEL_FILLRECT;
718#else
719 info->flags = FBINFO_DEFAULT;
720#endif
721
722 info->fbops = &tmiofb_ops;
723
724 strcpy(info->fix.id, "tmio-fb");
725 info->fix.smem_start = vram->start;
726 info->fix.smem_len = resource_size(vram);
727 info->fix.type = FB_TYPE_PACKED_PIXELS;
728 info->fix.visual = FB_VISUAL_TRUECOLOR;
729 info->fix.mmio_start = lcr->start;
730 info->fix.mmio_len = resource_size(lcr);
731 info->fix.accel = FB_ACCEL_NONE;
732 info->screen_size = info->fix.smem_len - (4 * TMIOFB_FIFO_SIZE);
733 info->pseudo_palette = par->pseudo_palette;
734
735 par->ccr = ioremap(ccr->start, resource_size(ccr));
736 if (!par->ccr) {
737 retval = -ENOMEM;
738 goto err_ioremap_ccr;
739 }
740
741 par->lcr = ioremap(info->fix.mmio_start, info->fix.mmio_len);
742 if (!par->lcr) {
743 retval = -ENOMEM;
744 goto err_ioremap_lcr;
745 }
746
747 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
748 if (!info->screen_base) {
749 retval = -ENOMEM;
750 goto err_ioremap_vram;
751 }
752
753 retval = request_irq(irq, &tmiofb_irq, IRQF_DISABLED,
754 dev->dev.bus_id, info);
755
756 if (retval)
757 goto err_request_irq;
758
759 platform_set_drvdata(dev, info);
760
761 retval = fb_find_mode(&info->var, info, mode_option,
762 data->modes, data->num_modes,
763 data->modes, 16);
764 if (!retval) {
765 retval = -EINVAL;
766 goto err_find_mode;
767 }
768
769 if (cell->enable) {
770 retval = cell->enable(dev);
771 if (retval)
772 goto err_enable;
773 }
774
775 retval = tmiofb_hw_init(dev);
776 if (retval)
777 goto err_hw_init;
778
779 fb_videomode_to_modelist(data->modes, data->num_modes,
780 &info->modelist);
781
782 retval = register_framebuffer(info);
783 if (retval < 0)
784 goto err_register_framebuffer;
785
786 printk(KERN_INFO "fb%d: %s frame buffer device\n",
787 info->node, info->fix.id);
788
789 return 0;
790
791err_register_framebuffer:
792/*err_set_par:*/
793 tmiofb_hw_stop(dev);
794err_hw_init:
795 if (cell->disable)
796 cell->disable(dev);
797err_enable:
798err_find_mode:
799 platform_set_drvdata(dev, NULL);
800 free_irq(irq, info);
801err_request_irq:
802 iounmap(info->screen_base);
803err_ioremap_vram:
804 iounmap(par->lcr);
805err_ioremap_lcr:
806 iounmap(par->ccr);
807err_ioremap_ccr:
808 framebuffer_release(info);
809 return retval;
810}
811
812static int __devexit tmiofb_remove(struct platform_device *dev)
813{
814 struct mfd_cell *cell = dev->dev.platform_data;
815 struct fb_info *info = platform_get_drvdata(dev);
816 int irq = platform_get_irq(dev, 0);
817 struct tmiofb_par *par;
818
819 if (info) {
820 par = info->par;
821 unregister_framebuffer(info);
822
823 tmiofb_hw_stop(dev);
824
825 if (cell->disable)
826 cell->disable(dev);
827
828 platform_set_drvdata(dev, NULL);
829
830 free_irq(irq, info);
831
832 iounmap(info->screen_base);
833 iounmap(par->lcr);
834 iounmap(par->ccr);
835
836 framebuffer_release(info);
837 }
838
839 return 0;
840}
841
842#ifdef DEBUG
843static void tmiofb_dump_regs(struct platform_device *dev)
844{
845 struct fb_info *info = platform_get_drvdata(dev);
846 struct tmiofb_par *par = info->par;
847
848 printk(KERN_DEBUG "lhccr:\n");
849#define CCR_PR(n) printk(KERN_DEBUG "\t" #n " = \t%04x\n",\
850 tmio_ioread16(par->ccr + CCR_ ## n));
851 CCR_PR(CMD);
852 CCR_PR(REVID);
853 CCR_PR(BASEL);
854 CCR_PR(BASEH);
855 CCR_PR(UGCC);
856 CCR_PR(GCC);
857 CCR_PR(USC);
858 CCR_PR(VRAMRTC);
859 CCR_PR(VRAMSAC);
860 CCR_PR(VRAMBC);
861#undef CCR_PR
862
863 printk(KERN_DEBUG "lcr: \n");
864#define LCR_PR(n) printk(KERN_DEBUG "\t" #n " = \t%04x\n",\
865 tmio_ioread16(par->lcr + LCR_ ## n));
866 LCR_PR(UIS);
867 LCR_PR(VHPN);
868 LCR_PR(CFSAL);
869 LCR_PR(CFSAH);
870 LCR_PR(CFS);
871 LCR_PR(CFWS);
872 LCR_PR(BBIE);
873 LCR_PR(BBISC);
874 LCR_PR(CCS);
875 LCR_PR(BBES);
876 LCR_PR(CMDL);
877 LCR_PR(CMDH);
878 LCR_PR(CFC);
879 LCR_PR(CCIFC);
880 LCR_PR(HWT);
881 LCR_PR(LCDCCRC);
882 LCR_PR(LCDCC);
883 LCR_PR(LCDCOPC);
884 LCR_PR(LCDIS);
885 LCR_PR(LCDIM);
886 LCR_PR(LCDIE);
887 LCR_PR(GDSAL);
888 LCR_PR(GDSAH);
889 LCR_PR(VHPCL);
890 LCR_PR(VHPCH);
891 LCR_PR(GM);
892 LCR_PR(HT);
893 LCR_PR(HDS);
894 LCR_PR(HSS);
895 LCR_PR(HSE);
896 LCR_PR(HNP);
897 LCR_PR(VT);
898 LCR_PR(VDS);
899 LCR_PR(VSS);
900 LCR_PR(VSE);
901 LCR_PR(CDLN);
902 LCR_PR(ILN);
903 LCR_PR(SP);
904 LCR_PR(MISC);
905 LCR_PR(VIHSS);
906 LCR_PR(VIVS);
907 LCR_PR(VIVE);
908 LCR_PR(VIVSS);
909 LCR_PR(VCCIS);
910 LCR_PR(VIDWSAL);
911 LCR_PR(VIDWSAH);
912 LCR_PR(VIDRSAL);
913 LCR_PR(VIDRSAH);
914 LCR_PR(VIPDDST);
915 LCR_PR(VIPDDET);
916 LCR_PR(VIE);
917 LCR_PR(VCS);
918 LCR_PR(VPHWC);
919 LCR_PR(VPHS);
920 LCR_PR(VPVWC);
921 LCR_PR(VPVS);
922 LCR_PR(PLHPIX);
923 LCR_PR(XS);
924 LCR_PR(XCKHW);
925 LCR_PR(STHS);
926 LCR_PR(VT2);
927 LCR_PR(YCKSW);
928 LCR_PR(YSTS);
929 LCR_PR(PPOLS);
930 LCR_PR(PRECW);
931 LCR_PR(VCLKHW);
932 LCR_PR(OC);
933#undef LCR_PR
934}
935#endif
936
937#ifdef CONFIG_PM
938static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
939{
940 struct fb_info *info = platform_get_drvdata(dev);
941 struct tmiofb_par *par = info->par;
942 struct mfd_cell *cell = dev->dev.platform_data;
943 int retval = 0;
944
945 acquire_console_sem();
946
947 fb_set_suspend(info, 1);
948
949 if (info->fbops->fb_sync)
950 info->fbops->fb_sync(info);
951
952
953 /*
954 * The fb should be usable even if interrupts are disabled (and they are
955 * during suspend/resume). Switch temporary to forced polling.
956 */
957 printk(KERN_INFO "tmiofb: switching to polling\n");
958 par->use_polling = true;
959 tmiofb_hw_stop(dev);
960
961 if (cell->suspend)
962 retval = cell->suspend(dev);
963
964 release_console_sem();
965
966 return retval;
967}
968
969static int tmiofb_resume(struct platform_device *dev)
970{
971 struct fb_info *info = platform_get_drvdata(dev);
972 struct mfd_cell *cell = dev->dev.platform_data;
973 int retval;
974
975 acquire_console_sem();
976
977 if (cell->resume) {
978 retval = cell->resume(dev);
979 if (retval)
980 goto out;
981 }
982
983 tmiofb_irq(-1, info);
984
985 tmiofb_hw_init(dev);
986
987 tmiofb_hw_mode(dev);
988
989 fb_set_suspend(info, 0);
990out:
991 release_console_sem();
992 return retval;
993}
994#else
995#define tmiofb_suspend NULL
996#define tmiofb_resume NULL
997#endif
998
999static struct platform_driver tmiofb_driver = {
1000 .driver.name = "tmio-fb",
1001 .driver.owner = THIS_MODULE,
1002 .probe = tmiofb_probe,
1003 .remove = __devexit_p(tmiofb_remove),
1004 .suspend = tmiofb_suspend,
1005 .resume = tmiofb_resume,
1006};
1007
1008/*--------------------------------------------------------------------------*/
1009
1010#ifndef MODULE
1011static void __init tmiofb_setup(char *options)
1012{
1013 char *this_opt;
1014
1015 if (!options || !*options)
1016 return;
1017
1018 while ((this_opt = strsep(&options, ",")) != NULL) {
1019 if (!*this_opt)
1020 continue;
1021 /*
1022 * FIXME
1023 */
1024 }
1025}
1026#endif
1027
1028static int __init tmiofb_init(void)
1029{
1030#ifndef MODULE
1031 char *option = NULL;
1032
1033 if (fb_get_options("tmiofb", &option))
1034 return -ENODEV;
1035 tmiofb_setup(option);
1036#endif
1037 return platform_driver_register(&tmiofb_driver);
1038}
1039
1040static void __exit tmiofb_cleanup(void)
1041{
1042 platform_driver_unregister(&tmiofb_driver);
1043}
1044
1045module_init(tmiofb_init);
1046module_exit(tmiofb_cleanup);
1047
1048MODULE_DESCRIPTION("TMIO framebuffer driver");
1049MODULE_AUTHOR("Chris Humbert, Dirk Opfer, Dmitry Baryshkov");
1050MODULE_LICENSE("GPL");
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 50744229c7a9..6c2d37fdd3b9 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -516,10 +516,12 @@ static int __devinit uvesafb_vbe_getmodes(struct uvesafb_ktask *task,
516 516
517 err = uvesafb_exec(task); 517 err = uvesafb_exec(task);
518 if (err || (task->t.regs.eax & 0xffff) != 0x004f) { 518 if (err || (task->t.regs.eax & 0xffff) != 0x004f) {
519 printk(KERN_ERR "uvesafb: Getting mode info block " 519 printk(KERN_WARNING "uvesafb: Getting mode info block "
520 "for mode 0x%x failed (eax=0x%x, err=%d)\n", 520 "for mode 0x%x failed (eax=0x%x, err=%d)\n",
521 *mode, (u32)task->t.regs.eax, err); 521 *mode, (u32)task->t.regs.eax, err);
522 return -EINVAL; 522 mode++;
523 par->vbe_modes_cnt--;
524 continue;
523 } 525 }
524 526
525 mib = task->buf; 527 mib = task->buf;
@@ -548,7 +550,10 @@ static int __devinit uvesafb_vbe_getmodes(struct uvesafb_ktask *task,
548 mib->depth = mib->bits_per_pixel; 550 mib->depth = mib->bits_per_pixel;
549 } 551 }
550 552
551 return 0; 553 if (par->vbe_modes_cnt > 0)
554 return 0;
555 else
556 return -EINVAL;
552} 557}
553 558
554/* 559/*
diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index e31bca8a0cb2..5b2938903ac2 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -58,7 +58,6 @@ struct vga16fb_par {
58 unsigned char ClockingMode; /* Seq-Controller:01h */ 58 unsigned char ClockingMode; /* Seq-Controller:01h */
59 } vga_state; 59 } vga_state;
60 struct vgastate state; 60 struct vgastate state;
61 struct mutex open_lock;
62 unsigned int ref_count; 61 unsigned int ref_count;
63 int palette_blanked, vesa_blanked, mode, isVGA; 62 int palette_blanked, vesa_blanked, mode, isVGA;
64 u8 misc, pel_msk, vss, clkdiv; 63 u8 misc, pel_msk, vss, clkdiv;
@@ -286,7 +285,6 @@ static int vga16fb_open(struct fb_info *info, int user)
286{ 285{
287 struct vga16fb_par *par = info->par; 286 struct vga16fb_par *par = info->par;
288 287
289 mutex_lock(&par->open_lock);
290 if (!par->ref_count) { 288 if (!par->ref_count) {
291 memset(&par->state, 0, sizeof(struct vgastate)); 289 memset(&par->state, 0, sizeof(struct vgastate));
292 par->state.flags = VGA_SAVE_FONTS | VGA_SAVE_MODE | 290 par->state.flags = VGA_SAVE_FONTS | VGA_SAVE_MODE |
@@ -294,7 +292,6 @@ static int vga16fb_open(struct fb_info *info, int user)
294 save_vga(&par->state); 292 save_vga(&par->state);
295 } 293 }
296 par->ref_count++; 294 par->ref_count++;
297 mutex_unlock(&par->open_lock);
298 295
299 return 0; 296 return 0;
300} 297}
@@ -303,15 +300,12 @@ static int vga16fb_release(struct fb_info *info, int user)
303{ 300{
304 struct vga16fb_par *par = info->par; 301 struct vga16fb_par *par = info->par;
305 302
306 mutex_lock(&par->open_lock); 303 if (!par->ref_count)
307 if (!par->ref_count) {
308 mutex_unlock(&par->open_lock);
309 return -EINVAL; 304 return -EINVAL;
310 } 305
311 if (par->ref_count == 1) 306 if (par->ref_count == 1)
312 restore_vga(&par->state); 307 restore_vga(&par->state);
313 par->ref_count--; 308 par->ref_count--;
314 mutex_unlock(&par->open_lock);
315 309
316 return 0; 310 return 0;
317} 311}
@@ -1326,7 +1320,6 @@ static int __init vga16fb_probe(struct platform_device *dev)
1326 printk(KERN_INFO "vga16fb: mapped to 0x%p\n", info->screen_base); 1320 printk(KERN_INFO "vga16fb: mapped to 0x%p\n", info->screen_base);
1327 par = info->par; 1321 par = info->par;
1328 1322
1329 mutex_init(&par->open_lock);
1330 par->isVGA = screen_info.orig_video_isVGA; 1323 par->isVGA = screen_info.orig_video_isVGA;
1331 par->palette_blanked = 0; 1324 par->palette_blanked = 0;
1332 par->vesa_blanked = 0; 1325 par->vesa_blanked = 0;
diff --git a/drivers/video/via/Makefile b/drivers/video/via/Makefile
new file mode 100644
index 000000000000..e533b4b6aba4
--- /dev/null
+++ b/drivers/video/via/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the VIA framebuffer driver (for Linux Kernel 2.6)
3#
4
5obj-$(CONFIG_FB_VIA) += viafb.o
6
7viafb-y :=viafbdev.o hw.o iface.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o
diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c
new file mode 100644
index 000000000000..632523ff1fb7
--- /dev/null
+++ b/drivers/video/via/accel.c
@@ -0,0 +1,279 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#include "global.h"
22
23void viafb_init_accel(void)
24{
25 viaparinfo->fbmem_free -= CURSOR_SIZE;
26 viaparinfo->cursor_start = viaparinfo->fbmem_free;
27 viaparinfo->fbmem_used += CURSOR_SIZE;
28
29 /* Reverse 8*1024 memory space for cursor image */
30 viaparinfo->fbmem_free -= (CURSOR_SIZE + VQ_SIZE);
31 viaparinfo->VQ_start = viaparinfo->fbmem_free;
32 viaparinfo->VQ_end = viaparinfo->VQ_start + VQ_SIZE - 1;
33 viaparinfo->fbmem_used += (CURSOR_SIZE + VQ_SIZE); }
34
35void viafb_init_2d_engine(void)
36{
37 u32 dwVQStartAddr, dwVQEndAddr;
38 u32 dwVQLen, dwVQStartL, dwVQEndL, dwVQStartEndH;
39
40 /* init 2D engine regs to reset 2D engine */
41 writel(0x0, viaparinfo->io_virt + VIA_REG_GEMODE);
42 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
43 writel(0x0, viaparinfo->io_virt + VIA_REG_DSTPOS);
44 writel(0x0, viaparinfo->io_virt + VIA_REG_DIMENSION);
45 writel(0x0, viaparinfo->io_virt + VIA_REG_PATADDR);
46 writel(0x0, viaparinfo->io_virt + VIA_REG_FGCOLOR);
47 writel(0x0, viaparinfo->io_virt + VIA_REG_BGCOLOR);
48 writel(0x0, viaparinfo->io_virt + VIA_REG_CLIPTL);
49 writel(0x0, viaparinfo->io_virt + VIA_REG_CLIPBR);
50 writel(0x0, viaparinfo->io_virt + VIA_REG_OFFSET);
51 writel(0x0, viaparinfo->io_virt + VIA_REG_KEYCONTROL);
52 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
53 writel(0x0, viaparinfo->io_virt + VIA_REG_DSTBASE);
54 writel(0x0, viaparinfo->io_virt + VIA_REG_PITCH);
55 writel(0x0, viaparinfo->io_virt + VIA_REG_MONOPAT1);
56
57 /* Init AGP and VQ regs */
58 switch (viaparinfo->chip_info->gfx_chip_name) {
59 case UNICHROME_K8M890:
60 case UNICHROME_P4M900:
61 writel(0x00100000, viaparinfo->io_virt + VIA_REG_CR_TRANSET);
62 writel(0x680A0000, viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
63 writel(0x02000000, viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
64 break;
65
66 default:
67 writel(0x00100000, viaparinfo->io_virt + VIA_REG_TRANSET);
68 writel(0x00000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
69 writel(0x00333004, viaparinfo->io_virt + VIA_REG_TRANSPACE);
70 writel(0x60000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
71 writel(0x61000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
72 writel(0x62000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
73 writel(0x63000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
74 writel(0x64000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
75 writel(0x7D000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
76
77 writel(0xFE020000, viaparinfo->io_virt + VIA_REG_TRANSET);
78 writel(0x00000000, viaparinfo->io_virt + VIA_REG_TRANSPACE);
79 break;
80 }
81 if (viaparinfo->VQ_start != 0) {
82 /* Enable VQ */
83 dwVQStartAddr = viaparinfo->VQ_start;
84 dwVQEndAddr = viaparinfo->VQ_end;
85
86 dwVQStartL = 0x50000000 | (dwVQStartAddr & 0xFFFFFF);
87 dwVQEndL = 0x51000000 | (dwVQEndAddr & 0xFFFFFF);
88 dwVQStartEndH = 0x52000000 |
89 ((dwVQStartAddr & 0xFF000000) >> 24) |
90 ((dwVQEndAddr & 0xFF000000) >> 16);
91 dwVQLen = 0x53000000 | (VQ_SIZE >> 3);
92 switch (viaparinfo->chip_info->gfx_chip_name) {
93 case UNICHROME_K8M890:
94 case UNICHROME_P4M900:
95 dwVQStartL |= 0x20000000;
96 dwVQEndL |= 0x20000000;
97 dwVQStartEndH |= 0x20000000;
98 dwVQLen |= 0x20000000;
99 break;
100 default:
101 break;
102 }
103
104 switch (viaparinfo->chip_info->gfx_chip_name) {
105 case UNICHROME_K8M890:
106 case UNICHROME_P4M900:
107 writel(0x00100000,
108 viaparinfo->io_virt + VIA_REG_CR_TRANSET);
109 writel(dwVQStartEndH,
110 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
111 writel(dwVQStartL,
112 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
113 writel(dwVQEndL,
114 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
115 writel(dwVQLen,
116 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
117 writel(0x74301001,
118 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
119 writel(0x00000000,
120 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
121 break;
122 default:
123 writel(0x00FE0000,
124 viaparinfo->io_virt + VIA_REG_TRANSET);
125 writel(0x080003FE,
126 viaparinfo->io_virt + VIA_REG_TRANSPACE);
127 writel(0x0A00027C,
128 viaparinfo->io_virt + VIA_REG_TRANSPACE);
129 writel(0x0B000260,
130 viaparinfo->io_virt + VIA_REG_TRANSPACE);
131 writel(0x0C000274,
132 viaparinfo->io_virt + VIA_REG_TRANSPACE);
133 writel(0x0D000264,
134 viaparinfo->io_virt + VIA_REG_TRANSPACE);
135 writel(0x0E000000,
136 viaparinfo->io_virt + VIA_REG_TRANSPACE);
137 writel(0x0F000020,
138 viaparinfo->io_virt + VIA_REG_TRANSPACE);
139 writel(0x1000027E,
140 viaparinfo->io_virt + VIA_REG_TRANSPACE);
141 writel(0x110002FE,
142 viaparinfo->io_virt + VIA_REG_TRANSPACE);
143 writel(0x200F0060,
144 viaparinfo->io_virt + VIA_REG_TRANSPACE);
145
146 writel(0x00000006,
147 viaparinfo->io_virt + VIA_REG_TRANSPACE);
148 writel(0x40008C0F,
149 viaparinfo->io_virt + VIA_REG_TRANSPACE);
150 writel(0x44000000,
151 viaparinfo->io_virt + VIA_REG_TRANSPACE);
152 writel(0x45080C04,
153 viaparinfo->io_virt + VIA_REG_TRANSPACE);
154 writel(0x46800408,
155 viaparinfo->io_virt + VIA_REG_TRANSPACE);
156
157 writel(dwVQStartEndH,
158 viaparinfo->io_virt + VIA_REG_TRANSPACE);
159 writel(dwVQStartL,
160 viaparinfo->io_virt + VIA_REG_TRANSPACE);
161 writel(dwVQEndL,
162 viaparinfo->io_virt + VIA_REG_TRANSPACE);
163 writel(dwVQLen,
164 viaparinfo->io_virt + VIA_REG_TRANSPACE);
165 break;
166 }
167 } else {
168 /* Disable VQ */
169 switch (viaparinfo->chip_info->gfx_chip_name) {
170 case UNICHROME_K8M890:
171 case UNICHROME_P4M900:
172 writel(0x00100000,
173 viaparinfo->io_virt + VIA_REG_CR_TRANSET);
174 writel(0x74301000,
175 viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
176 break;
177 default:
178 writel(0x00FE0000,
179 viaparinfo->io_virt + VIA_REG_TRANSET);
180 writel(0x00000004,
181 viaparinfo->io_virt + VIA_REG_TRANSPACE);
182 writel(0x40008C0F,
183 viaparinfo->io_virt + VIA_REG_TRANSPACE);
184 writel(0x44000000,
185 viaparinfo->io_virt + VIA_REG_TRANSPACE);
186 writel(0x45080C04,
187 viaparinfo->io_virt + VIA_REG_TRANSPACE);
188 writel(0x46800408,
189 viaparinfo->io_virt + VIA_REG_TRANSPACE);
190 break;
191 }
192 }
193
194 viafb_set_2d_color_depth(viaparinfo->bpp);
195
196 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
197 writel(0x0, viaparinfo->io_virt + VIA_REG_DSTBASE);
198
199 writel(VIA_PITCH_ENABLE |
200 (((viaparinfo->hres *
201 viaparinfo->bpp >> 3) >> 3) | (((viaparinfo->hres *
202 viaparinfo->
203 bpp >> 3) >> 3) << 16)),
204 viaparinfo->io_virt + VIA_REG_PITCH);
205}
206
207void viafb_set_2d_color_depth(int bpp)
208{
209 u32 dwGEMode;
210
211 dwGEMode = readl(viaparinfo->io_virt + 0x04) & 0xFFFFFCFF;
212
213 switch (bpp) {
214 case 16:
215 dwGEMode |= VIA_GEM_16bpp;
216 break;
217 case 32:
218 dwGEMode |= VIA_GEM_32bpp;
219 break;
220 default:
221 dwGEMode |= VIA_GEM_8bpp;
222 break;
223 }
224
225 /* Set BPP and Pitch */
226 writel(dwGEMode, viaparinfo->io_virt + VIA_REG_GEMODE);
227}
228
229void viafb_hw_cursor_init(void)
230{
231 /* Set Cursor Image Base Address */
232 writel(viaparinfo->cursor_start,
233 viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
234 writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_POS);
235 writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_ORG);
236 writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_BG);
237 writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_FG);
238}
239
240void viafb_show_hw_cursor(struct fb_info *info, int Status)
241{
242 u32 temp;
243 u32 iga_path = ((struct viafb_par *)(info->par))->iga_path;
244
245 temp = readl(viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
246 switch (Status) {
247 case HW_Cursor_ON:
248 temp |= 0x1;
249 break;
250 case HW_Cursor_OFF:
251 temp &= 0xFFFFFFFE;
252 break;
253 }
254 switch (iga_path) {
255 case IGA2:
256 temp |= 0x80000000;
257 break;
258 case IGA1:
259 default:
260 temp &= 0x7FFFFFFF;
261 }
262 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
263}
264
265int viafb_wait_engine_idle(void)
266{
267 int loop = 0;
268
269 while (!(readl(viaparinfo->io_virt + VIA_REG_STATUS) &
270 VIA_VR_QUEUE_BUSY) && (loop++ < MAXLOOP))
271 cpu_relax();
272
273 while ((readl(viaparinfo->io_virt + VIA_REG_STATUS) &
274 (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) &&
275 (loop++ < MAXLOOP))
276 cpu_relax();
277
278 return loop >= MAXLOOP;
279}
diff --git a/drivers/video/via/accel.h b/drivers/video/via/accel.h
new file mode 100644
index 000000000000..29bf854e8ccf
--- /dev/null
+++ b/drivers/video/via/accel.h
@@ -0,0 +1,169 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __ACCEL_H__
23#define __ACCEL_H__
24
25#define FB_ACCEL_VIA_UNICHROME 50
26
27/* MMIO Base Address Definition */
28#define MMIO_VGABASE 0x8000
29#define MMIO_CR_READ (MMIO_VGABASE + 0x3D4)
30#define MMIO_CR_WRITE (MMIO_VGABASE + 0x3D5)
31#define MMIO_SR_READ (MMIO_VGABASE + 0x3C4)
32#define MMIO_SR_WRITE (MMIO_VGABASE + 0x3C5)
33
34/* HW Cursor Status Define */
35#define HW_Cursor_ON 0
36#define HW_Cursor_OFF 1
37
38#define CURSOR_SIZE (8 * 1024)
39#define VQ_SIZE (256 * 1024)
40
41#define VIA_MMIO_BLTBASE 0x200000
42#define VIA_MMIO_BLTSIZE 0x200000
43
44/* Defines for 2D registers */
45#define VIA_REG_GECMD 0x000
46#define VIA_REG_GEMODE 0x004
47#define VIA_REG_SRCPOS 0x008
48#define VIA_REG_DSTPOS 0x00C
49/* width and height */
50#define VIA_REG_DIMENSION 0x010
51#define VIA_REG_PATADDR 0x014
52#define VIA_REG_FGCOLOR 0x018
53#define VIA_REG_BGCOLOR 0x01C
54/* top and left of clipping */
55#define VIA_REG_CLIPTL 0x020
56/* bottom and right of clipping */
57#define VIA_REG_CLIPBR 0x024
58#define VIA_REG_OFFSET 0x028
59/* color key control */
60#define VIA_REG_KEYCONTROL 0x02C
61#define VIA_REG_SRCBASE 0x030
62#define VIA_REG_DSTBASE 0x034
63/* pitch of src and dst */
64#define VIA_REG_PITCH 0x038
65#define VIA_REG_MONOPAT0 0x03C
66#define VIA_REG_MONOPAT1 0x040
67/* from 0x100 to 0x1ff */
68#define VIA_REG_COLORPAT 0x100
69
70/* VIA_REG_PITCH(0x38): Pitch Setting */
71#define VIA_PITCH_ENABLE 0x80000000
72
73/* defines for VIA HW cursor registers */
74#define VIA_REG_CURSOR_MODE 0x2D0
75#define VIA_REG_CURSOR_POS 0x2D4
76#define VIA_REG_CURSOR_ORG 0x2D8
77#define VIA_REG_CURSOR_BG 0x2DC
78#define VIA_REG_CURSOR_FG 0x2E0
79
80/* VIA_REG_GEMODE(0x04): GE mode */
81#define VIA_GEM_8bpp 0x00000000
82#define VIA_GEM_16bpp 0x00000100
83#define VIA_GEM_32bpp 0x00000300
84
85/* VIA_REG_GECMD(0x00): 2D Engine Command */
86#define VIA_GEC_NOOP 0x00000000
87#define VIA_GEC_BLT 0x00000001
88#define VIA_GEC_LINE 0x00000005
89
90/* Rotate Command */
91#define VIA_GEC_ROT 0x00000008
92
93#define VIA_GEC_SRC_XY 0x00000000
94#define VIA_GEC_SRC_LINEAR 0x00000010
95#define VIA_GEC_DST_XY 0x00000000
96#define VIA_GEC_DST_LINRAT 0x00000020
97
98#define VIA_GEC_SRC_FB 0x00000000
99#define VIA_GEC_SRC_SYS 0x00000040
100#define VIA_GEC_DST_FB 0x00000000
101#define VIA_GEC_DST_SYS 0x00000080
102
103/* source is mono */
104#define VIA_GEC_SRC_MONO 0x00000100
105/* pattern is mono */
106#define VIA_GEC_PAT_MONO 0x00000200
107/* mono src is opaque */
108#define VIA_GEC_MSRC_OPAQUE 0x00000000
109/* mono src is transparent */
110#define VIA_GEC_MSRC_TRANS 0x00000400
111/* pattern is in frame buffer */
112#define VIA_GEC_PAT_FB 0x00000000
113/* pattern is from reg setting */
114#define VIA_GEC_PAT_REG 0x00000800
115
116#define VIA_GEC_CLIP_DISABLE 0x00000000
117#define VIA_GEC_CLIP_ENABLE 0x00001000
118
119#define VIA_GEC_FIXCOLOR_PAT 0x00002000
120
121#define VIA_GEC_INCX 0x00000000
122#define VIA_GEC_DECY 0x00004000
123#define VIA_GEC_INCY 0x00000000
124#define VIA_GEC_DECX 0x00008000
125/* mono pattern is opaque */
126#define VIA_GEC_MPAT_OPAQUE 0x00000000
127/* mono pattern is transparent */
128#define VIA_GEC_MPAT_TRANS 0x00010000
129
130#define VIA_GEC_MONO_UNPACK 0x00000000
131#define VIA_GEC_MONO_PACK 0x00020000
132#define VIA_GEC_MONO_DWORD 0x00000000
133#define VIA_GEC_MONO_WORD 0x00040000
134#define VIA_GEC_MONO_BYTE 0x00080000
135
136#define VIA_GEC_LASTPIXEL_ON 0x00000000
137#define VIA_GEC_LASTPIXEL_OFF 0x00100000
138#define VIA_GEC_X_MAJOR 0x00000000
139#define VIA_GEC_Y_MAJOR 0x00200000
140#define VIA_GEC_QUICK_START 0x00800000
141
142/* defines for VIA 3D registers */
143#define VIA_REG_STATUS 0x400
144#define VIA_REG_CR_TRANSET 0x41C
145#define VIA_REG_CR_TRANSPACE 0x420
146#define VIA_REG_TRANSET 0x43C
147#define VIA_REG_TRANSPACE 0x440
148
149/* VIA_REG_STATUS(0x400): Engine Status */
150
151/* Command Regulator is busy */
152#define VIA_CMD_RGTR_BUSY 0x00000080
153/* 2D Engine is busy */
154#define VIA_2D_ENG_BUSY 0x00000002
155/* 3D Engine is busy */
156#define VIA_3D_ENG_BUSY 0x00000001
157/* Virtual Queue is busy */
158#define VIA_VR_QUEUE_BUSY 0x00020000
159
160#define MAXLOOP 0xFFFFFF
161
162void viafb_init_accel(void);
163void viafb_init_2d_engine(void);
164void set_2d_color_depth(int);
165void viafb_hw_cursor_init(void);
166void viafb_show_hw_cursor(struct fb_info *info, int Status); int
167viafb_wait_engine_idle(void); void viafb_set_2d_color_depth(int bpp);
168
169#endif /* __ACCEL_H__ */
diff --git a/drivers/video/via/chip.h b/drivers/video/via/chip.h
new file mode 100644
index 000000000000..dde95edc387a
--- /dev/null
+++ b/drivers/video/via/chip.h
@@ -0,0 +1,190 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#ifndef __CHIP_H__
22#define __CHIP_H__
23
24#include "global.h"
25
26/***************************************/
27/* Definition Graphic Chip Information */
28/***************************************/
29
30#define PCI_VIA_VENDOR_ID 0x1106
31
32/* Define VIA Graphic Chip Name */
33#define UNICHROME_CLE266 1
34#define UNICHROME_CLE266_DID 0x3122
35#define CLE266_REVISION_AX 0x0A
36#define CLE266_REVISION_CX 0x0C
37
38#define UNICHROME_K400 2
39#define UNICHROME_K400_DID 0x7205
40
41#define UNICHROME_K800 3
42#define UNICHROME_K800_DID 0x3108
43
44#define UNICHROME_PM800 4
45#define UNICHROME_PM800_DID 0x3118
46
47#define UNICHROME_CN700 5
48#define UNICHROME_CN700_DID 0x3344
49
50#define UNICHROME_CX700 6
51#define UNICHROME_CX700_DID 0x3157
52#define CX700_REVISION_700 0x0
53#define CX700_REVISION_700M 0x1
54#define CX700_REVISION_700M2 0x2
55
56#define UNICHROME_CN750 7
57#define UNICHROME_CN750_DID 0x3225
58
59#define UNICHROME_K8M890 8
60#define UNICHROME_K8M890_DID 0x3230
61
62#define UNICHROME_P4M890 9
63#define UNICHROME_P4M890_DID 0x3343
64
65#define UNICHROME_P4M900 10
66#define UNICHROME_P4M900_DID 0x3371
67
68#define UNICHROME_VX800 11
69#define UNICHROME_VX800_DID 0x1122
70
71/**************************************************/
72/* Definition TMDS Trasmitter Information */
73/**************************************************/
74
75/* Definition TMDS Trasmitter Index */
76#define NON_TMDS_TRANSMITTER 0x00
77#define VT1632_TMDS 0x01
78#define INTEGRATED_TMDS 0x42
79
80/* Definition TMDS Trasmitter I2C Slave Address */
81#define VT1632_TMDS_I2C_ADDR 0x10
82
83/**************************************************/
84/* Definition LVDS Trasmitter Information */
85/**************************************************/
86
87/* Definition LVDS Trasmitter Index */
88#define NON_LVDS_TRANSMITTER 0x00
89#define VT1631_LVDS 0x01
90#define VT1636_LVDS 0x0E
91#define INTEGRATED_LVDS 0x41
92
93/* Definition Digital Transmitter Mode */
94#define TX_DATA_12_BITS 0x01
95#define TX_DATA_24_BITS 0x02
96#define TX_DATA_DDR_MODE 0x04
97#define TX_DATA_SDR_MODE 0x08
98
99/* Definition LVDS Trasmitter I2C Slave Address */
100#define VT1631_LVDS_I2C_ADDR 0x70
101#define VT3271_LVDS_I2C_ADDR 0x80
102#define VT1636_LVDS_I2C_ADDR 0x80
103
104struct tmds_chip_information {
105 int tmds_chip_name;
106 int tmds_chip_slave_addr;
107 int dvi_panel_id;
108 int data_mode;
109 int output_interface;
110 int i2c_port;
111 int device_type;
112};
113
114struct lvds_chip_information {
115 int lvds_chip_name;
116 int lvds_chip_slave_addr;
117 int data_mode;
118 int output_interface;
119 int i2c_port;
120};
121
122struct chip_information {
123 int gfx_chip_name;
124 int gfx_chip_revision;
125 int chip_on_slot;
126 struct tmds_chip_information tmds_chip_info;
127 struct lvds_chip_information lvds_chip_info;
128 struct lvds_chip_information lvds_chip_info2;
129};
130
131struct crt_setting_information {
132 int iga_path;
133 int h_active;
134 int v_active;
135 int bpp;
136 int refresh_rate;
137};
138
139struct tmds_setting_information {
140 int iga_path;
141 int h_active;
142 int v_active;
143 int bpp;
144 int refresh_rate;
145 int get_dvi_size_method;
146 int max_pixel_clock;
147 int dvi_panel_size;
148 int dvi_panel_hres;
149 int dvi_panel_vres;
150 int native_size;
151};
152
153struct lvds_setting_information {
154 int iga_path;
155 int h_active;
156 int v_active;
157 int bpp;
158 int refresh_rate;
159 int get_lcd_size_method;
160 int lcd_panel_id;
161 int lcd_panel_size;
162 int lcd_panel_hres;
163 int lcd_panel_vres;
164 int display_method;
165 int device_lcd_dualedge;
166 int LCDDithering;
167 int lcd_mode;
168 u32 vclk; /*panel mode clock value */
169};
170
171struct GFX_DPA_SETTING {
172 int ClkRangeIndex;
173 u8 DVP0; /* CR96[3:0] */
174 u8 DVP0DataDri_S1; /* SR2A[5] */
175 u8 DVP0DataDri_S; /* SR1B[1] */
176 u8 DVP0ClockDri_S1; /* SR2A[4] */
177 u8 DVP0ClockDri_S; /* SR1E[2] */
178 u8 DVP1; /* CR9B[3:0] */
179 u8 DVP1Driving; /* SR65[3:0], Data and Clock driving */
180 u8 DFPHigh; /* CR97[3:0] */
181 u8 DFPLow; /* CR99[3:0] */
182
183};
184
185struct VT1636_DPA_SETTING {
186 int PanelSizeID;
187 u8 CLK_SEL_ST1;
188 u8 CLK_SEL_ST2;
189};
190#endif /* __CHIP_H__ */
diff --git a/drivers/video/via/debug.h b/drivers/video/via/debug.h
new file mode 100644
index 000000000000..86eacc2017f3
--- /dev/null
+++ b/drivers/video/via/debug.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#ifndef __DEBUG_H__
22#define __DEBUG_H__
23
24#ifndef VIAFB_DEBUG
25#define VIAFB_DEBUG 0
26#endif
27
28#if VIAFB_DEBUG
29#define DEBUG_MSG(f, a...) printk(f, ## a)
30#else
31#define DEBUG_MSG(f, a...)
32#endif
33
34#define VIAFB_WARN 0
35#if VIAFB_WARN
36#define WARN_MSG(f, a...) printk(f, ## a)
37#else
38#define WARN_MSG(f, a...)
39#endif
40
41#endif /* __DEBUG_H__ */
diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c
new file mode 100644
index 000000000000..d6965447ca69
--- /dev/null
+++ b/drivers/video/via/dvi.c
@@ -0,0 +1,682 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#include "global.h"
22
23static void tmds_register_write(int index, u8 data);
24static int tmds_register_read(int index);
25static int tmds_register_read_bytes(int index, u8 *buff, int buff_len);
26static int check_reduce_blanking_mode(int mode_index,
27 int refresh_rate);
28static int dvi_get_panel_size_from_DDCv1(void);
29static int dvi_get_panel_size_from_DDCv2(void);
30static unsigned char dvi_get_panel_info(void);
31static int viafb_dvi_query_EDID(void);
32
33static int check_tmds_chip(int device_id_subaddr, int device_id)
34{
35 if (tmds_register_read(device_id_subaddr) == device_id)
36 return OK;
37 else
38 return FAIL;
39}
40
41void viafb_init_dvi_size(void)
42{
43 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n");
44 DEBUG_MSG(KERN_INFO
45 "viaparinfo->tmds_setting_info->get_dvi_size_method %d\n",
46 viaparinfo->tmds_setting_info->get_dvi_size_method);
47
48 switch (viaparinfo->tmds_setting_info->get_dvi_size_method) {
49 case GET_DVI_SIZE_BY_SYSTEM_BIOS:
50 break;
51 case GET_DVI_SZIE_BY_HW_STRAPPING:
52 break;
53 case GET_DVI_SIZE_BY_VGA_BIOS:
54 default:
55 dvi_get_panel_info();
56 break;
57 }
58 return;
59}
60
61int viafb_tmds_trasmitter_identify(void)
62{
63 unsigned char sr2a = 0, sr1e = 0, sr3e = 0;
64
65 /* Turn on ouputting pad */
66 switch (viaparinfo->chip_info->gfx_chip_name) {
67 case UNICHROME_K8M890:
68 /*=* DFP Low Pad on *=*/
69 sr2a = viafb_read_reg(VIASR, SR2A);
70 viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
71 break;
72
73 case UNICHROME_P4M900:
74 case UNICHROME_P4M890:
75 /* DFP Low Pad on */
76 sr2a = viafb_read_reg(VIASR, SR2A);
77 viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
78 /* DVP0 Pad on */
79 sr1e = viafb_read_reg(VIASR, SR1E);
80 viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT6 + BIT7);
81 break;
82
83 default:
84 /* DVP0/DVP1 Pad on */
85 sr1e = viafb_read_reg(VIASR, SR1E);
86 viafb_write_reg_mask(SR1E, VIASR, 0xF0, BIT4 +
87 BIT5 + BIT6 + BIT7);
88 /* SR3E[1]Multi-function selection:
89 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
90 sr3e = viafb_read_reg(VIASR, SR3E);
91 viafb_write_reg_mask(SR3E, VIASR, 0x0, BIT5);
92 break;
93 }
94
95 /* Check for VT1632: */
96 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS;
97 viaparinfo->chip_info->
98 tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
99 viaparinfo->chip_info->tmds_chip_info.i2c_port = I2CPORTINDEX;
100 if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) {
101 /*
102 * Currently only support 12bits,dual edge,add 24bits mode later
103 */
104 tmds_register_write(0x08, 0x3b);
105
106 DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n");
107 DEBUG_MSG(KERN_INFO "\n %2d",
108 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name);
109 DEBUG_MSG(KERN_INFO "\n %2d",
110 viaparinfo->chip_info->tmds_chip_info.i2c_port);
111 return OK;
112 } else {
113 viaparinfo->chip_info->tmds_chip_info.i2c_port = GPIOPORTINDEX;
114 if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)
115 != FAIL) {
116 tmds_register_write(0x08, 0x3b);
117 DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n");
118 DEBUG_MSG(KERN_INFO "\n %2d",
119 viaparinfo->chip_info->
120 tmds_chip_info.tmds_chip_name);
121 DEBUG_MSG(KERN_INFO "\n %2d",
122 viaparinfo->chip_info->
123 tmds_chip_info.i2c_port);
124 return OK;
125 }
126 }
127
128 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = INTEGRATED_TMDS;
129
130 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) &&
131 ((viafb_display_hardware_layout == HW_LAYOUT_DVI_ONLY) ||
132 (viafb_display_hardware_layout == HW_LAYOUT_LCD_DVI))) {
133 DEBUG_MSG(KERN_INFO "\n Integrated TMDS ! \n");
134 return OK;
135 }
136
137 switch (viaparinfo->chip_info->gfx_chip_name) {
138 case UNICHROME_K8M890:
139 viafb_write_reg(SR2A, VIASR, sr2a);
140 break;
141
142 case UNICHROME_P4M900:
143 case UNICHROME_P4M890:
144 viafb_write_reg(SR2A, VIASR, sr2a);
145 viafb_write_reg(SR1E, VIASR, sr1e);
146 break;
147
148 default:
149 viafb_write_reg(SR1E, VIASR, sr1e);
150 viafb_write_reg(SR3E, VIASR, sr3e);
151 break;
152 }
153
154 viaparinfo->chip_info->
155 tmds_chip_info.tmds_chip_name = NON_TMDS_TRANSMITTER;
156 viaparinfo->chip_info->tmds_chip_info.
157 tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
158 return FAIL;
159}
160
161static void tmds_register_write(int index, u8 data)
162{
163 viaparinfo->i2c_stuff.i2c_port =
164 viaparinfo->chip_info->tmds_chip_info.i2c_port;
165
166 viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.
167 tmds_chip_slave_addr, index,
168 data);
169}
170
171static int tmds_register_read(int index)
172{
173 u8 data;
174
175 viaparinfo->i2c_stuff.i2c_port =
176 viaparinfo->chip_info->tmds_chip_info.i2c_port;
177 viafb_i2c_readbyte((u8) viaparinfo->chip_info->
178 tmds_chip_info.tmds_chip_slave_addr,
179 (u8) index, &data);
180 return data;
181}
182
183static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
184{
185 viaparinfo->i2c_stuff.i2c_port =
186 viaparinfo->chip_info->tmds_chip_info.i2c_port;
187 viafb_i2c_readbytes((u8) viaparinfo->chip_info->tmds_chip_info.
188 tmds_chip_slave_addr, (u8) index, buff, buff_len);
189 return 0;
190}
191
192static int check_reduce_blanking_mode(int mode_index,
193 int refresh_rate)
194{
195 if (refresh_rate != 60)
196 return false;
197
198 switch (mode_index) {
199 /* Following modes have reduce blanking mode. */
200 case VIA_RES_1360X768:
201 case VIA_RES_1400X1050:
202 case VIA_RES_1440X900:
203 case VIA_RES_1600X900:
204 case VIA_RES_1680X1050:
205 case VIA_RES_1920X1080:
206 case VIA_RES_1920X1200:
207 break;
208
209 default:
210 DEBUG_MSG(KERN_INFO
211 "This dvi mode %d have no reduce blanking mode!\n",
212 mode_index);
213 return false;
214 }
215
216 return true;
217}
218
219/* DVI Set Mode */
220void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga)
221{
222 struct VideoModeTable *videoMode = NULL;
223 struct crt_mode_table *pDviTiming;
224 unsigned long desirePixelClock, maxPixelClock;
225 int status = 0;
226 videoMode = viafb_get_modetbl_pointer(video_index);
227 pDviTiming = videoMode->crtc;
228 desirePixelClock = pDviTiming->clk / 1000000;
229 maxPixelClock = (unsigned long)viaparinfo->
230 tmds_setting_info->max_pixel_clock;
231
232 DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n");
233
234 if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) {
235 /*Check if reduce-blanking mode is exist */
236 status =
237 check_reduce_blanking_mode(video_index,
238 pDviTiming->refresh_rate);
239 if (status) {
240 video_index += 100; /*Use reduce-blanking mode */
241 videoMode = viafb_get_modetbl_pointer(video_index);
242 pDviTiming = videoMode->crtc;
243 DEBUG_MSG(KERN_INFO
244 "DVI use reduce blanking mode %d!!\n",
245 video_index);
246 }
247 }
248 viafb_fill_crtc_timing(pDviTiming, video_index, mode_bpp / 8, set_iga);
249 viafb_set_output_path(DEVICE_DVI, set_iga,
250 viaparinfo->chip_info->tmds_chip_info.output_interface);
251}
252
253/* Sense DVI Connector */
254int viafb_dvi_sense(void)
255{
256 u8 RegSR1E = 0, RegSR3E = 0, RegCR6B = 0, RegCR91 = 0,
257 RegCR93 = 0, RegCR9B = 0, data;
258 int ret = false;
259
260 DEBUG_MSG(KERN_INFO "viafb_dvi_sense!!\n");
261
262 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
263 /* DI1 Pad on */
264 RegSR1E = viafb_read_reg(VIASR, SR1E);
265 viafb_write_reg(SR1E, VIASR, RegSR1E | 0x30);
266
267 /* CR6B[0]VCK Input Selection: 1 = External clock. */
268 RegCR6B = viafb_read_reg(VIACR, CR6B);
269 viafb_write_reg(CR6B, VIACR, RegCR6B | 0x08);
270
271 /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
272 [0] Software Control Power Sequence */
273 RegCR91 = viafb_read_reg(VIACR, CR91);
274 viafb_write_reg(CR91, VIACR, 0x1D);
275
276 /* CR93[7] DI1 Data Source Selection: 1 = DSP2.
277 CR93[5] DI1 Clock Source: 1 = internal.
278 CR93[4] DI1 Clock Polarity.
279 CR93[3:1] DI1 Clock Adjust. CR93[0] DI1 enable */
280 RegCR93 = viafb_read_reg(VIACR, CR93);
281 viafb_write_reg(CR93, VIACR, 0x01);
282 } else {
283 /* DVP0/DVP1 Pad on */
284 RegSR1E = viafb_read_reg(VIASR, SR1E);
285 viafb_write_reg(SR1E, VIASR, RegSR1E | 0xF0);
286
287 /* SR3E[1]Multi-function selection:
288 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
289 RegSR3E = viafb_read_reg(VIASR, SR3E);
290 viafb_write_reg(SR3E, VIASR, RegSR3E & (~0x20));
291
292 /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
293 [0] Software Control Power Sequence */
294 RegCR91 = viafb_read_reg(VIACR, CR91);
295 viafb_write_reg(CR91, VIACR, 0x1D);
296
297 /*CR9B[4] DVP1 Data Source Selection: 1 = From secondary
298 display.CR9B[2:0] DVP1 Clock Adjust */
299 RegCR9B = viafb_read_reg(VIACR, CR9B);
300 viafb_write_reg(CR9B, VIACR, 0x01);
301 }
302
303 data = (u8) tmds_register_read(0x09);
304 if (data & 0x04)
305 ret = true;
306
307 if (ret == false) {
308 if (viafb_dvi_query_EDID())
309 ret = true;
310 }
311
312 /* Restore status */
313 viafb_write_reg(SR1E, VIASR, RegSR1E);
314 viafb_write_reg(CR91, VIACR, RegCR91);
315 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
316 viafb_write_reg(CR6B, VIACR, RegCR6B);
317 viafb_write_reg(CR93, VIACR, RegCR93);
318 } else {
319 viafb_write_reg(SR3E, VIASR, RegSR3E);
320 viafb_write_reg(CR9B, VIACR, RegCR9B);
321 }
322
323 return ret;
324}
325
326/* Query Flat Panel's EDID Table Version Through DVI Connector */
327static int viafb_dvi_query_EDID(void)
328{
329 u8 data0, data1;
330 int restore;
331
332 DEBUG_MSG(KERN_INFO "viafb_dvi_query_EDID!!\n");
333
334 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
335 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0;
336
337 data0 = (u8) tmds_register_read(0x00);
338 data1 = (u8) tmds_register_read(0x01);
339 if ((data0 == 0) && (data1 == 0xFF)) {
340 viaparinfo->chip_info->
341 tmds_chip_info.tmds_chip_slave_addr = restore;
342 return EDID_VERSION_1; /* Found EDID1 Table */
343 }
344
345 data0 = (u8) tmds_register_read(0x00);
346 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
347 if (data0 == 0x20)
348 return EDID_VERSION_2; /* Found EDID2 Table */
349 else
350 return false;
351}
352
353/*
354 *
355 * int dvi_get_panel_size_from_DDCv1(void)
356 *
357 * - Get Panel Size Using EDID1 Table
358 *
359 * Return Type: int
360 *
361 */
362static int dvi_get_panel_size_from_DDCv1(void)
363{
364 int i, max_h = 0, max_v = 0, tmp, restore;
365 unsigned char rData;
366 unsigned char EDID_DATA[18];
367
368 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n");
369
370 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
371 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0;
372
373 rData = tmds_register_read(0x23);
374 if (rData & 0x3C)
375 max_h = 640;
376 if (rData & 0xC0)
377 max_h = 720;
378 if (rData & 0x03)
379 max_h = 800;
380
381 rData = tmds_register_read(0x24);
382 if (rData & 0xC0)
383 max_h = 800;
384 if (rData & 0x1E)
385 max_h = 1024;
386 if (rData & 0x01)
387 max_h = 1280;
388
389 for (i = 0x25; i < 0x6D; i++) {
390 switch (i) {
391 case 0x26:
392 case 0x28:
393 case 0x2A:
394 case 0x2C:
395 case 0x2E:
396 case 0x30:
397 case 0x32:
398 case 0x34:
399 rData = tmds_register_read(i);
400 if (rData == 1)
401 break;
402 /* data = (data + 31) * 8 */
403 tmp = (rData + 31) << 3;
404 if (tmp > max_h)
405 max_h = tmp;
406 break;
407
408 case 0x36:
409 case 0x48:
410 case 0x5A:
411 case 0x6C:
412 tmds_register_read_bytes(i, EDID_DATA, 10);
413 if (!(EDID_DATA[0] || EDID_DATA[1])) {
414 /* The first two byte must be zero. */
415 if (EDID_DATA[3] == 0xFD) {
416 /* To get max pixel clock. */
417 viaparinfo->tmds_setting_info->
418 max_pixel_clock = EDID_DATA[9] * 10;
419 }
420 }
421 break;
422
423 default:
424 break;
425 }
426 }
427
428 switch (max_h) {
429 case 640:
430 viaparinfo->tmds_setting_info->dvi_panel_size =
431 VIA_RES_640X480;
432 break;
433 case 800:
434 viaparinfo->tmds_setting_info->dvi_panel_size =
435 VIA_RES_800X600;
436 break;
437 case 1024:
438 viaparinfo->tmds_setting_info->dvi_panel_size =
439 VIA_RES_1024X768;
440 break;
441 case 1280:
442 viaparinfo->tmds_setting_info->dvi_panel_size =
443 VIA_RES_1280X1024;
444 break;
445 case 1400:
446 viaparinfo->tmds_setting_info->dvi_panel_size =
447 VIA_RES_1400X1050;
448 break;
449 case 1440:
450 viaparinfo->tmds_setting_info->dvi_panel_size =
451 VIA_RES_1440X1050;
452 break;
453 case 1600:
454 viaparinfo->tmds_setting_info->dvi_panel_size =
455 VIA_RES_1600X1200;
456 break;
457 case 1920:
458 if (max_v == 1200) {
459 viaparinfo->tmds_setting_info->dvi_panel_size =
460 VIA_RES_1920X1200;
461 } else {
462 viaparinfo->tmds_setting_info->dvi_panel_size =
463 VIA_RES_1920X1080;
464 }
465
466 break;
467 default:
468 viaparinfo->tmds_setting_info->dvi_panel_size =
469 VIA_RES_1024X768;
470 DEBUG_MSG(KERN_INFO "Unknow panel size max resolution = %d !\
471 set default panel size.\n", max_h);
472 break;
473 }
474
475 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n",
476 viaparinfo->tmds_setting_info->max_pixel_clock);
477 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
478 return viaparinfo->tmds_setting_info->dvi_panel_size;
479}
480
481/*
482 *
483 * int dvi_get_panel_size_from_DDCv2(void)
484 *
485 * - Get Panel Size Using EDID2 Table
486 *
487 * Return Type: int
488 *
489 */
490static int dvi_get_panel_size_from_DDCv2(void)
491{
492 int HSize = 0, restore;
493 unsigned char R_Buffer[2];
494
495 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n");
496
497 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
498 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA2;
499
500 /* Horizontal: 0x76, 0x77 */
501 tmds_register_read_bytes(0x76, R_Buffer, 2);
502 HSize = R_Buffer[0];
503 HSize += R_Buffer[1] << 8;
504
505 switch (HSize) {
506 case 640:
507 viaparinfo->tmds_setting_info->dvi_panel_size =
508 VIA_RES_640X480;
509 break;
510 case 800:
511 viaparinfo->tmds_setting_info->dvi_panel_size =
512 VIA_RES_800X600;
513 break;
514 case 1024:
515 viaparinfo->tmds_setting_info->dvi_panel_size =
516 VIA_RES_1024X768;
517 break;
518 case 1280:
519 viaparinfo->tmds_setting_info->dvi_panel_size =
520 VIA_RES_1280X1024;
521 break;
522 case 1400:
523 viaparinfo->tmds_setting_info->dvi_panel_size =
524 VIA_RES_1400X1050;
525 break;
526 case 1440:
527 viaparinfo->tmds_setting_info->dvi_panel_size =
528 VIA_RES_1440X1050;
529 break;
530 case 1600:
531 viaparinfo->tmds_setting_info->dvi_panel_size =
532 VIA_RES_1600X1200;
533 break;
534 default:
535 viaparinfo->tmds_setting_info->dvi_panel_size =
536 VIA_RES_1024X768;
537 DEBUG_MSG(KERN_INFO "Unknow panel size max resolution = %d!\
538 set default panel size.\n", HSize);
539 break;
540 }
541
542 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
543 return viaparinfo->tmds_setting_info->dvi_panel_size;
544}
545
546/*
547 *
548 * unsigned char dvi_get_panel_info(void)
549 *
550 * - Get Panel Size
551 *
552 * Return Type: unsigned char
553 */
554static unsigned char dvi_get_panel_info(void)
555{
556 unsigned char dvipanelsize;
557 DEBUG_MSG(KERN_INFO "dvi_get_panel_info! \n");
558
559 viafb_dvi_sense();
560 switch (viafb_dvi_query_EDID()) {
561 case 1:
562 dvi_get_panel_size_from_DDCv1();
563 break;
564 case 2:
565 dvi_get_panel_size_from_DDCv2();
566 break;
567 default:
568 break;
569 }
570
571 DEBUG_MSG(KERN_INFO "dvi panel size is %2d \n",
572 viaparinfo->tmds_setting_info->dvi_panel_size);
573 dvipanelsize = (unsigned char)(viaparinfo->
574 tmds_setting_info->dvi_panel_size);
575 return dvipanelsize;
576}
577
578/* If Disable DVI, turn off pad */
579void viafb_dvi_disable(void)
580{
581 if (viaparinfo->chip_info->
582 tmds_chip_info.output_interface == INTERFACE_DVP0)
583 viafb_write_reg(SR1E, VIASR,
584 viafb_read_reg(VIASR, SR1E) & (~0xC0));
585
586 if (viaparinfo->chip_info->
587 tmds_chip_info.output_interface == INTERFACE_DVP1)
588 viafb_write_reg(SR1E, VIASR,
589 viafb_read_reg(VIASR, SR1E) & (~0x30));
590
591 if (viaparinfo->chip_info->
592 tmds_chip_info.output_interface == INTERFACE_DFP_HIGH)
593 viafb_write_reg(SR2A, VIASR,
594 viafb_read_reg(VIASR, SR2A) & (~0x0C));
595
596 if (viaparinfo->chip_info->
597 tmds_chip_info.output_interface == INTERFACE_DFP_LOW)
598 viafb_write_reg(SR2A, VIASR,
599 viafb_read_reg(VIASR, SR2A) & (~0x03));
600
601 if (viaparinfo->chip_info->
602 tmds_chip_info.output_interface == INTERFACE_TMDS)
603 /* Turn off TMDS power. */
604 viafb_write_reg(CRD2, VIACR,
605 viafb_read_reg(VIACR, CRD2) | 0x08);
606}
607
608/* If Enable DVI, turn off pad */
609void viafb_dvi_enable(void)
610{
611 u8 data;
612
613 if (viaparinfo->chip_info->
614 tmds_chip_info.output_interface == INTERFACE_DVP0) {
615 viafb_write_reg(SR1E, VIASR,
616 viafb_read_reg(VIASR, SR1E) | 0xC0);
617 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
618 tmds_register_write(0x88, 0x3b);
619 else
620 /*clear CR91[5] to direct on display period
621 in the secondary diplay path */
622 viafb_write_reg(CR91, VIACR,
623 viafb_read_reg(VIACR, CR91) & 0xDF);
624 }
625
626 if (viaparinfo->chip_info->
627 tmds_chip_info.output_interface == INTERFACE_DVP1) {
628 viafb_write_reg(SR1E, VIASR,
629 viafb_read_reg(VIASR, SR1E) | 0x30);
630
631 /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */
632 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
633 tmds_register_write(0x88, 0x3b);
634 } else {
635 /*clear CR91[5] to direct on display period
636 in the secondary diplay path */
637 viafb_write_reg(CR91, VIACR,
638 viafb_read_reg(VIACR, CR91) & 0xDF);
639 }
640
641 /*fix DVI cannot enable on EPIA-M board */
642 if (viafb_platform_epia_dvi == 1) {
643 viafb_write_reg_mask(CR91, VIACR, 0x1f, 0x1f);
644 viafb_write_reg_mask(CR88, VIACR, 0x00, BIT6 + BIT0);
645 if (viafb_bus_width == 24) {
646 if (viafb_device_lcd_dualedge == 1)
647 data = 0x3F;
648 else
649 data = 0x37;
650 viafb_i2c_writebyte(viaparinfo->chip_info->
651 tmds_chip_info.
652 tmds_chip_slave_addr,
653 0x08, data);
654 }
655 }
656 }
657
658 if (viaparinfo->chip_info->
659 tmds_chip_info.output_interface == INTERFACE_DFP_HIGH) {
660 viafb_write_reg(SR2A, VIASR,
661 viafb_read_reg(VIASR, SR2A) | 0x0C);
662 viafb_write_reg(CR91, VIACR,
663 viafb_read_reg(VIACR, CR91) & 0xDF);
664 }
665
666 if (viaparinfo->chip_info->
667 tmds_chip_info.output_interface == INTERFACE_DFP_LOW) {
668 viafb_write_reg(SR2A, VIASR,
669 viafb_read_reg(VIASR, SR2A) | 0x03);
670 viafb_write_reg(CR91, VIACR,
671 viafb_read_reg(VIACR, CR91) & 0xDF);
672 }
673 if (viaparinfo->chip_info->
674 tmds_chip_info.output_interface == INTERFACE_TMDS) {
675 /* Turn on Display period in the panel path. */
676 viafb_write_reg_mask(CR91, VIACR, 0, BIT7);
677
678 /* Turn on TMDS power. */
679 viafb_write_reg_mask(CRD2, VIACR, 0, BIT3);
680 }
681}
682
diff --git a/drivers/video/via/dvi.h b/drivers/video/via/dvi.h
new file mode 100644
index 000000000000..e1ec37fb0dc3
--- /dev/null
+++ b/drivers/video/via/dvi.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __DVI_H__
23#define __DVI_H__
24
25/*Definition TMDS Device ID register*/
26#define VT1632_DEVICE_ID_REG 0x02
27#define VT1632_DEVICE_ID 0x92
28
29#define GET_DVI_SIZE_BY_SYSTEM_BIOS 0x01
30#define GET_DVI_SIZE_BY_VGA_BIOS 0x02
31#define GET_DVI_SZIE_BY_HW_STRAPPING 0x03
32
33/* Definition DVI Panel ID*/
34/* Resolution: 640x480, Channel: single, Dithering: Enable */
35#define DVI_PANEL_ID0_640X480 0x00
36/* Resolution: 800x600, Channel: single, Dithering: Enable */
37#define DVI_PANEL_ID1_800x600 0x01
38/* Resolution: 1024x768, Channel: single, Dithering: Enable */
39#define DVI_PANEL_ID1_1024x768 0x02
40/* Resolution: 1280x768, Channel: single, Dithering: Enable */
41#define DVI_PANEL_ID1_1280x768 0x03
42/* Resolution: 1280x1024, Channel: dual, Dithering: Enable */
43#define DVI_PANEL_ID1_1280x1024 0x04
44/* Resolution: 1400x1050, Channel: dual, Dithering: Enable */
45#define DVI_PANEL_ID1_1400x1050 0x05
46/* Resolution: 1600x1200, Channel: dual, Dithering: Enable */
47#define DVI_PANEL_ID1_1600x1200 0x06
48
49/* Define the version of EDID*/
50#define EDID_VERSION_1 1
51#define EDID_VERSION_2 2
52
53#define DEV_CONNECT_DVI 0x01
54#define DEV_CONNECT_HDMI 0x02
55
56struct VideoModeTable *viafb_get_cea_mode_tbl_pointer(int Index);
57int viafb_dvi_sense(void);
58void viafb_dvi_disable(void);
59void viafb_dvi_enable(void);
60int viafb_tmds_trasmitter_identify(void);
61void viafb_init_dvi_size(void);
62void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga);
63
64#endif /* __DVI_H__ */
diff --git a/drivers/video/via/global.c b/drivers/video/via/global.c
new file mode 100644
index 000000000000..468be2425af3
--- /dev/null
+++ b/drivers/video/via/global.c
@@ -0,0 +1,60 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#include "global.h"
22int viafb_platform_epia_dvi = STATE_OFF;
23int viafb_device_lcd_dualedge = STATE_OFF;
24int viafb_bus_width = 12;
25int viafb_display_hardware_layout = HW_LAYOUT_LCD_DVI;
26int viafb_memsize;
27int viafb_DeviceStatus = CRT_Device;
28int viafb_hotplug;
29int viafb_refresh = 60;
30int viafb_refresh1 = 60;
31int viafb_lcd_dsp_method = LCD_EXPANDSION;
32int viafb_lcd_mode = LCD_OPENLDI;
33int viafb_bpp = 32;
34int viafb_bpp1 = 32;
35int viafb_accel = 1;
36int viafb_CRT_ON = 1;
37int viafb_DVI_ON;
38int viafb_LCD_ON ;
39int viafb_LCD2_ON;
40int viafb_SAMM_ON;
41int viafb_dual_fb;
42int viafb_hotplug_Xres = 640;
43int viafb_hotplug_Yres = 480;
44int viafb_hotplug_bpp = 32;
45int viafb_hotplug_refresh = 60;
46unsigned int viafb_second_offset;
47int viafb_second_size;
48int viafb_primary_dev = None_Device;
49void __iomem *viafb_FB_MM;
50unsigned int viafb_second_xres = 640;
51unsigned int viafb_second_yres = 480;
52unsigned int viafb_second_virtual_xres;
53unsigned int viafb_second_virtual_yres;
54int viafb_lcd_panel_id = LCD_PANEL_ID_MAXIMUM + 1;
55struct fb_cursor viacursor;
56struct fb_info *viafbinfo;
57struct fb_info *viafbinfo1;
58struct viafb_par *viaparinfo;
59struct viafb_par *viaparinfo1;
60
diff --git a/drivers/video/via/global.h b/drivers/video/via/global.h
new file mode 100644
index 000000000000..8e5263c5b812
--- /dev/null
+++ b/drivers/video/via/global.h
@@ -0,0 +1,90 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __GLOBAL_H__
23#define __GLOBAL_H__
24
25#include <linux/fb.h>
26#include <linux/delay.h>
27#include <linux/ioport.h>
28#include <linux/pci.h>
29#include <linux/io.h>
30#include <linux/uaccess.h>
31#include <linux/init.h>
32#include <linux/proc_fs.h>
33#include <linux/console.h>
34#include <linux/timer.h>
35
36#include "debug.h"
37
38#include "iface.h"
39#include "viafbdev.h"
40#include "chip.h"
41#include "debug.h"
42#include "accel.h"
43#include "share.h"
44#include "dvi.h"
45#include "viamode.h"
46#include "via_i2c.h"
47#include "hw.h"
48
49#include "lcd.h"
50#include "ioctl.h"
51#include "viamode.h"
52#include "via_utility.h"
53#include "vt1636.h"
54#include "tblDPASetting.h"
55#include "tbl1636.h"
56#include "viafbdev.h"
57
58/* External struct*/
59
60extern int viafb_platform_epia_dvi;
61extern int viafb_device_lcd_dualedge;
62extern int viafb_bus_width;
63extern int viafb_display_hardware_layout;
64extern struct offset offset_reg;
65extern struct viafb_par *viaparinfo;
66extern struct viafb_par *viaparinfo1;
67extern struct fb_info *viafbinfo;
68extern struct fb_info *viafbinfo1;
69extern int viafb_DeviceStatus;
70extern int viafb_refresh;
71extern int viafb_refresh1;
72extern int viafb_lcd_dsp_method;
73extern int viafb_lcd_mode;
74extern int viafb_bpp;
75extern int viafb_bpp1;
76
77extern int viafb_CRT_ON;
78extern int viafb_hotplug_Xres;
79extern int viafb_hotplug_Yres;
80extern int viafb_hotplug_bpp;
81extern int viafb_hotplug_refresh;
82extern int viafb_primary_dev;
83extern void __iomem *viafb_FB_MM;
84extern struct fb_cursor viacursor;
85
86extern unsigned int viafb_second_xres;
87extern unsigned int viafb_second_yres;
88extern int viafb_lcd_panel_id;
89
90#endif /* __GLOBAL_H__ */
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
new file mode 100644
index 000000000000..fcd53ceb88fa
--- /dev/null
+++ b/drivers/video/via/hw.c
@@ -0,0 +1,2865 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23
24static const struct pci_device_id_info pciidlist[] = {
25 {PCI_VIA_VENDOR_ID, UNICHROME_CLE266_DID, UNICHROME_CLE266},
26 {PCI_VIA_VENDOR_ID, UNICHROME_PM800_DID, UNICHROME_PM800},
27 {PCI_VIA_VENDOR_ID, UNICHROME_K400_DID, UNICHROME_K400},
28 {PCI_VIA_VENDOR_ID, UNICHROME_K800_DID, UNICHROME_K800},
29 {PCI_VIA_VENDOR_ID, UNICHROME_CN700_DID, UNICHROME_CN700},
30 {PCI_VIA_VENDOR_ID, UNICHROME_P4M890_DID, UNICHROME_P4M890},
31 {PCI_VIA_VENDOR_ID, UNICHROME_K8M890_DID, UNICHROME_K8M890},
32 {PCI_VIA_VENDOR_ID, UNICHROME_CX700_DID, UNICHROME_CX700},
33 {PCI_VIA_VENDOR_ID, UNICHROME_P4M900_DID, UNICHROME_P4M900},
34 {PCI_VIA_VENDOR_ID, UNICHROME_CN750_DID, UNICHROME_CN750},
35 {PCI_VIA_VENDOR_ID, UNICHROME_VX800_DID, UNICHROME_VX800},
36 {0, 0, 0}
37};
38
39struct offset offset_reg = {
40 /* IGA1 Offset Register */
41 {IGA1_OFFSET_REG_NUM, {{CR13, 0, 7}, {CR35, 5, 7} } },
42 /* IGA2 Offset Register */
43 {IGA2_OFFSET_REG_NUM, {{CR66, 0, 7}, {CR67, 0, 1} } }
44};
45
46static struct pll_map pll_value[] = {
47 {CLK_25_175M, CLE266_PLL_25_175M, K800_PLL_25_175M, CX700_25_175M},
48 {CLK_29_581M, CLE266_PLL_29_581M, K800_PLL_29_581M, CX700_29_581M},
49 {CLK_26_880M, CLE266_PLL_26_880M, K800_PLL_26_880M, CX700_26_880M},
50 {CLK_31_490M, CLE266_PLL_31_490M, K800_PLL_31_490M, CX700_31_490M},
51 {CLK_31_500M, CLE266_PLL_31_500M, K800_PLL_31_500M, CX700_31_500M},
52 {CLK_31_728M, CLE266_PLL_31_728M, K800_PLL_31_728M, CX700_31_728M},
53 {CLK_32_668M, CLE266_PLL_32_668M, K800_PLL_32_668M, CX700_32_668M},
54 {CLK_36_000M, CLE266_PLL_36_000M, K800_PLL_36_000M, CX700_36_000M},
55 {CLK_40_000M, CLE266_PLL_40_000M, K800_PLL_40_000M, CX700_40_000M},
56 {CLK_41_291M, CLE266_PLL_41_291M, K800_PLL_41_291M, CX700_41_291M},
57 {CLK_43_163M, CLE266_PLL_43_163M, K800_PLL_43_163M, CX700_43_163M},
58 {CLK_45_250M, CLE266_PLL_45_250M, K800_PLL_45_250M, CX700_45_250M},
59 {CLK_46_000M, CLE266_PLL_46_000M, K800_PLL_46_000M, CX700_46_000M},
60 {CLK_46_996M, CLE266_PLL_46_996M, K800_PLL_46_996M, CX700_46_996M},
61 {CLK_48_000M, CLE266_PLL_48_000M, K800_PLL_48_000M, CX700_48_000M},
62 {CLK_48_875M, CLE266_PLL_48_875M, K800_PLL_48_875M, CX700_48_875M},
63 {CLK_49_500M, CLE266_PLL_49_500M, K800_PLL_49_500M, CX700_49_500M},
64 {CLK_52_406M, CLE266_PLL_52_406M, K800_PLL_52_406M, CX700_52_406M},
65 {CLK_52_977M, CLE266_PLL_52_977M, K800_PLL_52_977M, CX700_52_977M},
66 {CLK_56_250M, CLE266_PLL_56_250M, K800_PLL_56_250M, CX700_56_250M},
67 {CLK_60_466M, CLE266_PLL_60_466M, K800_PLL_60_466M, CX700_60_466M},
68 {CLK_61_500M, CLE266_PLL_61_500M, K800_PLL_61_500M, CX700_61_500M},
69 {CLK_65_000M, CLE266_PLL_65_000M, K800_PLL_65_000M, CX700_65_000M},
70 {CLK_65_178M, CLE266_PLL_65_178M, K800_PLL_65_178M, CX700_65_178M},
71 {CLK_66_750M, CLE266_PLL_66_750M, K800_PLL_66_750M, CX700_66_750M},
72 {CLK_68_179M, CLE266_PLL_68_179M, K800_PLL_68_179M, CX700_68_179M},
73 {CLK_69_924M, CLE266_PLL_69_924M, K800_PLL_69_924M, CX700_69_924M},
74 {CLK_70_159M, CLE266_PLL_70_159M, K800_PLL_70_159M, CX700_70_159M},
75 {CLK_72_000M, CLE266_PLL_72_000M, K800_PLL_72_000M, CX700_72_000M},
76 {CLK_78_750M, CLE266_PLL_78_750M, K800_PLL_78_750M, CX700_78_750M},
77 {CLK_80_136M, CLE266_PLL_80_136M, K800_PLL_80_136M, CX700_80_136M},
78 {CLK_83_375M, CLE266_PLL_83_375M, K800_PLL_83_375M, CX700_83_375M},
79 {CLK_83_950M, CLE266_PLL_83_950M, K800_PLL_83_950M, CX700_83_950M},
80 {CLK_84_750M, CLE266_PLL_84_750M, K800_PLL_84_750M, CX700_84_750M},
81 {CLK_85_860M, CLE266_PLL_85_860M, K800_PLL_85_860M, CX700_85_860M},
82 {CLK_88_750M, CLE266_PLL_88_750M, K800_PLL_88_750M, CX700_88_750M},
83 {CLK_94_500M, CLE266_PLL_94_500M, K800_PLL_94_500M, CX700_94_500M},
84 {CLK_97_750M, CLE266_PLL_97_750M, K800_PLL_97_750M, CX700_97_750M},
85 {CLK_101_000M, CLE266_PLL_101_000M, K800_PLL_101_000M,
86 CX700_101_000M},
87 {CLK_106_500M, CLE266_PLL_106_500M, K800_PLL_106_500M,
88 CX700_106_500M},
89 {CLK_108_000M, CLE266_PLL_108_000M, K800_PLL_108_000M,
90 CX700_108_000M},
91 {CLK_113_309M, CLE266_PLL_113_309M, K800_PLL_113_309M,
92 CX700_113_309M},
93 {CLK_118_840M, CLE266_PLL_118_840M, K800_PLL_118_840M,
94 CX700_118_840M},
95 {CLK_119_000M, CLE266_PLL_119_000M, K800_PLL_119_000M,
96 CX700_119_000M},
97 {CLK_121_750M, CLE266_PLL_121_750M, K800_PLL_121_750M,
98 CX700_121_750M},
99 {CLK_125_104M, CLE266_PLL_125_104M, K800_PLL_125_104M,
100 CX700_125_104M},
101 {CLK_133_308M, CLE266_PLL_133_308M, K800_PLL_133_308M,
102 CX700_133_308M},
103 {CLK_135_000M, CLE266_PLL_135_000M, K800_PLL_135_000M,
104 CX700_135_000M},
105 {CLK_136_700M, CLE266_PLL_136_700M, K800_PLL_136_700M,
106 CX700_136_700M},
107 {CLK_138_400M, CLE266_PLL_138_400M, K800_PLL_138_400M,
108 CX700_138_400M},
109 {CLK_146_760M, CLE266_PLL_146_760M, K800_PLL_146_760M,
110 CX700_146_760M},
111 {CLK_153_920M, CLE266_PLL_153_920M, K800_PLL_153_920M,
112 CX700_153_920M},
113 {CLK_156_000M, CLE266_PLL_156_000M, K800_PLL_156_000M,
114 CX700_156_000M},
115 {CLK_157_500M, CLE266_PLL_157_500M, K800_PLL_157_500M,
116 CX700_157_500M},
117 {CLK_162_000M, CLE266_PLL_162_000M, K800_PLL_162_000M,
118 CX700_162_000M},
119 {CLK_187_000M, CLE266_PLL_187_000M, K800_PLL_187_000M,
120 CX700_187_000M},
121 {CLK_193_295M, CLE266_PLL_193_295M, K800_PLL_193_295M,
122 CX700_193_295M},
123 {CLK_202_500M, CLE266_PLL_202_500M, K800_PLL_202_500M,
124 CX700_202_500M},
125 {CLK_204_000M, CLE266_PLL_204_000M, K800_PLL_204_000M,
126 CX700_204_000M},
127 {CLK_218_500M, CLE266_PLL_218_500M, K800_PLL_218_500M,
128 CX700_218_500M},
129 {CLK_234_000M, CLE266_PLL_234_000M, K800_PLL_234_000M,
130 CX700_234_000M},
131 {CLK_267_250M, CLE266_PLL_267_250M, K800_PLL_267_250M,
132 CX700_267_250M},
133 {CLK_297_500M, CLE266_PLL_297_500M, K800_PLL_297_500M,
134 CX700_297_500M},
135 {CLK_74_481M, CLE266_PLL_74_481M, K800_PLL_74_481M, CX700_74_481M},
136 {CLK_172_798M, CLE266_PLL_172_798M, K800_PLL_172_798M,
137 CX700_172_798M},
138 {CLK_122_614M, CLE266_PLL_122_614M, K800_PLL_122_614M,
139 CX700_122_614M},
140 {CLK_74_270M, CLE266_PLL_74_270M, K800_PLL_74_270M, CX700_74_270M},
141 {CLK_148_500M, CLE266_PLL_148_500M, K800_PLL_148_500M,
142 CX700_148_500M}
143};
144
145static struct fifo_depth_select display_fifo_depth_reg = {
146 /* IGA1 FIFO Depth_Select */
147 {IGA1_FIFO_DEPTH_SELECT_REG_NUM, {{SR17, 0, 7} } },
148 /* IGA2 FIFO Depth_Select */
149 {IGA2_FIFO_DEPTH_SELECT_REG_NUM,
150 {{CR68, 4, 7}, {CR94, 7, 7}, {CR95, 7, 7} } }
151};
152
153static struct fifo_threshold_select fifo_threshold_select_reg = {
154 /* IGA1 FIFO Threshold Select */
155 {IGA1_FIFO_THRESHOLD_REG_NUM, {{SR16, 0, 5}, {SR16, 7, 7} } },
156 /* IGA2 FIFO Threshold Select */
157 {IGA2_FIFO_THRESHOLD_REG_NUM, {{CR68, 0, 3}, {CR95, 4, 6} } }
158};
159
160static struct fifo_high_threshold_select fifo_high_threshold_select_reg = {
161 /* IGA1 FIFO High Threshold Select */
162 {IGA1_FIFO_HIGH_THRESHOLD_REG_NUM, {{SR18, 0, 5}, {SR18, 7, 7} } },
163 /* IGA2 FIFO High Threshold Select */
164 {IGA2_FIFO_HIGH_THRESHOLD_REG_NUM, {{CR92, 0, 3}, {CR95, 0, 2} } }
165};
166
167static struct display_queue_expire_num display_queue_expire_num_reg = {
168 /* IGA1 Display Queue Expire Num */
169 {IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM, {{SR22, 0, 4} } },
170 /* IGA2 Display Queue Expire Num */
171 {IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM, {{CR94, 0, 6} } }
172};
173
174/* Definition Fetch Count Registers*/
175static struct fetch_count fetch_count_reg = {
176 /* IGA1 Fetch Count Register */
177 {IGA1_FETCH_COUNT_REG_NUM, {{SR1C, 0, 7}, {SR1D, 0, 1} } },
178 /* IGA2 Fetch Count Register */
179 {IGA2_FETCH_COUNT_REG_NUM, {{CR65, 0, 7}, {CR67, 2, 3} } }
180};
181
182static struct iga1_crtc_timing iga1_crtc_reg = {
183 /* IGA1 Horizontal Total */
184 {IGA1_HOR_TOTAL_REG_NUM, {{CR00, 0, 7}, {CR36, 3, 3} } },
185 /* IGA1 Horizontal Addressable Video */
186 {IGA1_HOR_ADDR_REG_NUM, {{CR01, 0, 7} } },
187 /* IGA1 Horizontal Blank Start */
188 {IGA1_HOR_BLANK_START_REG_NUM, {{CR02, 0, 7} } },
189 /* IGA1 Horizontal Blank End */
190 {IGA1_HOR_BLANK_END_REG_NUM,
191 {{CR03, 0, 4}, {CR05, 7, 7}, {CR33, 5, 5} } },
192 /* IGA1 Horizontal Sync Start */
193 {IGA1_HOR_SYNC_START_REG_NUM, {{CR04, 0, 7}, {CR33, 4, 4} } },
194 /* IGA1 Horizontal Sync End */
195 {IGA1_HOR_SYNC_END_REG_NUM, {{CR05, 0, 4} } },
196 /* IGA1 Vertical Total */
197 {IGA1_VER_TOTAL_REG_NUM,
198 {{CR06, 0, 7}, {CR07, 0, 0}, {CR07, 5, 5}, {CR35, 0, 0} } },
199 /* IGA1 Vertical Addressable Video */
200 {IGA1_VER_ADDR_REG_NUM,
201 {{CR12, 0, 7}, {CR07, 1, 1}, {CR07, 6, 6}, {CR35, 2, 2} } },
202 /* IGA1 Vertical Blank Start */
203 {IGA1_VER_BLANK_START_REG_NUM,
204 {{CR15, 0, 7}, {CR07, 3, 3}, {CR09, 5, 5}, {CR35, 3, 3} } },
205 /* IGA1 Vertical Blank End */
206 {IGA1_VER_BLANK_END_REG_NUM, {{CR16, 0, 7} } },
207 /* IGA1 Vertical Sync Start */
208 {IGA1_VER_SYNC_START_REG_NUM,
209 {{CR10, 0, 7}, {CR07, 2, 2}, {CR07, 7, 7}, {CR35, 1, 1} } },
210 /* IGA1 Vertical Sync End */
211 {IGA1_VER_SYNC_END_REG_NUM, {{CR11, 0, 3} } }
212};
213
214static struct iga2_crtc_timing iga2_crtc_reg = {
215 /* IGA2 Horizontal Total */
216 {IGA2_HOR_TOTAL_REG_NUM, {{CR50, 0, 7}, {CR55, 0, 3} } },
217 /* IGA2 Horizontal Addressable Video */
218 {IGA2_HOR_ADDR_REG_NUM, {{CR51, 0, 7}, {CR55, 4, 6} } },
219 /* IGA2 Horizontal Blank Start */
220 {IGA2_HOR_BLANK_START_REG_NUM, {{CR52, 0, 7}, {CR54, 0, 2} } },
221 /* IGA2 Horizontal Blank End */
222 {IGA2_HOR_BLANK_END_REG_NUM,
223 {{CR53, 0, 7}, {CR54, 3, 5}, {CR5D, 6, 6} } },
224 /* IGA2 Horizontal Sync Start */
225 {IGA2_HOR_SYNC_START_REG_NUM,
226 {{CR56, 0, 7}, {CR54, 6, 7}, {CR5C, 7, 7}, {CR5D, 7, 7} } },
227 /* IGA2 Horizontal Sync End */
228 {IGA2_HOR_SYNC_END_REG_NUM, {{CR57, 0, 7}, {CR5C, 6, 6} } },
229 /* IGA2 Vertical Total */
230 {IGA2_VER_TOTAL_REG_NUM, {{CR58, 0, 7}, {CR5D, 0, 2} } },
231 /* IGA2 Vertical Addressable Video */
232 {IGA2_VER_ADDR_REG_NUM, {{CR59, 0, 7}, {CR5D, 3, 5} } },
233 /* IGA2 Vertical Blank Start */
234 {IGA2_VER_BLANK_START_REG_NUM, {{CR5A, 0, 7}, {CR5C, 0, 2} } },
235 /* IGA2 Vertical Blank End */
236 {IGA2_VER_BLANK_END_REG_NUM, {{CR5B, 0, 7}, {CR5C, 3, 5} } },
237 /* IGA2 Vertical Sync Start */
238 {IGA2_VER_SYNC_START_REG_NUM, {{CR5E, 0, 7}, {CR5F, 5, 7} } },
239 /* IGA2 Vertical Sync End */
240 {IGA2_VER_SYNC_END_REG_NUM, {{CR5F, 0, 4} } }
241};
242
243static struct rgbLUT palLUT_table[] = {
244 /* {R,G,B} */
245 /* Index 0x00~0x03 */
246 {0x00, 0x00, 0x00}, {0x00, 0x00, 0x2A}, {0x00, 0x2A, 0x00}, {0x00,
247 0x2A,
248 0x2A},
249 /* Index 0x04~0x07 */
250 {0x2A, 0x00, 0x00}, {0x2A, 0x00, 0x2A}, {0x2A, 0x15, 0x00}, {0x2A,
251 0x2A,
252 0x2A},
253 /* Index 0x08~0x0B */
254 {0x15, 0x15, 0x15}, {0x15, 0x15, 0x3F}, {0x15, 0x3F, 0x15}, {0x15,
255 0x3F,
256 0x3F},
257 /* Index 0x0C~0x0F */
258 {0x3F, 0x15, 0x15}, {0x3F, 0x15, 0x3F}, {0x3F, 0x3F, 0x15}, {0x3F,
259 0x3F,
260 0x3F},
261 /* Index 0x10~0x13 */
262 {0x00, 0x00, 0x00}, {0x05, 0x05, 0x05}, {0x08, 0x08, 0x08}, {0x0B,
263 0x0B,
264 0x0B},
265 /* Index 0x14~0x17 */
266 {0x0E, 0x0E, 0x0E}, {0x11, 0x11, 0x11}, {0x14, 0x14, 0x14}, {0x18,
267 0x18,
268 0x18},
269 /* Index 0x18~0x1B */
270 {0x1C, 0x1C, 0x1C}, {0x20, 0x20, 0x20}, {0x24, 0x24, 0x24}, {0x28,
271 0x28,
272 0x28},
273 /* Index 0x1C~0x1F */
274 {0x2D, 0x2D, 0x2D}, {0x32, 0x32, 0x32}, {0x38, 0x38, 0x38}, {0x3F,
275 0x3F,
276 0x3F},
277 /* Index 0x20~0x23 */
278 {0x00, 0x00, 0x3F}, {0x10, 0x00, 0x3F}, {0x1F, 0x00, 0x3F}, {0x2F,
279 0x00,
280 0x3F},
281 /* Index 0x24~0x27 */
282 {0x3F, 0x00, 0x3F}, {0x3F, 0x00, 0x2F}, {0x3F, 0x00, 0x1F}, {0x3F,
283 0x00,
284 0x10},
285 /* Index 0x28~0x2B */
286 {0x3F, 0x00, 0x00}, {0x3F, 0x10, 0x00}, {0x3F, 0x1F, 0x00}, {0x3F,
287 0x2F,
288 0x00},
289 /* Index 0x2C~0x2F */
290 {0x3F, 0x3F, 0x00}, {0x2F, 0x3F, 0x00}, {0x1F, 0x3F, 0x00}, {0x10,
291 0x3F,
292 0x00},
293 /* Index 0x30~0x33 */
294 {0x00, 0x3F, 0x00}, {0x00, 0x3F, 0x10}, {0x00, 0x3F, 0x1F}, {0x00,
295 0x3F,
296 0x2F},
297 /* Index 0x34~0x37 */
298 {0x00, 0x3F, 0x3F}, {0x00, 0x2F, 0x3F}, {0x00, 0x1F, 0x3F}, {0x00,
299 0x10,
300 0x3F},
301 /* Index 0x38~0x3B */
302 {0x1F, 0x1F, 0x3F}, {0x27, 0x1F, 0x3F}, {0x2F, 0x1F, 0x3F}, {0x37,
303 0x1F,
304 0x3F},
305 /* Index 0x3C~0x3F */
306 {0x3F, 0x1F, 0x3F}, {0x3F, 0x1F, 0x37}, {0x3F, 0x1F, 0x2F}, {0x3F,
307 0x1F,
308 0x27},
309 /* Index 0x40~0x43 */
310 {0x3F, 0x1F, 0x1F}, {0x3F, 0x27, 0x1F}, {0x3F, 0x2F, 0x1F}, {0x3F,
311 0x3F,
312 0x1F},
313 /* Index 0x44~0x47 */
314 {0x3F, 0x3F, 0x1F}, {0x37, 0x3F, 0x1F}, {0x2F, 0x3F, 0x1F}, {0x27,
315 0x3F,
316 0x1F},
317 /* Index 0x48~0x4B */
318 {0x1F, 0x3F, 0x1F}, {0x1F, 0x3F, 0x27}, {0x1F, 0x3F, 0x2F}, {0x1F,
319 0x3F,
320 0x37},
321 /* Index 0x4C~0x4F */
322 {0x1F, 0x3F, 0x3F}, {0x1F, 0x37, 0x3F}, {0x1F, 0x2F, 0x3F}, {0x1F,
323 0x27,
324 0x3F},
325 /* Index 0x50~0x53 */
326 {0x2D, 0x2D, 0x3F}, {0x31, 0x2D, 0x3F}, {0x36, 0x2D, 0x3F}, {0x3A,
327 0x2D,
328 0x3F},
329 /* Index 0x54~0x57 */
330 {0x3F, 0x2D, 0x3F}, {0x3F, 0x2D, 0x3A}, {0x3F, 0x2D, 0x36}, {0x3F,
331 0x2D,
332 0x31},
333 /* Index 0x58~0x5B */
334 {0x3F, 0x2D, 0x2D}, {0x3F, 0x31, 0x2D}, {0x3F, 0x36, 0x2D}, {0x3F,
335 0x3A,
336 0x2D},
337 /* Index 0x5C~0x5F */
338 {0x3F, 0x3F, 0x2D}, {0x3A, 0x3F, 0x2D}, {0x36, 0x3F, 0x2D}, {0x31,
339 0x3F,
340 0x2D},
341 /* Index 0x60~0x63 */
342 {0x2D, 0x3F, 0x2D}, {0x2D, 0x3F, 0x31}, {0x2D, 0x3F, 0x36}, {0x2D,
343 0x3F,
344 0x3A},
345 /* Index 0x64~0x67 */
346 {0x2D, 0x3F, 0x3F}, {0x2D, 0x3A, 0x3F}, {0x2D, 0x36, 0x3F}, {0x2D,
347 0x31,
348 0x3F},
349 /* Index 0x68~0x6B */
350 {0x00, 0x00, 0x1C}, {0x07, 0x00, 0x1C}, {0x0E, 0x00, 0x1C}, {0x15,
351 0x00,
352 0x1C},
353 /* Index 0x6C~0x6F */
354 {0x1C, 0x00, 0x1C}, {0x1C, 0x00, 0x15}, {0x1C, 0x00, 0x0E}, {0x1C,
355 0x00,
356 0x07},
357 /* Index 0x70~0x73 */
358 {0x1C, 0x00, 0x00}, {0x1C, 0x07, 0x00}, {0x1C, 0x0E, 0x00}, {0x1C,
359 0x15,
360 0x00},
361 /* Index 0x74~0x77 */
362 {0x1C, 0x1C, 0x00}, {0x15, 0x1C, 0x00}, {0x0E, 0x1C, 0x00}, {0x07,
363 0x1C,
364 0x00},
365 /* Index 0x78~0x7B */
366 {0x00, 0x1C, 0x00}, {0x00, 0x1C, 0x07}, {0x00, 0x1C, 0x0E}, {0x00,
367 0x1C,
368 0x15},
369 /* Index 0x7C~0x7F */
370 {0x00, 0x1C, 0x1C}, {0x00, 0x15, 0x1C}, {0x00, 0x0E, 0x1C}, {0x00,
371 0x07,
372 0x1C},
373 /* Index 0x80~0x83 */
374 {0x0E, 0x0E, 0x1C}, {0x11, 0x0E, 0x1C}, {0x15, 0x0E, 0x1C}, {0x18,
375 0x0E,
376 0x1C},
377 /* Index 0x84~0x87 */
378 {0x1C, 0x0E, 0x1C}, {0x1C, 0x0E, 0x18}, {0x1C, 0x0E, 0x15}, {0x1C,
379 0x0E,
380 0x11},
381 /* Index 0x88~0x8B */
382 {0x1C, 0x0E, 0x0E}, {0x1C, 0x11, 0x0E}, {0x1C, 0x15, 0x0E}, {0x1C,
383 0x18,
384 0x0E},
385 /* Index 0x8C~0x8F */
386 {0x1C, 0x1C, 0x0E}, {0x18, 0x1C, 0x0E}, {0x15, 0x1C, 0x0E}, {0x11,
387 0x1C,
388 0x0E},
389 /* Index 0x90~0x93 */
390 {0x0E, 0x1C, 0x0E}, {0x0E, 0x1C, 0x11}, {0x0E, 0x1C, 0x15}, {0x0E,
391 0x1C,
392 0x18},
393 /* Index 0x94~0x97 */
394 {0x0E, 0x1C, 0x1C}, {0x0E, 0x18, 0x1C}, {0x0E, 0x15, 0x1C}, {0x0E,
395 0x11,
396 0x1C},
397 /* Index 0x98~0x9B */
398 {0x14, 0x14, 0x1C}, {0x16, 0x14, 0x1C}, {0x18, 0x14, 0x1C}, {0x1A,
399 0x14,
400 0x1C},
401 /* Index 0x9C~0x9F */
402 {0x1C, 0x14, 0x1C}, {0x1C, 0x14, 0x1A}, {0x1C, 0x14, 0x18}, {0x1C,
403 0x14,
404 0x16},
405 /* Index 0xA0~0xA3 */
406 {0x1C, 0x14, 0x14}, {0x1C, 0x16, 0x14}, {0x1C, 0x18, 0x14}, {0x1C,
407 0x1A,
408 0x14},
409 /* Index 0xA4~0xA7 */
410 {0x1C, 0x1C, 0x14}, {0x1A, 0x1C, 0x14}, {0x18, 0x1C, 0x14}, {0x16,
411 0x1C,
412 0x14},
413 /* Index 0xA8~0xAB */
414 {0x14, 0x1C, 0x14}, {0x14, 0x1C, 0x16}, {0x14, 0x1C, 0x18}, {0x14,
415 0x1C,
416 0x1A},
417 /* Index 0xAC~0xAF */
418 {0x14, 0x1C, 0x1C}, {0x14, 0x1A, 0x1C}, {0x14, 0x18, 0x1C}, {0x14,
419 0x16,
420 0x1C},
421 /* Index 0xB0~0xB3 */
422 {0x00, 0x00, 0x10}, {0x04, 0x00, 0x10}, {0x08, 0x00, 0x10}, {0x0C,
423 0x00,
424 0x10},
425 /* Index 0xB4~0xB7 */
426 {0x10, 0x00, 0x10}, {0x10, 0x00, 0x0C}, {0x10, 0x00, 0x08}, {0x10,
427 0x00,
428 0x04},
429 /* Index 0xB8~0xBB */
430 {0x10, 0x00, 0x00}, {0x10, 0x04, 0x00}, {0x10, 0x08, 0x00}, {0x10,
431 0x0C,
432 0x00},
433 /* Index 0xBC~0xBF */
434 {0x10, 0x10, 0x00}, {0x0C, 0x10, 0x00}, {0x08, 0x10, 0x00}, {0x04,
435 0x10,
436 0x00},
437 /* Index 0xC0~0xC3 */
438 {0x00, 0x10, 0x00}, {0x00, 0x10, 0x04}, {0x00, 0x10, 0x08}, {0x00,
439 0x10,
440 0x0C},
441 /* Index 0xC4~0xC7 */
442 {0x00, 0x10, 0x10}, {0x00, 0x0C, 0x10}, {0x00, 0x08, 0x10}, {0x00,
443 0x04,
444 0x10},
445 /* Index 0xC8~0xCB */
446 {0x08, 0x08, 0x10}, {0x0A, 0x08, 0x10}, {0x0C, 0x08, 0x10}, {0x0E,
447 0x08,
448 0x10},
449 /* Index 0xCC~0xCF */
450 {0x10, 0x08, 0x10}, {0x10, 0x08, 0x0E}, {0x10, 0x08, 0x0C}, {0x10,
451 0x08,
452 0x0A},
453 /* Index 0xD0~0xD3 */
454 {0x10, 0x08, 0x08}, {0x10, 0x0A, 0x08}, {0x10, 0x0C, 0x08}, {0x10,
455 0x0E,
456 0x08},
457 /* Index 0xD4~0xD7 */
458 {0x10, 0x10, 0x08}, {0x0E, 0x10, 0x08}, {0x0C, 0x10, 0x08}, {0x0A,
459 0x10,
460 0x08},
461 /* Index 0xD8~0xDB */
462 {0x08, 0x10, 0x08}, {0x08, 0x10, 0x0A}, {0x08, 0x10, 0x0C}, {0x08,
463 0x10,
464 0x0E},
465 /* Index 0xDC~0xDF */
466 {0x08, 0x10, 0x10}, {0x08, 0x0E, 0x10}, {0x08, 0x0C, 0x10}, {0x08,
467 0x0A,
468 0x10},
469 /* Index 0xE0~0xE3 */
470 {0x0B, 0x0B, 0x10}, {0x0C, 0x0B, 0x10}, {0x0D, 0x0B, 0x10}, {0x0F,
471 0x0B,
472 0x10},
473 /* Index 0xE4~0xE7 */
474 {0x10, 0x0B, 0x10}, {0x10, 0x0B, 0x0F}, {0x10, 0x0B, 0x0D}, {0x10,
475 0x0B,
476 0x0C},
477 /* Index 0xE8~0xEB */
478 {0x10, 0x0B, 0x0B}, {0x10, 0x0C, 0x0B}, {0x10, 0x0D, 0x0B}, {0x10,
479 0x0F,
480 0x0B},
481 /* Index 0xEC~0xEF */
482 {0x10, 0x10, 0x0B}, {0x0F, 0x10, 0x0B}, {0x0D, 0x10, 0x0B}, {0x0C,
483 0x10,
484 0x0B},
485 /* Index 0xF0~0xF3 */
486 {0x0B, 0x10, 0x0B}, {0x0B, 0x10, 0x0C}, {0x0B, 0x10, 0x0D}, {0x0B,
487 0x10,
488 0x0F},
489 /* Index 0xF4~0xF7 */
490 {0x0B, 0x10, 0x10}, {0x0B, 0x0F, 0x10}, {0x0B, 0x0D, 0x10}, {0x0B,
491 0x0C,
492 0x10},
493 /* Index 0xF8~0xFB */
494 {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00,
495 0x00,
496 0x00},
497 /* Index 0xFC~0xFF */
498 {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00,
499 0x00,
500 0x00}
501};
502
503static void set_crt_output_path(int set_iga);
504static void dvi_patch_skew_dvp0(void);
505static void dvi_patch_skew_dvp1(void);
506static void dvi_patch_skew_dvp_low(void);
507static void set_dvi_output_path(int set_iga, int output_interface);
508static void set_lcd_output_path(int set_iga, int output_interface);
509static int search_mode_setting(int ModeInfoIndex);
510static void load_fix_bit_crtc_reg(void);
511static void init_gfx_chip_info(void);
512static void init_tmds_chip_info(void);
513static void init_lvds_chip_info(void);
514static void device_screen_off(void);
515static void device_screen_on(void);
516static void set_display_channel(void);
517static void device_off(void);
518static void device_on(void);
519static void enable_second_display_channel(void);
520static void disable_second_display_channel(void);
521static int get_fb_size_from_pci(void);
522
523void viafb_write_reg(u8 index, u16 io_port, u8 data)
524{
525 outb(index, io_port);
526 outb(data, io_port + 1);
527 /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, data); */
528}
529u8 viafb_read_reg(int io_port, u8 index)
530{
531 outb(index, io_port);
532 return inb(io_port + 1);
533}
534
535void viafb_lock_crt(void)
536{
537 viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7);
538}
539
540void viafb_unlock_crt(void)
541{
542 viafb_write_reg_mask(CR11, VIACR, 0, BIT7);
543 viafb_write_reg_mask(CR47, VIACR, 0, BIT0);
544}
545
546void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask)
547{
548 u8 tmp;
549
550 outb(index, io_port);
551 tmp = inb(io_port + 1);
552 outb((data & mask) | (tmp & (~mask)), io_port + 1);
553 /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, tmp); */
554}
555
556void write_dac_reg(u8 index, u8 r, u8 g, u8 b)
557{
558 outb(index, LUT_INDEX_WRITE);
559 outb(r, LUT_DATA);
560 outb(g, LUT_DATA);
561 outb(b, LUT_DATA);
562}
563
564/*Set IGA path for each device*/
565void viafb_set_iga_path(void)
566{
567
568 if (viafb_SAMM_ON == 1) {
569 if (viafb_CRT_ON) {
570 if (viafb_primary_dev == CRT_Device)
571 viaparinfo->crt_setting_info->iga_path = IGA1;
572 else
573 viaparinfo->crt_setting_info->iga_path = IGA2;
574 }
575
576 if (viafb_DVI_ON) {
577 if (viafb_primary_dev == DVI_Device)
578 viaparinfo->tmds_setting_info->iga_path = IGA1;
579 else
580 viaparinfo->tmds_setting_info->iga_path = IGA2;
581 }
582
583 if (viafb_LCD_ON) {
584 if (viafb_primary_dev == LCD_Device) {
585 if (viafb_dual_fb &&
586 (viaparinfo->chip_info->gfx_chip_name ==
587 UNICHROME_CLE266)) {
588 viaparinfo->
589 lvds_setting_info->iga_path = IGA2;
590 viaparinfo->
591 crt_setting_info->iga_path = IGA1;
592 viaparinfo->
593 tmds_setting_info->iga_path = IGA1;
594 } else
595 viaparinfo->
596 lvds_setting_info->iga_path = IGA1;
597 } else {
598 viaparinfo->lvds_setting_info->iga_path = IGA2;
599 }
600 }
601 if (viafb_LCD2_ON) {
602 if (LCD2_Device == viafb_primary_dev)
603 viaparinfo->lvds_setting_info2->iga_path = IGA1;
604 else
605 viaparinfo->lvds_setting_info2->iga_path = IGA2;
606 }
607 } else {
608 viafb_SAMM_ON = 0;
609
610 if (viafb_CRT_ON && viafb_LCD_ON) {
611 viaparinfo->crt_setting_info->iga_path = IGA1;
612 viaparinfo->lvds_setting_info->iga_path = IGA2;
613 } else if (viafb_CRT_ON && viafb_DVI_ON) {
614 viaparinfo->crt_setting_info->iga_path = IGA1;
615 viaparinfo->tmds_setting_info->iga_path = IGA2;
616 } else if (viafb_LCD_ON && viafb_DVI_ON) {
617 viaparinfo->tmds_setting_info->iga_path = IGA1;
618 viaparinfo->lvds_setting_info->iga_path = IGA2;
619 } else if (viafb_LCD_ON && viafb_LCD2_ON) {
620 viaparinfo->lvds_setting_info->iga_path = IGA2;
621 viaparinfo->lvds_setting_info2->iga_path = IGA2;
622 } else if (viafb_CRT_ON) {
623 viaparinfo->crt_setting_info->iga_path = IGA1;
624 } else if (viafb_LCD_ON) {
625 viaparinfo->lvds_setting_info->iga_path = IGA2;
626 } else if (viafb_DVI_ON) {
627 viaparinfo->tmds_setting_info->iga_path = IGA1;
628 }
629 }
630}
631
632void viafb_set_start_addr(void)
633{
634 unsigned long offset = 0, tmp = 0, size = 0;
635 unsigned long length;
636
637 DEBUG_MSG(KERN_INFO "viafb_set_start_addr!\n");
638 viafb_unlock_crt();
639 /* update starting address of IGA1 */
640 viafb_write_reg(CR0C, VIACR, 0x00); /*initial starting address */
641 viafb_write_reg(CR0D, VIACR, 0x00);
642 viafb_write_reg(CR34, VIACR, 0x00);
643 viafb_write_reg_mask(CR48, VIACR, 0x00, 0x1F);
644
645 if (viafb_dual_fb) {
646 viaparinfo->iga_path = IGA1;
647 viaparinfo1->iga_path = IGA2;
648 }
649
650 if (viafb_SAMM_ON == 1) {
651 if (!viafb_dual_fb) {
652 if (viafb_second_size)
653 size = viafb_second_size * 1024 * 1024;
654 else
655 size = 8 * 1024 * 1024;
656 } else {
657
658 size = viaparinfo1->memsize;
659 }
660 offset = viafb_second_offset;
661 DEBUG_MSG(KERN_INFO
662 "viafb_second_size=%lx, second start_adddress=%lx\n",
663 size, offset);
664 }
665 if (viafb_SAMM_ON == 1) {
666 offset = offset >> 3;
667
668 tmp = viafb_read_reg(VIACR, 0x62) & 0x01;
669 tmp |= (offset & 0x7F) << 1;
670 viafb_write_reg(CR62, VIACR, tmp);
671 viafb_write_reg(CR63, VIACR, ((offset & 0x7F80) >> 7));
672 viafb_write_reg(CR64, VIACR, ((offset & 0x7F8000) >> 15));
673 viafb_write_reg(CRA3, VIACR, ((offset & 0x3800000) >> 23));
674 } else {
675 /* update starting address */
676 viafb_write_reg(CR62, VIACR, 0x00);
677 viafb_write_reg(CR63, VIACR, 0x00);
678 viafb_write_reg(CR64, VIACR, 0x00);
679 viafb_write_reg(CRA3, VIACR, 0x00);
680 }
681
682 if (viafb_SAMM_ON == 1) {
683 if (viafb_accel) {
684 if (!viafb_dual_fb)
685 length = size - viaparinfo->fbmem_used;
686 else
687 length = size - viaparinfo1->fbmem_used;
688 } else
689 length = size;
690 offset = (unsigned long)(void *)viafb_FB_MM +
691 viafb_second_offset;
692 memset((void *)offset, 0, length);
693 }
694
695 viafb_lock_crt();
696}
697
698void viafb_set_output_path(int device, int set_iga, int output_interface)
699{
700 switch (device) {
701 case DEVICE_CRT:
702 set_crt_output_path(set_iga);
703 break;
704 case DEVICE_DVI:
705 set_dvi_output_path(set_iga, output_interface);
706 break;
707 case DEVICE_LCD:
708 set_lcd_output_path(set_iga, output_interface);
709 break;
710 }
711}
712
713static void set_crt_output_path(int set_iga)
714{
715 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
716
717 switch (set_iga) {
718 case IGA1:
719 viafb_write_reg_mask(SR16, VIASR, 0x00, BIT6);
720 break;
721 case IGA2:
722 case IGA1_IGA2:
723 viafb_write_reg_mask(CR6A, VIACR, 0xC0, BIT6 + BIT7);
724 viafb_write_reg_mask(SR16, VIASR, 0x40, BIT6);
725 if (set_iga == IGA1_IGA2)
726 viafb_write_reg_mask(CR6B, VIACR, 0x08, BIT3);
727 break;
728 }
729}
730
731static void dvi_patch_skew_dvp0(void)
732{
733 /* Reset data driving first: */
734 viafb_write_reg_mask(SR1B, VIASR, 0, BIT1);
735 viafb_write_reg_mask(SR2A, VIASR, 0, BIT4);
736
737 switch (viaparinfo->chip_info->gfx_chip_name) {
738 case UNICHROME_P4M890:
739 {
740 if ((viaparinfo->tmds_setting_info->h_active == 1600) &&
741 (viaparinfo->tmds_setting_info->v_active ==
742 1200))
743 viafb_write_reg_mask(CR96, VIACR, 0x03,
744 BIT0 + BIT1 + BIT2);
745 else
746 viafb_write_reg_mask(CR96, VIACR, 0x07,
747 BIT0 + BIT1 + BIT2);
748 break;
749 }
750
751 case UNICHROME_P4M900:
752 {
753 viafb_write_reg_mask(CR96, VIACR, 0x07,
754 BIT0 + BIT1 + BIT2 + BIT3);
755 viafb_write_reg_mask(SR1B, VIASR, 0x02, BIT1);
756 viafb_write_reg_mask(SR2A, VIASR, 0x10, BIT4);
757 break;
758 }
759
760 default:
761 {
762 break;
763 }
764 }
765}
766
767static void dvi_patch_skew_dvp1(void)
768{
769 switch (viaparinfo->chip_info->gfx_chip_name) {
770 case UNICHROME_CX700:
771 {
772 break;
773 }
774
775 default:
776 {
777 break;
778 }
779 }
780}
781
782static void dvi_patch_skew_dvp_low(void)
783{
784 switch (viaparinfo->chip_info->gfx_chip_name) {
785 case UNICHROME_K8M890:
786 {
787 viafb_write_reg_mask(CR99, VIACR, 0x03, BIT0 + BIT1);
788 break;
789 }
790
791 case UNICHROME_P4M900:
792 {
793 viafb_write_reg_mask(CR99, VIACR, 0x08,
794 BIT0 + BIT1 + BIT2 + BIT3);
795 break;
796 }
797
798 case UNICHROME_P4M890:
799 {
800 viafb_write_reg_mask(CR99, VIACR, 0x0F,
801 BIT0 + BIT1 + BIT2 + BIT3);
802 break;
803 }
804
805 default:
806 {
807 break;
808 }
809 }
810}
811
812static void set_dvi_output_path(int set_iga, int output_interface)
813{
814 switch (output_interface) {
815 case INTERFACE_DVP0:
816 viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0);
817
818 if (set_iga == IGA1) {
819 viafb_write_reg_mask(CR96, VIACR, 0x00, BIT4);
820 viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 +
821 BIT5 + BIT7);
822 } else {
823 viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4);
824 viafb_write_reg_mask(CR6C, VIACR, 0xA1, BIT0 +
825 BIT5 + BIT7);
826 }
827
828 viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT7 + BIT6);
829
830 dvi_patch_skew_dvp0();
831 break;
832
833 case INTERFACE_DVP1:
834 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
835 if (set_iga == IGA1)
836 viafb_write_reg_mask(CR93, VIACR, 0x21,
837 BIT0 + BIT5 + BIT7);
838 else
839 viafb_write_reg_mask(CR93, VIACR, 0xA1,
840 BIT0 + BIT5 + BIT7);
841 } else {
842 if (set_iga == IGA1)
843 viafb_write_reg_mask(CR9B, VIACR, 0x00, BIT4);
844 else
845 viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4);
846 }
847
848 viafb_write_reg_mask(SR1E, VIASR, 0x30, BIT4 + BIT5);
849 dvi_patch_skew_dvp1();
850 break;
851 case INTERFACE_DFP_HIGH:
852 if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) {
853 if (set_iga == IGA1) {
854 viafb_write_reg_mask(CR96, VIACR, 0x00, BIT4);
855 viafb_write_reg_mask(CR97, VIACR, 0x03,
856 BIT0 + BIT1 + BIT4);
857 } else {
858 viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4);
859 viafb_write_reg_mask(CR97, VIACR, 0x13,
860 BIT0 + BIT1 + BIT4);
861 }
862 }
863 viafb_write_reg_mask(SR2A, VIASR, 0x0C, BIT2 + BIT3);
864 break;
865
866 case INTERFACE_DFP_LOW:
867 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
868 break;
869
870 if (set_iga == IGA1) {
871 viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4);
872 viafb_write_reg_mask(CR9B, VIACR, 0x00, BIT4);
873 } else {
874 viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4);
875 viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4);
876 }
877
878 viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
879 dvi_patch_skew_dvp_low();
880 break;
881
882 case INTERFACE_TMDS:
883 if (set_iga == IGA1)
884 viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4);
885 else
886 viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4);
887 break;
888 }
889
890 if (set_iga == IGA2) {
891 enable_second_display_channel();
892 /* Disable LCD Scaling */
893 viafb_write_reg_mask(CR79, VIACR, 0x00, BIT0);
894 }
895}
896
897static void set_lcd_output_path(int set_iga, int output_interface)
898{
899 DEBUG_MSG(KERN_INFO
900 "set_lcd_output_path, iga:%d,out_interface:%d\n",
901 set_iga, output_interface);
902 switch (set_iga) {
903 case IGA1:
904 viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3);
905 viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
906
907 disable_second_display_channel();
908 break;
909
910 case IGA2:
911 viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3);
912 viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
913
914 enable_second_display_channel();
915 break;
916
917 case IGA1_IGA2:
918 viafb_write_reg_mask(CR6B, VIACR, 0x08, BIT3);
919 viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
920
921 disable_second_display_channel();
922 break;
923 }
924
925 switch (output_interface) {
926 case INTERFACE_DVP0:
927 if (set_iga == IGA1) {
928 viafb_write_reg_mask(CR96, VIACR, 0x00, BIT4);
929 } else {
930 viafb_write_reg(CR91, VIACR, 0x00);
931 viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4);
932 }
933 break;
934
935 case INTERFACE_DVP1:
936 if (set_iga == IGA1)
937 viafb_write_reg_mask(CR9B, VIACR, 0x00, BIT4);
938 else {
939 viafb_write_reg(CR91, VIACR, 0x00);
940 viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4);
941 }
942 break;
943
944 case INTERFACE_DFP_HIGH:
945 if (set_iga == IGA1)
946 viafb_write_reg_mask(CR97, VIACR, 0x00, BIT4);
947 else {
948 viafb_write_reg(CR91, VIACR, 0x00);
949 viafb_write_reg_mask(CR97, VIACR, 0x10, BIT4);
950 viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4);
951 }
952 break;
953
954 case INTERFACE_DFP_LOW:
955 if (set_iga == IGA1)
956 viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4);
957 else {
958 viafb_write_reg(CR91, VIACR, 0x00);
959 viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4);
960 viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4);
961 }
962
963 break;
964
965 case INTERFACE_DFP:
966 if ((UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)
967 || (UNICHROME_P4M890 ==
968 viaparinfo->chip_info->gfx_chip_name))
969 viafb_write_reg_mask(CR97, VIACR, 0x84,
970 BIT7 + BIT2 + BIT1 + BIT0);
971 if (set_iga == IGA1) {
972 viafb_write_reg_mask(CR97, VIACR, 0x00, BIT4);
973 viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4);
974 } else {
975 viafb_write_reg(CR91, VIACR, 0x00);
976 viafb_write_reg_mask(CR97, VIACR, 0x10, BIT4);
977 viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4);
978 }
979 break;
980
981 case INTERFACE_LVDS0:
982 case INTERFACE_LVDS0LVDS1:
983 if (set_iga == IGA1)
984 viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4);
985 else
986 viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4);
987
988 break;
989
990 case INTERFACE_LVDS1:
991 if (set_iga == IGA1)
992 viafb_write_reg_mask(CR97, VIACR, 0x00, BIT4);
993 else
994 viafb_write_reg_mask(CR97, VIACR, 0x10, BIT4);
995 break;
996 }
997}
998
999/* Search Mode Index */
1000static int search_mode_setting(int ModeInfoIndex)
1001{
1002 int i = 0;
1003
1004 while ((i < NUM_TOTAL_MODETABLE) &&
1005 (ModeInfoIndex != CLE266Modes[i].ModeIndex))
1006 i++;
1007 if (i >= NUM_TOTAL_MODETABLE)
1008 i = 0;
1009 return i;
1010
1011}
1012
1013struct VideoModeTable *viafb_get_modetbl_pointer(int Index)
1014{
1015 struct VideoModeTable *TmpTbl = NULL;
1016 TmpTbl = &CLE266Modes[search_mode_setting(Index)];
1017 return TmpTbl;
1018}
1019
1020struct VideoModeTable *viafb_get_cea_mode_tbl_pointer(int Index)
1021{
1022 struct VideoModeTable *TmpTbl = NULL;
1023 int i = 0;
1024 while ((i < NUM_TOTAL_CEA_MODES) &&
1025 (Index != CEA_HDMI_Modes[i].ModeIndex))
1026 i++;
1027 if ((i < NUM_TOTAL_CEA_MODES))
1028 TmpTbl = &CEA_HDMI_Modes[i];
1029 else {
1030 /*Still use general timing if don't find CEA timing */
1031 i = 0;
1032 while ((i < NUM_TOTAL_MODETABLE) &&
1033 (Index != CLE266Modes[i].ModeIndex))
1034 i++;
1035 if (i >= NUM_TOTAL_MODETABLE)
1036 i = 0;
1037 TmpTbl = &CLE266Modes[i];
1038 }
1039 return TmpTbl;
1040}
1041
1042static void load_fix_bit_crtc_reg(void)
1043{
1044 /* always set to 1 */
1045 viafb_write_reg_mask(CR03, VIACR, 0x80, BIT7);
1046 /* line compare should set all bits = 1 (extend modes) */
1047 viafb_write_reg(CR18, VIACR, 0xff);
1048 /* line compare should set all bits = 1 (extend modes) */
1049 viafb_write_reg_mask(CR07, VIACR, 0x10, BIT4);
1050 /* line compare should set all bits = 1 (extend modes) */
1051 viafb_write_reg_mask(CR09, VIACR, 0x40, BIT6);
1052 /* line compare should set all bits = 1 (extend modes) */
1053 viafb_write_reg_mask(CR35, VIACR, 0x10, BIT4);
1054 /* line compare should set all bits = 1 (extend modes) */
1055 viafb_write_reg_mask(CR33, VIACR, 0x06, BIT0 + BIT1 + BIT2);
1056 /*viafb_write_reg_mask(CR32, VIACR, 0x01, BIT0); */
1057 /* extend mode always set to e3h */
1058 viafb_write_reg(CR17, VIACR, 0xe3);
1059 /* extend mode always set to 0h */
1060 viafb_write_reg(CR08, VIACR, 0x00);
1061 /* extend mode always set to 0h */
1062 viafb_write_reg(CR14, VIACR, 0x00);
1063
1064 /* If K8M800, enable Prefetch Mode. */
1065 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800)
1066 || (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K8M890))
1067 viafb_write_reg_mask(CR33, VIACR, 0x08, BIT3);
1068 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
1069 && (viaparinfo->chip_info->gfx_chip_revision == CLE266_REVISION_AX))
1070 viafb_write_reg_mask(SR1A, VIASR, 0x02, BIT1);
1071
1072}
1073
1074void viafb_load_reg(int timing_value, int viafb_load_reg_num,
1075 struct io_register *reg,
1076 int io_type)
1077{
1078 int reg_mask;
1079 int bit_num = 0;
1080 int data;
1081 int i, j;
1082 int shift_next_reg;
1083 int start_index, end_index, cr_index;
1084 u16 get_bit;
1085
1086 for (i = 0; i < viafb_load_reg_num; i++) {
1087 reg_mask = 0;
1088 data = 0;
1089 start_index = reg[i].start_bit;
1090 end_index = reg[i].end_bit;
1091 cr_index = reg[i].io_addr;
1092
1093 shift_next_reg = bit_num;
1094 for (j = start_index; j <= end_index; j++) {
1095 /*if (bit_num==8) timing_value = timing_value >>8; */
1096 reg_mask = reg_mask | (BIT0 << j);
1097 get_bit = (timing_value & (BIT0 << bit_num));
1098 data =
1099 data | ((get_bit >> shift_next_reg) << start_index);
1100 bit_num++;
1101 }
1102 if (io_type == VIACR)
1103 viafb_write_reg_mask(cr_index, VIACR, data, reg_mask);
1104 else
1105 viafb_write_reg_mask(cr_index, VIASR, data, reg_mask);
1106 }
1107
1108}
1109
1110/* Write Registers */
1111void viafb_write_regx(struct io_reg RegTable[], int ItemNum)
1112{
1113 int i;
1114 unsigned char RegTemp;
1115
1116 /*DEBUG_MSG(KERN_INFO "Table Size : %x!!\n",ItemNum ); */
1117
1118 for (i = 0; i < ItemNum; i++) {
1119 outb(RegTable[i].index, RegTable[i].port);
1120 RegTemp = inb(RegTable[i].port + 1);
1121 RegTemp = (RegTemp & (~RegTable[i].mask)) | RegTable[i].value;
1122 outb(RegTemp, RegTable[i].port + 1);
1123 }
1124}
1125
1126void viafb_load_offset_reg(int h_addr, int bpp_byte, int set_iga)
1127{
1128 int reg_value;
1129 int viafb_load_reg_num;
1130 struct io_register *reg;
1131
1132 switch (set_iga) {
1133 case IGA1_IGA2:
1134 case IGA1:
1135 reg_value = IGA1_OFFSET_FORMULA(h_addr, bpp_byte);
1136 viafb_load_reg_num = offset_reg.iga1_offset_reg.reg_num;
1137 reg = offset_reg.iga1_offset_reg.reg;
1138 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1139 if (set_iga == IGA1)
1140 break;
1141 case IGA2:
1142 reg_value = IGA2_OFFSET_FORMULA(h_addr, bpp_byte);
1143 viafb_load_reg_num = offset_reg.iga2_offset_reg.reg_num;
1144 reg = offset_reg.iga2_offset_reg.reg;
1145 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1146 break;
1147 }
1148}
1149
1150void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga)
1151{
1152 int reg_value;
1153 int viafb_load_reg_num;
1154 struct io_register *reg = NULL;
1155
1156 switch (set_iga) {
1157 case IGA1_IGA2:
1158 case IGA1:
1159 reg_value = IGA1_FETCH_COUNT_FORMULA(h_addr, bpp_byte);
1160 viafb_load_reg_num = fetch_count_reg.
1161 iga1_fetch_count_reg.reg_num;
1162 reg = fetch_count_reg.iga1_fetch_count_reg.reg;
1163 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR);
1164 if (set_iga == IGA1)
1165 break;
1166 case IGA2:
1167 reg_value = IGA2_FETCH_COUNT_FORMULA(h_addr, bpp_byte);
1168 viafb_load_reg_num = fetch_count_reg.
1169 iga2_fetch_count_reg.reg_num;
1170 reg = fetch_count_reg.iga2_fetch_count_reg.reg;
1171 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1172 break;
1173 }
1174
1175}
1176
1177void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active)
1178{
1179 int reg_value;
1180 int viafb_load_reg_num;
1181 struct io_register *reg = NULL;
1182 int iga1_fifo_max_depth = 0, iga1_fifo_threshold =
1183 0, iga1_fifo_high_threshold = 0, iga1_display_queue_expire_num = 0;
1184 int iga2_fifo_max_depth = 0, iga2_fifo_threshold =
1185 0, iga2_fifo_high_threshold = 0, iga2_display_queue_expire_num = 0;
1186
1187 if (set_iga == IGA1) {
1188 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) {
1189 iga1_fifo_max_depth = K800_IGA1_FIFO_MAX_DEPTH;
1190 iga1_fifo_threshold = K800_IGA1_FIFO_THRESHOLD;
1191 iga1_fifo_high_threshold =
1192 K800_IGA1_FIFO_HIGH_THRESHOLD;
1193 /* If resolution > 1280x1024, expire length = 64, else
1194 expire length = 128 */
1195 if ((hor_active > 1280) && (ver_active > 1024))
1196 iga1_display_queue_expire_num = 16;
1197 else
1198 iga1_display_queue_expire_num =
1199 K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1200
1201 }
1202
1203 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_PM800) {
1204 iga1_fifo_max_depth = P880_IGA1_FIFO_MAX_DEPTH;
1205 iga1_fifo_threshold = P880_IGA1_FIFO_THRESHOLD;
1206 iga1_fifo_high_threshold =
1207 P880_IGA1_FIFO_HIGH_THRESHOLD;
1208 iga1_display_queue_expire_num =
1209 P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1210
1211 /* If resolution > 1280x1024, expire length = 64, else
1212 expire length = 128 */
1213 if ((hor_active > 1280) && (ver_active > 1024))
1214 iga1_display_queue_expire_num = 16;
1215 else
1216 iga1_display_queue_expire_num =
1217 P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1218 }
1219
1220 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CN700) {
1221 iga1_fifo_max_depth = CN700_IGA1_FIFO_MAX_DEPTH;
1222 iga1_fifo_threshold = CN700_IGA1_FIFO_THRESHOLD;
1223 iga1_fifo_high_threshold =
1224 CN700_IGA1_FIFO_HIGH_THRESHOLD;
1225
1226 /* If resolution > 1280x1024, expire length = 64,
1227 else expire length = 128 */
1228 if ((hor_active > 1280) && (ver_active > 1024))
1229 iga1_display_queue_expire_num = 16;
1230 else
1231 iga1_display_queue_expire_num =
1232 CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1233 }
1234
1235 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) {
1236 iga1_fifo_max_depth = CX700_IGA1_FIFO_MAX_DEPTH;
1237 iga1_fifo_threshold = CX700_IGA1_FIFO_THRESHOLD;
1238 iga1_fifo_high_threshold =
1239 CX700_IGA1_FIFO_HIGH_THRESHOLD;
1240 iga1_display_queue_expire_num =
1241 CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1242 }
1243
1244 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K8M890) {
1245 iga1_fifo_max_depth = K8M890_IGA1_FIFO_MAX_DEPTH;
1246 iga1_fifo_threshold = K8M890_IGA1_FIFO_THRESHOLD;
1247 iga1_fifo_high_threshold =
1248 K8M890_IGA1_FIFO_HIGH_THRESHOLD;
1249 iga1_display_queue_expire_num =
1250 K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1251 }
1252
1253 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M890) {
1254 iga1_fifo_max_depth = P4M890_IGA1_FIFO_MAX_DEPTH;
1255 iga1_fifo_threshold = P4M890_IGA1_FIFO_THRESHOLD;
1256 iga1_fifo_high_threshold =
1257 P4M890_IGA1_FIFO_HIGH_THRESHOLD;
1258 iga1_display_queue_expire_num =
1259 P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1260 }
1261
1262 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M900) {
1263 iga1_fifo_max_depth = P4M900_IGA1_FIFO_MAX_DEPTH;
1264 iga1_fifo_threshold = P4M900_IGA1_FIFO_THRESHOLD;
1265 iga1_fifo_high_threshold =
1266 P4M900_IGA1_FIFO_HIGH_THRESHOLD;
1267 iga1_display_queue_expire_num =
1268 P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1269 }
1270
1271 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX800) {
1272 iga1_fifo_max_depth = VX800_IGA1_FIFO_MAX_DEPTH;
1273 iga1_fifo_threshold = VX800_IGA1_FIFO_THRESHOLD;
1274 iga1_fifo_high_threshold =
1275 VX800_IGA1_FIFO_HIGH_THRESHOLD;
1276 iga1_display_queue_expire_num =
1277 VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM;
1278 }
1279
1280 /* Set Display FIFO Depath Select */
1281 reg_value = IGA1_FIFO_DEPTH_SELECT_FORMULA(iga1_fifo_max_depth);
1282 viafb_load_reg_num =
1283 display_fifo_depth_reg.iga1_fifo_depth_select_reg.reg_num;
1284 reg = display_fifo_depth_reg.iga1_fifo_depth_select_reg.reg;
1285 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR);
1286
1287 /* Set Display FIFO Threshold Select */
1288 reg_value = IGA1_FIFO_THRESHOLD_FORMULA(iga1_fifo_threshold);
1289 viafb_load_reg_num =
1290 fifo_threshold_select_reg.
1291 iga1_fifo_threshold_select_reg.reg_num;
1292 reg =
1293 fifo_threshold_select_reg.
1294 iga1_fifo_threshold_select_reg.reg;
1295 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR);
1296
1297 /* Set FIFO High Threshold Select */
1298 reg_value =
1299 IGA1_FIFO_HIGH_THRESHOLD_FORMULA(iga1_fifo_high_threshold);
1300 viafb_load_reg_num =
1301 fifo_high_threshold_select_reg.
1302 iga1_fifo_high_threshold_select_reg.reg_num;
1303 reg =
1304 fifo_high_threshold_select_reg.
1305 iga1_fifo_high_threshold_select_reg.reg;
1306 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR);
1307
1308 /* Set Display Queue Expire Num */
1309 reg_value =
1310 IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA
1311 (iga1_display_queue_expire_num);
1312 viafb_load_reg_num =
1313 display_queue_expire_num_reg.
1314 iga1_display_queue_expire_num_reg.reg_num;
1315 reg =
1316 display_queue_expire_num_reg.
1317 iga1_display_queue_expire_num_reg.reg;
1318 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR);
1319
1320 } else {
1321 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) {
1322 iga2_fifo_max_depth = K800_IGA2_FIFO_MAX_DEPTH;
1323 iga2_fifo_threshold = K800_IGA2_FIFO_THRESHOLD;
1324 iga2_fifo_high_threshold =
1325 K800_IGA2_FIFO_HIGH_THRESHOLD;
1326
1327 /* If resolution > 1280x1024, expire length = 64,
1328 else expire length = 128 */
1329 if ((hor_active > 1280) && (ver_active > 1024))
1330 iga2_display_queue_expire_num = 16;
1331 else
1332 iga2_display_queue_expire_num =
1333 K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1334 }
1335
1336 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_PM800) {
1337 iga2_fifo_max_depth = P880_IGA2_FIFO_MAX_DEPTH;
1338 iga2_fifo_threshold = P880_IGA2_FIFO_THRESHOLD;
1339 iga2_fifo_high_threshold =
1340 P880_IGA2_FIFO_HIGH_THRESHOLD;
1341
1342 /* If resolution > 1280x1024, expire length = 64,
1343 else expire length = 128 */
1344 if ((hor_active > 1280) && (ver_active > 1024))
1345 iga2_display_queue_expire_num = 16;
1346 else
1347 iga2_display_queue_expire_num =
1348 P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1349 }
1350
1351 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CN700) {
1352 iga2_fifo_max_depth = CN700_IGA2_FIFO_MAX_DEPTH;
1353 iga2_fifo_threshold = CN700_IGA2_FIFO_THRESHOLD;
1354 iga2_fifo_high_threshold =
1355 CN700_IGA2_FIFO_HIGH_THRESHOLD;
1356
1357 /* If resolution > 1280x1024, expire length = 64,
1358 else expire length = 128 */
1359 if ((hor_active > 1280) && (ver_active > 1024))
1360 iga2_display_queue_expire_num = 16;
1361 else
1362 iga2_display_queue_expire_num =
1363 CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1364 }
1365
1366 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) {
1367 iga2_fifo_max_depth = CX700_IGA2_FIFO_MAX_DEPTH;
1368 iga2_fifo_threshold = CX700_IGA2_FIFO_THRESHOLD;
1369 iga2_fifo_high_threshold =
1370 CX700_IGA2_FIFO_HIGH_THRESHOLD;
1371 iga2_display_queue_expire_num =
1372 CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1373 }
1374
1375 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K8M890) {
1376 iga2_fifo_max_depth = K8M890_IGA2_FIFO_MAX_DEPTH;
1377 iga2_fifo_threshold = K8M890_IGA2_FIFO_THRESHOLD;
1378 iga2_fifo_high_threshold =
1379 K8M890_IGA2_FIFO_HIGH_THRESHOLD;
1380 iga2_display_queue_expire_num =
1381 K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1382 }
1383
1384 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M890) {
1385 iga2_fifo_max_depth = P4M890_IGA2_FIFO_MAX_DEPTH;
1386 iga2_fifo_threshold = P4M890_IGA2_FIFO_THRESHOLD;
1387 iga2_fifo_high_threshold =
1388 P4M890_IGA2_FIFO_HIGH_THRESHOLD;
1389 iga2_display_queue_expire_num =
1390 P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1391 }
1392
1393 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M900) {
1394 iga2_fifo_max_depth = P4M900_IGA2_FIFO_MAX_DEPTH;
1395 iga2_fifo_threshold = P4M900_IGA2_FIFO_THRESHOLD;
1396 iga2_fifo_high_threshold =
1397 P4M900_IGA2_FIFO_HIGH_THRESHOLD;
1398 iga2_display_queue_expire_num =
1399 P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1400 }
1401
1402 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX800) {
1403 iga2_fifo_max_depth = VX800_IGA2_FIFO_MAX_DEPTH;
1404 iga2_fifo_threshold = VX800_IGA2_FIFO_THRESHOLD;
1405 iga2_fifo_high_threshold =
1406 VX800_IGA2_FIFO_HIGH_THRESHOLD;
1407 iga2_display_queue_expire_num =
1408 VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM;
1409 }
1410
1411 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) {
1412 /* Set Display FIFO Depath Select */
1413 reg_value =
1414 IGA2_FIFO_DEPTH_SELECT_FORMULA(iga2_fifo_max_depth)
1415 - 1;
1416 /* Patch LCD in IGA2 case */
1417 viafb_load_reg_num =
1418 display_fifo_depth_reg.
1419 iga2_fifo_depth_select_reg.reg_num;
1420 reg =
1421 display_fifo_depth_reg.
1422 iga2_fifo_depth_select_reg.reg;
1423 viafb_load_reg(reg_value,
1424 viafb_load_reg_num, reg, VIACR);
1425 } else {
1426
1427 /* Set Display FIFO Depath Select */
1428 reg_value =
1429 IGA2_FIFO_DEPTH_SELECT_FORMULA(iga2_fifo_max_depth);
1430 viafb_load_reg_num =
1431 display_fifo_depth_reg.
1432 iga2_fifo_depth_select_reg.reg_num;
1433 reg =
1434 display_fifo_depth_reg.
1435 iga2_fifo_depth_select_reg.reg;
1436 viafb_load_reg(reg_value,
1437 viafb_load_reg_num, reg, VIACR);
1438 }
1439
1440 /* Set Display FIFO Threshold Select */
1441 reg_value = IGA2_FIFO_THRESHOLD_FORMULA(iga2_fifo_threshold);
1442 viafb_load_reg_num =
1443 fifo_threshold_select_reg.
1444 iga2_fifo_threshold_select_reg.reg_num;
1445 reg =
1446 fifo_threshold_select_reg.
1447 iga2_fifo_threshold_select_reg.reg;
1448 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1449
1450 /* Set FIFO High Threshold Select */
1451 reg_value =
1452 IGA2_FIFO_HIGH_THRESHOLD_FORMULA(iga2_fifo_high_threshold);
1453 viafb_load_reg_num =
1454 fifo_high_threshold_select_reg.
1455 iga2_fifo_high_threshold_select_reg.reg_num;
1456 reg =
1457 fifo_high_threshold_select_reg.
1458 iga2_fifo_high_threshold_select_reg.reg;
1459 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1460
1461 /* Set Display Queue Expire Num */
1462 reg_value =
1463 IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA
1464 (iga2_display_queue_expire_num);
1465 viafb_load_reg_num =
1466 display_queue_expire_num_reg.
1467 iga2_display_queue_expire_num_reg.reg_num;
1468 reg =
1469 display_queue_expire_num_reg.
1470 iga2_display_queue_expire_num_reg.reg;
1471 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1472
1473 }
1474
1475}
1476
1477u32 viafb_get_clk_value(int clk)
1478{
1479 int i;
1480
1481 for (i = 0; i < NUM_TOTAL_PLL_TABLE; i++) {
1482 if (clk == pll_value[i].clk) {
1483 switch (viaparinfo->chip_info->gfx_chip_name) {
1484 case UNICHROME_CLE266:
1485 case UNICHROME_K400:
1486 return pll_value[i].cle266_pll;
1487
1488 case UNICHROME_K800:
1489 case UNICHROME_PM800:
1490 case UNICHROME_CN700:
1491 return pll_value[i].k800_pll;
1492
1493 case UNICHROME_CX700:
1494 case UNICHROME_K8M890:
1495 case UNICHROME_P4M890:
1496 case UNICHROME_P4M900:
1497 case UNICHROME_VX800:
1498 return pll_value[i].cx700_pll;
1499 }
1500 }
1501 }
1502
1503 DEBUG_MSG(KERN_INFO "Can't find match PLL value\n\n");
1504 return 0;
1505}
1506
1507/* Set VCLK*/
1508void viafb_set_vclock(u32 CLK, int set_iga)
1509{
1510 unsigned char RegTemp;
1511
1512 /* H.W. Reset : ON */
1513 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7);
1514
1515 if ((set_iga == IGA1) || (set_iga == IGA1_IGA2)) {
1516 /* Change D,N FOR VCLK */
1517 switch (viaparinfo->chip_info->gfx_chip_name) {
1518 case UNICHROME_CLE266:
1519 case UNICHROME_K400:
1520 viafb_write_reg(SR46, VIASR, CLK / 0x100);
1521 viafb_write_reg(SR47, VIASR, CLK % 0x100);
1522 break;
1523
1524 case UNICHROME_K800:
1525 case UNICHROME_PM800:
1526 case UNICHROME_CN700:
1527 case UNICHROME_CX700:
1528 case UNICHROME_K8M890:
1529 case UNICHROME_P4M890:
1530 case UNICHROME_P4M900:
1531 case UNICHROME_VX800:
1532 viafb_write_reg(SR44, VIASR, CLK / 0x10000);
1533 DEBUG_MSG(KERN_INFO "\nSR44=%x", CLK / 0x10000);
1534 viafb_write_reg(SR45, VIASR, (CLK & 0xFFFF) / 0x100);
1535 DEBUG_MSG(KERN_INFO "\nSR45=%x",
1536 (CLK & 0xFFFF) / 0x100);
1537 viafb_write_reg(SR46, VIASR, CLK % 0x100);
1538 DEBUG_MSG(KERN_INFO "\nSR46=%x", CLK % 0x100);
1539 break;
1540 }
1541 }
1542
1543 if ((set_iga == IGA2) || (set_iga == IGA1_IGA2)) {
1544 /* Change D,N FOR LCK */
1545 switch (viaparinfo->chip_info->gfx_chip_name) {
1546 case UNICHROME_CLE266:
1547 case UNICHROME_K400:
1548 viafb_write_reg(SR44, VIASR, CLK / 0x100);
1549 viafb_write_reg(SR45, VIASR, CLK % 0x100);
1550 break;
1551
1552 case UNICHROME_K800:
1553 case UNICHROME_PM800:
1554 case UNICHROME_CN700:
1555 case UNICHROME_CX700:
1556 case UNICHROME_K8M890:
1557 case UNICHROME_P4M890:
1558 case UNICHROME_P4M900:
1559 case UNICHROME_VX800:
1560 viafb_write_reg(SR4A, VIASR, CLK / 0x10000);
1561 viafb_write_reg(SR4B, VIASR, (CLK & 0xFFFF) / 0x100);
1562 viafb_write_reg(SR4C, VIASR, CLK % 0x100);
1563 break;
1564 }
1565 }
1566
1567 /* H.W. Reset : OFF */
1568 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7);
1569
1570 /* Reset PLL */
1571 if ((set_iga == IGA1) || (set_iga == IGA1_IGA2)) {
1572 viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1);
1573 viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1);
1574 }
1575
1576 if ((set_iga == IGA2) || (set_iga == IGA1_IGA2)) {
1577 viafb_write_reg_mask(SR40, VIASR, 0x01, BIT0);
1578 viafb_write_reg_mask(SR40, VIASR, 0x00, BIT0);
1579 }
1580
1581 /* Fire! */
1582 RegTemp = inb(VIARMisc);
1583 outb(RegTemp | (BIT2 + BIT3), VIAWMisc);
1584}
1585
1586void viafb_load_crtc_timing(struct display_timing device_timing,
1587 int set_iga)
1588{
1589 int i;
1590 int viafb_load_reg_num = 0;
1591 int reg_value = 0;
1592 struct io_register *reg = NULL;
1593
1594 viafb_unlock_crt();
1595
1596 for (i = 0; i < 12; i++) {
1597 if (set_iga == IGA1) {
1598 switch (i) {
1599 case H_TOTAL_INDEX:
1600 reg_value =
1601 IGA1_HOR_TOTAL_FORMULA(device_timing.
1602 hor_total);
1603 viafb_load_reg_num =
1604 iga1_crtc_reg.hor_total.reg_num;
1605 reg = iga1_crtc_reg.hor_total.reg;
1606 break;
1607 case H_ADDR_INDEX:
1608 reg_value =
1609 IGA1_HOR_ADDR_FORMULA(device_timing.
1610 hor_addr);
1611 viafb_load_reg_num =
1612 iga1_crtc_reg.hor_addr.reg_num;
1613 reg = iga1_crtc_reg.hor_addr.reg;
1614 break;
1615 case H_BLANK_START_INDEX:
1616 reg_value =
1617 IGA1_HOR_BLANK_START_FORMULA
1618 (device_timing.hor_blank_start);
1619 viafb_load_reg_num =
1620 iga1_crtc_reg.hor_blank_start.reg_num;
1621 reg = iga1_crtc_reg.hor_blank_start.reg;
1622 break;
1623 case H_BLANK_END_INDEX:
1624 reg_value =
1625 IGA1_HOR_BLANK_END_FORMULA
1626 (device_timing.hor_blank_start,
1627 device_timing.hor_blank_end);
1628 viafb_load_reg_num =
1629 iga1_crtc_reg.hor_blank_end.reg_num;
1630 reg = iga1_crtc_reg.hor_blank_end.reg;
1631 break;
1632 case H_SYNC_START_INDEX:
1633 reg_value =
1634 IGA1_HOR_SYNC_START_FORMULA
1635 (device_timing.hor_sync_start);
1636 viafb_load_reg_num =
1637 iga1_crtc_reg.hor_sync_start.reg_num;
1638 reg = iga1_crtc_reg.hor_sync_start.reg;
1639 break;
1640 case H_SYNC_END_INDEX:
1641 reg_value =
1642 IGA1_HOR_SYNC_END_FORMULA
1643 (device_timing.hor_sync_start,
1644 device_timing.hor_sync_end);
1645 viafb_load_reg_num =
1646 iga1_crtc_reg.hor_sync_end.reg_num;
1647 reg = iga1_crtc_reg.hor_sync_end.reg;
1648 break;
1649 case V_TOTAL_INDEX:
1650 reg_value =
1651 IGA1_VER_TOTAL_FORMULA(device_timing.
1652 ver_total);
1653 viafb_load_reg_num =
1654 iga1_crtc_reg.ver_total.reg_num;
1655 reg = iga1_crtc_reg.ver_total.reg;
1656 break;
1657 case V_ADDR_INDEX:
1658 reg_value =
1659 IGA1_VER_ADDR_FORMULA(device_timing.
1660 ver_addr);
1661 viafb_load_reg_num =
1662 iga1_crtc_reg.ver_addr.reg_num;
1663 reg = iga1_crtc_reg.ver_addr.reg;
1664 break;
1665 case V_BLANK_START_INDEX:
1666 reg_value =
1667 IGA1_VER_BLANK_START_FORMULA
1668 (device_timing.ver_blank_start);
1669 viafb_load_reg_num =
1670 iga1_crtc_reg.ver_blank_start.reg_num;
1671 reg = iga1_crtc_reg.ver_blank_start.reg;
1672 break;
1673 case V_BLANK_END_INDEX:
1674 reg_value =
1675 IGA1_VER_BLANK_END_FORMULA
1676 (device_timing.ver_blank_start,
1677 device_timing.ver_blank_end);
1678 viafb_load_reg_num =
1679 iga1_crtc_reg.ver_blank_end.reg_num;
1680 reg = iga1_crtc_reg.ver_blank_end.reg;
1681 break;
1682 case V_SYNC_START_INDEX:
1683 reg_value =
1684 IGA1_VER_SYNC_START_FORMULA
1685 (device_timing.ver_sync_start);
1686 viafb_load_reg_num =
1687 iga1_crtc_reg.ver_sync_start.reg_num;
1688 reg = iga1_crtc_reg.ver_sync_start.reg;
1689 break;
1690 case V_SYNC_END_INDEX:
1691 reg_value =
1692 IGA1_VER_SYNC_END_FORMULA
1693 (device_timing.ver_sync_start,
1694 device_timing.ver_sync_end);
1695 viafb_load_reg_num =
1696 iga1_crtc_reg.ver_sync_end.reg_num;
1697 reg = iga1_crtc_reg.ver_sync_end.reg;
1698 break;
1699
1700 }
1701 }
1702
1703 if (set_iga == IGA2) {
1704 switch (i) {
1705 case H_TOTAL_INDEX:
1706 reg_value =
1707 IGA2_HOR_TOTAL_FORMULA(device_timing.
1708 hor_total);
1709 viafb_load_reg_num =
1710 iga2_crtc_reg.hor_total.reg_num;
1711 reg = iga2_crtc_reg.hor_total.reg;
1712 break;
1713 case H_ADDR_INDEX:
1714 reg_value =
1715 IGA2_HOR_ADDR_FORMULA(device_timing.
1716 hor_addr);
1717 viafb_load_reg_num =
1718 iga2_crtc_reg.hor_addr.reg_num;
1719 reg = iga2_crtc_reg.hor_addr.reg;
1720 break;
1721 case H_BLANK_START_INDEX:
1722 reg_value =
1723 IGA2_HOR_BLANK_START_FORMULA
1724 (device_timing.hor_blank_start);
1725 viafb_load_reg_num =
1726 iga2_crtc_reg.hor_blank_start.reg_num;
1727 reg = iga2_crtc_reg.hor_blank_start.reg;
1728 break;
1729 case H_BLANK_END_INDEX:
1730 reg_value =
1731 IGA2_HOR_BLANK_END_FORMULA
1732 (device_timing.hor_blank_start,
1733 device_timing.hor_blank_end);
1734 viafb_load_reg_num =
1735 iga2_crtc_reg.hor_blank_end.reg_num;
1736 reg = iga2_crtc_reg.hor_blank_end.reg;
1737 break;
1738 case H_SYNC_START_INDEX:
1739 reg_value =
1740 IGA2_HOR_SYNC_START_FORMULA
1741 (device_timing.hor_sync_start);
1742 if (UNICHROME_CN700 <=
1743 viaparinfo->chip_info->gfx_chip_name)
1744 viafb_load_reg_num =
1745 iga2_crtc_reg.hor_sync_start.
1746 reg_num;
1747 else
1748 viafb_load_reg_num = 3;
1749 reg = iga2_crtc_reg.hor_sync_start.reg;
1750 break;
1751 case H_SYNC_END_INDEX:
1752 reg_value =
1753 IGA2_HOR_SYNC_END_FORMULA
1754 (device_timing.hor_sync_start,
1755 device_timing.hor_sync_end);
1756 viafb_load_reg_num =
1757 iga2_crtc_reg.hor_sync_end.reg_num;
1758 reg = iga2_crtc_reg.hor_sync_end.reg;
1759 break;
1760 case V_TOTAL_INDEX:
1761 reg_value =
1762 IGA2_VER_TOTAL_FORMULA(device_timing.
1763 ver_total);
1764 viafb_load_reg_num =
1765 iga2_crtc_reg.ver_total.reg_num;
1766 reg = iga2_crtc_reg.ver_total.reg;
1767 break;
1768 case V_ADDR_INDEX:
1769 reg_value =
1770 IGA2_VER_ADDR_FORMULA(device_timing.
1771 ver_addr);
1772 viafb_load_reg_num =
1773 iga2_crtc_reg.ver_addr.reg_num;
1774 reg = iga2_crtc_reg.ver_addr.reg;
1775 break;
1776 case V_BLANK_START_INDEX:
1777 reg_value =
1778 IGA2_VER_BLANK_START_FORMULA
1779 (device_timing.ver_blank_start);
1780 viafb_load_reg_num =
1781 iga2_crtc_reg.ver_blank_start.reg_num;
1782 reg = iga2_crtc_reg.ver_blank_start.reg;
1783 break;
1784 case V_BLANK_END_INDEX:
1785 reg_value =
1786 IGA2_VER_BLANK_END_FORMULA
1787 (device_timing.ver_blank_start,
1788 device_timing.ver_blank_end);
1789 viafb_load_reg_num =
1790 iga2_crtc_reg.ver_blank_end.reg_num;
1791 reg = iga2_crtc_reg.ver_blank_end.reg;
1792 break;
1793 case V_SYNC_START_INDEX:
1794 reg_value =
1795 IGA2_VER_SYNC_START_FORMULA
1796 (device_timing.ver_sync_start);
1797 viafb_load_reg_num =
1798 iga2_crtc_reg.ver_sync_start.reg_num;
1799 reg = iga2_crtc_reg.ver_sync_start.reg;
1800 break;
1801 case V_SYNC_END_INDEX:
1802 reg_value =
1803 IGA2_VER_SYNC_END_FORMULA
1804 (device_timing.ver_sync_start,
1805 device_timing.ver_sync_end);
1806 viafb_load_reg_num =
1807 iga2_crtc_reg.ver_sync_end.reg_num;
1808 reg = iga2_crtc_reg.ver_sync_end.reg;
1809 break;
1810
1811 }
1812 }
1813 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1814 }
1815
1816 viafb_lock_crt();
1817}
1818
1819void viafb_set_color_depth(int bpp_byte, int set_iga)
1820{
1821 if (set_iga == IGA1) {
1822 switch (bpp_byte) {
1823 case MODE_8BPP:
1824 viafb_write_reg_mask(SR15, VIASR, 0x22, 0x7E);
1825 break;
1826 case MODE_16BPP:
1827 viafb_write_reg_mask(SR15, VIASR, 0xB6, 0xFE);
1828 break;
1829 case MODE_32BPP:
1830 viafb_write_reg_mask(SR15, VIASR, 0xAE, 0xFE);
1831 break;
1832 }
1833 } else {
1834 switch (bpp_byte) {
1835 case MODE_8BPP:
1836 viafb_write_reg_mask(CR67, VIACR, 0x00, BIT6 + BIT7);
1837 break;
1838 case MODE_16BPP:
1839 viafb_write_reg_mask(CR67, VIACR, 0x40, BIT6 + BIT7);
1840 break;
1841 case MODE_32BPP:
1842 viafb_write_reg_mask(CR67, VIACR, 0xC0, BIT6 + BIT7);
1843 break;
1844 }
1845 }
1846}
1847
1848void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
1849 int mode_index, int bpp_byte, int set_iga)
1850{
1851 struct VideoModeTable *video_mode;
1852 struct display_timing crt_reg;
1853 int i;
1854 int index = 0;
1855 int h_addr, v_addr;
1856 u32 pll_D_N;
1857
1858 video_mode = &CLE266Modes[search_mode_setting(mode_index)];
1859
1860 for (i = 0; i < video_mode->mode_array; i++) {
1861 index = i;
1862
1863 if (crt_table[i].refresh_rate == viaparinfo->
1864 crt_setting_info->refresh_rate)
1865 break;
1866 }
1867
1868 crt_reg = crt_table[index].crtc;
1869
1870 /* Mode 640x480 has border, but LCD/DFP didn't have border. */
1871 /* So we would delete border. */
1872 if ((viafb_LCD_ON | viafb_DVI_ON) && (mode_index == VIA_RES_640X480)
1873 && (viaparinfo->crt_setting_info->refresh_rate == 60)) {
1874 /* The border is 8 pixels. */
1875 crt_reg.hor_blank_start = crt_reg.hor_blank_start - 8;
1876
1877 /* Blanking time should add left and right borders. */
1878 crt_reg.hor_blank_end = crt_reg.hor_blank_end + 16;
1879 }
1880
1881 h_addr = crt_reg.hor_addr;
1882 v_addr = crt_reg.ver_addr;
1883
1884 /* update polarity for CRT timing */
1885 if (crt_table[index].h_sync_polarity == NEGATIVE) {
1886 if (crt_table[index].v_sync_polarity == NEGATIVE)
1887 outb((inb(VIARMisc) & (~(BIT6 + BIT7))) |
1888 (BIT6 + BIT7), VIAWMisc);
1889 else
1890 outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | (BIT6),
1891 VIAWMisc);
1892 } else {
1893 if (crt_table[index].v_sync_polarity == NEGATIVE)
1894 outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | (BIT7),
1895 VIAWMisc);
1896 else
1897 outb((inb(VIARMisc) & (~(BIT6 + BIT7))), VIAWMisc);
1898 }
1899
1900 if (set_iga == IGA1) {
1901 viafb_unlock_crt();
1902 viafb_write_reg(CR09, VIACR, 0x00); /*initial CR09=0 */
1903 viafb_write_reg_mask(CR11, VIACR, 0x00, BIT4 + BIT5 + BIT6);
1904 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7);
1905 }
1906
1907 switch (set_iga) {
1908 case IGA1:
1909 viafb_load_crtc_timing(crt_reg, IGA1);
1910 break;
1911 case IGA2:
1912 viafb_load_crtc_timing(crt_reg, IGA2);
1913 break;
1914 }
1915
1916 load_fix_bit_crtc_reg();
1917 viafb_lock_crt();
1918 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7);
1919 viafb_load_offset_reg(h_addr, bpp_byte, set_iga);
1920 viafb_load_fetch_count_reg(h_addr, bpp_byte, set_iga);
1921
1922 /* load FIFO */
1923 if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266)
1924 && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400))
1925 viafb_load_FIFO_reg(set_iga, h_addr, v_addr);
1926
1927 /* load SR Register About Memory and Color part */
1928 viafb_set_color_depth(bpp_byte, set_iga);
1929
1930 pll_D_N = viafb_get_clk_value(crt_table[index].clk);
1931 DEBUG_MSG(KERN_INFO "PLL=%x", pll_D_N);
1932 viafb_set_vclock(pll_D_N, set_iga);
1933
1934}
1935
1936void viafb_init_chip_info(void)
1937{
1938 init_gfx_chip_info();
1939 init_tmds_chip_info();
1940 init_lvds_chip_info();
1941
1942 viaparinfo->crt_setting_info->iga_path = IGA1;
1943 viaparinfo->crt_setting_info->refresh_rate = viafb_refresh;
1944
1945 /*Set IGA path for each device */
1946 viafb_set_iga_path();
1947
1948 viaparinfo->lvds_setting_info->display_method = viafb_lcd_dsp_method;
1949 viaparinfo->lvds_setting_info->get_lcd_size_method =
1950 GET_LCD_SIZE_BY_USER_SETTING;
1951 viaparinfo->lvds_setting_info->lcd_mode = viafb_lcd_mode;
1952 viaparinfo->lvds_setting_info2->display_method =
1953 viaparinfo->lvds_setting_info->display_method;
1954 viaparinfo->lvds_setting_info2->lcd_mode =
1955 viaparinfo->lvds_setting_info->lcd_mode;
1956}
1957
1958void viafb_update_device_setting(int hres, int vres,
1959 int bpp, int vmode_refresh, int flag)
1960{
1961 if (flag == 0) {
1962 viaparinfo->crt_setting_info->h_active = hres;
1963 viaparinfo->crt_setting_info->v_active = vres;
1964 viaparinfo->crt_setting_info->bpp = bpp;
1965 viaparinfo->crt_setting_info->refresh_rate =
1966 vmode_refresh;
1967
1968 viaparinfo->tmds_setting_info->h_active = hres;
1969 viaparinfo->tmds_setting_info->v_active = vres;
1970 viaparinfo->tmds_setting_info->bpp = bpp;
1971 viaparinfo->tmds_setting_info->refresh_rate =
1972 vmode_refresh;
1973
1974 viaparinfo->lvds_setting_info->h_active = hres;
1975 viaparinfo->lvds_setting_info->v_active = vres;
1976 viaparinfo->lvds_setting_info->bpp = bpp;
1977 viaparinfo->lvds_setting_info->refresh_rate =
1978 vmode_refresh;
1979 viaparinfo->lvds_setting_info2->h_active = hres;
1980 viaparinfo->lvds_setting_info2->v_active = vres;
1981 viaparinfo->lvds_setting_info2->bpp = bpp;
1982 viaparinfo->lvds_setting_info2->refresh_rate =
1983 vmode_refresh;
1984 } else {
1985
1986 if (viaparinfo->tmds_setting_info->iga_path == IGA2) {
1987 viaparinfo->tmds_setting_info->h_active = hres;
1988 viaparinfo->tmds_setting_info->v_active = vres;
1989 viaparinfo->tmds_setting_info->bpp = bpp;
1990 viaparinfo->tmds_setting_info->refresh_rate =
1991 vmode_refresh;
1992 }
1993
1994 if (viaparinfo->lvds_setting_info->iga_path == IGA2) {
1995 viaparinfo->lvds_setting_info->h_active = hres;
1996 viaparinfo->lvds_setting_info->v_active = vres;
1997 viaparinfo->lvds_setting_info->bpp = bpp;
1998 viaparinfo->lvds_setting_info->refresh_rate =
1999 vmode_refresh;
2000 }
2001 if (IGA2 == viaparinfo->lvds_setting_info2->iga_path) {
2002 viaparinfo->lvds_setting_info2->h_active = hres;
2003 viaparinfo->lvds_setting_info2->v_active = vres;
2004 viaparinfo->lvds_setting_info2->bpp = bpp;
2005 viaparinfo->lvds_setting_info2->refresh_rate =
2006 vmode_refresh;
2007 }
2008 }
2009}
2010
2011static void init_gfx_chip_info(void)
2012{
2013 struct pci_dev *pdev = NULL;
2014 u32 i;
2015 u8 tmp;
2016
2017 /* Indentify GFX Chip Name */
2018 for (i = 0; pciidlist[i].vendor != 0; i++) {
2019 pdev = pci_get_device(pciidlist[i].vendor,
2020 pciidlist[i].device, 0);
2021 if (pdev)
2022 break;
2023 }
2024
2025 if (!pciidlist[i].vendor)
2026 return ;
2027
2028 viaparinfo->chip_info->gfx_chip_name = pciidlist[i].chip_index;
2029
2030 /* Check revision of CLE266 Chip */
2031 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
2032 /* CR4F only define in CLE266.CX chip */
2033 tmp = viafb_read_reg(VIACR, CR4F);
2034 viafb_write_reg(CR4F, VIACR, 0x55);
2035 if (viafb_read_reg(VIACR, CR4F) != 0x55)
2036 viaparinfo->chip_info->gfx_chip_revision =
2037 CLE266_REVISION_AX;
2038 else
2039 viaparinfo->chip_info->gfx_chip_revision =
2040 CLE266_REVISION_CX;
2041 /* restore orignal CR4F value */
2042 viafb_write_reg(CR4F, VIACR, tmp);
2043 }
2044
2045 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) {
2046 tmp = viafb_read_reg(VIASR, SR43);
2047 DEBUG_MSG(KERN_INFO "SR43:%X\n", tmp);
2048 if (tmp & 0x02) {
2049 viaparinfo->chip_info->gfx_chip_revision =
2050 CX700_REVISION_700M2;
2051 } else if (tmp & 0x40) {
2052 viaparinfo->chip_info->gfx_chip_revision =
2053 CX700_REVISION_700M;
2054 } else {
2055 viaparinfo->chip_info->gfx_chip_revision =
2056 CX700_REVISION_700;
2057 }
2058 }
2059
2060 pci_dev_put(pdev);
2061}
2062
2063static void init_tmds_chip_info(void)
2064{
2065 viafb_tmds_trasmitter_identify();
2066
2067 if (INTERFACE_NONE == viaparinfo->chip_info->tmds_chip_info.
2068 output_interface) {
2069 switch (viaparinfo->chip_info->gfx_chip_name) {
2070 case UNICHROME_CX700:
2071 {
2072 /* we should check support by hardware layout.*/
2073 if ((viafb_display_hardware_layout ==
2074 HW_LAYOUT_DVI_ONLY)
2075 || (viafb_display_hardware_layout ==
2076 HW_LAYOUT_LCD_DVI)) {
2077 viaparinfo->chip_info->tmds_chip_info.
2078 output_interface = INTERFACE_TMDS;
2079 } else {
2080 viaparinfo->chip_info->tmds_chip_info.
2081 output_interface =
2082 INTERFACE_NONE;
2083 }
2084 break;
2085 }
2086 case UNICHROME_K8M890:
2087 case UNICHROME_P4M900:
2088 case UNICHROME_P4M890:
2089 /* TMDS on PCIE, we set DFPLOW as default. */
2090 viaparinfo->chip_info->tmds_chip_info.output_interface =
2091 INTERFACE_DFP_LOW;
2092 break;
2093 default:
2094 {
2095 /* set DVP1 default for DVI */
2096 viaparinfo->chip_info->tmds_chip_info
2097 .output_interface = INTERFACE_DVP1;
2098 }
2099 }
2100 }
2101
2102 DEBUG_MSG(KERN_INFO "TMDS Chip = %d\n",
2103 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name);
2104 viaparinfo->tmds_setting_info->get_dvi_size_method =
2105 GET_DVI_SIZE_BY_VGA_BIOS;
2106 viafb_init_dvi_size();
2107}
2108
2109static void init_lvds_chip_info(void)
2110{
2111 if (viafb_lcd_panel_id > LCD_PANEL_ID_MAXIMUM)
2112 viaparinfo->lvds_setting_info->get_lcd_size_method =
2113 GET_LCD_SIZE_BY_VGA_BIOS;
2114 else
2115 viaparinfo->lvds_setting_info->get_lcd_size_method =
2116 GET_LCD_SIZE_BY_USER_SETTING;
2117
2118 viafb_lvds_trasmitter_identify();
2119 viafb_init_lcd_size();
2120 viafb_init_lvds_output_interface(&viaparinfo->chip_info->lvds_chip_info,
2121 viaparinfo->lvds_setting_info);
2122 if (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
2123 viafb_init_lvds_output_interface(&viaparinfo->chip_info->
2124 lvds_chip_info2, viaparinfo->lvds_setting_info2);
2125 }
2126 /*If CX700,two singel LCD, we need to reassign
2127 LCD interface to different LVDS port */
2128 if ((UNICHROME_CX700 == viaparinfo->chip_info->gfx_chip_name)
2129 && (HW_LAYOUT_LCD1_LCD2 == viafb_display_hardware_layout)) {
2130 if ((INTEGRATED_LVDS == viaparinfo->chip_info->lvds_chip_info.
2131 lvds_chip_name) && (INTEGRATED_LVDS ==
2132 viaparinfo->chip_info->
2133 lvds_chip_info2.lvds_chip_name)) {
2134 viaparinfo->chip_info->lvds_chip_info.output_interface =
2135 INTERFACE_LVDS0;
2136 viaparinfo->chip_info->lvds_chip_info2.
2137 output_interface =
2138 INTERFACE_LVDS1;
2139 }
2140 }
2141
2142 DEBUG_MSG(KERN_INFO "LVDS Chip = %d\n",
2143 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name);
2144 DEBUG_MSG(KERN_INFO "LVDS1 output_interface = %d\n",
2145 viaparinfo->chip_info->lvds_chip_info.output_interface);
2146 DEBUG_MSG(KERN_INFO "LVDS2 output_interface = %d\n",
2147 viaparinfo->chip_info->lvds_chip_info.output_interface);
2148}
2149
2150void viafb_init_dac(int set_iga)
2151{
2152 int i;
2153 u8 tmp;
2154
2155 if (set_iga == IGA1) {
2156 /* access Primary Display's LUT */
2157 viafb_write_reg_mask(SR1A, VIASR, 0x00, BIT0);
2158 /* turn off LCK */
2159 viafb_write_reg_mask(SR1B, VIASR, 0x00, BIT7 + BIT6);
2160 for (i = 0; i < 256; i++) {
2161 write_dac_reg(i, palLUT_table[i].red,
2162 palLUT_table[i].green,
2163 palLUT_table[i].blue);
2164 }
2165 /* turn on LCK */
2166 viafb_write_reg_mask(SR1B, VIASR, 0xC0, BIT7 + BIT6);
2167 } else {
2168 tmp = viafb_read_reg(VIACR, CR6A);
2169 /* access Secondary Display's LUT */
2170 viafb_write_reg_mask(CR6A, VIACR, 0x40, BIT6);
2171 viafb_write_reg_mask(SR1A, VIASR, 0x01, BIT0);
2172 for (i = 0; i < 256; i++) {
2173 write_dac_reg(i, palLUT_table[i].red,
2174 palLUT_table[i].green,
2175 palLUT_table[i].blue);
2176 }
2177 /* set IGA1 DAC for default */
2178 viafb_write_reg_mask(SR1A, VIASR, 0x00, BIT0);
2179 viafb_write_reg(CR6A, VIACR, tmp);
2180 }
2181}
2182
2183static void device_screen_off(void)
2184{
2185 /* turn off CRT screen (IGA1) */
2186 viafb_write_reg_mask(SR01, VIASR, 0x20, BIT5);
2187}
2188
2189static void device_screen_on(void)
2190{
2191 /* turn on CRT screen (IGA1) */
2192 viafb_write_reg_mask(SR01, VIASR, 0x00, BIT5);
2193}
2194
2195static void set_display_channel(void)
2196{
2197 /*If viafb_LCD2_ON, on cx700, internal lvds's information
2198 is keeped on lvds_setting_info2 */
2199 if (viafb_LCD2_ON &&
2200 viaparinfo->lvds_setting_info2->device_lcd_dualedge) {
2201 /* For dual channel LCD: */
2202 /* Set to Dual LVDS channel. */
2203 viafb_write_reg_mask(CRD2, VIACR, 0x20, BIT4 + BIT5);
2204 } else if (viafb_LCD_ON && viafb_DVI_ON) {
2205 /* For LCD+DFP: */
2206 /* Set to LVDS1 + TMDS channel. */
2207 viafb_write_reg_mask(CRD2, VIACR, 0x10, BIT4 + BIT5);
2208 } else if (viafb_DVI_ON) {
2209 /* Set to single TMDS channel. */
2210 viafb_write_reg_mask(CRD2, VIACR, 0x30, BIT4 + BIT5);
2211 } else if (viafb_LCD_ON) {
2212 if (viaparinfo->lvds_setting_info->device_lcd_dualedge) {
2213 /* For dual channel LCD: */
2214 /* Set to Dual LVDS channel. */
2215 viafb_write_reg_mask(CRD2, VIACR, 0x20, BIT4 + BIT5);
2216 } else {
2217 /* Set to LVDS0 + LVDS1 channel. */
2218 viafb_write_reg_mask(CRD2, VIACR, 0x00, BIT4 + BIT5);
2219 }
2220 }
2221}
2222
2223int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2224 int vmode_index1, int hor_res1, int ver_res1, int video_bpp1)
2225{
2226 int i, j;
2227 int port;
2228 u8 value, index, mask;
2229 struct VideoModeTable *vmode_tbl;
2230 struct crt_mode_table *crt_timing;
2231 struct VideoModeTable *vmode_tbl1 = NULL;
2232 struct crt_mode_table *crt_timing1 = NULL;
2233
2234 DEBUG_MSG(KERN_INFO "Set Mode!!\n");
2235 DEBUG_MSG(KERN_INFO
2236 "vmode_index=%d hor_res=%d ver_res=%d video_bpp=%d\n",
2237 vmode_index, hor_res, ver_res, video_bpp);
2238
2239 device_screen_off();
2240 vmode_tbl = &CLE266Modes[search_mode_setting(vmode_index)];
2241 crt_timing = vmode_tbl->crtc;
2242
2243 if (viafb_SAMM_ON == 1) {
2244 vmode_tbl1 = &CLE266Modes[search_mode_setting(vmode_index1)];
2245 crt_timing1 = vmode_tbl1->crtc;
2246 }
2247
2248 inb(VIAStatus);
2249 outb(0x00, VIAAR);
2250
2251 /* Write Common Setting for Video Mode */
2252 switch (viaparinfo->chip_info->gfx_chip_name) {
2253 case UNICHROME_CLE266:
2254 viafb_write_regx(CLE266_ModeXregs, NUM_TOTAL_CLE266_ModeXregs);
2255 break;
2256
2257 case UNICHROME_K400:
2258 viafb_write_regx(KM400_ModeXregs, NUM_TOTAL_KM400_ModeXregs);
2259 break;
2260
2261 case UNICHROME_K800:
2262 case UNICHROME_PM800:
2263 viafb_write_regx(CN400_ModeXregs, NUM_TOTAL_CN400_ModeXregs);
2264 break;
2265
2266 case UNICHROME_CN700:
2267 case UNICHROME_K8M890:
2268 case UNICHROME_P4M890:
2269 case UNICHROME_P4M900:
2270 viafb_write_regx(CN700_ModeXregs, NUM_TOTAL_CN700_ModeXregs);
2271 break;
2272
2273 case UNICHROME_CX700:
2274 viafb_write_regx(CX700_ModeXregs, NUM_TOTAL_CX700_ModeXregs);
2275
2276 case UNICHROME_VX800:
2277 viafb_write_regx(VX800_ModeXregs, NUM_TOTAL_VX800_ModeXregs);
2278
2279 break;
2280 }
2281
2282 device_off();
2283
2284 /* Fill VPIT Parameters */
2285 /* Write Misc Register */
2286 outb(VPIT.Misc, VIAWMisc);
2287
2288 /* Write Sequencer */
2289 for (i = 1; i <= StdSR; i++) {
2290 outb(i, VIASR);
2291 outb(VPIT.SR[i - 1], VIASR + 1);
2292 }
2293
2294 viafb_set_start_addr();
2295 viafb_set_iga_path();
2296
2297 /* Write CRTC */
2298 viafb_fill_crtc_timing(crt_timing, vmode_index, video_bpp / 8, IGA1);
2299
2300 /* Write Graphic Controller */
2301 for (i = 0; i < StdGR; i++) {
2302 outb(i, VIAGR);
2303 outb(VPIT.GR[i], VIAGR + 1);
2304 }
2305
2306 /* Write Attribute Controller */
2307 for (i = 0; i < StdAR; i++) {
2308 inb(VIAStatus);
2309 outb(i, VIAAR);
2310 outb(VPIT.AR[i], VIAAR);
2311 }
2312
2313 inb(VIAStatus);
2314 outb(0x20, VIAAR);
2315
2316 /* Update Patch Register */
2317
2318 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
2319 || (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400)) {
2320 for (i = 0; i < NUM_TOTAL_PATCH_MODE; i++) {
2321 if (res_patch_table[i].mode_index == vmode_index) {
2322 for (j = 0;
2323 j < res_patch_table[i].table_length; j++) {
2324 index =
2325 res_patch_table[i].
2326 io_reg_table[j].index;
2327 port =
2328 res_patch_table[i].
2329 io_reg_table[j].port;
2330 value =
2331 res_patch_table[i].
2332 io_reg_table[j].value;
2333 mask =
2334 res_patch_table[i].
2335 io_reg_table[j].mask;
2336 viafb_write_reg_mask(index, port, value,
2337 mask);
2338 }
2339 }
2340 }
2341 }
2342
2343 if (viafb_SAMM_ON == 1) {
2344 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
2345 || (viaparinfo->chip_info->gfx_chip_name ==
2346 UNICHROME_K400)) {
2347 for (i = 0; i < NUM_TOTAL_PATCH_MODE; i++) {
2348 if (res_patch_table[i].mode_index ==
2349 vmode_index1) {
2350 for (j = 0;
2351 j <
2352 res_patch_table[i].
2353 table_length; j++) {
2354 index =
2355 res_patch_table[i].
2356 io_reg_table[j].index;
2357 port =
2358 res_patch_table[i].
2359 io_reg_table[j].port;
2360 value =
2361 res_patch_table[i].
2362 io_reg_table[j].value;
2363 mask =
2364 res_patch_table[i].
2365 io_reg_table[j].mask;
2366 viafb_write_reg_mask(index,
2367 port, value, mask);
2368 }
2369 }
2370 }
2371 }
2372 }
2373
2374 /* Update Refresh Rate Setting */
2375
2376 /* Clear On Screen */
2377
2378 /* CRT set mode */
2379 if (viafb_CRT_ON) {
2380 if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path ==
2381 IGA2)) {
2382 viafb_fill_crtc_timing(crt_timing1, vmode_index1,
2383 video_bpp1 / 8,
2384 viaparinfo->crt_setting_info->iga_path);
2385 } else {
2386 viafb_fill_crtc_timing(crt_timing, vmode_index,
2387 video_bpp / 8,
2388 viaparinfo->crt_setting_info->iga_path);
2389 }
2390
2391 set_crt_output_path(viaparinfo->crt_setting_info->iga_path);
2392
2393 /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode
2394 to 8 alignment (1368),there is several pixels (2 pixels)
2395 on right side of screen. */
2396 if (hor_res % 8) {
2397 viafb_unlock_crt();
2398 viafb_write_reg(CR02, VIACR,
2399 viafb_read_reg(VIACR, CR02) - 1);
2400 viafb_lock_crt();
2401 }
2402 }
2403
2404 if (viafb_DVI_ON) {
2405 if (viafb_SAMM_ON &&
2406 (viaparinfo->tmds_setting_info->iga_path == IGA2)) {
2407 viafb_dvi_set_mode(viafb_get_mode_index
2408 (viaparinfo->tmds_setting_info->h_active,
2409 viaparinfo->tmds_setting_info->
2410 v_active, 1),
2411 video_bpp1, viaparinfo->
2412 tmds_setting_info->iga_path);
2413 } else {
2414 viafb_dvi_set_mode(viafb_get_mode_index
2415 (viaparinfo->tmds_setting_info->h_active,
2416 viaparinfo->
2417 tmds_setting_info->v_active, 0),
2418 video_bpp, viaparinfo->
2419 tmds_setting_info->iga_path);
2420 }
2421 }
2422
2423 if (viafb_LCD_ON) {
2424 if (viafb_SAMM_ON &&
2425 (viaparinfo->lvds_setting_info->iga_path == IGA2)) {
2426 viaparinfo->lvds_setting_info->bpp = video_bpp1;
2427 viafb_lcd_set_mode(crt_timing1, viaparinfo->
2428 lvds_setting_info,
2429 &viaparinfo->chip_info->lvds_chip_info);
2430 } else {
2431 /* IGA1 doesn't have LCD scaling, so set it center. */
2432 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
2433 viaparinfo->lvds_setting_info->display_method =
2434 LCD_CENTERING;
2435 }
2436 viaparinfo->lvds_setting_info->bpp = video_bpp;
2437 viafb_lcd_set_mode(crt_timing, viaparinfo->
2438 lvds_setting_info,
2439 &viaparinfo->chip_info->lvds_chip_info);
2440 }
2441 }
2442 if (viafb_LCD2_ON) {
2443 if (viafb_SAMM_ON &&
2444 (viaparinfo->lvds_setting_info2->iga_path == IGA2)) {
2445 viaparinfo->lvds_setting_info2->bpp = video_bpp1;
2446 viafb_lcd_set_mode(crt_timing1, viaparinfo->
2447 lvds_setting_info2,
2448 &viaparinfo->chip_info->lvds_chip_info2);
2449 } else {
2450 /* IGA1 doesn't have LCD scaling, so set it center. */
2451 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
2452 viaparinfo->lvds_setting_info2->display_method =
2453 LCD_CENTERING;
2454 }
2455 viaparinfo->lvds_setting_info2->bpp = video_bpp;
2456 viafb_lcd_set_mode(crt_timing, viaparinfo->
2457 lvds_setting_info2,
2458 &viaparinfo->chip_info->lvds_chip_info2);
2459 }
2460 }
2461
2462 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700)
2463 && (viafb_LCD_ON || viafb_DVI_ON))
2464 set_display_channel();
2465
2466 /* If set mode normally, save resolution information for hot-plug . */
2467 if (!viafb_hotplug) {
2468 viafb_hotplug_Xres = hor_res;
2469 viafb_hotplug_Yres = ver_res;
2470 viafb_hotplug_bpp = video_bpp;
2471 viafb_hotplug_refresh = viafb_refresh;
2472
2473 if (viafb_DVI_ON)
2474 viafb_DeviceStatus = DVI_Device;
2475 else
2476 viafb_DeviceStatus = CRT_Device;
2477 }
2478 device_on();
2479
2480 if (viafb_SAMM_ON == 1)
2481 viafb_write_reg_mask(CR6A, VIACR, 0xC0, BIT6 + BIT7);
2482
2483 device_screen_on();
2484 return 1;
2485}
2486
2487int viafb_get_pixclock(int hres, int vres, int vmode_refresh)
2488{
2489 int i;
2490
2491 for (i = 0; i < NUM_TOTAL_RES_MAP_REFRESH; i++) {
2492 if ((hres == res_map_refresh_tbl[i].hres)
2493 && (vres == res_map_refresh_tbl[i].vres)
2494 && (vmode_refresh == res_map_refresh_tbl[i].vmode_refresh))
2495 return res_map_refresh_tbl[i].pixclock;
2496 }
2497 return RES_640X480_60HZ_PIXCLOCK;
2498
2499}
2500
2501int viafb_get_refresh(int hres, int vres, u32 long_refresh)
2502{
2503#define REFRESH_TOLERANCE 3
2504 int i, nearest = -1, diff = REFRESH_TOLERANCE;
2505 for (i = 0; i < NUM_TOTAL_RES_MAP_REFRESH; i++) {
2506 if ((hres == res_map_refresh_tbl[i].hres)
2507 && (vres == res_map_refresh_tbl[i].vres)
2508 && (diff > (abs(long_refresh -
2509 res_map_refresh_tbl[i].vmode_refresh)))) {
2510 diff = abs(long_refresh - res_map_refresh_tbl[i].
2511 vmode_refresh);
2512 nearest = i;
2513 }
2514 }
2515#undef REFRESH_TOLERANCE
2516 if (nearest > 0)
2517 return res_map_refresh_tbl[nearest].vmode_refresh;
2518 return 60;
2519}
2520
2521static void device_off(void)
2522{
2523 viafb_crt_disable();
2524 viafb_dvi_disable();
2525 viafb_lcd_disable();
2526}
2527
2528static void device_on(void)
2529{
2530 if (viafb_CRT_ON == 1)
2531 viafb_crt_enable();
2532 if (viafb_DVI_ON == 1)
2533 viafb_dvi_enable();
2534 if (viafb_LCD_ON == 1)
2535 viafb_lcd_enable();
2536}
2537
2538void viafb_crt_disable(void)
2539{
2540 viafb_write_reg_mask(CR36, VIACR, BIT5 + BIT4, BIT5 + BIT4);
2541}
2542
2543void viafb_crt_enable(void)
2544{
2545 viafb_write_reg_mask(CR36, VIACR, 0x0, BIT5 + BIT4);
2546}
2547
2548void viafb_get_mmio_info(unsigned long *mmio_base,
2549 unsigned long *mmio_len)
2550{
2551 struct pci_dev *pdev = NULL;
2552 u32 vendor, device;
2553 u32 i;
2554
2555 for (i = 0; pciidlist[i].vendor != 0; i++)
2556 if (viaparinfo->chip_info->gfx_chip_name ==
2557 pciidlist[i].chip_index)
2558 break;
2559
2560 if (!pciidlist[i].vendor)
2561 return ;
2562
2563 vendor = pciidlist[i].vendor;
2564 device = pciidlist[i].device;
2565
2566 pdev = pci_get_device(vendor, device, NULL);
2567
2568 if (!pdev) {
2569 *mmio_base = 0;
2570 *mmio_len = 0;
2571 return ;
2572 }
2573
2574 *mmio_base = pci_resource_start(pdev, 1);
2575 *mmio_len = pci_resource_len(pdev, 1);
2576
2577 pci_dev_put(pdev);
2578}
2579
2580static void enable_second_display_channel(void)
2581{
2582 /* to enable second display channel. */
2583 viafb_write_reg_mask(CR6A, VIACR, 0x00, BIT6);
2584 viafb_write_reg_mask(CR6A, VIACR, BIT7, BIT7);
2585 viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
2586}
2587
2588static void disable_second_display_channel(void)
2589{
2590 /* to disable second display channel. */
2591 viafb_write_reg_mask(CR6A, VIACR, 0x00, BIT6);
2592 viafb_write_reg_mask(CR6A, VIACR, 0x00, BIT7);
2593 viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
2594}
2595
2596void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len)
2597{
2598 struct pci_dev *pdev = NULL;
2599 u32 vendor, device;
2600 u32 i;
2601
2602 for (i = 0; pciidlist[i].vendor != 0; i++)
2603 if (viaparinfo->chip_info->gfx_chip_name ==
2604 pciidlist[i].chip_index)
2605 break;
2606
2607 if (!pciidlist[i].vendor)
2608 return ;
2609
2610 vendor = pciidlist[i].vendor;
2611 device = pciidlist[i].device;
2612
2613 pdev = pci_get_device(vendor, device, NULL);
2614
2615 if (!pdev) {
2616 *fb_base = viafb_read_reg(VIASR, SR30) << 24;
2617 *fb_len = viafb_get_memsize();
2618 DEBUG_MSG(KERN_INFO "Get FB info from SR30!\n");
2619 DEBUG_MSG(KERN_INFO "fb_base = %08x\n", *fb_base);
2620 DEBUG_MSG(KERN_INFO "fb_len = %08x\n", *fb_len);
2621 return ;
2622 }
2623
2624 *fb_base = (unsigned int)pci_resource_start(pdev, 0);
2625 *fb_len = get_fb_size_from_pci();
2626 DEBUG_MSG(KERN_INFO "Get FB info from PCI system!\n");
2627 DEBUG_MSG(KERN_INFO "fb_base = %08x\n", *fb_base);
2628 DEBUG_MSG(KERN_INFO "fb_len = %08x\n", *fb_len);
2629
2630 pci_dev_put(pdev);
2631}
2632
2633static int get_fb_size_from_pci(void)
2634{
2635 unsigned long configid, deviceid, FBSize = 0;
2636 int VideoMemSize;
2637 int DeviceFound = false;
2638
2639 for (configid = 0x80000000; configid < 0x80010800; configid += 0x100) {
2640 outl(configid, (unsigned long)0xCF8);
2641 deviceid = (inl((unsigned long)0xCFC) >> 16) & 0xffff;
2642
2643 switch (deviceid) {
2644 case CLE266:
2645 case KM400:
2646 outl(configid + 0xE0, (unsigned long)0xCF8);
2647 FBSize = inl((unsigned long)0xCFC);
2648 DeviceFound = true; /* Found device id */
2649 break;
2650
2651 case CN400_FUNCTION3:
2652 case CN700_FUNCTION3:
2653 case CX700_FUNCTION3:
2654 case KM800_FUNCTION3:
2655 case KM890_FUNCTION3:
2656 case P4M890_FUNCTION3:
2657 case P4M900_FUNCTION3:
2658 case VX800_FUNCTION3:
2659 /*case CN750_FUNCTION3: */
2660 outl(configid + 0xA0, (unsigned long)0xCF8);
2661 FBSize = inl((unsigned long)0xCFC);
2662 DeviceFound = true; /* Found device id */
2663 break;
2664
2665 default:
2666 break;
2667 }
2668
2669 if (DeviceFound)
2670 break;
2671 }
2672
2673 DEBUG_MSG(KERN_INFO "Device ID = %lx\n", deviceid);
2674
2675 FBSize = FBSize & 0x00007000;
2676 DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
2677
2678 if (viaparinfo->chip_info->gfx_chip_name < UNICHROME_CX700) {
2679 switch (FBSize) {
2680 case 0x00004000:
2681 VideoMemSize = (16 << 20); /*16M */
2682 break;
2683
2684 case 0x00005000:
2685 VideoMemSize = (32 << 20); /*32M */
2686 break;
2687
2688 case 0x00006000:
2689 VideoMemSize = (64 << 20); /*64M */
2690 break;
2691
2692 default:
2693 VideoMemSize = (32 << 20); /*32M */
2694 break;
2695 }
2696 } else {
2697 switch (FBSize) {
2698 case 0x00001000:
2699 VideoMemSize = (8 << 20); /*8M */
2700 break;
2701
2702 case 0x00002000:
2703 VideoMemSize = (16 << 20); /*16M */
2704 break;
2705
2706 case 0x00003000:
2707 VideoMemSize = (32 << 20); /*32M */
2708 break;
2709
2710 case 0x00004000:
2711 VideoMemSize = (64 << 20); /*64M */
2712 break;
2713
2714 case 0x00005000:
2715 VideoMemSize = (128 << 20); /*128M */
2716 break;
2717
2718 case 0x00006000:
2719 VideoMemSize = (256 << 20); /*256M */
2720 break;
2721
2722 default:
2723 VideoMemSize = (32 << 20); /*32M */
2724 break;
2725 }
2726 }
2727
2728 return VideoMemSize;
2729}
2730
2731void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
2732 *p_gfx_dpa_setting)
2733{
2734 switch (output_interface) {
2735 case INTERFACE_DVP0:
2736 {
2737 /* DVP0 Clock Polarity and Adjust: */
2738 viafb_write_reg_mask(CR96, VIACR,
2739 p_gfx_dpa_setting->DVP0, 0x0F);
2740
2741 /* DVP0 Clock and Data Pads Driving: */
2742 viafb_write_reg_mask(SR1E, VIASR,
2743 p_gfx_dpa_setting->DVP0ClockDri_S, BIT2);
2744 viafb_write_reg_mask(SR2A, VIASR,
2745 p_gfx_dpa_setting->DVP0ClockDri_S1,
2746 BIT4);
2747 viafb_write_reg_mask(SR1B, VIASR,
2748 p_gfx_dpa_setting->DVP0DataDri_S, BIT1);
2749 viafb_write_reg_mask(SR2A, VIASR,
2750 p_gfx_dpa_setting->DVP0DataDri_S1, BIT5);
2751 break;
2752 }
2753
2754 case INTERFACE_DVP1:
2755 {
2756 /* DVP1 Clock Polarity and Adjust: */
2757 viafb_write_reg_mask(CR9B, VIACR,
2758 p_gfx_dpa_setting->DVP1, 0x0F);
2759
2760 /* DVP1 Clock and Data Pads Driving: */
2761 viafb_write_reg_mask(SR65, VIASR,
2762 p_gfx_dpa_setting->DVP1Driving, 0x0F);
2763 break;
2764 }
2765
2766 case INTERFACE_DFP_HIGH:
2767 {
2768 viafb_write_reg_mask(CR97, VIACR,
2769 p_gfx_dpa_setting->DFPHigh, 0x0F);
2770 break;
2771 }
2772
2773 case INTERFACE_DFP_LOW:
2774 {
2775 viafb_write_reg_mask(CR99, VIACR,
2776 p_gfx_dpa_setting->DFPLow, 0x0F);
2777 break;
2778 }
2779
2780 case INTERFACE_DFP:
2781 {
2782 viafb_write_reg_mask(CR97, VIACR,
2783 p_gfx_dpa_setting->DFPHigh, 0x0F);
2784 viafb_write_reg_mask(CR99, VIACR,
2785 p_gfx_dpa_setting->DFPLow, 0x0F);
2786 break;
2787 }
2788 }
2789}
2790
2791void viafb_memory_pitch_patch(struct fb_info *info)
2792{
2793 if (info->var.xres != info->var.xres_virtual) {
2794 viafb_load_offset_reg(info->var.xres_virtual,
2795 info->var.bits_per_pixel >> 3, IGA1);
2796
2797 if (viafb_SAMM_ON) {
2798 viafb_load_offset_reg(viafb_second_virtual_xres,
2799 viafb_bpp1 >> 3,
2800 IGA2);
2801 } else {
2802 viafb_load_offset_reg(info->var.xres_virtual,
2803 info->var.bits_per_pixel >> 3, IGA2);
2804 }
2805
2806 }
2807}
2808
2809/*According var's xres, yres fill var's other timing information*/
2810void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
2811 int mode_index)
2812{
2813 struct VideoModeTable *vmode_tbl = NULL;
2814 struct crt_mode_table *crt_timing = NULL;
2815 struct display_timing crt_reg;
2816 int i = 0, index = 0;
2817 vmode_tbl = &CLE266Modes[search_mode_setting(mode_index)];
2818 crt_timing = vmode_tbl->crtc;
2819 for (i = 0; i < vmode_tbl->mode_array; i++) {
2820 index = i;
2821 if (crt_timing[i].refresh_rate == refresh)
2822 break;
2823 }
2824
2825 crt_reg = crt_timing[index].crtc;
2826 switch (var->bits_per_pixel) {
2827 case 8:
2828 var->red.offset = 0;
2829 var->green.offset = 0;
2830 var->blue.offset = 0;
2831 var->red.length = 6;
2832 var->green.length = 6;
2833 var->blue.length = 6;
2834 break;
2835 case 16:
2836 var->red.offset = 11;
2837 var->green.offset = 5;
2838 var->blue.offset = 0;
2839 var->red.length = 5;
2840 var->green.length = 6;
2841 var->blue.length = 5;
2842 break;
2843 case 32:
2844 var->red.offset = 16;
2845 var->green.offset = 8;
2846 var->blue.offset = 0;
2847 var->red.length = 8;
2848 var->green.length = 8;
2849 var->blue.length = 8;
2850 break;
2851 default:
2852 /* never happed, put here to keep consistent */
2853 break;
2854 }
2855
2856 var->pixclock = viafb_get_pixclock(var->xres, var->yres, refresh);
2857 var->left_margin =
2858 crt_reg.hor_total - (crt_reg.hor_sync_start + crt_reg.hor_sync_end);
2859 var->right_margin = crt_reg.hor_sync_start - crt_reg.hor_addr;
2860 var->hsync_len = crt_reg.hor_sync_end;
2861 var->upper_margin =
2862 crt_reg.ver_total - (crt_reg.ver_sync_start + crt_reg.ver_sync_end);
2863 var->lower_margin = crt_reg.ver_sync_start - crt_reg.ver_addr;
2864 var->vsync_len = crt_reg.ver_sync_end;
2865}
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
new file mode 100644
index 000000000000..6ff38fa8569a
--- /dev/null
+++ b/drivers/video/via/hw.h
@@ -0,0 +1,933 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __HW_H__
23#define __HW_H__
24
25#include "global.h"
26
27/***************************************************
28* Definition IGA1 Design Method of CRTC Registers *
29****************************************************/
30#define IGA1_HOR_TOTAL_FORMULA(x) (((x)/8)-5)
31#define IGA1_HOR_ADDR_FORMULA(x) (((x)/8)-1)
32#define IGA1_HOR_BLANK_START_FORMULA(x) (((x)/8)-1)
33#define IGA1_HOR_BLANK_END_FORMULA(x, y) (((x+y)/8)-1)
34#define IGA1_HOR_SYNC_START_FORMULA(x) ((x)/8)
35#define IGA1_HOR_SYNC_END_FORMULA(x, y) ((x+y)/8)
36
37#define IGA1_VER_TOTAL_FORMULA(x) ((x)-2)
38#define IGA1_VER_ADDR_FORMULA(x) ((x)-1)
39#define IGA1_VER_BLANK_START_FORMULA(x) ((x)-1)
40#define IGA1_VER_BLANK_END_FORMULA(x, y) ((x+y)-1)
41#define IGA1_VER_SYNC_START_FORMULA(x) ((x)-1)
42#define IGA1_VER_SYNC_END_FORMULA(x, y) ((x+y)-1)
43
44/***************************************************
45** Definition IGA2 Design Method of CRTC Registers *
46****************************************************/
47#define IGA2_HOR_TOTAL_FORMULA(x) ((x)-1)
48#define IGA2_HOR_ADDR_FORMULA(x) ((x)-1)
49#define IGA2_HOR_BLANK_START_FORMULA(x) ((x)-1)
50#define IGA2_HOR_BLANK_END_FORMULA(x, y) ((x+y)-1)
51#define IGA2_HOR_SYNC_START_FORMULA(x) ((x)-1)
52#define IGA2_HOR_SYNC_END_FORMULA(x, y) ((x+y)-1)
53
54#define IGA2_VER_TOTAL_FORMULA(x) ((x)-1)
55#define IGA2_VER_ADDR_FORMULA(x) ((x)-1)
56#define IGA2_VER_BLANK_START_FORMULA(x) ((x)-1)
57#define IGA2_VER_BLANK_END_FORMULA(x, y) ((x+y)-1)
58#define IGA2_VER_SYNC_START_FORMULA(x) ((x)-1)
59#define IGA2_VER_SYNC_END_FORMULA(x, y) ((x+y)-1)
60
61/**********************************************************/
62/* Definition IGA2 Design Method of CRTC Shadow Registers */
63/**********************************************************/
64#define IGA2_HOR_TOTAL_SHADOW_FORMULA(x) ((x/8)-5)
65#define IGA2_HOR_BLANK_END_SHADOW_FORMULA(x, y) (((x+y)/8)-1)
66#define IGA2_VER_TOTAL_SHADOW_FORMULA(x) ((x)-2)
67#define IGA2_VER_ADDR_SHADOW_FORMULA(x) ((x)-1)
68#define IGA2_VER_BLANK_START_SHADOW_FORMULA(x) ((x)-1)
69#define IGA2_VER_BLANK_END_SHADOW_FORMULA(x, y) ((x+y)-1)
70#define IGA2_VER_SYNC_START_SHADOW_FORMULA(x) (x)
71#define IGA2_VER_SYNC_END_SHADOW_FORMULA(x, y) (x+y)
72
73/* Define Register Number for IGA1 CRTC Timing */
74
75/* location: {CR00,0,7},{CR36,3,3} */
76#define IGA1_HOR_TOTAL_REG_NUM 2
77/* location: {CR01,0,7} */
78#define IGA1_HOR_ADDR_REG_NUM 1
79/* location: {CR02,0,7} */
80#define IGA1_HOR_BLANK_START_REG_NUM 1
81/* location: {CR03,0,4},{CR05,7,7},{CR33,5,5} */
82#define IGA1_HOR_BLANK_END_REG_NUM 3
83/* location: {CR04,0,7},{CR33,4,4} */
84#define IGA1_HOR_SYNC_START_REG_NUM 2
85/* location: {CR05,0,4} */
86#define IGA1_HOR_SYNC_END_REG_NUM 1
87/* location: {CR06,0,7},{CR07,0,0},{CR07,5,5},{CR35,0,0} */
88#define IGA1_VER_TOTAL_REG_NUM 4
89/* location: {CR12,0,7},{CR07,1,1},{CR07,6,6},{CR35,2,2} */
90#define IGA1_VER_ADDR_REG_NUM 4
91/* location: {CR15,0,7},{CR07,3,3},{CR09,5,5},{CR35,3,3} */
92#define IGA1_VER_BLANK_START_REG_NUM 4
93/* location: {CR16,0,7} */
94#define IGA1_VER_BLANK_END_REG_NUM 1
95/* location: {CR10,0,7},{CR07,2,2},{CR07,7,7},{CR35,1,1} */
96#define IGA1_VER_SYNC_START_REG_NUM 4
97/* location: {CR11,0,3} */
98#define IGA1_VER_SYNC_END_REG_NUM 1
99
100/* Define Register Number for IGA2 Shadow CRTC Timing */
101
102/* location: {CR6D,0,7},{CR71,3,3} */
103#define IGA2_SHADOW_HOR_TOTAL_REG_NUM 2
104/* location: {CR6E,0,7} */
105#define IGA2_SHADOW_HOR_BLANK_END_REG_NUM 1
106/* location: {CR6F,0,7},{CR71,0,2} */
107#define IGA2_SHADOW_VER_TOTAL_REG_NUM 2
108/* location: {CR70,0,7},{CR71,4,6} */
109#define IGA2_SHADOW_VER_ADDR_REG_NUM 2
110/* location: {CR72,0,7},{CR74,4,6} */
111#define IGA2_SHADOW_VER_BLANK_START_REG_NUM 2
112/* location: {CR73,0,7},{CR74,0,2} */
113#define IGA2_SHADOW_VER_BLANK_END_REG_NUM 2
114/* location: {CR75,0,7},{CR76,4,6} */
115#define IGA2_SHADOW_VER_SYNC_START_REG_NUM 2
116/* location: {CR76,0,3} */
117#define IGA2_SHADOW_VER_SYNC_END_REG_NUM 1
118
119/* Define Register Number for IGA2 CRTC Timing */
120
121/* location: {CR50,0,7},{CR55,0,3} */
122#define IGA2_HOR_TOTAL_REG_NUM 2
123/* location: {CR51,0,7},{CR55,4,6} */
124#define IGA2_HOR_ADDR_REG_NUM 2
125/* location: {CR52,0,7},{CR54,0,2} */
126#define IGA2_HOR_BLANK_START_REG_NUM 2
127/* location: CLE266: {CR53,0,7},{CR54,3,5} => CLE266's CR5D[6]
128is reserved, so it may have problem to set 1600x1200 on IGA2. */
129/* Others: {CR53,0,7},{CR54,3,5},{CR5D,6,6} */
130#define IGA2_HOR_BLANK_END_REG_NUM 3
131/* location: {CR56,0,7},{CR54,6,7},{CR5C,7,7} */
132/* VT3314 and Later: {CR56,0,7},{CR54,6,7},{CR5C,7,7}, {CR5D,7,7} */
133#define IGA2_HOR_SYNC_START_REG_NUM 4
134
135/* location: {CR57,0,7},{CR5C,6,6} */
136#define IGA2_HOR_SYNC_END_REG_NUM 2
137/* location: {CR58,0,7},{CR5D,0,2} */
138#define IGA2_VER_TOTAL_REG_NUM 2
139/* location: {CR59,0,7},{CR5D,3,5} */
140#define IGA2_VER_ADDR_REG_NUM 2
141/* location: {CR5A,0,7},{CR5C,0,2} */
142#define IGA2_VER_BLANK_START_REG_NUM 2
143/* location: {CR5E,0,7},{CR5C,3,5} */
144#define IGA2_VER_BLANK_END_REG_NUM 2
145/* location: {CR5E,0,7},{CR5F,5,7} */
146#define IGA2_VER_SYNC_START_REG_NUM 2
147/* location: {CR5F,0,4} */
148#define IGA2_VER_SYNC_END_REG_NUM 1
149
150/* Define Offset and Fetch Count Register*/
151
152/* location: {CR13,0,7},{CR35,5,7} */
153#define IGA1_OFFSET_REG_NUM 2
154/* 8 bytes alignment. */
155#define IGA1_OFFSER_ALIGN_BYTE 8
156/* x: H resolution, y: color depth */
157#define IGA1_OFFSET_FORMULA(x, y) ((x*y)/IGA1_OFFSER_ALIGN_BYTE)
158/* location: {SR1C,0,7},{SR1D,0,1} */
159#define IGA1_FETCH_COUNT_REG_NUM 2
160/* 16 bytes alignment. */
161#define IGA1_FETCH_COUNT_ALIGN_BYTE 16
162/* x: H resolution, y: color depth */
163#define IGA1_FETCH_COUNT_PATCH_VALUE 4
164#define IGA1_FETCH_COUNT_FORMULA(x, y) \
165 (((x*y)/IGA1_FETCH_COUNT_ALIGN_BYTE) + IGA1_FETCH_COUNT_PATCH_VALUE)
166
167/* location: {CR66,0,7},{CR67,0,1} */
168#define IGA2_OFFSET_REG_NUM 2
169#define IGA2_OFFSET_ALIGN_BYTE 8
170/* x: H resolution, y: color depth */
171#define IGA2_OFFSET_FORMULA(x, y) ((x*y)/IGA2_OFFSET_ALIGN_BYTE)
172/* location: {CR65,0,7},{CR67,2,3} */
173#define IGA2_FETCH_COUNT_REG_NUM 2
174#define IGA2_FETCH_COUNT_ALIGN_BYTE 16
175#define IGA2_FETCH_COUNT_PATCH_VALUE 0
176#define IGA2_FETCH_COUNT_FORMULA(x, y) \
177 (((x*y)/IGA2_FETCH_COUNT_ALIGN_BYTE) + IGA2_FETCH_COUNT_PATCH_VALUE)
178
179/* Staring Address*/
180
181/* location: {CR0C,0,7},{CR0D,0,7},{CR34,0,7},{CR48,0,1} */
182#define IGA1_STARTING_ADDR_REG_NUM 4
183/* location: {CR62,1,7},{CR63,0,7},{CR64,0,7} */
184#define IGA2_STARTING_ADDR_REG_NUM 3
185
186/* Define Display OFFSET*/
187/* These value are by HW suggested value*/
188/* location: {SR17,0,7} */
189#define K800_IGA1_FIFO_MAX_DEPTH 384
190/* location: {SR16,0,5},{SR16,7,7} */
191#define K800_IGA1_FIFO_THRESHOLD 328
192/* location: {SR18,0,5},{SR18,7,7} */
193#define K800_IGA1_FIFO_HIGH_THRESHOLD 296
194/* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
195 /* because HW only 5 bits */
196#define K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
197
198/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
199#define K800_IGA2_FIFO_MAX_DEPTH 384
200/* location: {CR68,0,3},{CR95,4,6} */
201#define K800_IGA2_FIFO_THRESHOLD 328
202/* location: {CR92,0,3},{CR95,0,2} */
203#define K800_IGA2_FIFO_HIGH_THRESHOLD 296
204/* location: {CR94,0,6} */
205#define K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
206
207/* location: {SR17,0,7} */
208#define P880_IGA1_FIFO_MAX_DEPTH 192
209/* location: {SR16,0,5},{SR16,7,7} */
210#define P880_IGA1_FIFO_THRESHOLD 128
211/* location: {SR18,0,5},{SR18,7,7} */
212#define P880_IGA1_FIFO_HIGH_THRESHOLD 64
213/* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
214 /* because HW only 5 bits */
215#define P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
216
217/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
218#define P880_IGA2_FIFO_MAX_DEPTH 96
219/* location: {CR68,0,3},{CR95,4,6} */
220#define P880_IGA2_FIFO_THRESHOLD 64
221/* location: {CR92,0,3},{CR95,0,2} */
222#define P880_IGA2_FIFO_HIGH_THRESHOLD 32
223/* location: {CR94,0,6} */
224#define P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
225
226/* VT3314 chipset*/
227
228/* location: {SR17,0,7} */
229#define CN700_IGA1_FIFO_MAX_DEPTH 96
230/* location: {SR16,0,5},{SR16,7,7} */
231#define CN700_IGA1_FIFO_THRESHOLD 80
232/* location: {SR18,0,5},{SR18,7,7} */
233#define CN700_IGA1_FIFO_HIGH_THRESHOLD 64
234/* location: {SR22,0,4}. (128/4) =64, P800 must be set zero,
235 because HW only 5 bits */
236#define CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
237/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
238#define CN700_IGA2_FIFO_MAX_DEPTH 96
239/* location: {CR68,0,3},{CR95,4,6} */
240#define CN700_IGA2_FIFO_THRESHOLD 80
241/* location: {CR92,0,3},{CR95,0,2} */
242#define CN700_IGA2_FIFO_HIGH_THRESHOLD 32
243/* location: {CR94,0,6} */
244#define CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
245
246/* For VT3324, these values are suggested by HW */
247/* location: {SR17,0,7} */
248#define CX700_IGA1_FIFO_MAX_DEPTH 192
249/* location: {SR16,0,5},{SR16,7,7} */
250#define CX700_IGA1_FIFO_THRESHOLD 128
251/* location: {SR18,0,5},{SR18,7,7} */
252#define CX700_IGA1_FIFO_HIGH_THRESHOLD 128
253/* location: {SR22,0,4} */
254#define CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
255
256/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
257#define CX700_IGA2_FIFO_MAX_DEPTH 96
258/* location: {CR68,0,3},{CR95,4,6} */
259#define CX700_IGA2_FIFO_THRESHOLD 64
260/* location: {CR92,0,3},{CR95,0,2} */
261#define CX700_IGA2_FIFO_HIGH_THRESHOLD 32
262/* location: {CR94,0,6} */
263#define CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
264
265/* VT3336 chipset*/
266/* location: {SR17,0,7} */
267#define K8M890_IGA1_FIFO_MAX_DEPTH 360
268/* location: {SR16,0,5},{SR16,7,7} */
269#define K8M890_IGA1_FIFO_THRESHOLD 328
270/* location: {SR18,0,5},{SR18,7,7} */
271#define K8M890_IGA1_FIFO_HIGH_THRESHOLD 296
272/* location: {SR22,0,4}. */
273#define K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
274
275/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
276#define K8M890_IGA2_FIFO_MAX_DEPTH 360
277/* location: {CR68,0,3},{CR95,4,6} */
278#define K8M890_IGA2_FIFO_THRESHOLD 328
279/* location: {CR92,0,3},{CR95,0,2} */
280#define K8M890_IGA2_FIFO_HIGH_THRESHOLD 296
281/* location: {CR94,0,6} */
282#define K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 124
283
284/* VT3327 chipset*/
285/* location: {SR17,0,7} */
286#define P4M890_IGA1_FIFO_MAX_DEPTH 96
287/* location: {SR16,0,5},{SR16,7,7} */
288#define P4M890_IGA1_FIFO_THRESHOLD 76
289/* location: {SR18,0,5},{SR18,7,7} */
290#define P4M890_IGA1_FIFO_HIGH_THRESHOLD 64
291/* location: {SR22,0,4}. (32/4) =8 */
292#define P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
293/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
294#define P4M890_IGA2_FIFO_MAX_DEPTH 96
295/* location: {CR68,0,3},{CR95,4,6} */
296#define P4M890_IGA2_FIFO_THRESHOLD 76
297/* location: {CR92,0,3},{CR95,0,2} */
298#define P4M890_IGA2_FIFO_HIGH_THRESHOLD 64
299/* location: {CR94,0,6} */
300#define P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
301
302/* VT3364 chipset*/
303/* location: {SR17,0,7} */
304#define P4M900_IGA1_FIFO_MAX_DEPTH 96
305/* location: {SR16,0,5},{SR16,7,7} */
306#define P4M900_IGA1_FIFO_THRESHOLD 76
307/* location: {SR18,0,5},{SR18,7,7} */
308#define P4M900_IGA1_FIFO_HIGH_THRESHOLD 76
309/* location: {SR22,0,4}. */
310#define P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
311/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
312#define P4M900_IGA2_FIFO_MAX_DEPTH 96
313/* location: {CR68,0,3},{CR95,4,6} */
314#define P4M900_IGA2_FIFO_THRESHOLD 76
315/* location: {CR92,0,3},{CR95,0,2} */
316#define P4M900_IGA2_FIFO_HIGH_THRESHOLD 76
317/* location: {CR94,0,6} */
318#define P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
319
320/* For VT3353, these values are suggested by HW */
321/* location: {SR17,0,7} */
322#define VX800_IGA1_FIFO_MAX_DEPTH 192
323/* location: {SR16,0,5},{SR16,7,7} */
324#define VX800_IGA1_FIFO_THRESHOLD 152
325/* location: {SR18,0,5},{SR18,7,7} */
326#define VX800_IGA1_FIFO_HIGH_THRESHOLD 152
327/* location: {SR22,0,4} */
328#define VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 64
329/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
330#define VX800_IGA2_FIFO_MAX_DEPTH 96
331/* location: {CR68,0,3},{CR95,4,6} */
332#define VX800_IGA2_FIFO_THRESHOLD 64
333/* location: {CR92,0,3},{CR95,0,2} */
334#define VX800_IGA2_FIFO_HIGH_THRESHOLD 32
335/* location: {CR94,0,6} */
336#define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
337
338#define IGA1_FIFO_DEPTH_SELECT_REG_NUM 1
339#define IGA1_FIFO_THRESHOLD_REG_NUM 2
340#define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM 2
341#define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
342
343#define IGA2_FIFO_DEPTH_SELECT_REG_NUM 3
344#define IGA2_FIFO_THRESHOLD_REG_NUM 2
345#define IGA2_FIFO_HIGH_THRESHOLD_REG_NUM 2
346#define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
347
348#define IGA1_FIFO_DEPTH_SELECT_FORMULA(x) ((x/2)-1)
349#define IGA1_FIFO_THRESHOLD_FORMULA(x) (x/4)
350#define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
351#define IGA1_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
352#define IGA2_FIFO_DEPTH_SELECT_FORMULA(x) (((x/2)/4)-1)
353#define IGA2_FIFO_THRESHOLD_FORMULA(x) (x/4)
354#define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
355#define IGA2_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
356
357/************************************************************************/
358/* LCD Timing */
359/************************************************************************/
360
361/* 500 ms = 500000 us */
362#define LCD_POWER_SEQ_TD0 500000
363/* 50 ms = 50000 us */
364#define LCD_POWER_SEQ_TD1 50000
365/* 0 us */
366#define LCD_POWER_SEQ_TD2 0
367/* 210 ms = 210000 us */
368#define LCD_POWER_SEQ_TD3 210000
369/* 2^10 * (1/14.31818M) = 71.475 us (K400.revA) */
370#define CLE266_POWER_SEQ_UNIT 71
371/* 2^11 * (1/14.31818M) = 142.95 us (K400.revB) */
372#define K800_POWER_SEQ_UNIT 142
373/* 2^13 * (1/14.31818M) = 572.1 us */
374#define P880_POWER_SEQ_UNIT 572
375
376#define CLE266_POWER_SEQ_FORMULA(x) ((x)/CLE266_POWER_SEQ_UNIT)
377#define K800_POWER_SEQ_FORMULA(x) ((x)/K800_POWER_SEQ_UNIT)
378#define P880_POWER_SEQ_FORMULA(x) ((x)/P880_POWER_SEQ_UNIT)
379
380/* location: {CR8B,0,7},{CR8F,0,3} */
381#define LCD_POWER_SEQ_TD0_REG_NUM 2
382/* location: {CR8C,0,7},{CR8F,4,7} */
383#define LCD_POWER_SEQ_TD1_REG_NUM 2
384/* location: {CR8D,0,7},{CR90,0,3} */
385#define LCD_POWER_SEQ_TD2_REG_NUM 2
386/* location: {CR8E,0,7},{CR90,4,7} */
387#define LCD_POWER_SEQ_TD3_REG_NUM 2
388
389/* LCD Scaling factor*/
390/* x: indicate setting horizontal size*/
391/* y: indicate panel horizontal size*/
392
393/* Horizontal scaling factor 10 bits (2^10) */
394#define CLE266_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
395/* Vertical scaling factor 10 bits (2^10) */
396#define CLE266_LCD_VER_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
397/* Horizontal scaling factor 10 bits (2^12) */
398#define K800_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*4096)/(y-1))
399/* Vertical scaling factor 10 bits (2^11) */
400#define K800_LCD_VER_SCF_FORMULA(x, y) (((x-1)*2048)/(y-1))
401
402/* location: {CR9F,0,1},{CR77,0,7},{CR79,4,5} */
403#define LCD_HOR_SCALING_FACTOR_REG_NUM 3
404/* location: {CR79,3,3},{CR78,0,7},{CR79,6,7} */
405#define LCD_VER_SCALING_FACTOR_REG_NUM 3
406/* location: {CR77,0,7},{CR79,4,5} */
407#define LCD_HOR_SCALING_FACTOR_REG_NUM_CLE 2
408/* location: {CR78,0,7},{CR79,6,7} */
409#define LCD_VER_SCALING_FACTOR_REG_NUM_CLE 2
410
411/************************************************
412 ***** Define IGA1 Display Timing *****
413 ************************************************/
414struct io_register {
415 u8 io_addr;
416 u8 start_bit;
417 u8 end_bit;
418};
419
420/* IGA1 Horizontal Total */
421struct iga1_hor_total {
422 int reg_num;
423 struct io_register reg[IGA1_HOR_TOTAL_REG_NUM];
424};
425
426/* IGA1 Horizontal Addressable Video */
427struct iga1_hor_addr {
428 int reg_num;
429 struct io_register reg[IGA1_HOR_ADDR_REG_NUM];
430};
431
432/* IGA1 Horizontal Blank Start */
433struct iga1_hor_blank_start {
434 int reg_num;
435 struct io_register reg[IGA1_HOR_BLANK_START_REG_NUM];
436};
437
438/* IGA1 Horizontal Blank End */
439struct iga1_hor_blank_end {
440 int reg_num;
441 struct io_register reg[IGA1_HOR_BLANK_END_REG_NUM];
442};
443
444/* IGA1 Horizontal Sync Start */
445struct iga1_hor_sync_start {
446 int reg_num;
447 struct io_register reg[IGA1_HOR_SYNC_START_REG_NUM];
448};
449
450/* IGA1 Horizontal Sync End */
451struct iga1_hor_sync_end {
452 int reg_num;
453 struct io_register reg[IGA1_HOR_SYNC_END_REG_NUM];
454};
455
456/* IGA1 Vertical Total */
457struct iga1_ver_total {
458 int reg_num;
459 struct io_register reg[IGA1_VER_TOTAL_REG_NUM];
460};
461
462/* IGA1 Vertical Addressable Video */
463struct iga1_ver_addr {
464 int reg_num;
465 struct io_register reg[IGA1_VER_ADDR_REG_NUM];
466};
467
468/* IGA1 Vertical Blank Start */
469struct iga1_ver_blank_start {
470 int reg_num;
471 struct io_register reg[IGA1_VER_BLANK_START_REG_NUM];
472};
473
474/* IGA1 Vertical Blank End */
475struct iga1_ver_blank_end {
476 int reg_num;
477 struct io_register reg[IGA1_VER_BLANK_END_REG_NUM];
478};
479
480/* IGA1 Vertical Sync Start */
481struct iga1_ver_sync_start {
482 int reg_num;
483 struct io_register reg[IGA1_VER_SYNC_START_REG_NUM];
484};
485
486/* IGA1 Vertical Sync End */
487struct iga1_ver_sync_end {
488 int reg_num;
489 struct io_register reg[IGA1_VER_SYNC_END_REG_NUM];
490};
491
492/*****************************************************
493** Define IGA2 Shadow Display Timing ****
494*****************************************************/
495
496/* IGA2 Shadow Horizontal Total */
497struct iga2_shadow_hor_total {
498 int reg_num;
499 struct io_register reg[IGA2_SHADOW_HOR_TOTAL_REG_NUM];
500};
501
502/* IGA2 Shadow Horizontal Blank End */
503struct iga2_shadow_hor_blank_end {
504 int reg_num;
505 struct io_register reg[IGA2_SHADOW_HOR_BLANK_END_REG_NUM];
506};
507
508/* IGA2 Shadow Vertical Total */
509struct iga2_shadow_ver_total {
510 int reg_num;
511 struct io_register reg[IGA2_SHADOW_VER_TOTAL_REG_NUM];
512};
513
514/* IGA2 Shadow Vertical Addressable Video */
515struct iga2_shadow_ver_addr {
516 int reg_num;
517 struct io_register reg[IGA2_SHADOW_VER_ADDR_REG_NUM];
518};
519
520/* IGA2 Shadow Vertical Blank Start */
521struct iga2_shadow_ver_blank_start {
522 int reg_num;
523 struct io_register reg[IGA2_SHADOW_VER_BLANK_START_REG_NUM];
524};
525
526/* IGA2 Shadow Vertical Blank End */
527struct iga2_shadow_ver_blank_end {
528 int reg_num;
529 struct io_register reg[IGA2_SHADOW_VER_BLANK_END_REG_NUM];
530};
531
532/* IGA2 Shadow Vertical Sync Start */
533struct iga2_shadow_ver_sync_start {
534 int reg_num;
535 struct io_register reg[IGA2_SHADOW_VER_SYNC_START_REG_NUM];
536};
537
538/* IGA2 Shadow Vertical Sync End */
539struct iga2_shadow_ver_sync_end {
540 int reg_num;
541 struct io_register reg[IGA2_SHADOW_VER_SYNC_END_REG_NUM];
542};
543
544/*****************************************************
545** Define IGA2 Display Timing ****
546******************************************************/
547
548/* IGA2 Horizontal Total */
549struct iga2_hor_total {
550 int reg_num;
551 struct io_register reg[IGA2_HOR_TOTAL_REG_NUM];
552};
553
554/* IGA2 Horizontal Addressable Video */
555struct iga2_hor_addr {
556 int reg_num;
557 struct io_register reg[IGA2_HOR_ADDR_REG_NUM];
558};
559
560/* IGA2 Horizontal Blank Start */
561struct iga2_hor_blank_start {
562 int reg_num;
563 struct io_register reg[IGA2_HOR_BLANK_START_REG_NUM];
564};
565
566/* IGA2 Horizontal Blank End */
567struct iga2_hor_blank_end {
568 int reg_num;
569 struct io_register reg[IGA2_HOR_BLANK_END_REG_NUM];
570};
571
572/* IGA2 Horizontal Sync Start */
573struct iga2_hor_sync_start {
574 int reg_num;
575 struct io_register reg[IGA2_HOR_SYNC_START_REG_NUM];
576};
577
578/* IGA2 Horizontal Sync End */
579struct iga2_hor_sync_end {
580 int reg_num;
581 struct io_register reg[IGA2_HOR_SYNC_END_REG_NUM];
582};
583
584/* IGA2 Vertical Total */
585struct iga2_ver_total {
586 int reg_num;
587 struct io_register reg[IGA2_VER_TOTAL_REG_NUM];
588};
589
590/* IGA2 Vertical Addressable Video */
591struct iga2_ver_addr {
592 int reg_num;
593 struct io_register reg[IGA2_VER_ADDR_REG_NUM];
594};
595
596/* IGA2 Vertical Blank Start */
597struct iga2_ver_blank_start {
598 int reg_num;
599 struct io_register reg[IGA2_VER_BLANK_START_REG_NUM];
600};
601
602/* IGA2 Vertical Blank End */
603struct iga2_ver_blank_end {
604 int reg_num;
605 struct io_register reg[IGA2_VER_BLANK_END_REG_NUM];
606};
607
608/* IGA2 Vertical Sync Start */
609struct iga2_ver_sync_start {
610 int reg_num;
611 struct io_register reg[IGA2_VER_SYNC_START_REG_NUM];
612};
613
614/* IGA2 Vertical Sync End */
615struct iga2_ver_sync_end {
616 int reg_num;
617 struct io_register reg[IGA2_VER_SYNC_END_REG_NUM];
618};
619
620/* IGA1 Offset Register */
621struct iga1_offset {
622 int reg_num;
623 struct io_register reg[IGA1_OFFSET_REG_NUM];
624};
625
626/* IGA2 Offset Register */
627struct iga2_offset {
628 int reg_num;
629 struct io_register reg[IGA2_OFFSET_REG_NUM];
630};
631
632struct offset {
633 struct iga1_offset iga1_offset_reg;
634 struct iga2_offset iga2_offset_reg;
635};
636
637/* IGA1 Fetch Count Register */
638struct iga1_fetch_count {
639 int reg_num;
640 struct io_register reg[IGA1_FETCH_COUNT_REG_NUM];
641};
642
643/* IGA2 Fetch Count Register */
644struct iga2_fetch_count {
645 int reg_num;
646 struct io_register reg[IGA2_FETCH_COUNT_REG_NUM];
647};
648
649struct fetch_count {
650 struct iga1_fetch_count iga1_fetch_count_reg;
651 struct iga2_fetch_count iga2_fetch_count_reg;
652};
653
654/* Starting Address Register */
655struct iga1_starting_addr {
656 int reg_num;
657 struct io_register reg[IGA1_STARTING_ADDR_REG_NUM];
658};
659
660struct iga2_starting_addr {
661 int reg_num;
662 struct io_register reg[IGA2_STARTING_ADDR_REG_NUM];
663};
664
665struct starting_addr {
666 struct iga1_starting_addr iga1_starting_addr_reg;
667 struct iga2_starting_addr iga2_starting_addr_reg;
668};
669
670/* LCD Power Sequence Timer */
671struct lcd_pwd_seq_td0 {
672 int reg_num;
673 struct io_register reg[LCD_POWER_SEQ_TD0_REG_NUM];
674};
675
676struct lcd_pwd_seq_td1 {
677 int reg_num;
678 struct io_register reg[LCD_POWER_SEQ_TD1_REG_NUM];
679};
680
681struct lcd_pwd_seq_td2 {
682 int reg_num;
683 struct io_register reg[LCD_POWER_SEQ_TD2_REG_NUM];
684};
685
686struct lcd_pwd_seq_td3 {
687 int reg_num;
688 struct io_register reg[LCD_POWER_SEQ_TD3_REG_NUM];
689};
690
691struct _lcd_pwd_seq_timer {
692 struct lcd_pwd_seq_td0 td0;
693 struct lcd_pwd_seq_td1 td1;
694 struct lcd_pwd_seq_td2 td2;
695 struct lcd_pwd_seq_td3 td3;
696};
697
698/* LCD Scaling Factor */
699struct _lcd_hor_scaling_factor {
700 int reg_num;
701 struct io_register reg[LCD_HOR_SCALING_FACTOR_REG_NUM];
702};
703
704struct _lcd_ver_scaling_factor {
705 int reg_num;
706 struct io_register reg[LCD_VER_SCALING_FACTOR_REG_NUM];
707};
708
709struct _lcd_scaling_factor {
710 struct _lcd_hor_scaling_factor lcd_hor_scaling_factor;
711 struct _lcd_ver_scaling_factor lcd_ver_scaling_factor;
712};
713
714struct pll_map {
715 u32 clk;
716 u32 cle266_pll;
717 u32 k800_pll;
718 u32 cx700_pll;
719};
720
721struct rgbLUT {
722 u8 red;
723 u8 green;
724 u8 blue;
725};
726
727struct lcd_pwd_seq_timer {
728 u16 td0;
729 u16 td1;
730 u16 td2;
731 u16 td3;
732};
733
734/* Display FIFO Relation Registers*/
735struct iga1_fifo_depth_select {
736 int reg_num;
737 struct io_register reg[IGA1_FIFO_DEPTH_SELECT_REG_NUM];
738};
739
740struct iga1_fifo_threshold_select {
741 int reg_num;
742 struct io_register reg[IGA1_FIFO_THRESHOLD_REG_NUM];
743};
744
745struct iga1_fifo_high_threshold_select {
746 int reg_num;
747 struct io_register reg[IGA1_FIFO_HIGH_THRESHOLD_REG_NUM];
748};
749
750struct iga1_display_queue_expire_num {
751 int reg_num;
752 struct io_register reg[IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
753};
754
755struct iga2_fifo_depth_select {
756 int reg_num;
757 struct io_register reg[IGA2_FIFO_DEPTH_SELECT_REG_NUM];
758};
759
760struct iga2_fifo_threshold_select {
761 int reg_num;
762 struct io_register reg[IGA2_FIFO_THRESHOLD_REG_NUM];
763};
764
765struct iga2_fifo_high_threshold_select {
766 int reg_num;
767 struct io_register reg[IGA2_FIFO_HIGH_THRESHOLD_REG_NUM];
768};
769
770struct iga2_display_queue_expire_num {
771 int reg_num;
772 struct io_register reg[IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
773};
774
775struct fifo_depth_select {
776 struct iga1_fifo_depth_select iga1_fifo_depth_select_reg;
777 struct iga2_fifo_depth_select iga2_fifo_depth_select_reg;
778};
779
780struct fifo_threshold_select {
781 struct iga1_fifo_threshold_select iga1_fifo_threshold_select_reg;
782 struct iga2_fifo_threshold_select iga2_fifo_threshold_select_reg;
783};
784
785struct fifo_high_threshold_select {
786 struct iga1_fifo_high_threshold_select
787 iga1_fifo_high_threshold_select_reg;
788 struct iga2_fifo_high_threshold_select
789 iga2_fifo_high_threshold_select_reg;
790};
791
792struct display_queue_expire_num {
793 struct iga1_display_queue_expire_num
794 iga1_display_queue_expire_num_reg;
795 struct iga2_display_queue_expire_num
796 iga2_display_queue_expire_num_reg;
797};
798
799struct iga1_crtc_timing {
800 struct iga1_hor_total hor_total;
801 struct iga1_hor_addr hor_addr;
802 struct iga1_hor_blank_start hor_blank_start;
803 struct iga1_hor_blank_end hor_blank_end;
804 struct iga1_hor_sync_start hor_sync_start;
805 struct iga1_hor_sync_end hor_sync_end;
806 struct iga1_ver_total ver_total;
807 struct iga1_ver_addr ver_addr;
808 struct iga1_ver_blank_start ver_blank_start;
809 struct iga1_ver_blank_end ver_blank_end;
810 struct iga1_ver_sync_start ver_sync_start;
811 struct iga1_ver_sync_end ver_sync_end;
812};
813
814struct iga2_shadow_crtc_timing {
815 struct iga2_shadow_hor_total hor_total_shadow;
816 struct iga2_shadow_hor_blank_end hor_blank_end_shadow;
817 struct iga2_shadow_ver_total ver_total_shadow;
818 struct iga2_shadow_ver_addr ver_addr_shadow;
819 struct iga2_shadow_ver_blank_start ver_blank_start_shadow;
820 struct iga2_shadow_ver_blank_end ver_blank_end_shadow;
821 struct iga2_shadow_ver_sync_start ver_sync_start_shadow;
822 struct iga2_shadow_ver_sync_end ver_sync_end_shadow;
823};
824
825struct iga2_crtc_timing {
826 struct iga2_hor_total hor_total;
827 struct iga2_hor_addr hor_addr;
828 struct iga2_hor_blank_start hor_blank_start;
829 struct iga2_hor_blank_end hor_blank_end;
830 struct iga2_hor_sync_start hor_sync_start;
831 struct iga2_hor_sync_end hor_sync_end;
832 struct iga2_ver_total ver_total;
833 struct iga2_ver_addr ver_addr;
834 struct iga2_ver_blank_start ver_blank_start;
835 struct iga2_ver_blank_end ver_blank_end;
836 struct iga2_ver_sync_start ver_sync_start;
837 struct iga2_ver_sync_end ver_sync_end;
838};
839
840/* device ID */
841#define CLE266 0x3123
842#define KM400 0x3205
843#define CN400_FUNCTION2 0x2259
844#define CN400_FUNCTION3 0x3259
845/* support VT3314 chipset */
846#define CN700_FUNCTION2 0x2314
847#define CN700_FUNCTION3 0x3208
848/* VT3324 chipset */
849#define CX700_FUNCTION2 0x2324
850#define CX700_FUNCTION3 0x3324
851/* VT3204 chipset*/
852#define KM800_FUNCTION3 0x3204
853/* VT3336 chipset*/
854#define KM890_FUNCTION3 0x3336
855/* VT3327 chipset*/
856#define P4M890_FUNCTION3 0x3327
857/* VT3293 chipset*/
858#define CN750_FUNCTION3 0x3208
859/* VT3364 chipset*/
860#define P4M900_FUNCTION3 0x3364
861/* VT3353 chipset*/
862#define VX800_FUNCTION3 0x3353
863
864#define NUM_TOTAL_PLL_TABLE ARRAY_SIZE(pll_value)
865
866struct IODATA {
867 u8 Index;
868 u8 Mask;
869 u8 Data;
870};
871
872struct pci_device_id_info {
873 u32 vendor;
874 u32 device;
875 u32 chip_index;
876};
877
878extern unsigned int viafb_second_virtual_xres;
879extern unsigned int viafb_second_offset;
880extern int viafb_second_size;
881extern int viafb_SAMM_ON;
882extern int viafb_dual_fb;
883extern int viafb_LCD2_ON;
884extern int viafb_LCD_ON;
885extern int viafb_DVI_ON;
886extern int viafb_accel;
887extern int viafb_hotplug;
888
889void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask);
890void viafb_set_output_path(int device, int set_iga,
891 int output_interface);
892void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
893 int mode_index, int bpp_byte, int set_iga);
894
895void viafb_set_vclock(u32 CLK, int set_iga);
896void viafb_load_reg(int timing_value, int viafb_load_reg_num,
897 struct io_register *reg,
898 int io_type);
899void viafb_crt_disable(void);
900void viafb_crt_enable(void);
901void init_ad9389(void);
902/* Access I/O Function */
903void viafb_write_reg(u8 index, u16 io_port, u8 data);
904u8 viafb_read_reg(int io_port, u8 index);
905void viafb_lock_crt(void);
906void viafb_unlock_crt(void);
907void viafb_load_offset_reg(int h_addr, int bpp_byte, int set_iga);
908void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
909void viafb_write_regx(struct io_reg RegTable[], int ItemNum);
910struct VideoModeTable *viafb_get_modetbl_pointer(int Index);
911u32 viafb_get_clk_value(int clk);
912void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
913void viafb_set_color_depth(int bpp_byte, int set_iga);
914void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
915 *p_gfx_dpa_setting);
916
917int viafb_setmode(int vmode_index, int hor_res, int ver_res,
918 int video_bpp, int vmode_index1, int hor_res1,
919 int ver_res1, int video_bpp1);
920void viafb_init_chip_info(void);
921void viafb_init_dac(int set_iga);
922int viafb_get_pixclock(int hres, int vres, int vmode_refresh);
923int viafb_get_refresh(int hres, int vres, u32 float_refresh);
924void viafb_update_device_setting(int hres, int vres, int bpp,
925 int vmode_refresh, int flag);
926void viafb_get_mmio_info(unsigned long *mmio_base,
927 unsigned long *mmio_len);
928
929void viafb_set_iga_path(void);
930void viafb_set_start_addr(void);
931void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
932
933#endif /* __HW_H__ */
diff --git a/drivers/video/via/iface.c b/drivers/video/via/iface.c
new file mode 100644
index 000000000000..1570636c8d51
--- /dev/null
+++ b/drivers/video/via/iface.c
@@ -0,0 +1,78 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23
24/* Get frame buffer size from VGA BIOS */
25
26unsigned int viafb_get_memsize(void)
27{
28 unsigned int m;
29
30 /* If memory size provided by user */
31 if (viafb_memsize)
32 m = viafb_memsize * Mb;
33 else {
34 m = (unsigned int)viafb_read_reg(VIASR, SR39);
35 m = m * (4 * Mb);
36
37 if ((m < (16 * Mb)) || (m > (64 * Mb)))
38 m = 16 * Mb;
39 }
40 DEBUG_MSG(KERN_INFO "framebuffer size = %d Mb\n", m / Mb);
41 return m;
42}
43
44/* Get Video Buffer Starting Physical Address(back door)*/
45
46unsigned long viafb_get_videobuf_addr(void)
47{
48 struct pci_dev *pdev = NULL;
49 unsigned char sys_mem;
50 unsigned char video_mem;
51 unsigned long sys_mem_size;
52 unsigned long video_mem_size;
53 /*system memory = 256 MB, video memory 64 MB */
54 unsigned long vmem_starting_adr = 0x0C000000;
55
56 pdev =
57 (struct pci_dev *)pci_get_device(VIA_K800_BRIDGE_VID,
58 VIA_K800_BRIDGE_DID, NULL);
59 if (pdev != NULL) {
60 pci_read_config_byte(pdev, VIA_K800_SYSTEM_MEMORY_REG,
61 &sys_mem);
62 pci_read_config_byte(pdev, VIA_K800_VIDEO_MEMORY_REG,
63 &video_mem);
64 video_mem = (video_mem & 0x70) >> 4;
65 sys_mem_size = ((unsigned long)sys_mem) << 24;
66 if (video_mem != 0)
67 video_mem_size = (1 << (video_mem)) * 1024 * 1024;
68 else
69 video_mem_size = 0;
70
71 vmem_starting_adr = sys_mem_size - video_mem_size;
72 pci_dev_put(pdev);
73 }
74
75 DEBUG_MSG(KERN_INFO "Video Memory Starting Address = %lx \n",
76 vmem_starting_adr);
77 return vmem_starting_adr;
78}
diff --git a/drivers/video/via/iface.h b/drivers/video/via/iface.h
new file mode 100644
index 000000000000..790ec3e3aea2
--- /dev/null
+++ b/drivers/video/via/iface.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __IFACE_H__
23#define __IFACE_H__
24
25#define Kb (1024)
26#define Mb (Kb*Kb)
27
28#define VIA_K800_BRIDGE_VID 0x1106
29#define VIA_K800_BRIDGE_DID 0x3204
30
31#define VIA_K800_SYSTEM_MEMORY_REG 0x47
32#define VIA_K800_VIDEO_MEMORY_REG 0xA1
33
34extern int viafb_memsize;
35unsigned int viafb_get_memsize(void);
36unsigned long viafb_get_videobuf_addr(void);
37
38#endif /* __IFACE_H__ */
diff --git a/drivers/video/via/ioctl.c b/drivers/video/via/ioctl.c
new file mode 100644
index 000000000000..da03c074e32a
--- /dev/null
+++ b/drivers/video/via/ioctl.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23
24int viafb_ioctl_get_viafb_info(u_long arg)
25{
26 struct viafb_ioctl_info viainfo;
27
28 viainfo.viafb_id = VIAID;
29 viainfo.vendor_id = PCI_VIA_VENDOR_ID;
30
31 switch (viaparinfo->chip_info->gfx_chip_name) {
32 case UNICHROME_CLE266:
33 viainfo.device_id = UNICHROME_CLE266_DID;
34 break;
35
36 case UNICHROME_K400:
37 viainfo.device_id = UNICHROME_K400_DID;
38 break;
39
40 case UNICHROME_K800:
41 viainfo.device_id = UNICHROME_K800_DID;
42 break;
43
44 case UNICHROME_PM800:
45 viainfo.device_id = UNICHROME_PM800_DID;
46 break;
47
48 case UNICHROME_CN700:
49 viainfo.device_id = UNICHROME_CN700_DID;
50 break;
51
52 case UNICHROME_CX700:
53 viainfo.device_id = UNICHROME_CX700_DID;
54 break;
55
56 case UNICHROME_K8M890:
57 viainfo.device_id = UNICHROME_K8M890_DID;
58 break;
59
60 case UNICHROME_P4M890:
61 viainfo.device_id = UNICHROME_P4M890_DID;
62 break;
63
64 case UNICHROME_P4M900:
65 viainfo.device_id = UNICHROME_P4M900_DID;
66 break;
67 }
68
69 viainfo.version = VERSION_MAJOR;
70 viainfo.revision = VERSION_MINOR;
71
72 if (copy_to_user((void __user *)arg, &viainfo, sizeof(viainfo)))
73 return -EFAULT;
74
75 return 0;
76}
77
78/* Hot-Plug Priority: DVI > CRT*/
79int viafb_ioctl_hotplug(int hres, int vres, int bpp)
80{
81 int DVIsense, status = 0;
82 DEBUG_MSG(KERN_INFO "viafb_ioctl_hotplug!!\n");
83
84 if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name !=
85 NON_TMDS_TRANSMITTER) {
86 DVIsense = viafb_dvi_sense();
87
88 if (DVIsense) {
89 DEBUG_MSG(KERN_INFO "DVI Attached...\n");
90 if (viafb_DeviceStatus != DVI_Device) {
91 viafb_DVI_ON = 1;
92 viafb_CRT_ON = 0;
93 viafb_LCD_ON = 0;
94 viafb_DeviceStatus = DVI_Device;
95 return viafb_DeviceStatus;
96 }
97 status = 1;
98 } else
99 DEBUG_MSG(KERN_INFO "DVI De-attached...\n");
100 }
101
102 if ((viafb_DeviceStatus != CRT_Device) && (status == 0)) {
103 viafb_CRT_ON = 1;
104 viafb_DVI_ON = 0;
105 viafb_LCD_ON = 0;
106
107 viafb_DeviceStatus = CRT_Device;
108 return viafb_DeviceStatus;
109 }
110
111 return 0;
112}
diff --git a/drivers/video/via/ioctl.h b/drivers/video/via/ioctl.h
new file mode 100644
index 000000000000..842fe30b9868
--- /dev/null
+++ b/drivers/video/via/ioctl.h
@@ -0,0 +1,210 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __IOCTL_H__
23#define __IOCTL_H__
24
25#ifndef __user
26#define __user
27#endif
28
29/* VIAFB IOCTL definition */
30#define VIAFB_GET_INFO_SIZE 0x56494101 /* 'VIA\01' */
31#define VIAFB_GET_INFO 0x56494102 /* 'VIA\02' */
32#define VIAFB_HOTPLUG 0x56494103 /* 'VIA\03' */
33#define VIAFB_SET_HOTPLUG_FLAG 0x56494104 /* 'VIA\04' */
34#define VIAFB_GET_RESOLUTION 0x56494105 /* 'VIA\05' */
35#define VIAFB_GET_SAMM_INFO 0x56494107 /* 'VIA\07' */
36#define VIAFB_TURN_ON_OUTPUT_DEVICE 0x56494108 /* 'VIA\08' */
37#define VIAFB_TURN_OFF_OUTPUT_DEVICE 0x56494109 /* 'VIA\09' */
38#define VIAFB_SET_DEVICE 0x5649410A
39#define VIAFB_GET_DEVICE 0x5649410B
40#define VIAFB_GET_DRIVER_VERSION 0x56494112 /* 'VIA\12' */
41#define VIAFB_GET_CHIP_INFO 0x56494113 /* 'VIA\13' */
42#define VIAFB_SET_DEVICE_INFO 0x56494114
43#define VIAFB_GET_DEVICE_INFO 0x56494115
44
45#define VIAFB_GET_DEVICE_SUPPORT 0x56494118
46#define VIAFB_GET_DEVICE_CONNECT 0x56494119
47#define VIAFB_GET_PANEL_SUPPORT_EXPAND 0x5649411A
48#define VIAFB_GET_DRIVER_NAME 0x56494122
49#define VIAFB_GET_DEVICE_SUPPORT_STATE 0x56494123
50#define VIAFB_GET_GAMMA_LUT 0x56494124
51#define VIAFB_SET_GAMMA_LUT 0x56494125
52#define VIAFB_GET_GAMMA_SUPPORT_STATE 0x56494126
53#define VIAFB_SET_VIDEO_DEVICE 0x56494127
54#define VIAFB_GET_VIDEO_DEVICE 0x56494128
55#define VIAFB_SET_SECOND_MODE 0x56494129
56#define VIAFB_SYNC_SURFACE 0x56494130
57#define VIAFB_GET_DRIVER_CAPS 0x56494131
58#define VIAFB_GET_IGA_SCALING_INFO 0x56494132
59#define VIAFB_GET_PANEL_MAX_SIZE 0x56494133
60#define VIAFB_GET_PANEL_MAX_POSITION 0x56494134
61#define VIAFB_SET_PANEL_SIZE 0x56494135
62#define VIAFB_SET_PANEL_POSITION 0x56494136
63#define VIAFB_GET_PANEL_POSITION 0x56494137
64#define VIAFB_GET_PANEL_SIZE 0x56494138
65
66#define None_Device 0x00
67#define CRT_Device 0x01
68#define LCD_Device 0x02
69#define DVI_Device 0x08
70#define CRT2_Device 0x10
71#define LCD2_Device 0x40
72
73#define OP_LCD_CENTERING 0x01
74#define OP_LCD_PANEL_ID 0x02
75#define OP_LCD_MODE 0x03
76
77/*SAMM operation flag*/
78#define OP_SAMM 0x80
79
80#define LCD_PANEL_ID_MAXIMUM 22
81
82#define STATE_ON 0x1
83#define STATE_OFF 0x0
84#define STATE_DEFAULT 0xFFFF
85
86#define MAX_ACTIVE_DEV_NUM 2
87
88struct device_t {
89 unsigned short crt:1;
90 unsigned short dvi:1;
91 unsigned short lcd:1;
92 unsigned short samm:1;
93 unsigned short lcd_dsp_cent:1;
94 unsigned char lcd_mode:1;
95 unsigned short epia_dvi:1;
96 unsigned short lcd_dual_edge:1;
97 unsigned short lcd2:1;
98
99 unsigned short primary_dev;
100 unsigned char lcd_panel_id;
101 unsigned short xres, yres;
102 unsigned short xres1, yres1;
103 unsigned short refresh;
104 unsigned short bpp;
105 unsigned short refresh1;
106 unsigned short bpp1;
107 unsigned short sequence;
108 unsigned short bus_width;
109};
110
111struct viafb_ioctl_info {
112 u32 viafb_id; /* for identifying viafb */
113#define VIAID 0x56494146 /* Identify myself with 'VIAF' */
114 u16 vendor_id;
115 u16 device_id;
116 u8 version;
117 u8 revision;
118 u8 reserved[246]; /* for future use */
119};
120
121struct viafb_ioctl_mode {
122 u32 xres;
123 u32 yres;
124 u32 refresh;
125 u32 bpp;
126 u32 xres_sec;
127 u32 yres_sec;
128 u32 virtual_xres_sec;
129 u32 virtual_yres_sec;
130 u32 refresh_sec;
131 u32 bpp_sec;
132};
133struct viafb_ioctl_samm {
134 u32 samm_status;
135 u32 size_prim;
136 u32 size_sec;
137 u32 mem_base;
138 u32 offset_sec;
139};
140
141struct viafb_driver_version {
142 int iMajorNum;
143 int iKernelNum;
144 int iOSNum;
145 int iMinorNum;
146};
147
148struct viafb_ioctl_lcd_attribute {
149 unsigned int panel_id;
150 unsigned int display_center;
151 unsigned int lcd_mode;
152};
153
154struct viafb_ioctl_setting {
155 /* Enable or disable active devices */
156 unsigned short device_flag;
157 /* Indicate which device should be turn on or turn off. */
158 unsigned short device_status;
159 unsigned int reserved;
160 /* Indicate which LCD's attribute can be changed. */
161 unsigned short lcd_operation_flag;
162 /* 1: SAMM ON 0: SAMM OFF */
163 unsigned short samm_status;
164 /* horizontal resolution of first device */
165 unsigned short first_dev_hor_res;
166 /* vertical resolution of first device */
167 unsigned short first_dev_ver_res;
168 /* horizontal resolution of second device */
169 unsigned short second_dev_hor_res;
170 /* vertical resolution of second device */
171 unsigned short second_dev_ver_res;
172 /* refresh rate of first device */
173 unsigned short first_dev_refresh;
174 /* bpp of first device */
175 unsigned short first_dev_bpp;
176 /* refresh rate of second device */
177 unsigned short second_dev_refresh;
178 /* bpp of second device */
179 unsigned short second_dev_bpp;
180 /* Indicate which device are primary display device. */
181 unsigned int primary_device;
182 /* Indicate which device will show video. only valid in duoview mode */
183 unsigned int video_device_status;
184 unsigned int struct_reserved[34];
185 struct viafb_ioctl_lcd_attribute lcd_attributes;
186};
187
188struct _UTFunctionCaps {
189 unsigned int dw3DScalingState;
190 unsigned int reserved[31];
191};
192
193struct _POSITIONVALUE {
194 unsigned int dwX;
195 unsigned int dwY;
196};
197
198struct _panel_size_pos_info {
199 unsigned int device_type;
200 int x;
201 int y;
202};
203
204extern int viafb_LCD_ON;
205extern int viafb_DVI_ON;
206
207int viafb_ioctl_get_viafb_info(u_long arg);
208int viafb_ioctl_hotplug(int hres, int vres, int bpp);
209
210#endif /* __IOCTL_H__ */
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c
new file mode 100644
index 000000000000..6c7290a6a447
--- /dev/null
+++ b/drivers/video/via/lcd.c
@@ -0,0 +1,1821 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23#include "lcdtbl.h"
24
25static struct iga2_shadow_crtc_timing iga2_shadow_crtc_reg = {
26 /* IGA2 Shadow Horizontal Total */
27 {IGA2_SHADOW_HOR_TOTAL_REG_NUM, {{CR6D, 0, 7}, {CR71, 3, 3} } },
28 /* IGA2 Shadow Horizontal Blank End */
29 {IGA2_SHADOW_HOR_BLANK_END_REG_NUM, {{CR6E, 0, 7} } },
30 /* IGA2 Shadow Vertical Total */
31 {IGA2_SHADOW_VER_TOTAL_REG_NUM, {{CR6F, 0, 7}, {CR71, 0, 2} } },
32 /* IGA2 Shadow Vertical Addressable Video */
33 {IGA2_SHADOW_VER_ADDR_REG_NUM, {{CR70, 0, 7}, {CR71, 4, 6} } },
34 /* IGA2 Shadow Vertical Blank Start */
35 {IGA2_SHADOW_VER_BLANK_START_REG_NUM,
36 {{CR72, 0, 7}, {CR74, 4, 6} } },
37 /* IGA2 Shadow Vertical Blank End */
38 {IGA2_SHADOW_VER_BLANK_END_REG_NUM, {{CR73, 0, 7}, {CR74, 0, 2} } },
39 /* IGA2 Shadow Vertical Sync Start */
40 {IGA2_SHADOW_VER_SYNC_START_REG_NUM, {{CR75, 0, 7}, {CR76, 4, 6} } },
41 /* IGA2 Shadow Vertical Sync End */
42 {IGA2_SHADOW_VER_SYNC_END_REG_NUM, {{CR76, 0, 3} } }
43};
44
45static struct _lcd_scaling_factor lcd_scaling_factor = {
46 /* LCD Horizontal Scaling Factor Register */
47 {LCD_HOR_SCALING_FACTOR_REG_NUM,
48 {{CR9F, 0, 1}, {CR77, 0, 7}, {CR79, 4, 5} } },
49 /* LCD Vertical Scaling Factor Register */
50 {LCD_VER_SCALING_FACTOR_REG_NUM,
51 {{CR79, 3, 3}, {CR78, 0, 7}, {CR79, 6, 7} } }
52};
53static struct _lcd_scaling_factor lcd_scaling_factor_CLE = {
54 /* LCD Horizontal Scaling Factor Register */
55 {LCD_HOR_SCALING_FACTOR_REG_NUM_CLE, {{CR77, 0, 7}, {CR79, 4, 5} } },
56 /* LCD Vertical Scaling Factor Register */
57 {LCD_VER_SCALING_FACTOR_REG_NUM_CLE, {{CR78, 0, 7}, {CR79, 6, 7} } }
58};
59
60static int check_lvds_chip(int device_id_subaddr, int device_id);
61static bool lvds_identify_integratedlvds(void);
62static int fp_id_to_vindex(int panel_id);
63static int lvds_register_read(int index);
64static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres,
65 int panel_vres);
66static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
67 int panel_id);
68static void load_lcd_p880_patch_tbl(int set_hres, int set_vres,
69 int panel_id);
70static void load_lcd_patch_regs(int set_hres, int set_vres,
71 int panel_id, int set_iga);
72static void via_pitch_alignment_patch_lcd(
73 struct lvds_setting_information *plvds_setting_info,
74 struct lvds_chip_information
75 *plvds_chip_info);
76static void lcd_patch_skew_dvp0(struct lvds_setting_information
77 *plvds_setting_info,
78 struct lvds_chip_information *plvds_chip_info);
79static void lcd_patch_skew_dvp1(struct lvds_setting_information
80 *plvds_setting_info,
81 struct lvds_chip_information *plvds_chip_info);
82static void lcd_patch_skew(struct lvds_setting_information
83 *plvds_setting_info, struct lvds_chip_information *plvds_chip_info);
84
85static void integrated_lvds_disable(struct lvds_setting_information
86 *plvds_setting_info,
87 struct lvds_chip_information *plvds_chip_info);
88static void integrated_lvds_enable(struct lvds_setting_information
89 *plvds_setting_info,
90 struct lvds_chip_information *plvds_chip_info);
91static void lcd_powersequence_off(void);
92static void lcd_powersequence_on(void);
93static void fill_lcd_format(void);
94static void check_diport_of_integrated_lvds(
95 struct lvds_chip_information *plvds_chip_info,
96 struct lvds_setting_information
97 *plvds_setting_info);
98static struct display_timing lcd_centering_timging(struct display_timing
99 mode_crt_reg,
100 struct display_timing panel_crt_reg);
101static void load_crtc_shadow_timing(struct display_timing mode_timing,
102 struct display_timing panel_timing);
103static void viafb_load_scaling_factor_for_p4m900(int set_hres,
104 int set_vres, int panel_hres, int panel_vres);
105
106static int check_lvds_chip(int device_id_subaddr, int device_id)
107{
108 if (lvds_register_read(device_id_subaddr) == device_id)
109 return OK;
110 else
111 return FAIL;
112}
113
114void viafb_init_lcd_size(void)
115{
116 DEBUG_MSG(KERN_INFO "viafb_init_lcd_size()\n");
117 DEBUG_MSG(KERN_INFO
118 "viaparinfo->lvds_setting_info->get_lcd_size_method %d\n",
119 viaparinfo->lvds_setting_info->get_lcd_size_method);
120
121 switch (viaparinfo->lvds_setting_info->get_lcd_size_method) {
122 case GET_LCD_SIZE_BY_SYSTEM_BIOS:
123 break;
124 case GET_LCD_SZIE_BY_HW_STRAPPING:
125 break;
126 case GET_LCD_SIZE_BY_VGA_BIOS:
127 DEBUG_MSG(KERN_INFO "Get LCD Size method by VGA BIOS !!\n");
128 viaparinfo->lvds_setting_info->lcd_panel_size =
129 fp_id_to_vindex(viafb_lcd_panel_id);
130 DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n",
131 viaparinfo->lvds_setting_info->lcd_panel_id);
132 DEBUG_MSG(KERN_INFO "LCD Panel Size = %d\n",
133 viaparinfo->lvds_setting_info->lcd_panel_size);
134 break;
135 case GET_LCD_SIZE_BY_USER_SETTING:
136 DEBUG_MSG(KERN_INFO "Get LCD Size method by user setting !!\n");
137 viaparinfo->lvds_setting_info->lcd_panel_size =
138 fp_id_to_vindex(viafb_lcd_panel_id);
139 DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n",
140 viaparinfo->lvds_setting_info->lcd_panel_id);
141 DEBUG_MSG(KERN_INFO "LCD Panel Size = %d\n",
142 viaparinfo->lvds_setting_info->lcd_panel_size);
143 break;
144 default:
145 DEBUG_MSG(KERN_INFO "viafb_init_lcd_size fail\n");
146 viaparinfo->lvds_setting_info->lcd_panel_id =
147 LCD_PANEL_ID1_800X600;
148 viaparinfo->lvds_setting_info->lcd_panel_size =
149 fp_id_to_vindex(LCD_PANEL_ID1_800X600);
150 }
151 viaparinfo->lvds_setting_info2->lcd_panel_id =
152 viaparinfo->lvds_setting_info->lcd_panel_id;
153 viaparinfo->lvds_setting_info2->lcd_panel_size =
154 viaparinfo->lvds_setting_info->lcd_panel_size;
155 viaparinfo->lvds_setting_info2->lcd_panel_hres =
156 viaparinfo->lvds_setting_info->lcd_panel_hres;
157 viaparinfo->lvds_setting_info2->lcd_panel_vres =
158 viaparinfo->lvds_setting_info->lcd_panel_vres;
159 viaparinfo->lvds_setting_info2->device_lcd_dualedge =
160 viaparinfo->lvds_setting_info->device_lcd_dualedge;
161 viaparinfo->lvds_setting_info2->LCDDithering =
162 viaparinfo->lvds_setting_info->LCDDithering;
163}
164
165static bool lvds_identify_integratedlvds(void)
166{
167 if (viafb_display_hardware_layout == HW_LAYOUT_LCD_EXTERNAL_LCD2) {
168 /* Two dual channel LCD (Internal LVDS + External LVDS): */
169 /* If we have an external LVDS, such as VT1636, we should
170 have its chip ID already. */
171 if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
172 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name =
173 INTEGRATED_LVDS;
174 DEBUG_MSG(KERN_INFO "Support two dual channel LVDS!\
175 (Internal LVDS + External LVDS)\n");
176 } else {
177 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
178 INTEGRATED_LVDS;
179 DEBUG_MSG(KERN_INFO "Not found external LVDS,\
180 so can't support two dual channel LVDS!\n");
181 }
182 } else if (viafb_display_hardware_layout == HW_LAYOUT_LCD1_LCD2) {
183 /* Two single channel LCD (Internal LVDS + Internal LVDS): */
184 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
185 INTEGRATED_LVDS;
186 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name =
187 INTEGRATED_LVDS;
188 DEBUG_MSG(KERN_INFO "Support two single channel LVDS!\
189 (Internal LVDS + Internal LVDS)\n");
190 } else if (viafb_display_hardware_layout != HW_LAYOUT_DVI_ONLY) {
191 /* If we have found external LVDS, just use it,
192 otherwise, we will use internal LVDS as default. */
193 if (!viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
194 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
195 INTEGRATED_LVDS;
196 DEBUG_MSG(KERN_INFO "Found Integrated LVDS!\n");
197 }
198 } else {
199 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
200 NON_LVDS_TRANSMITTER;
201 DEBUG_MSG(KERN_INFO "Do not support LVDS!\n");
202 return false;
203 }
204
205 return true;
206}
207
208int viafb_lvds_trasmitter_identify(void)
209{
210 viaparinfo->i2c_stuff.i2c_port = I2CPORTINDEX;
211 if (viafb_lvds_identify_vt1636()) {
212 viaparinfo->chip_info->lvds_chip_info.i2c_port = I2CPORTINDEX;
213 DEBUG_MSG(KERN_INFO
214 "Found VIA VT1636 LVDS on port i2c 0x31 \n");
215 } else {
216 viaparinfo->i2c_stuff.i2c_port = GPIOPORTINDEX;
217 if (viafb_lvds_identify_vt1636()) {
218 viaparinfo->chip_info->lvds_chip_info.i2c_port =
219 GPIOPORTINDEX;
220 DEBUG_MSG(KERN_INFO
221 "Found VIA VT1636 LVDS on port gpio 0x2c \n");
222 }
223 }
224
225 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700)
226 lvds_identify_integratedlvds();
227
228 if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name)
229 return true;
230 /* Check for VT1631: */
231 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = VT1631_LVDS;
232 viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr =
233 VT1631_LVDS_I2C_ADDR;
234
235 if (check_lvds_chip(VT1631_DEVICE_ID_REG, VT1631_DEVICE_ID) != FAIL) {
236 DEBUG_MSG(KERN_INFO "\n VT1631 LVDS ! \n");
237 DEBUG_MSG(KERN_INFO "\n %2d",
238 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name);
239 DEBUG_MSG(KERN_INFO "\n %2d",
240 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name);
241 return OK;
242 }
243
244 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
245 NON_LVDS_TRANSMITTER;
246 viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr =
247 VT1631_LVDS_I2C_ADDR;
248 return FAIL;
249}
250
251static int fp_id_to_vindex(int panel_id)
252{
253 DEBUG_MSG(KERN_INFO "fp_get_panel_id()\n");
254
255 if (panel_id > LCD_PANEL_ID_MAXIMUM)
256 viafb_lcd_panel_id = panel_id =
257 viafb_read_reg(VIACR, CR3F) & 0x0F;
258
259 switch (panel_id) {
260 case 0x0:
261 viaparinfo->lvds_setting_info->lcd_panel_hres = 640;
262 viaparinfo->lvds_setting_info->lcd_panel_vres = 480;
263 viaparinfo->lvds_setting_info->lcd_panel_id =
264 LCD_PANEL_ID0_640X480;
265 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
266 viaparinfo->lvds_setting_info->LCDDithering = 1;
267 return VIA_RES_640X480;
268 break;
269 case 0x1:
270 viaparinfo->lvds_setting_info->lcd_panel_hres = 800;
271 viaparinfo->lvds_setting_info->lcd_panel_vres = 600;
272 viaparinfo->lvds_setting_info->lcd_panel_id =
273 LCD_PANEL_ID1_800X600;
274 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
275 viaparinfo->lvds_setting_info->LCDDithering = 1;
276 return VIA_RES_800X600;
277 break;
278 case 0x2:
279 viaparinfo->lvds_setting_info->lcd_panel_hres = 1024;
280 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
281 viaparinfo->lvds_setting_info->lcd_panel_id =
282 LCD_PANEL_ID2_1024X768;
283 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
284 viaparinfo->lvds_setting_info->LCDDithering = 1;
285 return VIA_RES_1024X768;
286 break;
287 case 0x3:
288 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
289 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
290 viaparinfo->lvds_setting_info->lcd_panel_id =
291 LCD_PANEL_ID3_1280X768;
292 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
293 viaparinfo->lvds_setting_info->LCDDithering = 1;
294 return VIA_RES_1280X768;
295 break;
296 case 0x4:
297 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
298 viaparinfo->lvds_setting_info->lcd_panel_vres = 1024;
299 viaparinfo->lvds_setting_info->lcd_panel_id =
300 LCD_PANEL_ID4_1280X1024;
301 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
302 viaparinfo->lvds_setting_info->LCDDithering = 1;
303 return VIA_RES_1280X1024;
304 break;
305 case 0x5:
306 viaparinfo->lvds_setting_info->lcd_panel_hres = 1400;
307 viaparinfo->lvds_setting_info->lcd_panel_vres = 1050;
308 viaparinfo->lvds_setting_info->lcd_panel_id =
309 LCD_PANEL_ID5_1400X1050;
310 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
311 viaparinfo->lvds_setting_info->LCDDithering = 1;
312 return VIA_RES_1400X1050;
313 break;
314 case 0x6:
315 viaparinfo->lvds_setting_info->lcd_panel_hres = 1600;
316 viaparinfo->lvds_setting_info->lcd_panel_vres = 1200;
317 viaparinfo->lvds_setting_info->lcd_panel_id =
318 LCD_PANEL_ID6_1600X1200;
319 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
320 viaparinfo->lvds_setting_info->LCDDithering = 1;
321 return VIA_RES_1600X1200;
322 break;
323 case 0x8:
324 viaparinfo->lvds_setting_info->lcd_panel_hres = 800;
325 viaparinfo->lvds_setting_info->lcd_panel_vres = 480;
326 viaparinfo->lvds_setting_info->lcd_panel_id =
327 LCD_PANEL_IDA_800X480;
328 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
329 viaparinfo->lvds_setting_info->LCDDithering = 1;
330 return VIA_RES_800X480;
331 break;
332 case 0x9:
333 viaparinfo->lvds_setting_info->lcd_panel_hres = 1024;
334 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
335 viaparinfo->lvds_setting_info->lcd_panel_id =
336 LCD_PANEL_ID2_1024X768;
337 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
338 viaparinfo->lvds_setting_info->LCDDithering = 1;
339 return VIA_RES_1024X768;
340 break;
341 case 0xA:
342 viaparinfo->lvds_setting_info->lcd_panel_hres = 1024;
343 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
344 viaparinfo->lvds_setting_info->lcd_panel_id =
345 LCD_PANEL_ID2_1024X768;
346 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
347 viaparinfo->lvds_setting_info->LCDDithering = 0;
348 return VIA_RES_1024X768;
349 break;
350 case 0xB:
351 viaparinfo->lvds_setting_info->lcd_panel_hres = 1024;
352 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
353 viaparinfo->lvds_setting_info->lcd_panel_id =
354 LCD_PANEL_ID2_1024X768;
355 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
356 viaparinfo->lvds_setting_info->LCDDithering = 0;
357 return VIA_RES_1024X768;
358 break;
359 case 0xC:
360 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
361 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
362 viaparinfo->lvds_setting_info->lcd_panel_id =
363 LCD_PANEL_ID3_1280X768;
364 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
365 viaparinfo->lvds_setting_info->LCDDithering = 0;
366 return VIA_RES_1280X768;
367 break;
368 case 0xD:
369 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
370 viaparinfo->lvds_setting_info->lcd_panel_vres = 1024;
371 viaparinfo->lvds_setting_info->lcd_panel_id =
372 LCD_PANEL_ID4_1280X1024;
373 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
374 viaparinfo->lvds_setting_info->LCDDithering = 0;
375 return VIA_RES_1280X1024;
376 break;
377 case 0xE:
378 viaparinfo->lvds_setting_info->lcd_panel_hres = 1400;
379 viaparinfo->lvds_setting_info->lcd_panel_vres = 1050;
380 viaparinfo->lvds_setting_info->lcd_panel_id =
381 LCD_PANEL_ID5_1400X1050;
382 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
383 viaparinfo->lvds_setting_info->LCDDithering = 0;
384 return VIA_RES_1400X1050;
385 break;
386 case 0xF:
387 viaparinfo->lvds_setting_info->lcd_panel_hres = 1600;
388 viaparinfo->lvds_setting_info->lcd_panel_vres = 1200;
389 viaparinfo->lvds_setting_info->lcd_panel_id =
390 LCD_PANEL_ID6_1600X1200;
391 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
392 viaparinfo->lvds_setting_info->LCDDithering = 0;
393 return VIA_RES_1600X1200;
394 break;
395 case 0x10:
396 viaparinfo->lvds_setting_info->lcd_panel_hres = 1366;
397 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
398 viaparinfo->lvds_setting_info->lcd_panel_id =
399 LCD_PANEL_ID7_1366X768;
400 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
401 viaparinfo->lvds_setting_info->LCDDithering = 0;
402 return VIA_RES_1368X768;
403 break;
404 case 0x11:
405 viaparinfo->lvds_setting_info->lcd_panel_hres = 1024;
406 viaparinfo->lvds_setting_info->lcd_panel_vres = 600;
407 viaparinfo->lvds_setting_info->lcd_panel_id =
408 LCD_PANEL_ID8_1024X600;
409 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
410 viaparinfo->lvds_setting_info->LCDDithering = 1;
411 return VIA_RES_1024X600;
412 break;
413 case 0x12:
414 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
415 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
416 viaparinfo->lvds_setting_info->lcd_panel_id =
417 LCD_PANEL_ID3_1280X768;
418 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
419 viaparinfo->lvds_setting_info->LCDDithering = 1;
420 return VIA_RES_1280X768;
421 break;
422 case 0x13:
423 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
424 viaparinfo->lvds_setting_info->lcd_panel_vres = 800;
425 viaparinfo->lvds_setting_info->lcd_panel_id =
426 LCD_PANEL_ID9_1280X800;
427 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
428 viaparinfo->lvds_setting_info->LCDDithering = 1;
429 return VIA_RES_1280X800;
430 break;
431 case 0x14:
432 viaparinfo->lvds_setting_info->lcd_panel_hres = 1360;
433 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
434 viaparinfo->lvds_setting_info->lcd_panel_id =
435 LCD_PANEL_IDB_1360X768;
436 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
437 viaparinfo->lvds_setting_info->LCDDithering = 0;
438 return VIA_RES_1360X768;
439 break;
440 case 0x15:
441 viaparinfo->lvds_setting_info->lcd_panel_hres = 1280;
442 viaparinfo->lvds_setting_info->lcd_panel_vres = 768;
443 viaparinfo->lvds_setting_info->lcd_panel_id =
444 LCD_PANEL_ID3_1280X768;
445 viaparinfo->lvds_setting_info->device_lcd_dualedge = 1;
446 viaparinfo->lvds_setting_info->LCDDithering = 0;
447 return VIA_RES_1280X768;
448 break;
449 case 0x16:
450 viaparinfo->lvds_setting_info->lcd_panel_hres = 480;
451 viaparinfo->lvds_setting_info->lcd_panel_vres = 640;
452 viaparinfo->lvds_setting_info->lcd_panel_id =
453 LCD_PANEL_IDC_480X640;
454 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
455 viaparinfo->lvds_setting_info->LCDDithering = 1;
456 return VIA_RES_480X640;
457 break;
458 default:
459 viaparinfo->lvds_setting_info->lcd_panel_hres = 800;
460 viaparinfo->lvds_setting_info->lcd_panel_vres = 600;
461 viaparinfo->lvds_setting_info->lcd_panel_id =
462 LCD_PANEL_ID1_800X600;
463 viaparinfo->lvds_setting_info->device_lcd_dualedge = 0;
464 viaparinfo->lvds_setting_info->LCDDithering = 1;
465 return VIA_RES_800X600;
466 }
467}
468
469static int lvds_register_read(int index)
470{
471 u8 data;
472
473 viaparinfo->i2c_stuff.i2c_port = GPIOPORTINDEX;
474 viafb_i2c_readbyte((u8) viaparinfo->chip_info->
475 lvds_chip_info.lvds_chip_slave_addr,
476 (u8) index, &data);
477 return data;
478}
479
480static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres,
481 int panel_vres)
482{
483 int reg_value = 0;
484 int viafb_load_reg_num;
485 struct io_register *reg = NULL;
486
487 DEBUG_MSG(KERN_INFO "load_lcd_scaling()!!\n");
488
489 /* LCD Scaling Enable */
490 viafb_write_reg_mask(CR79, VIACR, 0x07, BIT0 + BIT1 + BIT2);
491 if (UNICHROME_P4M900 == viaparinfo->chip_info->gfx_chip_name) {
492 viafb_load_scaling_factor_for_p4m900(set_hres, set_vres,
493 panel_hres, panel_vres);
494 return;
495 }
496
497 /* Check if expansion for horizontal */
498 if (set_hres != panel_hres) {
499 /* Load Horizontal Scaling Factor */
500 switch (viaparinfo->chip_info->gfx_chip_name) {
501 case UNICHROME_CLE266:
502 case UNICHROME_K400:
503 reg_value =
504 CLE266_LCD_HOR_SCF_FORMULA(set_hres, panel_hres);
505 viafb_load_reg_num =
506 lcd_scaling_factor_CLE.lcd_hor_scaling_factor.
507 reg_num;
508 reg = lcd_scaling_factor_CLE.lcd_hor_scaling_factor.reg;
509 viafb_load_reg(reg_value,
510 viafb_load_reg_num, reg, VIACR);
511 break;
512 case UNICHROME_K800:
513 case UNICHROME_PM800:
514 case UNICHROME_CN700:
515 case UNICHROME_CX700:
516 case UNICHROME_K8M890:
517 case UNICHROME_P4M890:
518 reg_value =
519 K800_LCD_HOR_SCF_FORMULA(set_hres, panel_hres);
520 /* Horizontal scaling enabled */
521 viafb_write_reg_mask(CRA2, VIACR, 0xC0, BIT7 + BIT6);
522 viafb_load_reg_num =
523 lcd_scaling_factor.lcd_hor_scaling_factor.reg_num;
524 reg = lcd_scaling_factor.lcd_hor_scaling_factor.reg;
525 viafb_load_reg(reg_value,
526 viafb_load_reg_num, reg, VIACR);
527 break;
528 }
529
530 DEBUG_MSG(KERN_INFO "Horizontal Scaling value = %d", reg_value);
531 } else {
532 /* Horizontal scaling disabled */
533 viafb_write_reg_mask(CRA2, VIACR, 0x00, BIT7);
534 }
535
536 /* Check if expansion for vertical */
537 if (set_vres != panel_vres) {
538 /* Load Vertical Scaling Factor */
539 switch (viaparinfo->chip_info->gfx_chip_name) {
540 case UNICHROME_CLE266:
541 case UNICHROME_K400:
542 reg_value =
543 CLE266_LCD_VER_SCF_FORMULA(set_vres, panel_vres);
544 viafb_load_reg_num =
545 lcd_scaling_factor_CLE.lcd_ver_scaling_factor.
546 reg_num;
547 reg = lcd_scaling_factor_CLE.lcd_ver_scaling_factor.reg;
548 viafb_load_reg(reg_value,
549 viafb_load_reg_num, reg, VIACR);
550 break;
551 case UNICHROME_K800:
552 case UNICHROME_PM800:
553 case UNICHROME_CN700:
554 case UNICHROME_CX700:
555 case UNICHROME_K8M890:
556 case UNICHROME_P4M890:
557 reg_value =
558 K800_LCD_VER_SCF_FORMULA(set_vres, panel_vres);
559 /* Vertical scaling enabled */
560 viafb_write_reg_mask(CRA2, VIACR, 0x08, BIT3);
561 viafb_load_reg_num =
562 lcd_scaling_factor.lcd_ver_scaling_factor.reg_num;
563 reg = lcd_scaling_factor.lcd_ver_scaling_factor.reg;
564 viafb_load_reg(reg_value,
565 viafb_load_reg_num, reg, VIACR);
566 break;
567 }
568
569 DEBUG_MSG(KERN_INFO "Vertical Scaling value = %d", reg_value);
570 } else {
571 /* Vertical scaling disabled */
572 viafb_write_reg_mask(CRA2, VIACR, 0x00, BIT3);
573 }
574}
575
576static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
577 int panel_id)
578{
579 int vmode_index;
580 int reg_num = 0;
581 struct io_reg *lcd_patch_reg = NULL;
582
583 if (viaparinfo->lvds_setting_info->iga_path == IGA2)
584 vmode_index = viafb_get_mode_index(set_hres, set_vres, 1);
585 else
586 vmode_index = viafb_get_mode_index(set_hres, set_vres, 0);
587 switch (panel_id) {
588 /* LCD 800x600 */
589 case LCD_PANEL_ID1_800X600:
590 switch (vmode_index) {
591 case VIA_RES_640X400:
592 case VIA_RES_640X480:
593 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_8X6;
594 lcd_patch_reg = K400_LCD_RES_6X4_8X6;
595 break;
596 case VIA_RES_720X480:
597 case VIA_RES_720X576:
598 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_8X6;
599 lcd_patch_reg = K400_LCD_RES_7X4_8X6;
600 break;
601 }
602 break;
603
604 /* LCD 1024x768 */
605 case LCD_PANEL_ID2_1024X768:
606 switch (vmode_index) {
607 case VIA_RES_640X400:
608 case VIA_RES_640X480:
609 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_10X7;
610 lcd_patch_reg = K400_LCD_RES_6X4_10X7;
611 break;
612 case VIA_RES_720X480:
613 case VIA_RES_720X576:
614 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_10X7;
615 lcd_patch_reg = K400_LCD_RES_7X4_10X7;
616 break;
617 case VIA_RES_800X600:
618 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_10X7;
619 lcd_patch_reg = K400_LCD_RES_8X6_10X7;
620 break;
621 }
622 break;
623
624 /* LCD 1280x1024 */
625 case LCD_PANEL_ID4_1280X1024:
626 switch (vmode_index) {
627 case VIA_RES_640X400:
628 case VIA_RES_640X480:
629 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_12X10;
630 lcd_patch_reg = K400_LCD_RES_6X4_12X10;
631 break;
632 case VIA_RES_720X480:
633 case VIA_RES_720X576:
634 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_12X10;
635 lcd_patch_reg = K400_LCD_RES_7X4_12X10;
636 break;
637 case VIA_RES_800X600:
638 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_12X10;
639 lcd_patch_reg = K400_LCD_RES_8X6_12X10;
640 break;
641 case VIA_RES_1024X768:
642 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_12X10;
643 lcd_patch_reg = K400_LCD_RES_10X7_12X10;
644 break;
645
646 }
647 break;
648
649 /* LCD 1400x1050 */
650 case LCD_PANEL_ID5_1400X1050:
651 switch (vmode_index) {
652 case VIA_RES_640X480:
653 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_14X10;
654 lcd_patch_reg = K400_LCD_RES_6X4_14X10;
655 break;
656 case VIA_RES_800X600:
657 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_14X10;
658 lcd_patch_reg = K400_LCD_RES_8X6_14X10;
659 break;
660 case VIA_RES_1024X768:
661 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_14X10;
662 lcd_patch_reg = K400_LCD_RES_10X7_14X10;
663 break;
664 case VIA_RES_1280X768:
665 case VIA_RES_1280X800:
666 case VIA_RES_1280X960:
667 case VIA_RES_1280X1024:
668 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_14X10;
669 lcd_patch_reg = K400_LCD_RES_12X10_14X10;
670 break;
671 }
672 break;
673
674 /* LCD 1600x1200 */
675 case LCD_PANEL_ID6_1600X1200:
676 switch (vmode_index) {
677 case VIA_RES_640X400:
678 case VIA_RES_640X480:
679 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_16X12;
680 lcd_patch_reg = K400_LCD_RES_6X4_16X12;
681 break;
682 case VIA_RES_720X480:
683 case VIA_RES_720X576:
684 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_16X12;
685 lcd_patch_reg = K400_LCD_RES_7X4_16X12;
686 break;
687 case VIA_RES_800X600:
688 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_16X12;
689 lcd_patch_reg = K400_LCD_RES_8X6_16X12;
690 break;
691 case VIA_RES_1024X768:
692 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_16X12;
693 lcd_patch_reg = K400_LCD_RES_10X7_16X12;
694 break;
695 case VIA_RES_1280X768:
696 case VIA_RES_1280X800:
697 case VIA_RES_1280X960:
698 case VIA_RES_1280X1024:
699 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_16X12;
700 lcd_patch_reg = K400_LCD_RES_12X10_16X12;
701 break;
702 }
703 break;
704
705 /* LCD 1366x768 */
706 case LCD_PANEL_ID7_1366X768:
707 switch (vmode_index) {
708 case VIA_RES_640X480:
709 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_1366X7;
710 lcd_patch_reg = K400_LCD_RES_6X4_1366X7;
711 break;
712 case VIA_RES_720X480:
713 case VIA_RES_720X576:
714 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_1366X7;
715 lcd_patch_reg = K400_LCD_RES_7X4_1366X7;
716 break;
717 case VIA_RES_800X600:
718 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_1366X7;
719 lcd_patch_reg = K400_LCD_RES_8X6_1366X7;
720 break;
721 case VIA_RES_1024X768:
722 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_1366X7;
723 lcd_patch_reg = K400_LCD_RES_10X7_1366X7;
724 break;
725 case VIA_RES_1280X768:
726 case VIA_RES_1280X800:
727 case VIA_RES_1280X960:
728 case VIA_RES_1280X1024:
729 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_1366X7;
730 lcd_patch_reg = K400_LCD_RES_12X10_1366X7;
731 break;
732 }
733 break;
734
735 /* LCD 1360x768 */
736 case LCD_PANEL_IDB_1360X768:
737 break;
738 }
739 if (reg_num != 0) {
740 /* H.W. Reset : ON */
741 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7);
742
743 viafb_write_regx(lcd_patch_reg, reg_num);
744
745 /* H.W. Reset : OFF */
746 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7);
747
748 /* Reset PLL */
749 viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1);
750 viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1);
751
752 /* Fire! */
753 outb(inb(VIARMisc) | (BIT2 + BIT3), VIAWMisc);
754 }
755}
756
757static void load_lcd_p880_patch_tbl(int set_hres, int set_vres,
758 int panel_id)
759{
760 int vmode_index;
761 int reg_num = 0;
762 struct io_reg *lcd_patch_reg = NULL;
763
764 if (viaparinfo->lvds_setting_info->iga_path == IGA2)
765 vmode_index = viafb_get_mode_index(set_hres, set_vres, 1);
766 else
767 vmode_index = viafb_get_mode_index(set_hres, set_vres, 0);
768
769 switch (panel_id) {
770 case LCD_PANEL_ID5_1400X1050:
771 switch (vmode_index) {
772 case VIA_RES_640X480:
773 reg_num = NUM_TOTAL_P880_LCD_RES_6X4_14X10;
774 lcd_patch_reg = P880_LCD_RES_6X4_14X10;
775 break;
776 case VIA_RES_800X600:
777 reg_num = NUM_TOTAL_P880_LCD_RES_8X6_14X10;
778 lcd_patch_reg = P880_LCD_RES_8X6_14X10;
779 break;
780 }
781 break;
782 case LCD_PANEL_ID6_1600X1200:
783 switch (vmode_index) {
784 case VIA_RES_640X400:
785 case VIA_RES_640X480:
786 reg_num = NUM_TOTAL_P880_LCD_RES_6X4_16X12;
787 lcd_patch_reg = P880_LCD_RES_6X4_16X12;
788 break;
789 case VIA_RES_720X480:
790 case VIA_RES_720X576:
791 reg_num = NUM_TOTAL_P880_LCD_RES_7X4_16X12;
792 lcd_patch_reg = P880_LCD_RES_7X4_16X12;
793 break;
794 case VIA_RES_800X600:
795 reg_num = NUM_TOTAL_P880_LCD_RES_8X6_16X12;
796 lcd_patch_reg = P880_LCD_RES_8X6_16X12;
797 break;
798 case VIA_RES_1024X768:
799 reg_num = NUM_TOTAL_P880_LCD_RES_10X7_16X12;
800 lcd_patch_reg = P880_LCD_RES_10X7_16X12;
801 break;
802 case VIA_RES_1280X768:
803 case VIA_RES_1280X960:
804 case VIA_RES_1280X1024:
805 reg_num = NUM_TOTAL_P880_LCD_RES_12X10_16X12;
806 lcd_patch_reg = P880_LCD_RES_12X10_16X12;
807 break;
808 }
809 break;
810
811 }
812 if (reg_num != 0) {
813 /* H.W. Reset : ON */
814 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7);
815
816 viafb_write_regx(lcd_patch_reg, reg_num);
817
818 /* H.W. Reset : OFF */
819 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7);
820
821 /* Reset PLL */
822 viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1);
823 viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1);
824
825 /* Fire! */
826 outb(inb(VIARMisc) | (BIT2 + BIT3), VIAWMisc);
827 }
828}
829
830static void load_lcd_patch_regs(int set_hres, int set_vres,
831 int panel_id, int set_iga)
832{
833 int vmode_index;
834
835 if (viaparinfo->lvds_setting_info->iga_path == IGA2)
836 vmode_index = viafb_get_mode_index(set_hres, set_vres, 1);
837 else
838 vmode_index = viafb_get_mode_index(set_hres, set_vres, 0);
839
840 viafb_unlock_crt();
841
842 /* Patch for simultaneous & Expansion */
843 if ((set_iga == IGA1_IGA2) &&
844 (viaparinfo->lvds_setting_info->display_method ==
845 LCD_EXPANDSION)) {
846 switch (viaparinfo->chip_info->gfx_chip_name) {
847 case UNICHROME_CLE266:
848 case UNICHROME_K400:
849 load_lcd_k400_patch_tbl(set_hres, set_vres, panel_id);
850 break;
851 case UNICHROME_K800:
852 break;
853 case UNICHROME_PM800:
854 case UNICHROME_CN700:
855 case UNICHROME_CX700:
856 load_lcd_p880_patch_tbl(set_hres, set_vres, panel_id);
857 }
858 }
859
860 viafb_lock_crt();
861}
862
863static void via_pitch_alignment_patch_lcd(
864 struct lvds_setting_information *plvds_setting_info,
865 struct lvds_chip_information
866 *plvds_chip_info)
867{
868 unsigned char cr13, cr35, cr65, cr66, cr67;
869 unsigned long dwScreenPitch = 0;
870 unsigned long dwPitch;
871
872 dwPitch = plvds_setting_info->h_active * (plvds_setting_info->bpp >> 3);
873 if (dwPitch & 0x1F) {
874 dwScreenPitch = ((dwPitch + 31) & ~31) >> 3;
875 if (plvds_setting_info->iga_path == IGA2) {
876 if (plvds_setting_info->bpp > 8) {
877 cr66 = (unsigned char)(dwScreenPitch & 0xFF);
878 viafb_write_reg(CR66, VIACR, cr66);
879 cr67 = viafb_read_reg(VIACR, CR67) & 0xFC;
880 cr67 |=
881 (unsigned
882 char)((dwScreenPitch & 0x300) >> 8);
883 viafb_write_reg(CR67, VIACR, cr67);
884 }
885
886 /* Fetch Count */
887 cr67 = viafb_read_reg(VIACR, CR67) & 0xF3;
888 cr67 |= (unsigned char)((dwScreenPitch & 0x600) >> 7);
889 viafb_write_reg(CR67, VIACR, cr67);
890 cr65 = (unsigned char)((dwScreenPitch >> 1) & 0xFF);
891 cr65 += 2;
892 viafb_write_reg(CR65, VIACR, cr65);
893 } else {
894 if (plvds_setting_info->bpp > 8) {
895 cr13 = (unsigned char)(dwScreenPitch & 0xFF);
896 viafb_write_reg(CR13, VIACR, cr13);
897 cr35 = viafb_read_reg(VIACR, CR35) & 0x1F;
898 cr35 |=
899 (unsigned
900 char)((dwScreenPitch & 0x700) >> 3);
901 viafb_write_reg(CR35, VIACR, cr35);
902 }
903 }
904 }
905}
906static void lcd_patch_skew_dvp0(struct lvds_setting_information
907 *plvds_setting_info,
908 struct lvds_chip_information *plvds_chip_info)
909{
910 if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) {
911 switch (viaparinfo->chip_info->gfx_chip_name) {
912 case UNICHROME_P4M900:
913 viafb_vt1636_patch_skew_on_vt3364(plvds_setting_info,
914 plvds_chip_info);
915 break;
916 case UNICHROME_P4M890:
917 viafb_vt1636_patch_skew_on_vt3327(plvds_setting_info,
918 plvds_chip_info);
919 break;
920 }
921 }
922}
923static void lcd_patch_skew_dvp1(struct lvds_setting_information
924 *plvds_setting_info,
925 struct lvds_chip_information *plvds_chip_info)
926{
927 if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) {
928 switch (viaparinfo->chip_info->gfx_chip_name) {
929 case UNICHROME_CX700:
930 viafb_vt1636_patch_skew_on_vt3324(plvds_setting_info,
931 plvds_chip_info);
932 break;
933 }
934 }
935}
936static void lcd_patch_skew(struct lvds_setting_information
937 *plvds_setting_info, struct lvds_chip_information *plvds_chip_info)
938{
939 DEBUG_MSG(KERN_INFO "lcd_patch_skew\n");
940 switch (plvds_chip_info->output_interface) {
941 case INTERFACE_DVP0:
942 lcd_patch_skew_dvp0(plvds_setting_info, plvds_chip_info);
943 break;
944 case INTERFACE_DVP1:
945 lcd_patch_skew_dvp1(plvds_setting_info, plvds_chip_info);
946 break;
947 case INTERFACE_DFP_LOW:
948 if (UNICHROME_P4M900 == viaparinfo->chip_info->gfx_chip_name) {
949 viafb_write_reg_mask(CR99, VIACR, 0x08,
950 BIT0 + BIT1 + BIT2 + BIT3);
951 }
952 break;
953 }
954}
955
956/* LCD Set Mode */
957void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table,
958 struct lvds_setting_information *plvds_setting_info,
959 struct lvds_chip_information *plvds_chip_info)
960{
961 int video_index = plvds_setting_info->lcd_panel_size;
962 int set_iga = plvds_setting_info->iga_path;
963 int mode_bpp = plvds_setting_info->bpp;
964 int viafb_load_reg_num = 0;
965 int reg_value = 0;
966 int set_hres, set_vres;
967 int panel_hres, panel_vres;
968 u32 pll_D_N;
969 int offset;
970 struct io_register *reg = NULL;
971 struct display_timing mode_crt_reg, panel_crt_reg;
972 struct crt_mode_table *panel_crt_table = NULL;
973 struct VideoModeTable *vmode_tbl = NULL;
974
975 DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n");
976 /* Get mode table */
977 mode_crt_reg = mode_crt_table->crtc;
978 /* Get panel table Pointer */
979 vmode_tbl = viafb_get_modetbl_pointer(video_index);
980 panel_crt_table = vmode_tbl->crtc;
981 panel_crt_reg = panel_crt_table->crtc;
982 DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n");
983 set_hres = plvds_setting_info->h_active;
984 set_vres = plvds_setting_info->v_active;
985 panel_hres = plvds_setting_info->lcd_panel_hres;
986 panel_vres = plvds_setting_info->lcd_panel_vres;
987 if (VT1636_LVDS == plvds_chip_info->lvds_chip_name)
988 viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info);
989 plvds_setting_info->vclk = panel_crt_table->clk;
990 if (set_iga == IGA1) {
991 /* IGA1 doesn't have LCD scaling, so set it as centering. */
992 viafb_load_crtc_timing(lcd_centering_timging
993 (mode_crt_reg, panel_crt_reg), IGA1);
994 } else {
995 /* Expansion */
996 if ((plvds_setting_info->display_method ==
997 LCD_EXPANDSION) & ((set_hres != panel_hres)
998 || (set_vres != panel_vres))) {
999 /* expansion timing IGA2 loaded panel set timing*/
1000 viafb_load_crtc_timing(panel_crt_reg, IGA2);
1001 DEBUG_MSG(KERN_INFO "viafb_load_crtc_timing!!\n");
1002 load_lcd_scaling(set_hres, set_vres, panel_hres,
1003 panel_vres);
1004 DEBUG_MSG(KERN_INFO "load_lcd_scaling!!\n");
1005 } else { /* Centering */
1006 /* centering timing IGA2 always loaded panel
1007 and mode releative timing */
1008 viafb_load_crtc_timing(lcd_centering_timging
1009 (mode_crt_reg, panel_crt_reg), IGA2);
1010 viafb_write_reg_mask(CR79, VIACR, 0x00,
1011 BIT0 + BIT1 + BIT2);
1012 /* LCD scaling disabled */
1013 }
1014 }
1015
1016 if (set_iga == IGA1_IGA2) {
1017 load_crtc_shadow_timing(mode_crt_reg, panel_crt_reg);
1018 /* Fill shadow registers */
1019
1020 switch (plvds_setting_info->lcd_panel_id) {
1021 case LCD_PANEL_ID0_640X480:
1022 offset = 80;
1023 break;
1024 case LCD_PANEL_ID1_800X600:
1025 case LCD_PANEL_IDA_800X480:
1026 offset = 110;
1027 break;
1028 case LCD_PANEL_ID2_1024X768:
1029 offset = 150;
1030 break;
1031 case LCD_PANEL_ID3_1280X768:
1032 case LCD_PANEL_ID4_1280X1024:
1033 case LCD_PANEL_ID5_1400X1050:
1034 case LCD_PANEL_ID9_1280X800:
1035 offset = 190;
1036 break;
1037 case LCD_PANEL_ID6_1600X1200:
1038 offset = 250;
1039 break;
1040 case LCD_PANEL_ID7_1366X768:
1041 case LCD_PANEL_IDB_1360X768:
1042 offset = 212;
1043 break;
1044 default:
1045 offset = 140;
1046 break;
1047 }
1048
1049 /* Offset for simultaneous */
1050 reg_value = offset;
1051 viafb_load_reg_num = offset_reg.iga2_offset_reg.reg_num;
1052 reg = offset_reg.iga2_offset_reg.reg;
1053 viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR);
1054 DEBUG_MSG(KERN_INFO "viafb_load_reg!!\n");
1055 viafb_load_fetch_count_reg(set_hres, 4, IGA2);
1056 /* Fetch count for simultaneous */
1057 } else { /* SAMM */
1058 /* Offset for IGA2 only */
1059 viafb_load_offset_reg(set_hres, mode_bpp / 8, set_iga);
1060 /* Fetch count for IGA2 only */
1061 viafb_load_fetch_count_reg(set_hres, mode_bpp / 8, set_iga);
1062
1063 if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266)
1064 && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400))
1065 viafb_load_FIFO_reg(set_iga, set_hres, set_vres);
1066
1067 viafb_set_color_depth(mode_bpp / 8, set_iga);
1068 }
1069
1070 fill_lcd_format();
1071
1072 pll_D_N = viafb_get_clk_value(panel_crt_table[0].clk);
1073 DEBUG_MSG(KERN_INFO "PLL=0x%x", pll_D_N);
1074 viafb_set_vclock(pll_D_N, set_iga);
1075
1076 viafb_set_output_path(DEVICE_LCD, set_iga,
1077 plvds_chip_info->output_interface);
1078 lcd_patch_skew(plvds_setting_info, plvds_chip_info);
1079
1080 /* If K8M800, enable LCD Prefetch Mode. */
1081 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800)
1082 || (UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name))
1083 viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0);
1084
1085 load_lcd_patch_regs(set_hres, set_vres,
1086 plvds_setting_info->lcd_panel_id, set_iga);
1087
1088 DEBUG_MSG(KERN_INFO "load_lcd_patch_regs!!\n");
1089
1090 /* Patch for non 32bit alignment mode */
1091 via_pitch_alignment_patch_lcd(plvds_setting_info, plvds_chip_info);
1092}
1093
1094static void integrated_lvds_disable(struct lvds_setting_information
1095 *plvds_setting_info,
1096 struct lvds_chip_information *plvds_chip_info)
1097{
1098 bool turn_off_first_powersequence = false;
1099 bool turn_off_second_powersequence = false;
1100 if (INTERFACE_LVDS0LVDS1 == plvds_chip_info->output_interface)
1101 turn_off_first_powersequence = true;
1102 if (INTERFACE_LVDS0 == plvds_chip_info->output_interface)
1103 turn_off_first_powersequence = true;
1104 if (INTERFACE_LVDS1 == plvds_chip_info->output_interface)
1105 turn_off_second_powersequence = true;
1106 if (turn_off_second_powersequence) {
1107 /* Use second power sequence control: */
1108
1109 /* Turn off power sequence. */
1110 viafb_write_reg_mask(CRD4, VIACR, 0, BIT1);
1111
1112 /* Turn off back light. */
1113 viafb_write_reg_mask(CRD3, VIACR, 0xC0, BIT6 + BIT7);
1114 }
1115 if (turn_off_first_powersequence) {
1116 /* Use first power sequence control: */
1117
1118 /* Turn off power sequence. */
1119 viafb_write_reg_mask(CR6A, VIACR, 0, BIT3);
1120
1121 /* Turn off back light. */
1122 viafb_write_reg_mask(CR91, VIACR, 0xC0, BIT6 + BIT7);
1123 }
1124
1125 /* Turn DFP High/Low Pad off. */
1126 viafb_write_reg_mask(SR2A, VIASR, 0, BIT0 + BIT1 + BIT2 + BIT3);
1127
1128 /* Power off LVDS channel. */
1129 switch (plvds_chip_info->output_interface) {
1130 case INTERFACE_LVDS0:
1131 {
1132 viafb_write_reg_mask(CRD2, VIACR, 0x80, BIT7);
1133 break;
1134 }
1135
1136 case INTERFACE_LVDS1:
1137 {
1138 viafb_write_reg_mask(CRD2, VIACR, 0x40, BIT6);
1139 break;
1140 }
1141
1142 case INTERFACE_LVDS0LVDS1:
1143 {
1144 viafb_write_reg_mask(CRD2, VIACR, 0xC0, BIT6 + BIT7);
1145 break;
1146 }
1147 }
1148}
1149
1150static void integrated_lvds_enable(struct lvds_setting_information
1151 *plvds_setting_info,
1152 struct lvds_chip_information *plvds_chip_info)
1153{
1154 bool turn_on_first_powersequence = false;
1155 bool turn_on_second_powersequence = false;
1156
1157 DEBUG_MSG(KERN_INFO "integrated_lvds_enable, out_interface:%d\n",
1158 plvds_chip_info->output_interface);
1159 if (plvds_setting_info->lcd_mode == LCD_SPWG)
1160 viafb_write_reg_mask(CRD2, VIACR, 0x00, BIT0 + BIT1);
1161 else
1162 viafb_write_reg_mask(CRD2, VIACR, 0x03, BIT0 + BIT1);
1163 if (INTERFACE_LVDS0LVDS1 == plvds_chip_info->output_interface)
1164 turn_on_first_powersequence = true;
1165 if (INTERFACE_LVDS0 == plvds_chip_info->output_interface)
1166 turn_on_first_powersequence = true;
1167 if (INTERFACE_LVDS1 == plvds_chip_info->output_interface)
1168 turn_on_second_powersequence = true;
1169
1170 if (turn_on_second_powersequence) {
1171 /* Use second power sequence control: */
1172
1173 /* Use hardware control power sequence. */
1174 viafb_write_reg_mask(CRD3, VIACR, 0, BIT0);
1175
1176 /* Turn on back light. */
1177 viafb_write_reg_mask(CRD3, VIACR, 0, BIT6 + BIT7);
1178
1179 /* Turn on hardware power sequence. */
1180 viafb_write_reg_mask(CRD4, VIACR, 0x02, BIT1);
1181 }
1182 if (turn_on_first_powersequence) {
1183 /* Use first power sequence control: */
1184
1185 /* Use hardware control power sequence. */
1186 viafb_write_reg_mask(CR91, VIACR, 0, BIT0);
1187
1188 /* Turn on back light. */
1189 viafb_write_reg_mask(CR91, VIACR, 0, BIT6 + BIT7);
1190
1191 /* Turn on hardware power sequence. */
1192 viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
1193 }
1194
1195 /* Turn DFP High/Low pad on. */
1196 viafb_write_reg_mask(SR2A, VIASR, 0x0F, BIT0 + BIT1 + BIT2 + BIT3);
1197
1198 /* Power on LVDS channel. */
1199 switch (plvds_chip_info->output_interface) {
1200 case INTERFACE_LVDS0:
1201 {
1202 viafb_write_reg_mask(CRD2, VIACR, 0, BIT7);
1203 break;
1204 }
1205
1206 case INTERFACE_LVDS1:
1207 {
1208 viafb_write_reg_mask(CRD2, VIACR, 0, BIT6);
1209 break;
1210 }
1211
1212 case INTERFACE_LVDS0LVDS1:
1213 {
1214 viafb_write_reg_mask(CRD2, VIACR, 0, BIT6 + BIT7);
1215 break;
1216 }
1217 }
1218}
1219
1220void viafb_lcd_disable(void)
1221{
1222
1223 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
1224 lcd_powersequence_off();
1225 /* DI1 pad off */
1226 viafb_write_reg_mask(SR1E, VIASR, 0x00, 0x30);
1227 } else if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) {
1228 if (viafb_LCD2_ON
1229 && (INTEGRATED_LVDS ==
1230 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name))
1231 integrated_lvds_disable(viaparinfo->lvds_setting_info,
1232 &viaparinfo->chip_info->lvds_chip_info2);
1233 if (INTEGRATED_LVDS ==
1234 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name)
1235 integrated_lvds_disable(viaparinfo->lvds_setting_info,
1236 &viaparinfo->chip_info->lvds_chip_info);
1237 if (VT1636_LVDS == viaparinfo->chip_info->
1238 lvds_chip_info.lvds_chip_name)
1239 viafb_disable_lvds_vt1636(viaparinfo->lvds_setting_info,
1240 &viaparinfo->chip_info->lvds_chip_info);
1241 } else if (VT1636_LVDS ==
1242 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1243 viafb_disable_lvds_vt1636(viaparinfo->lvds_setting_info,
1244 &viaparinfo->chip_info->lvds_chip_info);
1245 } else {
1246 /* DFP-HL pad off */
1247 viafb_write_reg_mask(SR2A, VIASR, 0x00, 0x0F);
1248 /* Backlight off */
1249 viafb_write_reg_mask(SR3D, VIASR, 0x00, 0x20);
1250 /* 24 bit DI data paht off */
1251 viafb_write_reg_mask(CR91, VIACR, 0x80, 0x80);
1252 /* Simultaneout disabled */
1253 viafb_write_reg_mask(CR6B, VIACR, 0x00, 0x08);
1254 }
1255
1256 /* Disable expansion bit */
1257 viafb_write_reg_mask(CR79, VIACR, 0x00, 0x01);
1258 /* CRT path set to IGA1 */
1259 viafb_write_reg_mask(SR16, VIASR, 0x00, 0x40);
1260 /* Simultaneout disabled */
1261 viafb_write_reg_mask(CR6B, VIACR, 0x00, 0x08);
1262 /* IGA2 path disabled */
1263 viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x80);
1264
1265}
1266
1267void viafb_lcd_enable(void)
1268{
1269 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
1270 /* DI1 pad on */
1271 viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30);
1272 lcd_powersequence_on();
1273 } else if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) {
1274 if (viafb_LCD2_ON && (INTEGRATED_LVDS ==
1275 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name))
1276 integrated_lvds_enable(viaparinfo->lvds_setting_info2, \
1277 &viaparinfo->chip_info->lvds_chip_info2);
1278 if (INTEGRATED_LVDS ==
1279 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name)
1280 integrated_lvds_enable(viaparinfo->lvds_setting_info,
1281 &viaparinfo->chip_info->lvds_chip_info);
1282 if (VT1636_LVDS == viaparinfo->chip_info->
1283 lvds_chip_info.lvds_chip_name)
1284 viafb_enable_lvds_vt1636(viaparinfo->
1285 lvds_setting_info, &viaparinfo->chip_info->
1286 lvds_chip_info);
1287 } else if (VT1636_LVDS ==
1288 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1289 viafb_enable_lvds_vt1636(viaparinfo->lvds_setting_info,
1290 &viaparinfo->chip_info->lvds_chip_info);
1291 } else {
1292 /* DFP-HL pad on */
1293 viafb_write_reg_mask(SR2A, VIASR, 0x0F, 0x0F);
1294 /* Backlight on */
1295 viafb_write_reg_mask(SR3D, VIASR, 0x20, 0x20);
1296 /* 24 bit DI data paht on */
1297 viafb_write_reg_mask(CR91, VIACR, 0x00, 0x80);
1298
1299 /* Set data source selection bit by iga path */
1300 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1301 /* DFP-H set to IGA1 */
1302 viafb_write_reg_mask(CR97, VIACR, 0x00, 0x10);
1303 /* DFP-L set to IGA1 */
1304 viafb_write_reg_mask(CR99, VIACR, 0x00, 0x10);
1305 } else {
1306 /* DFP-H set to IGA2 */
1307 viafb_write_reg_mask(CR97, VIACR, 0x10, 0x10);
1308 /* DFP-L set to IGA2 */
1309 viafb_write_reg_mask(CR99, VIACR, 0x10, 0x10);
1310 }
1311 /* LCD enabled */
1312 viafb_write_reg_mask(CR6A, VIACR, 0x48, 0x48);
1313 }
1314
1315 if ((viaparinfo->lvds_setting_info->iga_path == IGA1)
1316 || (viaparinfo->lvds_setting_info->iga_path == IGA1_IGA2)) {
1317 /* CRT path set to IGA2 */
1318 viafb_write_reg_mask(SR16, VIASR, 0x40, 0x40);
1319 /* IGA2 path disabled */
1320 viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x80);
1321 /* IGA2 path enabled */
1322 } else { /* IGA2 */
1323 viafb_write_reg_mask(CR6A, VIACR, 0x80, 0x80);
1324 }
1325
1326}
1327
1328static void lcd_powersequence_off(void)
1329{
1330 int i, mask, data;
1331
1332 /* Software control power sequence */
1333 viafb_write_reg_mask(CR91, VIACR, 0x11, 0x11);
1334
1335 for (i = 0; i < 3; i++) {
1336 mask = PowerSequenceOff[0][i];
1337 data = PowerSequenceOff[1][i] & mask;
1338 viafb_write_reg_mask(CR91, VIACR, (u8) data, (u8) mask);
1339 udelay(PowerSequenceOff[2][i]);
1340 }
1341
1342 /* Disable LCD */
1343 viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x08);
1344}
1345
1346static void lcd_powersequence_on(void)
1347{
1348 int i, mask, data;
1349
1350 /* Software control power sequence */
1351 viafb_write_reg_mask(CR91, VIACR, 0x11, 0x11);
1352
1353 /* Enable LCD */
1354 viafb_write_reg_mask(CR6A, VIACR, 0x08, 0x08);
1355
1356 for (i = 0; i < 3; i++) {
1357 mask = PowerSequenceOn[0][i];
1358 data = PowerSequenceOn[1][i] & mask;
1359 viafb_write_reg_mask(CR91, VIACR, (u8) data, (u8) mask);
1360 udelay(PowerSequenceOn[2][i]);
1361 }
1362
1363 udelay(1);
1364}
1365
1366static void fill_lcd_format(void)
1367{
1368 u8 bdithering = 0, bdual = 0;
1369
1370 if (viaparinfo->lvds_setting_info->device_lcd_dualedge)
1371 bdual = BIT4;
1372 if (viaparinfo->lvds_setting_info->LCDDithering)
1373 bdithering = BIT0;
1374 /* Dual & Dithering */
1375 viafb_write_reg_mask(CR88, VIACR, (bdithering | bdual), BIT4 + BIT0);
1376}
1377
1378static void check_diport_of_integrated_lvds(
1379 struct lvds_chip_information *plvds_chip_info,
1380 struct lvds_setting_information
1381 *plvds_setting_info)
1382{
1383 /* Determine LCD DI Port by hardware layout. */
1384 switch (viafb_display_hardware_layout) {
1385 case HW_LAYOUT_LCD_ONLY:
1386 {
1387 if (plvds_setting_info->device_lcd_dualedge) {
1388 plvds_chip_info->output_interface =
1389 INTERFACE_LVDS0LVDS1;
1390 } else {
1391 plvds_chip_info->output_interface =
1392 INTERFACE_LVDS0;
1393 }
1394
1395 break;
1396 }
1397
1398 case HW_LAYOUT_DVI_ONLY:
1399 {
1400 plvds_chip_info->output_interface = INTERFACE_NONE;
1401 break;
1402 }
1403
1404 case HW_LAYOUT_LCD1_LCD2:
1405 case HW_LAYOUT_LCD_EXTERNAL_LCD2:
1406 {
1407 plvds_chip_info->output_interface =
1408 INTERFACE_LVDS0LVDS1;
1409 break;
1410 }
1411
1412 case HW_LAYOUT_LCD_DVI:
1413 {
1414 plvds_chip_info->output_interface = INTERFACE_LVDS1;
1415 break;
1416 }
1417
1418 default:
1419 {
1420 plvds_chip_info->output_interface = INTERFACE_LVDS1;
1421 break;
1422 }
1423 }
1424
1425 DEBUG_MSG(KERN_INFO
1426 "Display Hardware Layout: 0x%x, LCD DI Port: 0x%x\n",
1427 viafb_display_hardware_layout,
1428 plvds_chip_info->output_interface);
1429}
1430
1431void viafb_init_lvds_output_interface(struct lvds_chip_information
1432 *plvds_chip_info,
1433 struct lvds_setting_information
1434 *plvds_setting_info)
1435{
1436 if (INTERFACE_NONE != plvds_chip_info->output_interface) {
1437 /*Do nothing, lcd port is specified by module parameter */
1438 return;
1439 }
1440
1441 switch (plvds_chip_info->lvds_chip_name) {
1442
1443 case VT1636_LVDS:
1444 switch (viaparinfo->chip_info->gfx_chip_name) {
1445 case UNICHROME_CX700:
1446 plvds_chip_info->output_interface = INTERFACE_DVP1;
1447 break;
1448 case UNICHROME_CN700:
1449 plvds_chip_info->output_interface = INTERFACE_DFP_LOW;
1450 break;
1451 default:
1452 plvds_chip_info->output_interface = INTERFACE_DVP0;
1453 break;
1454 }
1455 break;
1456
1457 case INTEGRATED_LVDS:
1458 check_diport_of_integrated_lvds(plvds_chip_info,
1459 plvds_setting_info);
1460 break;
1461
1462 default:
1463 switch (viaparinfo->chip_info->gfx_chip_name) {
1464 case UNICHROME_K8M890:
1465 case UNICHROME_P4M900:
1466 case UNICHROME_P4M890:
1467 plvds_chip_info->output_interface = INTERFACE_DFP_LOW;
1468 break;
1469 default:
1470 plvds_chip_info->output_interface = INTERFACE_DFP;
1471 break;
1472 }
1473 break;
1474 }
1475}
1476
1477static struct display_timing lcd_centering_timging(struct display_timing
1478 mode_crt_reg,
1479 struct display_timing panel_crt_reg)
1480{
1481 struct display_timing crt_reg;
1482
1483 crt_reg.hor_total = panel_crt_reg.hor_total;
1484 crt_reg.hor_addr = mode_crt_reg.hor_addr;
1485 crt_reg.hor_blank_start =
1486 (panel_crt_reg.hor_addr - mode_crt_reg.hor_addr) / 2 +
1487 crt_reg.hor_addr;
1488 crt_reg.hor_blank_end = panel_crt_reg.hor_blank_end;
1489 crt_reg.hor_sync_start =
1490 (panel_crt_reg.hor_sync_start -
1491 panel_crt_reg.hor_blank_start) + crt_reg.hor_blank_start;
1492 crt_reg.hor_sync_end = panel_crt_reg.hor_sync_end;
1493
1494 crt_reg.ver_total = panel_crt_reg.ver_total;
1495 crt_reg.ver_addr = mode_crt_reg.ver_addr;
1496 crt_reg.ver_blank_start =
1497 (panel_crt_reg.ver_addr - mode_crt_reg.ver_addr) / 2 +
1498 crt_reg.ver_addr;
1499 crt_reg.ver_blank_end = panel_crt_reg.ver_blank_end;
1500 crt_reg.ver_sync_start =
1501 (panel_crt_reg.ver_sync_start -
1502 panel_crt_reg.ver_blank_start) + crt_reg.ver_blank_start;
1503 crt_reg.ver_sync_end = panel_crt_reg.ver_sync_end;
1504
1505 return crt_reg;
1506}
1507
1508static void load_crtc_shadow_timing(struct display_timing mode_timing,
1509 struct display_timing panel_timing)
1510{
1511 struct io_register *reg = NULL;
1512 int i;
1513 int viafb_load_reg_Num = 0;
1514 int reg_value = 0;
1515
1516 if (viaparinfo->lvds_setting_info->display_method == LCD_EXPANDSION) {
1517 /* Expansion */
1518 for (i = 12; i < 20; i++) {
1519 switch (i) {
1520 case H_TOTAL_SHADOW_INDEX:
1521 reg_value =
1522 IGA2_HOR_TOTAL_SHADOW_FORMULA
1523 (panel_timing.hor_total);
1524 viafb_load_reg_Num =
1525 iga2_shadow_crtc_reg.hor_total_shadow.
1526 reg_num;
1527 reg = iga2_shadow_crtc_reg.hor_total_shadow.reg;
1528 break;
1529 case H_BLANK_END_SHADOW_INDEX:
1530 reg_value =
1531 IGA2_HOR_BLANK_END_SHADOW_FORMULA
1532 (panel_timing.hor_blank_start,
1533 panel_timing.hor_blank_end);
1534 viafb_load_reg_Num =
1535 iga2_shadow_crtc_reg.
1536 hor_blank_end_shadow.reg_num;
1537 reg =
1538 iga2_shadow_crtc_reg.
1539 hor_blank_end_shadow.reg;
1540 break;
1541 case V_TOTAL_SHADOW_INDEX:
1542 reg_value =
1543 IGA2_VER_TOTAL_SHADOW_FORMULA
1544 (panel_timing.ver_total);
1545 viafb_load_reg_Num =
1546 iga2_shadow_crtc_reg.ver_total_shadow.
1547 reg_num;
1548 reg = iga2_shadow_crtc_reg.ver_total_shadow.reg;
1549 break;
1550 case V_ADDR_SHADOW_INDEX:
1551 reg_value =
1552 IGA2_VER_ADDR_SHADOW_FORMULA
1553 (panel_timing.ver_addr);
1554 viafb_load_reg_Num =
1555 iga2_shadow_crtc_reg.ver_addr_shadow.
1556 reg_num;
1557 reg = iga2_shadow_crtc_reg.ver_addr_shadow.reg;
1558 break;
1559 case V_BLANK_SATRT_SHADOW_INDEX:
1560 reg_value =
1561 IGA2_VER_BLANK_START_SHADOW_FORMULA
1562 (panel_timing.ver_blank_start);
1563 viafb_load_reg_Num =
1564 iga2_shadow_crtc_reg.
1565 ver_blank_start_shadow.reg_num;
1566 reg =
1567 iga2_shadow_crtc_reg.
1568 ver_blank_start_shadow.reg;
1569 break;
1570 case V_BLANK_END_SHADOW_INDEX:
1571 reg_value =
1572 IGA2_VER_BLANK_END_SHADOW_FORMULA
1573 (panel_timing.ver_blank_start,
1574 panel_timing.ver_blank_end);
1575 viafb_load_reg_Num =
1576 iga2_shadow_crtc_reg.
1577 ver_blank_end_shadow.reg_num;
1578 reg =
1579 iga2_shadow_crtc_reg.
1580 ver_blank_end_shadow.reg;
1581 break;
1582 case V_SYNC_SATRT_SHADOW_INDEX:
1583 reg_value =
1584 IGA2_VER_SYNC_START_SHADOW_FORMULA
1585 (panel_timing.ver_sync_start);
1586 viafb_load_reg_Num =
1587 iga2_shadow_crtc_reg.
1588 ver_sync_start_shadow.reg_num;
1589 reg =
1590 iga2_shadow_crtc_reg.
1591 ver_sync_start_shadow.reg;
1592 break;
1593 case V_SYNC_END_SHADOW_INDEX:
1594 reg_value =
1595 IGA2_VER_SYNC_END_SHADOW_FORMULA
1596 (panel_timing.ver_sync_start,
1597 panel_timing.ver_sync_end);
1598 viafb_load_reg_Num =
1599 iga2_shadow_crtc_reg.
1600 ver_sync_end_shadow.reg_num;
1601 reg =
1602 iga2_shadow_crtc_reg.
1603 ver_sync_end_shadow.reg;
1604 break;
1605 }
1606 viafb_load_reg(reg_value,
1607 viafb_load_reg_Num, reg, VIACR);
1608 }
1609 } else { /* Centering */
1610 for (i = 12; i < 20; i++) {
1611 switch (i) {
1612 case H_TOTAL_SHADOW_INDEX:
1613 reg_value =
1614 IGA2_HOR_TOTAL_SHADOW_FORMULA
1615 (panel_timing.hor_total);
1616 viafb_load_reg_Num =
1617 iga2_shadow_crtc_reg.hor_total_shadow.
1618 reg_num;
1619 reg = iga2_shadow_crtc_reg.hor_total_shadow.reg;
1620 break;
1621 case H_BLANK_END_SHADOW_INDEX:
1622 reg_value =
1623 IGA2_HOR_BLANK_END_SHADOW_FORMULA
1624 (panel_timing.hor_blank_start,
1625 panel_timing.hor_blank_end);
1626 viafb_load_reg_Num =
1627 iga2_shadow_crtc_reg.
1628 hor_blank_end_shadow.reg_num;
1629 reg =
1630 iga2_shadow_crtc_reg.
1631 hor_blank_end_shadow.reg;
1632 break;
1633 case V_TOTAL_SHADOW_INDEX:
1634 reg_value =
1635 IGA2_VER_TOTAL_SHADOW_FORMULA
1636 (panel_timing.ver_total);
1637 viafb_load_reg_Num =
1638 iga2_shadow_crtc_reg.ver_total_shadow.
1639 reg_num;
1640 reg = iga2_shadow_crtc_reg.ver_total_shadow.reg;
1641 break;
1642 case V_ADDR_SHADOW_INDEX:
1643 reg_value =
1644 IGA2_VER_ADDR_SHADOW_FORMULA
1645 (mode_timing.ver_addr);
1646 viafb_load_reg_Num =
1647 iga2_shadow_crtc_reg.ver_addr_shadow.
1648 reg_num;
1649 reg = iga2_shadow_crtc_reg.ver_addr_shadow.reg;
1650 break;
1651 case V_BLANK_SATRT_SHADOW_INDEX:
1652 reg_value =
1653 IGA2_VER_BLANK_START_SHADOW_FORMULA
1654 (mode_timing.ver_blank_start);
1655 viafb_load_reg_Num =
1656 iga2_shadow_crtc_reg.
1657 ver_blank_start_shadow.reg_num;
1658 reg =
1659 iga2_shadow_crtc_reg.
1660 ver_blank_start_shadow.reg;
1661 break;
1662 case V_BLANK_END_SHADOW_INDEX:
1663 reg_value =
1664 IGA2_VER_BLANK_END_SHADOW_FORMULA
1665 (panel_timing.ver_blank_start,
1666 panel_timing.ver_blank_end);
1667 viafb_load_reg_Num =
1668 iga2_shadow_crtc_reg.
1669 ver_blank_end_shadow.reg_num;
1670 reg =
1671 iga2_shadow_crtc_reg.
1672 ver_blank_end_shadow.reg;
1673 break;
1674 case V_SYNC_SATRT_SHADOW_INDEX:
1675 reg_value =
1676 IGA2_VER_SYNC_START_SHADOW_FORMULA(
1677 (panel_timing.ver_sync_start -
1678 panel_timing.ver_blank_start) +
1679 (panel_timing.ver_addr -
1680 mode_timing.ver_addr) / 2 +
1681 mode_timing.ver_addr);
1682 viafb_load_reg_Num =
1683 iga2_shadow_crtc_reg.ver_sync_start_shadow.
1684 reg_num;
1685 reg =
1686 iga2_shadow_crtc_reg.ver_sync_start_shadow.
1687 reg;
1688 break;
1689 case V_SYNC_END_SHADOW_INDEX:
1690 reg_value =
1691 IGA2_VER_SYNC_END_SHADOW_FORMULA(
1692 (panel_timing.ver_sync_start -
1693 panel_timing.ver_blank_start) +
1694 (panel_timing.ver_addr -
1695 mode_timing.ver_addr) / 2 +
1696 mode_timing.ver_addr,
1697 panel_timing.ver_sync_end);
1698 viafb_load_reg_Num =
1699 iga2_shadow_crtc_reg.ver_sync_end_shadow.
1700 reg_num;
1701 reg =
1702 iga2_shadow_crtc_reg.ver_sync_end_shadow.
1703 reg;
1704 break;
1705 }
1706 viafb_load_reg(reg_value,
1707 viafb_load_reg_Num, reg, VIACR);
1708 }
1709 }
1710}
1711
1712bool viafb_lcd_get_mobile_state(bool *mobile)
1713{
1714 unsigned char *romptr, *tableptr;
1715 u8 core_base;
1716 unsigned char *biosptr;
1717 /* Rom address */
1718 u32 romaddr = 0x000C0000;
1719 u16 start_pattern = 0;
1720
1721 biosptr = ioremap(romaddr, 0x10000);
1722
1723 memcpy(&start_pattern, biosptr, 2);
1724 /* Compare pattern */
1725 if (start_pattern == 0xAA55) {
1726 /* Get the start of Table */
1727 /* 0x1B means BIOS offset position */
1728 romptr = biosptr + 0x1B;
1729 tableptr = biosptr + *((u16 *) romptr);
1730
1731 /* Get the start of biosver structure */
1732 /* 18 means BIOS version position. */
1733 romptr = tableptr + 18;
1734 romptr = biosptr + *((u16 *) romptr);
1735
1736 /* The offset should be 44, but the
1737 actual image is less three char. */
1738 /* pRom += 44; */
1739 romptr += 41;
1740
1741 core_base = *romptr++;
1742
1743 if (core_base & 0x8)
1744 *mobile = false;
1745 else
1746 *mobile = true;
1747 /* release memory */
1748 iounmap(biosptr);
1749
1750 return true;
1751 } else {
1752 iounmap(biosptr);
1753 return false;
1754 }
1755}
1756
1757static void viafb_load_scaling_factor_for_p4m900(int set_hres,
1758 int set_vres, int panel_hres, int panel_vres)
1759{
1760 int h_scaling_factor;
1761 int v_scaling_factor;
1762 u8 cra2 = 0;
1763 u8 cr77 = 0;
1764 u8 cr78 = 0;
1765 u8 cr79 = 0;
1766 u8 cr9f = 0;
1767 /* Check if expansion for horizontal */
1768 if (set_hres < panel_hres) {
1769 /* Load Horizontal Scaling Factor */
1770
1771 /* For VIA_K8M800 or later chipsets. */
1772 h_scaling_factor =
1773 K800_LCD_HOR_SCF_FORMULA(set_hres, panel_hres);
1774 /* HSCaleFactor[1:0] at CR9F[1:0] */
1775 cr9f = h_scaling_factor & 0x0003;
1776 /* HSCaleFactor[9:2] at CR77[7:0] */
1777 cr77 = (h_scaling_factor & 0x03FC) >> 2;
1778 /* HSCaleFactor[11:10] at CR79[5:4] */
1779 cr79 = (h_scaling_factor & 0x0C00) >> 10;
1780 cr79 <<= 4;
1781
1782 /* Horizontal scaling enabled */
1783 cra2 = 0xC0;
1784
1785 DEBUG_MSG(KERN_INFO "Horizontal Scaling value = %d\n",
1786 h_scaling_factor);
1787 } else {
1788 /* Horizontal scaling disabled */
1789 cra2 = 0x00;
1790 }
1791
1792 /* Check if expansion for vertical */
1793 if (set_vres < panel_vres) {
1794 /* Load Vertical Scaling Factor */
1795
1796 /* For VIA_K8M800 or later chipsets. */
1797 v_scaling_factor =
1798 K800_LCD_VER_SCF_FORMULA(set_vres, panel_vres);
1799
1800 /* Vertical scaling enabled */
1801 cra2 |= 0x08;
1802 /* VSCaleFactor[0] at CR79[3] */
1803 cr79 |= ((v_scaling_factor & 0x0001) << 3);
1804 /* VSCaleFactor[8:1] at CR78[7:0] */
1805 cr78 |= (v_scaling_factor & 0x01FE) >> 1;
1806 /* VSCaleFactor[10:9] at CR79[7:6] */
1807 cr79 |= ((v_scaling_factor & 0x0600) >> 9) << 6;
1808
1809 DEBUG_MSG(KERN_INFO "Vertical Scaling value = %d\n",
1810 v_scaling_factor);
1811 } else {
1812 /* Vertical scaling disabled */
1813 cra2 |= 0x00;
1814 }
1815
1816 viafb_write_reg_mask(CRA2, VIACR, cra2, BIT3 + BIT6 + BIT7);
1817 viafb_write_reg_mask(CR77, VIACR, cr77, 0xFF);
1818 viafb_write_reg_mask(CR78, VIACR, cr78, 0xFF);
1819 viafb_write_reg_mask(CR79, VIACR, cr79, 0xF8);
1820 viafb_write_reg_mask(CR9F, VIACR, cr9f, BIT0 + BIT1);
1821}
diff --git a/drivers/video/via/lcd.h b/drivers/video/via/lcd.h
new file mode 100644
index 000000000000..071f47cf5be1
--- /dev/null
+++ b/drivers/video/via/lcd.h
@@ -0,0 +1,94 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#ifndef __LCD_H__
22#define __LCD_H__
23
24/*Definition TMDS Device ID register*/
25#define VT1631_DEVICE_ID_REG 0x02
26#define VT1631_DEVICE_ID 0x92
27
28#define VT3271_DEVICE_ID_REG 0x02
29#define VT3271_DEVICE_ID 0x71
30
31#define GET_LCD_SIZE_BY_SYSTEM_BIOS 0x01
32#define GET_LCD_SIZE_BY_VGA_BIOS 0x02
33#define GET_LCD_SZIE_BY_HW_STRAPPING 0x03
34#define GET_LCD_SIZE_BY_USER_SETTING 0x04
35
36/* Definition DVI Panel ID*/
37/* Resolution: 640x480, Channel: single, Dithering: Enable */
38#define LCD_PANEL_ID0_640X480 0x00
39/* Resolution: 800x600, Channel: single, Dithering: Enable */
40#define LCD_PANEL_ID1_800X600 0x01
41/* Resolution: 1024x768, Channel: single, Dithering: Enable */
42#define LCD_PANEL_ID2_1024X768 0x02
43/* Resolution: 1280x768, Channel: single, Dithering: Enable */
44#define LCD_PANEL_ID3_1280X768 0x03
45/* Resolution: 1280x1024, Channel: dual, Dithering: Enable */
46#define LCD_PANEL_ID4_1280X1024 0x04
47/* Resolution: 1400x1050, Channel: dual, Dithering: Enable */
48#define LCD_PANEL_ID5_1400X1050 0x05
49/* Resolution: 1600x1200, Channel: dual, Dithering: Enable */
50#define LCD_PANEL_ID6_1600X1200 0x06
51/* Resolution: 1366x768, Channel: single, Dithering: Disable */
52#define LCD_PANEL_ID7_1366X768 0x07
53/* Resolution: 1024x600, Channel: single, Dithering: Enable*/
54#define LCD_PANEL_ID8_1024X600 0x08
55/* Resolution: 1280x800, Channel: single, Dithering: Enable*/
56#define LCD_PANEL_ID9_1280X800 0x09
57/* Resolution: 800x480, Channel: single, Dithering: Enable*/
58#define LCD_PANEL_IDA_800X480 0x0A
59/* Resolution: 1360x768, Channel: single, Dithering: Disable*/
60#define LCD_PANEL_IDB_1360X768 0x0B
61/* Resolution: 480x640, Channel: single, Dithering: Enable */
62#define LCD_PANEL_IDC_480X640 0x0C
63
64
65extern int viafb_LCD2_ON;
66extern int viafb_LCD_ON;
67extern int viafb_DVI_ON;
68
69void viafb_disable_lvds_vt1636(struct lvds_setting_information
70 *plvds_setting_info,
71 struct lvds_chip_information *plvds_chip_info);
72void viafb_enable_lvds_vt1636(struct lvds_setting_information
73 *plvds_setting_info,
74 struct lvds_chip_information *plvds_chip_info);
75void viafb_lcd_disable(void);
76void viafb_lcd_enable(void);
77void viafb_init_lcd_size(void);
78void viafb_init_lvds_output_interface(struct lvds_chip_information
79 *plvds_chip_info,
80 struct lvds_setting_information
81 *plvds_setting_info);
82void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table,
83 struct lvds_setting_information *plvds_setting_info,
84 struct lvds_chip_information *plvds_chip_info);
85int viafb_lvds_trasmitter_identify(void);
86void viafb_init_lvds_output_interface(struct lvds_chip_information
87 *plvds_chip_info,
88 struct lvds_setting_information
89 *plvds_setting_info);
90bool viafb_lcd_get_mobile_state(bool *mobile);
91void viafb_load_crtc_timing(struct display_timing device_timing,
92 int set_iga);
93
94#endif /* __LCD_H__ */
diff --git a/drivers/video/via/lcdtbl.h b/drivers/video/via/lcdtbl.h
new file mode 100644
index 000000000000..6f3dd800be59
--- /dev/null
+++ b/drivers/video/via/lcdtbl.h
@@ -0,0 +1,591 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#ifndef __LCDTBL_H__
22#define __LCDTBL_H__
23
24#include "share.h"
25
26/* CLE266 Software Power Sequence */
27/* {Mask}, {Data}, {Delay} */
28int PowerSequenceOn[3][3] =
29 { {0x10, 0x08, 0x06}, {0x10, 0x08, 0x06}, {0x19, 0x1FE, 0x01} };
30int PowerSequenceOff[3][3] =
31 { {0x06, 0x08, 0x10}, {0x00, 0x00, 0x00}, {0xD2, 0x19, 0x01} };
32
33/* ++++++ P880 ++++++ */
34/* Panel 1600x1200 */
35struct io_reg P880_LCD_RES_6X4_16X12[] = {
36 /*IGA2 Horizontal Total */
37 {VIACR, CR50, 0xFF, 0x73}, {VIACR, CR55, 0x0F, 0x08},
38 /*IGA2 Horizontal Blank End */
39 {VIACR, CR53, 0xFF, 0x73}, {VIACR, CR54, 0x38, 0x00},
40 {VIACR, CR5D, 0x40, 0x40},
41 /*IGA2 Horizontal Total Shadow */
42 {VIACR, CR6D, 0xFF, 0x5A}, {VIACR, CR71, 0x08, 0x00},
43 /*IGA2 Horizontal Blank End Shadow */
44 {VIACR, CR6E, 0xFF, 0x5E},
45 /*IGA2 Offset */
46 {VIACR, CR66, 0xFF, 0xD6}, {VIACR, CR67, 0x03, 0x00},
47 /*VCLK*/ {VIASR, SR44, 0xFF, 0x7D}, {VIASR, SR45, 0xFF, 0x8C},
48 {VIASR, SR46, 0xFF, 0x02}
49
50};
51
52#define NUM_TOTAL_P880_LCD_RES_6X4_16X12 ARRAY_SIZE(P880_LCD_RES_6X4_16X12)
53
54struct io_reg P880_LCD_RES_7X4_16X12[] = {
55 /*IGA2 Horizontal Total */
56 {VIACR, CR50, 0xFF, 0x67}, {VIACR, CR55, 0x0F, 0x08},
57 /*IGA2 Horizontal Blank End */
58 {VIACR, CR53, 0xFF, 0x67}, {VIACR, CR54, 0x38, 0x00},
59 {VIACR, CR5D, 0x40, 0x40},
60 /*IGA2 Horizontal Total Shadow */
61 {VIACR, CR6D, 0xFF, 0x74}, {VIACR, CR71, 0x08, 0x00},
62 /*IGA2 Horizontal Blank End Shadow */
63 {VIACR, CR6E, 0xFF, 0x78},
64 /*IGA2 Offset */
65 {VIACR, CR66, 0xFF, 0xF5}, {VIACR, CR67, 0x03, 0x00},
66 /*VCLK*/ {VIASR, SR44, 0xFF, 0x78}, {VIASR, SR45, 0xFF, 0x8C},
67 {VIASR, SR46, 0xFF, 0x01}
68
69};
70
71#define NUM_TOTAL_P880_LCD_RES_7X4_16X12 ARRAY_SIZE(P880_LCD_RES_7X4_16X12)
72
73struct io_reg P880_LCD_RES_8X6_16X12[] = {
74 /*IGA2 Horizontal Total */
75 {VIACR, CR50, 0xFF, 0x65}, {VIACR, CR55, 0x0F, 0x08},
76 /*IGA2 Horizontal Blank End */
77 {VIACR, CR53, 0xFF, 0x65}, {VIACR, CR54, 0x38, 0x00},
78 {VIACR, CR5D, 0x40, 0x40},
79 /*IGA2 Horizontal Total Shadow */
80 {VIACR, CR6D, 0xFF, 0x7F}, {VIACR, CR71, 0x08, 0x00},
81 /*IGA2 Horizontal Blank End Shadow */
82 {VIACR, CR6E, 0xFF, 0x83},
83 /*IGA2 Offset */
84 {VIACR, CR66, 0xFF, 0xE1}, {VIACR, CR67, 0x03, 0x00},
85 /*VCLK*/ {VIASR, SR44, 0xFF, 0x6D}, {VIASR, SR45, 0xFF, 0x88},
86 {VIASR, SR46, 0xFF, 0x03}
87
88};
89
90#define NUM_TOTAL_P880_LCD_RES_8X6_16X12 ARRAY_SIZE(P880_LCD_RES_8X6_16X12)
91
92struct io_reg P880_LCD_RES_10X7_16X12[] = {
93 /*IGA2 Horizontal Total */
94 {VIACR, CR50, 0xFF, 0x65}, {VIACR, CR55, 0x0F, 0x08},
95 /*IGA2 Horizontal Blank End */
96 {VIACR, CR53, 0xFF, 0x65}, {VIACR, CR54, 0x38, 0x00},
97 {VIACR, CR5D, 0x40, 0x40},
98 /*IGA2 Horizontal Total Shadow */
99 {VIACR, CR6D, 0xFF, 0xAB}, {VIACR, CR71, 0x08, 0x00},
100 /*IGA2 Horizontal Blank End Shadow */
101 {VIACR, CR6E, 0xFF, 0xAF},
102 /*IGA2 Offset */
103 {VIACR, CR66, 0xFF, 0xF0}, {VIACR, CR67, 0x03, 0x00},
104 /*VCLK*/ {VIASR, SR44, 0xFF, 0x92}, {VIASR, SR45, 0xFF, 0x88},
105 {VIASR, SR46, 0xFF, 0x03}
106
107};
108
109#define NUM_TOTAL_P880_LCD_RES_10X7_16X12 ARRAY_SIZE(P880_LCD_RES_10X7_16X12)
110
111struct io_reg P880_LCD_RES_12X10_16X12[] = {
112 /*IGA2 Horizontal Total */
113 {VIACR, CR50, 0xFF, 0x7D}, {VIACR, CR55, 0x0F, 0x08},
114 /*IGA2 Horizontal Blank End */
115 {VIACR, CR53, 0xFF, 0x7D}, {VIACR, CR54, 0x38, 0x00},
116 {VIACR, CR5D, 0x40, 0x40},
117 /*IGA2 Horizontal Total Shadow */
118 {VIACR, CR6D, 0xFF, 0xD0}, {VIACR, CR71, 0x08, 0x00},
119 /*IGA2 Horizontal Blank End Shadow */
120 {VIACR, CR6E, 0xFF, 0xD4},
121 /*IGA2 Offset */
122 {VIACR, CR66, 0xFF, 0xFA}, {VIACR, CR67, 0x03, 0x00},
123 /*VCLK*/ {VIASR, SR44, 0xFF, 0xF6}, {VIASR, SR45, 0xFF, 0x88},
124 {VIASR, SR46, 0xFF, 0x05}
125
126};
127
128#define NUM_TOTAL_P880_LCD_RES_12X10_16X12 ARRAY_SIZE(P880_LCD_RES_12X10_16X12)
129
130/* Panel 1400x1050 */
131struct io_reg P880_LCD_RES_6X4_14X10[] = {
132 /* 640x480 */
133 /* IGA2 Horizontal Total */
134 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x56},
135 /* IGA2 Horizontal Blank End */
136 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x75},
137 {VIACR, CR5D, 0x40, 0x24},
138 /* IGA2 Horizontal Total Shadow */
139 {VIACR, CR6D, 0xFF, 0x5F}, {VIACR, CR71, 0x08, 0x44},
140 /* IGA2 Horizontal Blank End Shadow */
141 {VIACR, CR6E, 0xFF, 0x63},
142 /* IGA2 Offset */
143 {VIACR, CR66, 0xFF, 0xB4}, {VIACR, CR67, 0x03, 0x00},
144 /* VCLK */
145 {VIASR, SR44, 0xFF, 0xC6}, {VIASR, SR45, 0xFF, 0x8C},
146 {VIASR, SR46, 0xFF, 0x05}
147};
148
149#define NUM_TOTAL_P880_LCD_RES_6X4_14X10 ARRAY_SIZE(P880_LCD_RES_6X4_14X10)
150
151struct io_reg P880_LCD_RES_8X6_14X10[] = {
152 /* 800x600 */
153 /* IGA2 Horizontal Total */
154 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x56},
155 /* IGA2 Horizontal Blank End */
156 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x75},
157 {VIACR, CR5D, 0x40, 0x24},
158 /* IGA2 Horizontal Total Shadow */
159 {VIACR, CR6D, 0xFF, 0x7F}, {VIACR, CR71, 0x08, 0x44},
160 /* IGA2 Horizontal Blank End Shadow */
161 {VIACR, CR6E, 0xFF, 0x83},
162 /* IGA2 Offset */
163 {VIACR, CR66, 0xFF, 0xBE}, {VIACR, CR67, 0x03, 0x00},
164 /* VCLK */
165 {VIASR, SR44, 0xFF, 0x06}, {VIASR, SR45, 0xFF, 0x8D},
166 {VIASR, SR46, 0xFF, 0x05}
167};
168
169#define NUM_TOTAL_P880_LCD_RES_8X6_14X10 ARRAY_SIZE(P880_LCD_RES_8X6_14X10)
170
171/* ++++++ K400 ++++++ */
172/* Panel 1600x1200 */
173struct io_reg K400_LCD_RES_6X4_16X12[] = {
174 /*IGA2 Horizontal Total */
175 {VIACR, CR50, 0xFF, 0x73}, {VIACR, CR55, 0x0F, 0x08},
176 /*IGA2 Horizontal Blank End */
177 {VIACR, CR53, 0xFF, 0x73}, {VIACR, CR54, 0x38, 0x00},
178 {VIACR, CR5D, 0x40, 0x40},
179 /*IGA2 Horizontal Total Shadow */
180 {VIACR, CR6D, 0xFF, 0x5A}, {VIACR, CR71, 0x08, 0x00},
181 /*IGA2 Horizontal Blank End Shadow */
182 {VIACR, CR6E, 0xFF, 0x5E},
183 /*IGA2 Offset */
184 {VIACR, CR66, 0xFF, 0xDA}, {VIACR, CR67, 0x03, 0x00},
185 /*VCLK*/ {VIASR, SR46, 0xFF, 0xC4}, {VIASR, SR47, 0xFF, 0x7F}
186};
187
188#define NUM_TOTAL_K400_LCD_RES_6X4_16X12 ARRAY_SIZE(K400_LCD_RES_6X4_16X12)
189
190struct io_reg K400_LCD_RES_7X4_16X12[] = {
191 /*IGA2 Horizontal Total */
192 {VIACR, CR50, 0xFF, 0x67}, {VIACR, CR55, 0x0F, 0x08},
193 /*IGA2 Horizontal Blank End */
194 {VIACR, CR53, 0xFF, 0x67}, {VIACR, CR54, 0x38, 0x00},
195 {VIACR, CR5D, 0x40, 0x40},
196 /*IGA2 Horizontal Total Shadow */
197 {VIACR, CR6D, 0xFF, 0x74}, {VIACR, CR71, 0x08, 0x00},
198 /*IGA2 Horizontal Blank End Shadow */
199 {VIACR, CR6E, 0xFF, 0x78},
200 /*IGA2 Offset */
201 {VIACR, CR66, 0xFF, 0xF5}, {VIACR, CR67, 0x03, 0x00},
202 /*VCLK*/ {VIASR, SR46, 0xFF, 0x46}, {VIASR, SR47, 0xFF, 0x3D}
203};
204
205#define NUM_TOTAL_K400_LCD_RES_7X4_16X12 ARRAY_SIZE(K400_LCD_RES_7X4_16X12)
206
207struct io_reg K400_LCD_RES_8X6_16X12[] = {
208 /*IGA2 Horizontal Total */
209 {VIACR, CR50, 0xFF, 0x65}, {VIACR, CR55, 0x0F, 0x08},
210 /*IGA2 Horizontal Blank End */
211 {VIACR, CR53, 0xFF, 0x65}, {VIACR, CR54, 0x38, 0x00},
212 {VIACR, CR5D, 0x40, 0x40},
213 /*IGA2 Horizontal Total Shadow */
214 {VIACR, CR6D, 0xFF, 0x7F}, {VIACR, CR71, 0x08, 0x00},
215 /*IGA2 Horizontal Blank End Shadow */
216 {VIACR, CR6E, 0xFF, 0x83},
217 /*IGA2 Offset */
218 {VIACR, CR66, 0xFF, 0xE1}, {VIACR, CR67, 0x03, 0x00},
219 /*VCLK*/ {VIASR, SR46, 0xFF, 0x85}, {VIASR, SR47, 0xFF, 0x6F}
220};
221
222#define NUM_TOTAL_K400_LCD_RES_8X6_16X12 ARRAY_SIZE(K400_LCD_RES_8X6_16X12)
223
224struct io_reg K400_LCD_RES_10X7_16X12[] = {
225 /*IGA2 Horizontal Total */
226 {VIACR, CR50, 0xFF, 0x65}, {VIACR, CR55, 0x0F, 0x08},
227 /*IGA2 Horizontal Blank End */
228 {VIACR, CR53, 0xFF, 0x65}, {VIACR, CR54, 0x38, 0x00},
229 {VIACR, CR5D, 0x40, 0x40},
230 /*IGA2 Horizontal Total Shadow */
231 {VIACR, CR6D, 0xFF, 0xAB}, {VIACR, CR71, 0x08, 0x00},
232 /*IGA2 Horizontal Blank End Shadow */
233 {VIACR, CR6E, 0xFF, 0xAF},
234 /*IGA2 Offset */
235 {VIACR, CR66, 0xFF, 0xF0}, {VIACR, CR67, 0x03, 0x00},
236 /*VCLK*/ {VIASR, SR46, 0xFF, 0x45}, {VIASR, SR47, 0xFF, 0x4A}
237};
238
239#define NUM_TOTAL_K400_LCD_RES_10X7_16X12 ARRAY_SIZE(K400_LCD_RES_10X7_16X12)
240
241struct io_reg K400_LCD_RES_12X10_16X12[] = {
242 /*IGA2 Horizontal Total */
243 {VIACR, CR50, 0xFF, 0x7D}, {VIACR, CR55, 0x0F, 0x08},
244 /*IGA2 Horizontal Blank End */
245 {VIACR, CR53, 0xFF, 0x7D}, {VIACR, CR54, 0x38, 0x00},
246 {VIACR, CR5D, 0x40, 0x40},
247 /*IGA2 Horizontal Total Shadow */
248 {VIACR, CR6D, 0xFF, 0xD0}, {VIACR, CR71, 0x08, 0x00},
249 /*IGA2 Horizontal Blank End Shadow */
250 {VIACR, CR6E, 0xFF, 0xD4},
251 /*IGA2 Offset */
252 {VIACR, CR66, 0xFF, 0xFA}, {VIACR, CR67, 0x03, 0x00},
253 /*VCLK*/ {VIASR, SR46, 0xFF, 0x47}, {VIASR, SR47, 0xFF, 0x7C}
254};
255
256#define NUM_TOTAL_K400_LCD_RES_12X10_16X12 ARRAY_SIZE(K400_LCD_RES_12X10_16X12)
257
258/* Panel 1400x1050 */
259struct io_reg K400_LCD_RES_6X4_14X10[] = {
260 /* 640x400 */
261 /* IGA2 Horizontal Total */
262 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x56},
263 /* IGA2 Horizontal Blank End */
264 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x75},
265 {VIACR, CR5D, 0x40, 0x24},
266 /* IGA2 Horizontal Total Shadow */
267 {VIACR, CR6D, 0xFF, 0x5F}, {VIACR, CR71, 0x08, 0x44},
268 /* IGA2 Horizontal Blank End Shadow */
269 {VIACR, CR6E, 0xFF, 0x63},
270 /* IGA2 Offset */
271 {VIACR, CR66, 0xFF, 0xB4}, {VIACR, CR67, 0x03, 0x00},
272 /* VCLK */
273 {VIASR, SR46, 0xFF, 0x07}, {VIASR, SR47, 0xFF, 0x19}
274};
275
276#define NUM_TOTAL_K400_LCD_RES_6X4_14X10 ARRAY_SIZE(K400_LCD_RES_6X4_14X10)
277
278struct io_reg K400_LCD_RES_8X6_14X10[] = {
279 /* 800x600 */
280 /* IGA2 Horizontal Total */
281 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x56},
282 /* IGA2 Horizontal Blank End */
283 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x75},
284 {VIACR, CR5D, 0x40, 0x24},
285 /* IGA2 Horizontal Total Shadow */
286 {VIACR, CR6D, 0xFF, 0x7F}, {VIACR, CR71, 0x08, 0x44},
287 /* IGA2 Horizontal Blank End Shadow */
288 {VIACR, CR6E, 0xFF, 0x83},
289 /* IGA2 Offset */
290 {VIACR, CR66, 0xFF, 0xBE}, {VIACR, CR67, 0x03, 0x00},
291 /* VCLK */
292 {VIASR, SR46, 0xFF, 0x07}, {VIASR, SR47, 0xFF, 0x21}
293};
294
295#define NUM_TOTAL_K400_LCD_RES_8X6_14X10 ARRAY_SIZE(K400_LCD_RES_8X6_14X10)
296
297struct io_reg K400_LCD_RES_10X7_14X10[] = {
298 /* 1024x768 */
299 /* IGA2 Horizontal Total */
300 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x56},
301 /* IGA2 Horizontal Blank End */
302 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x75},
303 {VIACR, CR5D, 0x40, 0x24},
304 /* IGA2 Horizontal Total Shadow */
305 {VIACR, CR6D, 0xFF, 0xA3}, {VIACR, CR71, 0x08, 0x44},
306 /* IGA2 Horizontal Blank End Shadow */
307 {VIACR, CR6E, 0xFF, 0xA7},
308 /* IGA2 Offset */
309 {VIACR, CR66, 0xFF, 0xC3}, {VIACR, CR67, 0x03, 0x04},
310 /* VCLK */
311 {VIASR, SR46, 0xFF, 0x05}, {VIASR, SR47, 0xFF, 0x1E}
312};
313
314#define NUM_TOTAL_K400_LCD_RES_10X7_14X10 ARRAY_SIZE(K400_LCD_RES_10X7_14X10)
315
316struct io_reg K400_LCD_RES_12X10_14X10[] = {
317 /* 1280x768, 1280x960, 1280x1024 */
318 /* IGA2 Horizontal Total */
319 {VIACR, CR50, 0xFF, 0x97}, {VIACR, CR55, 0x0F, 0x56},
320 /* IGA2 Horizontal Blank End */
321 {VIACR, CR53, 0xFF, 0x97}, {VIACR, CR54, 0x38, 0x75},
322 {VIACR, CR5D, 0x40, 0x24},
323 /* IGA2 Horizontal Total Shadow */
324 {VIACR, CR6D, 0xFF, 0xCE}, {VIACR, CR71, 0x08, 0x44},
325 /* IGA2 Horizontal Blank End Shadow */
326 {VIACR, CR6E, 0xFF, 0xD2},
327 /* IGA2 Offset */
328 {VIACR, CR66, 0xFF, 0xC9}, {VIACR, CR67, 0x03, 0x04},
329 /* VCLK */
330 {VIASR, SR46, 0xFF, 0x84}, {VIASR, SR47, 0xFF, 0x79}
331};
332
333#define NUM_TOTAL_K400_LCD_RES_12X10_14X10 ARRAY_SIZE(K400_LCD_RES_12X10_14X10)
334
335/* ++++++ K400 ++++++ */
336/* Panel 1366x768 */
337struct io_reg K400_LCD_RES_6X4_1366X7[] = {
338 /* 640x400 */
339 /* IGA2 Horizontal Total */
340 {VIACR, CR50, 0xFF, 0x47}, {VIACR, CR55, 0x0F, 0x35},
341 /* IGA2 Horizontal Blank End */
342 {VIACR, CR53, 0xFF, 0x47}, {VIACR, CR54, 0x38, 0x2B},
343 {VIACR, CR5D, 0x40, 0x13},
344 /* IGA2 Horizontal Total Shadow */
345 {VIACR, CR6D, 0xFF, 0x60}, {VIACR, CR71, 0x08, 0x23},
346 /* IGA2 Horizontal Blank End Shadow */
347 {VIACR, CR6E, 0xFF, 0x64},
348 /* IGA2 Offset */
349 {VIACR, CR66, 0xFF, 0x8C}, {VIACR, CR67, 0x03, 0x00},
350 /* VCLK */
351 {VIASR, SR46, 0xFF, 0x87}, {VIASR, SR47, 0xFF, 0x4C}
352};
353
354#define NUM_TOTAL_K400_LCD_RES_6X4_1366X7 ARRAY_SIZE(K400_LCD_RES_6X4_1366X7)
355
356struct io_reg K400_LCD_RES_7X4_1366X7[] = {
357 /* IGA2 Horizontal Total */
358 {VIACR, CR50, 0xFF, 0x3B}, {VIACR, CR55, 0x0F, 0x35},
359 /* IGA2 Horizontal Blank End */
360 {VIACR, CR53, 0xFF, 0x3B}, {VIACR, CR54, 0x38, 0x2B},
361 {VIACR, CR5D, 0x40, 0x13},
362 /* IGA2 Horizontal Total Shadow */
363 {VIACR, CR6D, 0xFF, 0x71}, {VIACR, CR71, 0x08, 0x23},
364 /* IGA2 Horizontal Blank End Shadow */
365 {VIACR, CR6E, 0xFF, 0x75},
366 /* IGA2 Offset */
367 {VIACR, CR66, 0xFF, 0x96}, {VIACR, CR67, 0x03, 0x00},
368 /* VCLK */
369 {VIASR, SR46, 0xFF, 0x05}, {VIASR, SR47, 0xFF, 0x10}
370};
371
372#define NUM_TOTAL_K400_LCD_RES_7X4_1366X7 ARRAY_SIZE(K400_LCD_RES_7X4_1366X7)
373
374struct io_reg K400_LCD_RES_8X6_1366X7[] = {
375 /* 800x600 */
376 /* IGA2 Horizontal Total */
377 {VIACR, CR50, 0xFF, 0x37}, {VIACR, CR55, 0x0F, 0x35},
378 /* IGA2 Horizontal Blank End */
379 {VIACR, CR53, 0xFF, 0x37}, {VIACR, CR54, 0x38, 0x2B},
380 {VIACR, CR5D, 0x40, 0x13},
381 /* IGA2 Horizontal Total Shadow */
382 {VIACR, CR6D, 0xFF, 0x7E}, {VIACR, CR71, 0x08, 0x23},
383 /* IGA2 Horizontal Blank End Shadow */
384 {VIACR, CR6E, 0xFF, 0x82},
385 /* IGA2 Offset */
386 {VIACR, CR66, 0xFF, 0x8C}, {VIACR, CR67, 0x03, 0x00},
387 /* VCLK */
388 {VIASR, SR46, 0xFF, 0x84}, {VIASR, SR47, 0xFF, 0xB9}
389};
390
391#define NUM_TOTAL_K400_LCD_RES_8X6_1366X7 ARRAY_SIZE(K400_LCD_RES_8X6_1366X7)
392
393struct io_reg K400_LCD_RES_10X7_1366X7[] = {
394 /* 1024x768 */
395 /* IGA2 Horizontal Total */
396 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x56},
397 /* IGA2 Horizontal Blank End */
398 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x75},
399 {VIACR, CR5D, 0x40, 0x24},
400 /* IGA2 Horizontal Total Shadow */
401 {VIACR, CR6D, 0xFF, 0xA3}, {VIACR, CR71, 0x08, 0x44},
402 /* IGA2 Horizontal Blank End Shadow */
403 {VIACR, CR6E, 0xFF, 0xA7},
404 /* IGA2 Offset */
405 {VIACR, CR66, 0xFF, 0xC3}, {VIACR, CR67, 0x03, 0x04},
406 /* VCLK */
407 {VIASR, SR46, 0xFF, 0x05}, {VIASR, SR47, 0xFF, 0x1E}
408};
409
410#define NUM_TOTAL_K400_LCD_RES_10X7_1366X7 ARRAY_SIZE(K400_LCD_RES_10X7_1366X7)
411
412struct io_reg K400_LCD_RES_12X10_1366X7[] = {
413 /* 1280x768, 1280x960, 1280x1024 */
414 /* IGA2 Horizontal Total */
415 {VIACR, CR50, 0xFF, 0x97}, {VIACR, CR55, 0x0F, 0x56},
416 /* IGA2 Horizontal Blank End */
417 {VIACR, CR53, 0xFF, 0x97}, {VIACR, CR54, 0x38, 0x75},
418 {VIACR, CR5D, 0x40, 0x24},
419 /* IGA2 Horizontal Total Shadow */
420 {VIACR, CR6D, 0xFF, 0xCE}, {VIACR, CR71, 0x08, 0x44},
421 /* IGA2 Horizontal Blank End Shadow */
422 {VIACR, CR6E, 0xFF, 0xD2},
423 /* IGA2 Offset */
424 {VIACR, CR66, 0xFF, 0xC9}, {VIACR, CR67, 0x03, 0x04},
425 /* VCLK */
426 {VIASR, SR46, 0xFF, 0x84}, {VIASR, SR47, 0xFF, 0x79}
427};
428
429#define NUM_TOTAL_K400_LCD_RES_12X10_1366X7\
430 ARRAY_SIZE(K400_LCD_RES_12X10_1366X7)
431
432/* ++++++ K400 ++++++ */
433/* Panel 1280x1024 */
434struct io_reg K400_LCD_RES_6X4_12X10[] = {
435 /*IGA2 Horizontal Total */
436 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x46},
437 /*IGA2 Horizontal Blank End */
438 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x74},
439 {VIACR, CR5D, 0x40, 0x1C},
440 /*IGA2 Horizontal Total Shadow */
441 {VIACR, CR6D, 0xFF, 0x5F}, {VIACR, CR71, 0x08, 0x34},
442 /*IGA2 Horizontal Blank End Shadow */
443 {VIACR, CR6E, 0xFF, 0x63},
444 /*IGA2 Offset */
445 {VIACR, CR66, 0xFF, 0xAA}, {VIACR, CR67, 0x03, 0x00},
446 /*VCLK*/ {VIASR, SR46, 0xFF, 0x07}, {VIASR, SR47, 0xFF, 0x19}
447};
448
449#define NUM_TOTAL_K400_LCD_RES_6X4_12X10 ARRAY_SIZE(K400_LCD_RES_6X4_12X10)
450
451struct io_reg K400_LCD_RES_7X4_12X10[] = {
452 /*IGA2 Horizontal Total */
453 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x46},
454 /*IGA2 Horizontal Blank End */
455 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x74},
456 {VIACR, CR5D, 0x40, 0x1C},
457 /*IGA2 Horizontal Total Shadow */
458 {VIACR, CR6D, 0xFF, 0x68}, {VIACR, CR71, 0x08, 0x34},
459 /*IGA2 Horizontal Blank End Shadow */
460 {VIACR, CR6E, 0xFF, 0x6C},
461 /*IGA2 Offset */
462 {VIACR, CR66, 0xFF, 0xA8}, {VIACR, CR67, 0x03, 0x00},
463 /*VCLK*/ {VIASR, SR46, 0xFF, 0x87}, {VIASR, SR47, 0xFF, 0xED}
464};
465
466#define NUM_TOTAL_K400_LCD_RES_7X4_12X10 ARRAY_SIZE(K400_LCD_RES_7X4_12X10)
467
468struct io_reg K400_LCD_RES_8X6_12X10[] = {
469 /*IGA2 Horizontal Total */
470 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x46},
471 /*IGA2 Horizontal Blank End */
472 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x74},
473 {VIACR, CR5D, 0x40, 0x1C},
474 /*IGA2 Horizontal Total Shadow */
475 {VIACR, CR6D, 0xFF, 0x7F}, {VIACR, CR71, 0x08, 0x34},
476 /*IGA2 Horizontal Blank End Shadow */
477 {VIACR, CR6E, 0xFF, 0x83},
478 /*IGA2 Offset */
479 {VIACR, CR66, 0xFF, 0xBE}, {VIACR, CR67, 0x03, 0x00},
480 /*VCLK*/ {VIASR, SR46, 0xFF, 0x07}, {VIASR, SR47, 0xFF, 0x21}
481};
482
483#define NUM_TOTAL_K400_LCD_RES_8X6_12X10 ARRAY_SIZE(K400_LCD_RES_8X6_12X10)
484
485struct io_reg K400_LCD_RES_10X7_12X10[] = {
486 /*IGA2 Horizontal Total */
487 {VIACR, CR50, 0xFF, 0x9D}, {VIACR, CR55, 0x0F, 0x46},
488 /*IGA2 Horizontal Blank End */
489 {VIACR, CR53, 0xFF, 0x9D}, {VIACR, CR54, 0x38, 0x74},
490 {VIACR, CR5D, 0x40, 0x1C},
491 /*IGA2 Horizontal Total Shadow */
492 {VIACR, CR6D, 0xFF, 0xA3}, {VIACR, CR71, 0x08, 0x34},
493 /*IGA2 Horizontal Blank End Shadow */
494 {VIACR, CR6E, 0xFF, 0xA7},
495 /*IGA2 Offset */
496 {VIACR, CR66, 0xFF, 0xBE}, {VIACR, CR67, 0x03, 0x04},
497 /*VCLK*/ {VIASR, SR46, 0xFF, 0x05}, {VIASR, SR47, 0xFF, 0x1E}
498};
499
500#define NUM_TOTAL_K400_LCD_RES_10X7_12X10 ARRAY_SIZE(K400_LCD_RES_10X7_12X10)
501
502/* ++++++ K400 ++++++ */
503/* Panel 1024x768 */
504struct io_reg K400_LCD_RES_6X4_10X7[] = {
505 /*IGA2 Horizontal Total */
506 {VIACR, CR50, 0xFF, 0x47}, {VIACR, CR55, 0x0F, 0x35},
507 /*IGA2 Horizontal Blank End */
508 {VIACR, CR53, 0xFF, 0x47}, {VIACR, CR54, 0x38, 0x2B},
509 {VIACR, CR5D, 0x40, 0x13},
510 /*IGA2 Horizontal Total Shadow */
511 {VIACR, CR6D, 0xFF, 0x60}, {VIACR, CR71, 0x08, 0x23},
512 /*IGA2 Horizontal Blank End Shadow */
513 {VIACR, CR6E, 0xFF, 0x64},
514 /*IGA2 Offset */
515 {VIACR, CR66, 0xFF, 0x8C}, {VIACR, CR67, 0x03, 0x00},
516 /*VCLK*/ {VIASR, SR46, 0xFF, 0x87}, {VIASR, SR47, 0xFF, 0x4C}
517};
518
519#define NUM_TOTAL_K400_LCD_RES_6X4_10X7 ARRAY_SIZE(K400_LCD_RES_6X4_10X7)
520
521struct io_reg K400_LCD_RES_7X4_10X7[] = {
522 /*IGA2 Horizontal Total */
523 {VIACR, CR50, 0xFF, 0x3B}, {VIACR, CR55, 0x0F, 0x35},
524 /*IGA2 Horizontal Blank End */
525 {VIACR, CR53, 0xFF, 0x3B}, {VIACR, CR54, 0x38, 0x2B},
526 {VIACR, CR5D, 0x40, 0x13},
527 /*IGA2 Horizontal Total Shadow */
528 {VIACR, CR6D, 0xFF, 0x71}, {VIACR, CR71, 0x08, 0x23},
529 /*IGA2 Horizontal Blank End Shadow */
530 {VIACR, CR6E, 0xFF, 0x75},
531 /*IGA2 Offset */
532 {VIACR, CR66, 0xFF, 0x96}, {VIACR, CR67, 0x03, 0x00},
533 /*VCLK*/ {VIASR, SR46, 0xFF, 0x05}, {VIASR, SR47, 0xFF, 0x10}
534};
535
536#define NUM_TOTAL_K400_LCD_RES_7X4_10X7 ARRAY_SIZE(K400_LCD_RES_7X4_10X7)
537
538struct io_reg K400_LCD_RES_8X6_10X7[] = {
539 /*IGA2 Horizontal Total */
540 {VIACR, CR50, 0xFF, 0x37}, {VIACR, CR55, 0x0F, 0x35},
541 /*IGA2 Horizontal Blank End */
542 {VIACR, CR53, 0xFF, 0x37}, {VIACR, CR54, 0x38, 0x2B},
543 {VIACR, CR5D, 0x40, 0x13},
544 /*IGA2 Horizontal Total Shadow */
545 {VIACR, CR6D, 0xFF, 0x7E}, {VIACR, CR71, 0x08, 0x23},
546 /*IGA2 Horizontal Blank End Shadow */
547 {VIACR, CR6E, 0xFF, 0x82},
548 /*IGA2 Offset */
549 {VIACR, CR66, 0xFF, 0x8C}, {VIACR, CR67, 0x03, 0x00},
550 /*VCLK*/ {VIASR, SR46, 0xFF, 0x84}, {VIASR, SR47, 0xFF, 0xB9}
551};
552
553#define NUM_TOTAL_K400_LCD_RES_8X6_10X7 ARRAY_SIZE(K400_LCD_RES_8X6_10X7)
554
555/* ++++++ K400 ++++++ */
556/* Panel 800x600 */
557struct io_reg K400_LCD_RES_6X4_8X6[] = {
558 /*IGA2 Horizontal Total */
559 {VIACR, CR50, 0xFF, 0x1A}, {VIACR, CR55, 0x0F, 0x34},
560 /*IGA2 Horizontal Blank End */
561 {VIACR, CR53, 0xFF, 0x1A}, {VIACR, CR54, 0x38, 0xE3},
562 {VIACR, CR5D, 0x40, 0x12},
563 /*IGA2 Horizontal Total Shadow */
564 {VIACR, CR6D, 0xFF, 0x5F}, {VIACR, CR71, 0x08, 0x22},
565 /*IGA2 Horizontal Blank End Shadow */
566 {VIACR, CR6E, 0xFF, 0x63},
567 /*IGA2 Offset */
568 {VIACR, CR66, 0xFF, 0x6E}, {VIACR, CR67, 0x03, 0x00},
569 /*VCLK*/ {VIASR, SR46, 0xFF, 0x86}, {VIASR, SR47, 0xFF, 0xB3}
570};
571
572#define NUM_TOTAL_K400_LCD_RES_6X4_8X6 ARRAY_SIZE(K400_LCD_RES_6X4_8X6)
573
574struct io_reg K400_LCD_RES_7X4_8X6[] = {
575 /*IGA2 Horizontal Total */
576 {VIACR, CR50, 0xFF, 0x1F}, {VIACR, CR55, 0x0F, 0x34},
577 /*IGA2 Horizontal Blank End */
578 {VIACR, CR53, 0xFF, 0x1F}, {VIACR, CR54, 0x38, 0xE3},
579 {VIACR, CR5D, 0x40, 0x12},
580 /*IGA2 Horizontal Total Shadow */
581 {VIACR, CR6D, 0xFF, 0x7F}, {VIACR, CR71, 0x08, 0x22},
582 /*IGA2 Horizontal Blank End Shadow */
583 {VIACR, CR6E, 0xFF, 0x83},
584 /*IGA2 Offset */
585 {VIACR, CR66, 0xFF, 0x78}, {VIACR, CR67, 0x03, 0x00},
586 /*VCLK*/ {VIASR, SR46, 0xFF, 0xC4}, {VIASR, SR47, 0xFF, 0x59}
587};
588
589#define NUM_TOTAL_K400_LCD_RES_7X4_8X6 ARRAY_SIZE(K400_LCD_RES_7X4_8X6)
590
591#endif /* __LCDTBL_H__ */
diff --git a/drivers/video/via/share.h b/drivers/video/via/share.h
new file mode 100644
index 000000000000..2e1254da9c8c
--- /dev/null
+++ b/drivers/video/via/share.h
@@ -0,0 +1,1105 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __SHARE_H__
23#define __SHARE_H__
24
25/* Define Return Value */
26#define FAIL -1
27#define OK 1
28
29#ifndef NULL
30#define NULL 0
31#endif
32
33/* Define Bit Field */
34#define BIT0 0x01
35#define BIT1 0x02
36#define BIT2 0x04
37#define BIT3 0x08
38#define BIT4 0x10
39#define BIT5 0x20
40#define BIT6 0x40
41#define BIT7 0x80
42
43/* Video Memory Size */
44#define VIDEO_MEMORY_SIZE_16M 0x1000000
45
46/* Definition Mode Index
47*/
48#define VIA_RES_640X480 0
49#define VIA_RES_800X600 1
50#define VIA_RES_1024X768 2
51#define VIA_RES_1152X864 3
52#define VIA_RES_1280X1024 4
53#define VIA_RES_1600X1200 5
54#define VIA_RES_1440X1050 6
55#define VIA_RES_1280X768 7
56#define VIA_RES_1280X960 8
57#define VIA_RES_1920X1440 9
58#define VIA_RES_848X480 10
59#define VIA_RES_1400X1050 11
60#define VIA_RES_720X480 12
61#define VIA_RES_720X576 13
62#define VIA_RES_1024X512 14
63#define VIA_RES_856X480 15
64#define VIA_RES_1024X576 16
65#define VIA_RES_640X400 17
66#define VIA_RES_1280X720 18
67#define VIA_RES_1920X1080 19
68#define VIA_RES_800X480 20
69#define VIA_RES_1368X768 21
70#define VIA_RES_1024X600 22
71#define VIA_RES_1280X800 23
72#define VIA_RES_1680X1050 24
73#define VIA_RES_960X600 25
74#define VIA_RES_1000X600 26
75#define VIA_RES_1088X612 27
76#define VIA_RES_1152X720 28
77#define VIA_RES_1200X720 29
78#define VIA_RES_1280X600 30
79#define VIA_RES_1360X768 31
80#define VIA_RES_1366X768 32
81#define VIA_RES_1440X900 33
82#define VIA_RES_1600X900 34
83#define VIA_RES_1600X1024 35
84#define VIA_RES_1792X1344 36
85#define VIA_RES_1856X1392 37
86#define VIA_RES_1920X1200 38
87#define VIA_RES_2048X1536 39
88#define VIA_RES_480X640 40
89
90/*Reduce Blanking*/
91#define VIA_RES_1360X768_RB 131
92#define VIA_RES_1440X900_RB 133
93#define VIA_RES_1400X1050_RB 111
94#define VIA_RES_1600X900_RB 134
95#define VIA_RES_1680X1050_RB 124
96#define VIA_RES_1920X1080_RB 119
97#define VIA_RES_1920X1200_RB 138
98
99#define VIA_RES_INVALID 255
100
101/* standard VGA IO port
102*/
103#define VIARMisc 0x3CC
104#define VIAWMisc 0x3C2
105#define VIAStatus 0x3DA
106#define VIACR 0x3D4
107#define VIASR 0x3C4
108#define VIAGR 0x3CE
109#define VIAAR 0x3C0
110
111#define StdCR 0x19
112#define StdSR 0x04
113#define StdGR 0x09
114#define StdAR 0x14
115
116#define PatchCR 11
117
118/* Display path */
119#define IGA1 1
120#define IGA2 2
121#define IGA1_IGA2 3
122
123/* Define Color Depth */
124#define MODE_8BPP 1
125#define MODE_16BPP 2
126#define MODE_32BPP 4
127
128#define GR20 0x20
129#define GR21 0x21
130#define GR22 0x22
131
132/* Sequencer Registers */
133#define SR01 0x01
134#define SR10 0x10
135#define SR12 0x12
136#define SR15 0x15
137#define SR16 0x16
138#define SR17 0x17
139#define SR18 0x18
140#define SR1B 0x1B
141#define SR1A 0x1A
142#define SR1C 0x1C
143#define SR1D 0x1D
144#define SR1E 0x1E
145#define SR1F 0x1F
146#define SR20 0x20
147#define SR21 0x21
148#define SR22 0x22
149#define SR2A 0x2A
150#define SR2D 0x2D
151#define SR2E 0x2E
152
153#define SR30 0x30
154#define SR39 0x39
155#define SR3D 0x3D
156#define SR3E 0x3E
157#define SR3F 0x3F
158#define SR40 0x40
159#define SR43 0x43
160#define SR44 0x44
161#define SR45 0x45
162#define SR46 0x46
163#define SR47 0x47
164#define SR48 0x48
165#define SR49 0x49
166#define SR4A 0x4A
167#define SR4B 0x4B
168#define SR4C 0x4C
169#define SR52 0x52
170#define SR5E 0x5E
171#define SR65 0x65
172
173/* CRT Controller Registers */
174#define CR00 0x00
175#define CR01 0x01
176#define CR02 0x02
177#define CR03 0x03
178#define CR04 0x04
179#define CR05 0x05
180#define CR06 0x06
181#define CR07 0x07
182#define CR08 0x08
183#define CR09 0x09
184#define CR0A 0x0A
185#define CR0B 0x0B
186#define CR0C 0x0C
187#define CR0D 0x0D
188#define CR0E 0x0E
189#define CR0F 0x0F
190#define CR10 0x10
191#define CR11 0x11
192#define CR12 0x12
193#define CR13 0x13
194#define CR14 0x14
195#define CR15 0x15
196#define CR16 0x16
197#define CR17 0x17
198#define CR18 0x18
199
200/* Extend CRT Controller Registers */
201#define CR30 0x30
202#define CR31 0x31
203#define CR32 0x32
204#define CR33 0x33
205#define CR34 0x34
206#define CR35 0x35
207#define CR36 0x36
208#define CR37 0x37
209#define CR38 0x38
210#define CR39 0x39
211#define CR3A 0x3A
212#define CR3B 0x3B
213#define CR3C 0x3C
214#define CR3D 0x3D
215#define CR3E 0x3E
216#define CR3F 0x3F
217#define CR40 0x40
218#define CR41 0x41
219#define CR42 0x42
220#define CR43 0x43
221#define CR44 0x44
222#define CR45 0x45
223#define CR46 0x46
224#define CR47 0x47
225#define CR48 0x48
226#define CR49 0x49
227#define CR4A 0x4A
228#define CR4B 0x4B
229#define CR4C 0x4C
230#define CR4D 0x4D
231#define CR4E 0x4E
232#define CR4F 0x4F
233#define CR50 0x50
234#define CR51 0x51
235#define CR52 0x52
236#define CR53 0x53
237#define CR54 0x54
238#define CR55 0x55
239#define CR56 0x56
240#define CR57 0x57
241#define CR58 0x58
242#define CR59 0x59
243#define CR5A 0x5A
244#define CR5B 0x5B
245#define CR5C 0x5C
246#define CR5D 0x5D
247#define CR5E 0x5E
248#define CR5F 0x5F
249#define CR60 0x60
250#define CR61 0x61
251#define CR62 0x62
252#define CR63 0x63
253#define CR64 0x64
254#define CR65 0x65
255#define CR66 0x66
256#define CR67 0x67
257#define CR68 0x68
258#define CR69 0x69
259#define CR6A 0x6A
260#define CR6B 0x6B
261#define CR6C 0x6C
262#define CR6D 0x6D
263#define CR6E 0x6E
264#define CR6F 0x6F
265#define CR70 0x70
266#define CR71 0x71
267#define CR72 0x72
268#define CR73 0x73
269#define CR74 0x74
270#define CR75 0x75
271#define CR76 0x76
272#define CR77 0x77
273#define CR78 0x78
274#define CR79 0x79
275#define CR7A 0x7A
276#define CR7B 0x7B
277#define CR7C 0x7C
278#define CR7D 0x7D
279#define CR7E 0x7E
280#define CR7F 0x7F
281#define CR80 0x80
282#define CR81 0x81
283#define CR82 0x82
284#define CR83 0x83
285#define CR84 0x84
286#define CR85 0x85
287#define CR86 0x86
288#define CR87 0x87
289#define CR88 0x88
290#define CR89 0x89
291#define CR8A 0x8A
292#define CR8B 0x8B
293#define CR8C 0x8C
294#define CR8D 0x8D
295#define CR8E 0x8E
296#define CR8F 0x8F
297#define CR90 0x90
298#define CR91 0x91
299#define CR92 0x92
300#define CR93 0x93
301#define CR94 0x94
302#define CR95 0x95
303#define CR96 0x96
304#define CR97 0x97
305#define CR98 0x98
306#define CR99 0x99
307#define CR9A 0x9A
308#define CR9B 0x9B
309#define CR9C 0x9C
310#define CR9D 0x9D
311#define CR9E 0x9E
312#define CR9F 0x9F
313#define CRA0 0xA0
314#define CRA1 0xA1
315#define CRA2 0xA2
316#define CRA3 0xA3
317#define CRD2 0xD2
318#define CRD3 0xD3
319#define CRD4 0xD4
320
321/* LUT Table*/
322#define LUT_DATA 0x3C9 /* DACDATA */
323#define LUT_INDEX_READ 0x3C7 /* DACRX */
324#define LUT_INDEX_WRITE 0x3C8 /* DACWX */
325#define DACMASK 0x3C6
326
327/* Definition Device */
328#define DEVICE_CRT 0x01
329#define DEVICE_DVI 0x03
330#define DEVICE_LCD 0x04
331
332/* Device output interface */
333#define INTERFACE_NONE 0x00
334#define INTERFACE_ANALOG_RGB 0x01
335#define INTERFACE_DVP0 0x02
336#define INTERFACE_DVP1 0x03
337#define INTERFACE_DFP_HIGH 0x04
338#define INTERFACE_DFP_LOW 0x05
339#define INTERFACE_DFP 0x06
340#define INTERFACE_LVDS0 0x07
341#define INTERFACE_LVDS1 0x08
342#define INTERFACE_LVDS0LVDS1 0x09
343#define INTERFACE_TMDS 0x0A
344
345#define HW_LAYOUT_LCD_ONLY 0x01
346#define HW_LAYOUT_DVI_ONLY 0x02
347#define HW_LAYOUT_LCD_DVI 0x03
348#define HW_LAYOUT_LCD1_LCD2 0x04
349#define HW_LAYOUT_LCD_EXTERNAL_LCD2 0x10
350
351/* Definition Refresh Rate */
352#define REFRESH_50 50
353#define REFRESH_60 60
354#define REFRESH_75 75
355#define REFRESH_85 85
356#define REFRESH_100 100
357#define REFRESH_120 120
358
359/* Definition Sync Polarity*/
360#define NEGATIVE 1
361#define POSITIVE 0
362
363/*480x640@60 Sync Polarity (GTF)
364*/
365#define M480X640_R60_HSP NEGATIVE
366#define M480X640_R60_VSP POSITIVE
367
368/*640x480@60 Sync Polarity (VESA Mode)
369*/
370#define M640X480_R60_HSP NEGATIVE
371#define M640X480_R60_VSP NEGATIVE
372
373/*640x480@75 Sync Polarity (VESA Mode)
374*/
375#define M640X480_R75_HSP NEGATIVE
376#define M640X480_R75_VSP NEGATIVE
377
378/*640x480@85 Sync Polarity (VESA Mode)
379*/
380#define M640X480_R85_HSP NEGATIVE
381#define M640X480_R85_VSP NEGATIVE
382
383/*640x480@100 Sync Polarity (GTF Mode)
384*/
385#define M640X480_R100_HSP NEGATIVE
386#define M640X480_R100_VSP POSITIVE
387
388/*640x480@120 Sync Polarity (GTF Mode)
389*/
390#define M640X480_R120_HSP NEGATIVE
391#define M640X480_R120_VSP POSITIVE
392
393/*720x480@60 Sync Polarity (GTF Mode)
394*/
395#define M720X480_R60_HSP NEGATIVE
396#define M720X480_R60_VSP POSITIVE
397
398/*720x576@60 Sync Polarity (GTF Mode)
399*/
400#define M720X576_R60_HSP NEGATIVE
401#define M720X576_R60_VSP POSITIVE
402
403/*800x600@60 Sync Polarity (VESA Mode)
404*/
405#define M800X600_R60_HSP POSITIVE
406#define M800X600_R60_VSP POSITIVE
407
408/*800x600@75 Sync Polarity (VESA Mode)
409*/
410#define M800X600_R75_HSP POSITIVE
411#define M800X600_R75_VSP POSITIVE
412
413/*800x600@85 Sync Polarity (VESA Mode)
414*/
415#define M800X600_R85_HSP POSITIVE
416#define M800X600_R85_VSP POSITIVE
417
418/*800x600@100 Sync Polarity (GTF Mode)
419*/
420#define M800X600_R100_HSP NEGATIVE
421#define M800X600_R100_VSP POSITIVE
422
423/*800x600@120 Sync Polarity (GTF Mode)
424*/
425#define M800X600_R120_HSP NEGATIVE
426#define M800X600_R120_VSP POSITIVE
427
428/*800x480@60 Sync Polarity (CVT Mode)
429*/
430#define M800X480_R60_HSP NEGATIVE
431#define M800X480_R60_VSP POSITIVE
432
433/*848x480@60 Sync Polarity (CVT Mode)
434*/
435#define M848X480_R60_HSP NEGATIVE
436#define M848X480_R60_VSP POSITIVE
437
438/*852x480@60 Sync Polarity (GTF Mode)
439*/
440#define M852X480_R60_HSP NEGATIVE
441#define M852X480_R60_VSP POSITIVE
442
443/*1024x512@60 Sync Polarity (GTF Mode)
444*/
445#define M1024X512_R60_HSP NEGATIVE
446#define M1024X512_R60_VSP POSITIVE
447
448/*1024x600@60 Sync Polarity (GTF Mode)
449*/
450#define M1024X600_R60_HSP NEGATIVE
451#define M1024X600_R60_VSP POSITIVE
452
453/*1024x768@60 Sync Polarity (VESA Mode)
454*/
455#define M1024X768_R60_HSP NEGATIVE
456#define M1024X768_R60_VSP NEGATIVE
457
458/*1024x768@75 Sync Polarity (VESA Mode)
459*/
460#define M1024X768_R75_HSP POSITIVE
461#define M1024X768_R75_VSP POSITIVE
462
463/*1024x768@85 Sync Polarity (VESA Mode)
464*/
465#define M1024X768_R85_HSP POSITIVE
466#define M1024X768_R85_VSP POSITIVE
467
468/*1024x768@100 Sync Polarity (GTF Mode)
469*/
470#define M1024X768_R100_HSP NEGATIVE
471#define M1024X768_R100_VSP POSITIVE
472
473/*1152x864@75 Sync Polarity (VESA Mode)
474*/
475#define M1152X864_R75_HSP POSITIVE
476#define M1152X864_R75_VSP POSITIVE
477
478/*1280x720@60 Sync Polarity (GTF Mode)
479*/
480#define M1280X720_R60_HSP NEGATIVE
481#define M1280X720_R60_VSP POSITIVE
482
483/* 1280x768@50 Sync Polarity (GTF Mode) */
484#define M1280X768_R50_HSP NEGATIVE
485#define M1280X768_R50_VSP POSITIVE
486
487/*1280x768@60 Sync Polarity (GTF Mode)
488*/
489#define M1280X768_R60_HSP NEGATIVE
490#define M1280X768_R60_VSP POSITIVE
491
492/*1280x800@60 Sync Polarity (CVT Mode)
493*/
494#define M1280X800_R60_HSP NEGATIVE
495#define M1280X800_R60_VSP POSITIVE
496
497/*1280x960@60 Sync Polarity (VESA Mode)
498*/
499#define M1280X960_R60_HSP POSITIVE
500#define M1280X960_R60_VSP POSITIVE
501
502/*1280x1024@60 Sync Polarity (VESA Mode)
503*/
504#define M1280X1024_R60_HSP POSITIVE
505#define M1280X1024_R60_VSP POSITIVE
506
507/* 1360x768@60 Sync Polarity (CVT Mode) */
508#define M1360X768_R60_HSP POSITIVE
509#define M1360X768_R60_VSP POSITIVE
510
511/* 1360x768@60 Sync Polarity (CVT Reduce Blanking Mode) */
512#define M1360X768_RB_R60_HSP POSITIVE
513#define M1360X768_RB_R60_VSP NEGATIVE
514
515/* 1368x768@50 Sync Polarity (GTF Mode) */
516#define M1368X768_R50_HSP NEGATIVE
517#define M1368X768_R50_VSP POSITIVE
518
519/* 1368x768@60 Sync Polarity (VESA Mode) */
520#define M1368X768_R60_HSP NEGATIVE
521#define M1368X768_R60_VSP POSITIVE
522
523/*1280x1024@75 Sync Polarity (VESA Mode)
524*/
525#define M1280X1024_R75_HSP POSITIVE
526#define M1280X1024_R75_VSP POSITIVE
527
528/*1280x1024@85 Sync Polarity (VESA Mode)
529*/
530#define M1280X1024_R85_HSP POSITIVE
531#define M1280X1024_R85_VSP POSITIVE
532
533/*1440x1050@60 Sync Polarity (GTF Mode)
534*/
535#define M1440X1050_R60_HSP NEGATIVE
536#define M1440X1050_R60_VSP POSITIVE
537
538/*1600x1200@60 Sync Polarity (VESA Mode)
539*/
540#define M1600X1200_R60_HSP POSITIVE
541#define M1600X1200_R60_VSP POSITIVE
542
543/*1600x1200@75 Sync Polarity (VESA Mode)
544*/
545#define M1600X1200_R75_HSP POSITIVE
546#define M1600X1200_R75_VSP POSITIVE
547
548/* 1680x1050@60 Sync Polarity (CVT Mode) */
549#define M1680x1050_R60_HSP NEGATIVE
550#define M1680x1050_R60_VSP NEGATIVE
551
552/* 1680x1050@60 Sync Polarity (CVT Reduce Blanking Mode) */
553#define M1680x1050_RB_R60_HSP POSITIVE
554#define M1680x1050_RB_R60_VSP NEGATIVE
555
556/* 1680x1050@75 Sync Polarity (CVT Mode) */
557#define M1680x1050_R75_HSP NEGATIVE
558#define M1680x1050_R75_VSP POSITIVE
559
560/*1920x1080@60 Sync Polarity (CVT Mode)
561*/
562#define M1920X1080_R60_HSP NEGATIVE
563#define M1920X1080_R60_VSP POSITIVE
564
565/* 1920x1080@60 Sync Polarity (CVT Reduce Blanking Mode) */
566#define M1920X1080_RB_R60_HSP POSITIVE
567#define M1920X1080_RB_R60_VSP NEGATIVE
568
569/*1920x1440@60 Sync Polarity (VESA Mode)
570*/
571#define M1920X1440_R60_HSP NEGATIVE
572#define M1920X1440_R60_VSP POSITIVE
573
574/*1920x1440@75 Sync Polarity (VESA Mode)
575*/
576#define M1920X1440_R75_HSP NEGATIVE
577#define M1920X1440_R75_VSP POSITIVE
578
579#if 0
580/* 1400x1050@60 Sync Polarity (VESA Mode) */
581#define M1400X1050_R60_HSP NEGATIVE
582#define M1400X1050_R60_VSP NEGATIVE
583#endif
584
585/* 1400x1050@60 Sync Polarity (CVT Mode) */
586#define M1400X1050_R60_HSP NEGATIVE
587#define M1400X1050_R60_VSP POSITIVE
588
589/* 1400x1050@60 Sync Polarity (CVT Reduce Blanking Mode) */
590#define M1400X1050_RB_R60_HSP POSITIVE
591#define M1400X1050_RB_R60_VSP NEGATIVE
592
593/* 1400x1050@75 Sync Polarity (CVT Mode) */
594#define M1400X1050_R75_HSP NEGATIVE
595#define M1400X1050_R75_VSP POSITIVE
596
597/* 960x600@60 Sync Polarity (CVT Mode) */
598#define M960X600_R60_HSP NEGATIVE
599#define M960X600_R60_VSP POSITIVE
600
601/* 1000x600@60 Sync Polarity (GTF Mode) */
602#define M1000X600_R60_HSP NEGATIVE
603#define M1000X600_R60_VSP POSITIVE
604
605/* 1024x576@60 Sync Polarity (GTF Mode) */
606#define M1024X576_R60_HSP NEGATIVE
607#define M1024X576_R60_VSP POSITIVE
608
609/*1024x600@60 Sync Polarity (GTF Mode)*/
610#define M1024X600_R60_HSP NEGATIVE
611#define M1024X600_R60_VSP POSITIVE
612
613/* 1088x612@60 Sync Polarity (CVT Mode) */
614#define M1088X612_R60_HSP NEGATIVE
615#define M1088X612_R60_VSP POSITIVE
616
617/* 1152x720@60 Sync Polarity (CVT Mode) */
618#define M1152X720_R60_HSP NEGATIVE
619#define M1152X720_R60_VSP POSITIVE
620
621/* 1200x720@60 Sync Polarity (GTF Mode) */
622#define M1200X720_R60_HSP NEGATIVE
623#define M1200X720_R60_VSP POSITIVE
624
625/* 1280x600@60 Sync Polarity (GTF Mode) */
626#define M1280x600_R60_HSP NEGATIVE
627#define M1280x600_R60_VSP POSITIVE
628
629/* 1280x720@50 Sync Polarity (GTF Mode) */
630#define M1280X720_R50_HSP NEGATIVE
631#define M1280X720_R50_VSP POSITIVE
632
633/* 1280x720@60 Sync Polarity (CEA Mode) */
634#define M1280X720_CEA_R60_HSP POSITIVE
635#define M1280X720_CEA_R60_VSP POSITIVE
636
637/* 1440x900@60 Sync Polarity (CVT Mode) */
638#define M1440X900_R60_HSP NEGATIVE
639#define M1440X900_R60_VSP POSITIVE
640
641/* 1440x900@75 Sync Polarity (CVT Mode) */
642#define M1440X900_R75_HSP NEGATIVE
643#define M1440X900_R75_VSP POSITIVE
644
645/* 1440x900@60 Sync Polarity (CVT Reduce Blanking Mode) */
646#define M1440X900_RB_R60_HSP POSITIVE
647#define M1440X900_RB_R60_VSP NEGATIVE
648
649/* 1600x900@60 Sync Polarity (CVT Mode) */
650#define M1600X900_R60_HSP NEGATIVE
651#define M1600X900_R60_VSP POSITIVE
652
653/* 1600x900@60 Sync Polarity (CVT Reduce Blanking Mode) */
654#define M1600X900_RB_R60_HSP POSITIVE
655#define M1600X900_RB_R60_VSP NEGATIVE
656
657/* 1600x1024@60 Sync Polarity (GTF Mode) */
658#define M1600X1024_R60_HSP NEGATIVE
659#define M1600X1024_R60_VSP POSITIVE
660
661/* 1792x1344@60 Sync Polarity (DMT Mode) */
662#define M1792x1344_R60_HSP NEGATIVE
663#define M1792x1344_R60_VSP POSITIVE
664
665/* 1856x1392@60 Sync Polarity (DMT Mode) */
666#define M1856x1392_R60_HSP NEGATIVE
667#define M1856x1392_R60_VSP POSITIVE
668
669/* 1920x1200@60 Sync Polarity (CVT Mode) */
670#define M1920X1200_R60_HSP NEGATIVE
671#define M1920X1200_R60_VSP POSITIVE
672
673/* 1920x1200@60 Sync Polarity (CVT Reduce Blanking Mode) */
674#define M1920X1200_RB_R60_HSP POSITIVE
675#define M1920X1200_RB_R60_VSP NEGATIVE
676
677/* 1920x1080@60 Sync Polarity (CEA Mode) */
678#define M1920X1080_CEA_R60_HSP POSITIVE
679#define M1920X1080_CEA_R60_VSP POSITIVE
680
681/* 2048x1536@60 Sync Polarity (CVT Mode) */
682#define M2048x1536_R60_HSP NEGATIVE
683#define M2048x1536_R60_VSP POSITIVE
684
685/* define PLL index: */
686#define CLK_25_175M 25175000
687#define CLK_26_880M 26880000
688#define CLK_29_581M 29581000
689#define CLK_31_490M 31490000
690#define CLK_31_500M 31500000
691#define CLK_31_728M 31728000
692#define CLK_32_668M 32688000
693#define CLK_36_000M 36000000
694#define CLK_40_000M 40000000
695#define CLK_41_291M 41291000
696#define CLK_43_163M 43163000
697#define CLK_45_250M 45250000 /* 45.46MHz */
698#define CLK_46_000M 46000000
699#define CLK_46_996M 46996000
700#define CLK_48_000M 48000000
701#define CLK_48_875M 48875000
702#define CLK_49_500M 49500000
703#define CLK_52_406M 52406000
704#define CLK_52_977M 52977000
705#define CLK_56_250M 56250000
706#define CLK_60_466M 60466000
707#define CLK_61_500M 61500000
708#define CLK_65_000M 65000000
709#define CLK_65_178M 65178000
710#define CLK_66_750M 66750000 /* 67.116MHz */
711#define CLK_68_179M 68179000
712#define CLK_69_924M 69924000
713#define CLK_70_159M 70159000
714#define CLK_72_000M 72000000
715#define CLK_74_270M 74270000
716#define CLK_78_750M 78750000
717#define CLK_80_136M 80136000
718#define CLK_83_375M 83375000
719#define CLK_83_950M 83950000
720#define CLK_84_750M 84750000 /* 84.537Mhz */
721#define CLK_85_860M 85860000
722#define CLK_88_750M 88750000
723#define CLK_94_500M 94500000
724#define CLK_97_750M 97750000
725#define CLK_101_000M 101000000
726#define CLK_106_500M 106500000
727#define CLK_108_000M 108000000
728#define CLK_113_309M 113309000
729#define CLK_118_840M 118840000
730#define CLK_119_000M 119000000
731#define CLK_121_750M 121750000 /* 121.704MHz */
732#define CLK_125_104M 125104000
733#define CLK_133_308M 133308000
734#define CLK_135_000M 135000000
735#define CLK_136_700M 136700000
736#define CLK_138_400M 138400000
737#define CLK_146_760M 146760000
738#define CLK_148_500M 148500000
739
740#define CLK_153_920M 153920000
741#define CLK_156_000M 156000000
742#define CLK_157_500M 157500000
743#define CLK_162_000M 162000000
744#define CLK_187_000M 187000000
745#define CLK_193_295M 193295000
746#define CLK_202_500M 202500000
747#define CLK_204_000M 204000000
748#define CLK_218_500M 218500000
749#define CLK_234_000M 234000000
750#define CLK_267_250M 267250000
751#define CLK_297_500M 297500000
752#define CLK_74_481M 74481000
753#define CLK_172_798M 172798000
754#define CLK_122_614M 122614000
755
756/* CLE266 PLL value
757*/
758#define CLE266_PLL_25_175M 0x0000C763
759#define CLE266_PLL_26_880M 0x0000440F
760#define CLE266_PLL_29_581M 0x00008421
761#define CLE266_PLL_31_490M 0x00004721
762#define CLE266_PLL_31_500M 0x0000C3B5
763#define CLE266_PLL_31_728M 0x0000471F
764#define CLE266_PLL_32_668M 0x0000C449
765#define CLE266_PLL_36_000M 0x0000C5E5
766#define CLE266_PLL_40_000M 0x0000C459
767#define CLE266_PLL_41_291M 0x00004417
768#define CLE266_PLL_43_163M 0x0000C579
769#define CLE266_PLL_45_250M 0x0000C57F /* 45.46MHz */
770#define CLE266_PLL_46_000M 0x0000875A
771#define CLE266_PLL_46_996M 0x0000C4E9
772#define CLE266_PLL_48_000M 0x00001443
773#define CLE266_PLL_48_875M 0x00001D63
774#define CLE266_PLL_49_500M 0x00008653
775#define CLE266_PLL_52_406M 0x0000C475
776#define CLE266_PLL_52_977M 0x00004525
777#define CLE266_PLL_56_250M 0x000047B7
778#define CLE266_PLL_60_466M 0x0000494C
779#define CLE266_PLL_61_500M 0x00001456
780#define CLE266_PLL_65_000M 0x000086ED
781#define CLE266_PLL_65_178M 0x0000855B
782#define CLE266_PLL_66_750M 0x0000844B /* 67.116MHz */
783#define CLE266_PLL_68_179M 0x00000413
784#define CLE266_PLL_69_924M 0x00001153
785#define CLE266_PLL_70_159M 0x00001462
786#define CLE266_PLL_72_000M 0x00001879
787#define CLE266_PLL_74_270M 0x00004853
788#define CLE266_PLL_78_750M 0x00004321
789#define CLE266_PLL_80_136M 0x0000051C
790#define CLE266_PLL_83_375M 0x0000C25D
791#define CLE266_PLL_83_950M 0x00000729
792#define CLE266_PLL_84_750M 0x00008576 /* 84.537MHz */
793#define CLE266_PLL_85_860M 0x00004754
794#define CLE266_PLL_88_750M 0x0000051F
795#define CLE266_PLL_94_500M 0x00000521
796#define CLE266_PLL_97_750M 0x00004652
797#define CLE266_PLL_101_000M 0x0000497F
798#define CLE266_PLL_106_500M 0x00008477 /* 106.491463 MHz */
799#define CLE266_PLL_108_000M 0x00008479
800#define CLE266_PLL_113_309M 0x00000C5F
801#define CLE266_PLL_118_840M 0x00004553
802#define CLE266_PLL_119_000M 0x00000D6C
803#define CLE266_PLL_121_750M 0x00004555 /* 121.704MHz */
804#define CLE266_PLL_125_104M 0x000006B5
805#define CLE266_PLL_133_308M 0x0000465F
806#define CLE266_PLL_135_000M 0x0000455E
807#define CLE266_PLL_136_700M 0x00000C73
808#define CLE266_PLL_138_400M 0x00000957
809#define CLE266_PLL_146_760M 0x00004567
810#define CLE266_PLL_148_500M 0x00000853
811#define CLE266_PLL_153_920M 0x00000856
812#define CLE266_PLL_156_000M 0x0000456D
813#define CLE266_PLL_157_500M 0x000005B7
814#define CLE266_PLL_162_000M 0x00004571
815#define CLE266_PLL_187_000M 0x00000976
816#define CLE266_PLL_193_295M 0x0000086C
817#define CLE266_PLL_202_500M 0x00000763
818#define CLE266_PLL_204_000M 0x00000764
819#define CLE266_PLL_218_500M 0x0000065C
820#define CLE266_PLL_234_000M 0x00000662
821#define CLE266_PLL_267_250M 0x00000670
822#define CLE266_PLL_297_500M 0x000005E6
823#define CLE266_PLL_74_481M 0x0000051A
824#define CLE266_PLL_172_798M 0x00004579
825#define CLE266_PLL_122_614M 0x0000073C
826
827/* K800 PLL value
828*/
829#define K800_PLL_25_175M 0x00539001
830#define K800_PLL_26_880M 0x001C8C80
831#define K800_PLL_29_581M 0x00409080
832#define K800_PLL_31_490M 0x006F9001
833#define K800_PLL_31_500M 0x008B9002
834#define K800_PLL_31_728M 0x00AF9003
835#define K800_PLL_32_668M 0x00909002
836#define K800_PLL_36_000M 0x009F9002
837#define K800_PLL_40_000M 0x00578C02
838#define K800_PLL_41_291M 0x00438C01
839#define K800_PLL_43_163M 0x00778C03
840#define K800_PLL_45_250M 0x007D8C83 /* 45.46MHz */
841#define K800_PLL_46_000M 0x00658C02
842#define K800_PLL_46_996M 0x00818C83
843#define K800_PLL_48_000M 0x00848C83
844#define K800_PLL_48_875M 0x00508C81
845#define K800_PLL_49_500M 0x00518C01
846#define K800_PLL_52_406M 0x00738C02
847#define K800_PLL_52_977M 0x00928C83
848#define K800_PLL_56_250M 0x007C8C02
849#define K800_PLL_60_466M 0x00A78C83
850#define K800_PLL_61_500M 0x00AA8C83
851#define K800_PLL_65_000M 0x006B8C01
852#define K800_PLL_65_178M 0x00B48C83
853#define K800_PLL_66_750M 0x00948C82 /* 67.116MHz */
854#define K800_PLL_68_179M 0x00708C01
855#define K800_PLL_69_924M 0x00C18C83
856#define K800_PLL_70_159M 0x00C28C83
857#define K800_PLL_72_000M 0x009F8C82
858#define K800_PLL_74_270M 0x00ce0c03
859#define K800_PLL_78_750M 0x00408801
860#define K800_PLL_80_136M 0x00428801
861#define K800_PLL_83_375M 0x005B0882
862#define K800_PLL_83_950M 0x00738803
863#define K800_PLL_84_750M 0x00748883 /* 84.477MHz */
864#define K800_PLL_85_860M 0x00768883
865#define K800_PLL_88_750M 0x007A8883
866#define K800_PLL_94_500M 0x00828803
867#define K800_PLL_97_750M 0x00878883
868#define K800_PLL_101_000M 0x008B8883
869#define K800_PLL_106_500M 0x00758882 /* 106.491463 MHz */
870#define K800_PLL_108_000M 0x00778882
871#define K800_PLL_113_309M 0x005D8881
872#define K800_PLL_118_840M 0x00A48883
873#define K800_PLL_119_000M 0x00838882
874#define K800_PLL_121_750M 0x00A88883 /* 121.704MHz */
875#define K800_PLL_125_104M 0x00688801
876#define K800_PLL_133_308M 0x005D8801
877#define K800_PLL_135_000M 0x001A4081
878#define K800_PLL_136_700M 0x00BD8883
879#define K800_PLL_138_400M 0x00728881
880#define K800_PLL_146_760M 0x00CC8883
881#define K800_PLL_148_500M 0x00ce0803
882#define K800_PLL_153_920M 0x00548482
883#define K800_PLL_156_000M 0x006B8483
884#define K800_PLL_157_500M 0x00142080
885#define K800_PLL_162_000M 0x006F8483
886#define K800_PLL_187_000M 0x00818483
887#define K800_PLL_193_295M 0x004F8481
888#define K800_PLL_202_500M 0x00538481
889#define K800_PLL_204_000M 0x008D8483
890#define K800_PLL_218_500M 0x00978483
891#define K800_PLL_234_000M 0x00608401
892#define K800_PLL_267_250M 0x006E8481
893#define K800_PLL_297_500M 0x00A48402
894#define K800_PLL_74_481M 0x007B8C81
895#define K800_PLL_172_798M 0x00778483
896#define K800_PLL_122_614M 0x00878882
897
898/* PLL for VT3324 */
899#define CX700_25_175M 0x008B1003
900#define CX700_26_719M 0x00931003
901#define CX700_26_880M 0x00941003
902#define CX700_29_581M 0x00A49003
903#define CX700_31_490M 0x00AE1003
904#define CX700_31_500M 0x00AE1003
905#define CX700_31_728M 0x00AF1003
906#define CX700_32_668M 0x00B51003
907#define CX700_36_000M 0x00C81003
908#define CX700_40_000M 0x006E0C03
909#define CX700_41_291M 0x00710C03
910#define CX700_43_163M 0x00770C03
911#define CX700_45_250M 0x007D0C03 /* 45.46MHz */
912#define CX700_46_000M 0x007F0C03
913#define CX700_46_996M 0x00818C83
914#define CX700_48_000M 0x00840C03
915#define CX700_48_875M 0x00508C81
916#define CX700_49_500M 0x00880C03
917#define CX700_52_406M 0x00730C02
918#define CX700_52_977M 0x00920C03
919#define CX700_56_250M 0x009B0C03
920#define CX700_60_466M 0x00460C00
921#define CX700_61_500M 0x00AA0C03
922#define CX700_65_000M 0x006B0C01
923#define CX700_65_178M 0x006B0C01
924#define CX700_66_750M 0x00940C02 /*67.116MHz */
925#define CX700_68_179M 0x00BC0C03
926#define CX700_69_924M 0x00C10C03
927#define CX700_70_159M 0x00C20C03
928#define CX700_72_000M 0x009F0C02
929#define CX700_74_270M 0x00CE0C03
930#define CX700_74_481M 0x00CE0C03
931#define CX700_78_750M 0x006C0803
932#define CX700_80_136M 0x006E0803
933#define CX700_83_375M 0x005B0882
934#define CX700_83_950M 0x00730803
935#define CX700_84_750M 0x00740803 /* 84.537Mhz */
936#define CX700_85_860M 0x00760803
937#define CX700_88_750M 0x00AC8885
938#define CX700_94_500M 0x00820803
939#define CX700_97_750M 0x00870803
940#define CX700_101_000M 0x008B0803
941#define CX700_106_500M 0x00750802
942#define CX700_108_000M 0x00950803
943#define CX700_113_309M 0x005D0801
944#define CX700_118_840M 0x00A40803
945#define CX700_119_000M 0x00830802
946#define CX700_121_750M 0x00420800 /* 121.704MHz */
947#define CX700_125_104M 0x00AD0803
948#define CX700_133_308M 0x00930802
949#define CX700_135_000M 0x00950802
950#define CX700_136_700M 0x00BD0803
951#define CX700_138_400M 0x00720801
952#define CX700_146_760M 0x00CC0803
953#define CX700_148_500M 0x00a40802
954#define CX700_153_920M 0x00540402
955#define CX700_156_000M 0x006B0403
956#define CX700_157_500M 0x006C0403
957#define CX700_162_000M 0x006F0403
958#define CX700_172_798M 0x00770403
959#define CX700_187_000M 0x00810403
960#define CX700_193_295M 0x00850403
961#define CX700_202_500M 0x008C0403
962#define CX700_204_000M 0x008D0403
963#define CX700_218_500M 0x00970403
964#define CX700_234_000M 0x00600401
965#define CX700_267_250M 0x00B90403
966#define CX700_297_500M 0x00CE0403
967#define CX700_122_614M 0x00870802
968
969/* Definition CRTC Timing Index */
970#define H_TOTAL_INDEX 0
971#define H_ADDR_INDEX 1
972#define H_BLANK_START_INDEX 2
973#define H_BLANK_END_INDEX 3
974#define H_SYNC_START_INDEX 4
975#define H_SYNC_END_INDEX 5
976#define V_TOTAL_INDEX 6
977#define V_ADDR_INDEX 7
978#define V_BLANK_START_INDEX 8
979#define V_BLANK_END_INDEX 9
980#define V_SYNC_START_INDEX 10
981#define V_SYNC_END_INDEX 11
982#define H_TOTAL_SHADOW_INDEX 12
983#define H_BLANK_END_SHADOW_INDEX 13
984#define V_TOTAL_SHADOW_INDEX 14
985#define V_ADDR_SHADOW_INDEX 15
986#define V_BLANK_SATRT_SHADOW_INDEX 16
987#define V_BLANK_END_SHADOW_INDEX 17
988#define V_SYNC_SATRT_SHADOW_INDEX 18
989#define V_SYNC_END_SHADOW_INDEX 19
990
991/* Definition Video Mode Pixel Clock (picoseconds)
992*/
993#define RES_480X640_60HZ_PIXCLOCK 39722
994#define RES_640X480_60HZ_PIXCLOCK 39722
995#define RES_640X480_75HZ_PIXCLOCK 31747
996#define RES_640X480_85HZ_PIXCLOCK 27777
997#define RES_640X480_100HZ_PIXCLOCK 23168
998#define RES_640X480_120HZ_PIXCLOCK 19081
999#define RES_720X480_60HZ_PIXCLOCK 37020
1000#define RES_720X576_60HZ_PIXCLOCK 30611
1001#define RES_800X600_60HZ_PIXCLOCK 25000
1002#define RES_800X600_75HZ_PIXCLOCK 20203
1003#define RES_800X600_85HZ_PIXCLOCK 17777
1004#define RES_800X600_100HZ_PIXCLOCK 14667
1005#define RES_800X600_120HZ_PIXCLOCK 11912
1006#define RES_800X480_60HZ_PIXCLOCK 33805
1007#define RES_848X480_60HZ_PIXCLOCK 31756
1008#define RES_856X480_60HZ_PIXCLOCK 31518
1009#define RES_1024X512_60HZ_PIXCLOCK 24218
1010#define RES_1024X600_60HZ_PIXCLOCK 20460
1011#define RES_1024X768_60HZ_PIXCLOCK 15385
1012#define RES_1024X768_75HZ_PIXCLOCK 12699
1013#define RES_1024X768_85HZ_PIXCLOCK 10582
1014#define RES_1024X768_100HZ_PIXCLOCK 8825
1015#define RES_1152X864_75HZ_PIXCLOCK 9259
1016#define RES_1280X768_60HZ_PIXCLOCK 12480
1017#define RES_1280X800_60HZ_PIXCLOCK 11994
1018#define RES_1280X960_60HZ_PIXCLOCK 9259
1019#define RES_1280X1024_60HZ_PIXCLOCK 9260
1020#define RES_1280X1024_75HZ_PIXCLOCK 7408
1021#define RES_1280X768_85HZ_PIXCLOCK 6349
1022#define RES_1440X1050_60HZ_PIXCLOCK 7993
1023#define RES_1600X1200_60HZ_PIXCLOCK 6172
1024#define RES_1600X1200_75HZ_PIXCLOCK 4938
1025#define RES_1280X720_60HZ_PIXCLOCK 13426
1026#define RES_1920X1080_60HZ_PIXCLOCK 5787
1027#define RES_1400X1050_60HZ_PIXCLOCK 8214
1028#define RES_1400X1050_75HZ_PIXCLOCK 6410
1029#define RES_1368X768_60HZ_PIXCLOCK 11647
1030#define RES_960X600_60HZ_PIXCLOCK 22099
1031#define RES_1000X600_60HZ_PIXCLOCK 20834
1032#define RES_1024X576_60HZ_PIXCLOCK 21278
1033#define RES_1088X612_60HZ_PIXCLOCK 18877
1034#define RES_1152X720_60HZ_PIXCLOCK 14981
1035#define RES_1200X720_60HZ_PIXCLOCK 14253
1036#define RES_1280X600_60HZ_PIXCLOCK 16260
1037#define RES_1280X720_50HZ_PIXCLOCK 16538
1038#define RES_1280X768_50HZ_PIXCLOCK 15342
1039#define RES_1366X768_50HZ_PIXCLOCK 14301
1040#define RES_1366X768_60HZ_PIXCLOCK 11646
1041#define RES_1360X768_60HZ_PIXCLOCK 11799
1042#define RES_1440X900_60HZ_PIXCLOCK 9390
1043#define RES_1440X900_75HZ_PIXCLOCK 7315
1044#define RES_1600X900_60HZ_PIXCLOCK 8415
1045#define RES_1600X1024_60HZ_PIXCLOCK 7315
1046#define RES_1680X1050_60HZ_PIXCLOCK 6814
1047#define RES_1680X1050_75HZ_PIXCLOCK 5348
1048#define RES_1792X1344_60HZ_PIXCLOCK 4902
1049#define RES_1856X1392_60HZ_PIXCLOCK 4577
1050#define RES_1920X1200_60HZ_PIXCLOCK 5173
1051#define RES_1920X1440_60HZ_PIXCLOCK 4274
1052#define RES_1920X1440_75HZ_PIXCLOCK 3367
1053#define RES_2048X1536_60HZ_PIXCLOCK 3742
1054
1055#define RES_1360X768_RB_60HZ_PIXCLOCK 13889
1056#define RES_1400X1050_RB_60HZ_PIXCLOCK 9901
1057#define RES_1440X900_RB_60HZ_PIXCLOCK 11268
1058#define RES_1600X900_RB_60HZ_PIXCLOCK 10230
1059#define RES_1680X1050_RB_60HZ_PIXCLOCK 8403
1060#define RES_1920X1080_RB_60HZ_PIXCLOCK 7225
1061#define RES_1920X1200_RB_60HZ_PIXCLOCK 6497
1062
1063/* LCD display method
1064*/
1065#define LCD_EXPANDSION 0x00
1066#define LCD_CENTERING 0x01
1067
1068/* LCD mode
1069*/
1070#define LCD_OPENLDI 0x00
1071#define LCD_SPWG 0x01
1072
1073/* Define display timing
1074*/
1075struct display_timing {
1076 u16 hor_total;
1077 u16 hor_addr;
1078 u16 hor_blank_start;
1079 u16 hor_blank_end;
1080 u16 hor_sync_start;
1081 u16 hor_sync_end;
1082 u16 ver_total;
1083 u16 ver_addr;
1084 u16 ver_blank_start;
1085 u16 ver_blank_end;
1086 u16 ver_sync_start;
1087 u16 ver_sync_end;
1088};
1089
1090struct crt_mode_table {
1091 int refresh_rate;
1092 unsigned long clk;
1093 int h_sync_polarity;
1094 int v_sync_polarity;
1095 struct display_timing crtc;
1096};
1097
1098struct io_reg {
1099 int port;
1100 u8 index;
1101 u8 mask;
1102 u8 value;
1103};
1104
1105#endif /* __SHARE_H__ */
diff --git a/drivers/video/via/tbl1636.c b/drivers/video/via/tbl1636.c
new file mode 100644
index 000000000000..2d8453429d4a
--- /dev/null
+++ b/drivers/video/via/tbl1636.c
@@ -0,0 +1,71 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23struct IODATA COMMON_INIT_TBL_VT1636[] = {
24/* Index, Mask, Value */
25 /* Set panel power sequence timing */
26 {0x10, 0xC0, 0x00},
27 /* T1: VDD on - Data on. Each increment is 1 ms. (50ms = 031h) */
28 {0x0B, 0xFF, 0x40},
29 /* T2: Data on - Backlight on. Each increment is 2 ms. (210ms = 068h) */
30 {0x0C, 0xFF, 0x31},
31 /* T3: Backlight off -Data off. Each increment is 2 ms. (210ms = 068h)*/
32 {0x0D, 0xFF, 0x31},
33 /* T4: Data off - VDD off. Each increment is 1 ms. (50ms = 031h) */
34 {0x0E, 0xFF, 0x68},
35 /* T5: VDD off - VDD on. Each increment is 100 ms. (500ms = 04h) */
36 {0x0F, 0xFF, 0x68},
37 /* LVDS output power up */
38 {0x09, 0xA0, 0xA0},
39 /* turn on back light */
40 {0x10, 0x33, 0x13}
41};
42
43struct IODATA DUAL_CHANNEL_ENABLE_TBL_VT1636[] = {
44/* Index, Mask, Value */
45 {0x08, 0xF0, 0xE0} /* Input Data Mode Select */
46};
47
48struct IODATA SINGLE_CHANNEL_ENABLE_TBL_VT1636[] = {
49/* Index, Mask, Value */
50 {0x08, 0xF0, 0x00} /* Input Data Mode Select */
51};
52
53struct IODATA DITHERING_ENABLE_TBL_VT1636[] = {
54/* Index, Mask, Value */
55 {0x0A, 0x70, 0x50}
56};
57
58struct IODATA DITHERING_DISABLE_TBL_VT1636[] = {
59/* Index, Mask, Value */
60 {0x0A, 0x70, 0x00}
61};
62
63struct IODATA VDD_ON_TBL_VT1636[] = {
64/* Index, Mask, Value */
65 {0x10, 0x20, 0x20}
66};
67
68struct IODATA VDD_OFF_TBL_VT1636[] = {
69/* Index, Mask, Value */
70 {0x10, 0x20, 0x00}
71};
diff --git a/drivers/video/via/tbl1636.h b/drivers/video/via/tbl1636.h
new file mode 100644
index 000000000000..d906055f1511
--- /dev/null
+++ b/drivers/video/via/tbl1636.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef _TBL1636_H_
23#define _TBL1636_H_
24#include "hw.h"
25
26extern struct IODATA COMMON_INIT_TBL_VT1636[8];
27extern struct IODATA DUAL_CHANNEL_ENABLE_TBL_VT1636[1];
28extern struct IODATA SINGLE_CHANNEL_ENABLE_TBL_VT1636[1];
29extern struct IODATA DITHERING_ENABLE_TBL_VT1636[1];
30extern struct IODATA DITHERING_DISABLE_TBL_VT1636[1];
31extern struct IODATA VDD_ON_TBL_VT1636[1];
32extern struct IODATA VDD_OFF_TBL_VT1636[1];
33
34#endif /* _VIA_TBL1636_H_ */
diff --git a/drivers/video/via/tblDPASetting.c b/drivers/video/via/tblDPASetting.c
new file mode 100644
index 000000000000..0c4c8cc712f4
--- /dev/null
+++ b/drivers/video/via/tblDPASetting.c
@@ -0,0 +1,109 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23/* For VT3324: */
24struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3324[] = {
25 /* Panel ID, CLK_SEL_ST1[09], CLK_SEL_ST2[08] */
26 {LCD_PANEL_ID0_640X480, 0x00, 0x00}, /* For 640x480 */
27 {LCD_PANEL_ID1_800X600, 0x00, 0x00}, /* For 800x600 */
28 {LCD_PANEL_ID2_1024X768, 0x00, 0x00}, /* For 1024x768 */
29 {LCD_PANEL_ID3_1280X768, 0x00, 0x00}, /* For 1280x768 */
30 {LCD_PANEL_ID4_1280X1024, 0x00, 0x00}, /* For 1280x1024 */
31 {LCD_PANEL_ID5_1400X1050, 0x00, 0x00}, /* For 1400x1050 */
32 {LCD_PANEL_ID6_1600X1200, 0x0B, 0x03} /* For 1600x1200 */
33};
34
35struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3324[] = {
36/* ClkRange, DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
37 DVP1Driving, DFPHigh, DFPLow */
38/* CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], CR9B,
39 SR65, CR97, CR99 */
40 /* LCK/VCK < 30000000 will use this value */
41 {DPA_CLK_RANGE_30M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
42 0x00},
43 /* 30000000 < LCK/VCK < 50000000 will use this value */
44 {DPA_CLK_RANGE_30_50M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
45 0x00},
46 /* 50000000 < LCK/VCK < 70000000 will use this value */
47 {DPA_CLK_RANGE_50_70M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
48 0x00},
49 /* 70000000 < LCK/VCK < 100000000 will use this value */
50 {DPA_CLK_RANGE_70_100M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
51 0x00},
52 /* 100000000 < LCK/VCK < 15000000 will use this value */
53 {DPA_CLK_RANGE_100_150M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
54 0x00},
55 /* 15000000 < LCK/VCK will use this value */
56 {DPA_CLK_RANGE_150M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0E, 0x00,
57 0x00},
58};
59
60/* For VT3327: */
61struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3327[] = {
62 /* Panel ID, CLK_SEL_ST1[09], CLK_SEL_ST2[08] */
63 {LCD_PANEL_ID0_640X480, 0x00, 0x00}, /* For 640x480 */
64 {LCD_PANEL_ID1_800X600, 0x00, 0x00}, /* For 800x600 */
65 {LCD_PANEL_ID2_1024X768, 0x00, 0x00}, /* For 1024x768 */
66 {LCD_PANEL_ID3_1280X768, 0x00, 0x00}, /* For 1280x768 */
67 {LCD_PANEL_ID4_1280X1024, 0x00, 0x00}, /* For 1280x1024 */
68 {LCD_PANEL_ID5_1400X1050, 0x00, 0x00}, /* For 1400x1050 */
69 {LCD_PANEL_ID6_1600X1200, 0x00, 0x00} /* For 1600x1200 */
70};
71
72struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3327[] = {
73/* ClkRange,DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
74 DVP1Driving, DFPHigh, DFPLow */
75/* CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], CR9B,
76 SR65, CR97, CR99 */
77/* LCK/VCK < 30000000 will use this value */
78{DPA_CLK_RANGE_30M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x01},
79/* 30000000 < LCK/VCK < 50000000 will use this value */
80{DPA_CLK_RANGE_30_50M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x01},
81/* 50000000 < LCK/VCK < 70000000 will use this value */
82{DPA_CLK_RANGE_50_70M, 0x06, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x01},
83/* 70000000 < LCK/VCK < 100000000 will use this value */
84{DPA_CLK_RANGE_70_100M, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x03},
85/* 100000000 < LCK/VCK < 15000000 will use this value */
86{DPA_CLK_RANGE_100_150M, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02},
87/* 15000000 < LCK/VCK will use this value */
88{DPA_CLK_RANGE_150M, 0x00, 0x20, 0x00, 0x10, 0x00, 0x03, 0x00, 0x0D, 0x03},
89};
90
91/* For VT3364: */
92struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3364[] = {
93/* ClkRange,DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
94 DVP1Driving, DFPHigh, DFPLow */
95/* CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], CR9B,
96 SR65, CR97, CR99 */
97/* LCK/VCK < 30000000 will use this value */
98{DPA_CLK_RANGE_30M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08},
99/* 30000000 < LCK/VCK < 50000000 will use this value */
100{DPA_CLK_RANGE_30_50M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08},
101/* 50000000 < LCK/VCK < 70000000 will use this value */
102{DPA_CLK_RANGE_50_70M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08},
103/* 70000000 < LCK/VCK < 100000000 will use this value */
104{DPA_CLK_RANGE_70_100M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08},
105/* 100000000 < LCK/VCK < 15000000 will use this value */
106{DPA_CLK_RANGE_100_150M, 0x03, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08},
107/* 15000000 < LCK/VCK will use this value */
108{DPA_CLK_RANGE_150M, 0x01, 0x00, 0x02, 0x10, 0x00, 0x03, 0x00, 0x00, 0x08},
109};
diff --git a/drivers/video/via/tblDPASetting.h b/drivers/video/via/tblDPASetting.h
new file mode 100644
index 000000000000..b065a83481d3
--- /dev/null
+++ b/drivers/video/via/tblDPASetting.h
@@ -0,0 +1,47 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef _TBLDPASETTING_H_
23#define _TBLDPASETTING_H_
24#include "global.h"
25
26#define DPA_CLK_30M 30000000
27#define DPA_CLK_50M 50000000
28#define DPA_CLK_70M 70000000
29#define DPA_CLK_100M 100000000
30#define DPA_CLK_150M 150000000
31
32enum DPA_RANGE {
33 DPA_CLK_RANGE_30M,
34 DPA_CLK_RANGE_30_50M,
35 DPA_CLK_RANGE_50_70M,
36 DPA_CLK_RANGE_70_100M,
37 DPA_CLK_RANGE_100_150M,
38 DPA_CLK_RANGE_150M
39};
40
41extern struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3324[7];
42extern struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3324[6];
43extern struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3327[7];
44extern struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3327[];
45extern struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3364[6];
46
47#endif
diff --git a/drivers/video/via/via_i2c.c b/drivers/video/via/via_i2c.c
new file mode 100644
index 000000000000..0f3ed4eb236d
--- /dev/null
+++ b/drivers/video/via/via_i2c.c
@@ -0,0 +1,177 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23
24static void via_i2c_setscl(void *data, int state)
25{
26 u8 val;
27 struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
28
29 val = viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0xF0;
30 if (state)
31 val |= 0x20;
32 else
33 val &= ~0x20;
34 switch (via_i2c_chan->i2c_port) {
35 case I2CPORTINDEX:
36 val |= 0x01;
37 break;
38 case GPIOPORTINDEX:
39 val |= 0x80;
40 break;
41 default:
42 DEBUG_MSG("via_i2c: specify wrong i2c port.\n");
43 }
44 viafb_write_reg(via_i2c_chan->i2c_port, VIASR, val);
45}
46
47static int via_i2c_getscl(void *data)
48{
49 struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
50
51 if (viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0x08)
52 return 1;
53 return 0;
54}
55
56static int via_i2c_getsda(void *data)
57{
58 struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
59
60 if (viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0x04)
61 return 1;
62 return 0;
63}
64
65static void via_i2c_setsda(void *data, int state)
66{
67 u8 val;
68 struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
69
70 val = viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0xF0;
71 if (state)
72 val |= 0x10;
73 else
74 val &= ~0x10;
75 switch (via_i2c_chan->i2c_port) {
76 case I2CPORTINDEX:
77 val |= 0x01;
78 break;
79 case GPIOPORTINDEX:
80 val |= 0x40;
81 break;
82 default:
83 DEBUG_MSG("via_i2c: specify wrong i2c port.\n");
84 }
85 viafb_write_reg(via_i2c_chan->i2c_port, VIASR, val);
86}
87
88int viafb_i2c_readbyte(u8 slave_addr, u8 index, u8 *pdata)
89{
90 u8 mm1[] = {0x00};
91 struct i2c_msg msgs[2];
92
93 *pdata = 0;
94 msgs[0].flags = 0;
95 msgs[1].flags = I2C_M_RD;
96 msgs[0].addr = msgs[1].addr = slave_addr / 2;
97 mm1[0] = index;
98 msgs[0].len = 1; msgs[1].len = 1;
99 msgs[0].buf = mm1; msgs[1].buf = pdata;
100 i2c_transfer(&viaparinfo->i2c_stuff.adapter, msgs, 2);
101
102 return 0;
103}
104
105int viafb_i2c_writebyte(u8 slave_addr, u8 index, u8 data)
106{
107 u8 msg[2] = { index, data };
108 struct i2c_msg msgs;
109
110 msgs.flags = 0;
111 msgs.addr = slave_addr / 2;
112 msgs.len = 2;
113 msgs.buf = msg;
114 return i2c_transfer(&viaparinfo->i2c_stuff.adapter, &msgs, 1);
115}
116
117int viafb_i2c_readbytes(u8 slave_addr, u8 index, u8 *buff, int buff_len)
118{
119 u8 mm1[] = {0x00};
120 struct i2c_msg msgs[2];
121
122 msgs[0].flags = 0;
123 msgs[1].flags = I2C_M_RD;
124 msgs[0].addr = msgs[1].addr = slave_addr / 2;
125 mm1[0] = index;
126 msgs[0].len = 1; msgs[1].len = buff_len;
127 msgs[0].buf = mm1; msgs[1].buf = buff;
128 i2c_transfer(&viaparinfo->i2c_stuff.adapter, msgs, 2);
129 return 0;
130}
131
132int viafb_create_i2c_bus(void *viapar)
133{
134 int ret;
135 struct viafb_par *par = (struct viafb_par *)viapar;
136
137 strcpy(par->i2c_stuff.adapter.name, "via_i2c");
138 par->i2c_stuff.i2c_port = 0x0;
139 par->i2c_stuff.adapter.owner = THIS_MODULE;
140 par->i2c_stuff.adapter.id = 0x01FFFF;
141 par->i2c_stuff.adapter.class = 0;
142 par->i2c_stuff.adapter.algo_data = &par->i2c_stuff.algo;
143 par->i2c_stuff.adapter.dev.parent = NULL;
144 par->i2c_stuff.algo.setsda = via_i2c_setsda;
145 par->i2c_stuff.algo.setscl = via_i2c_setscl;
146 par->i2c_stuff.algo.getsda = via_i2c_getsda;
147 par->i2c_stuff.algo.getscl = via_i2c_getscl;
148 par->i2c_stuff.algo.udelay = 40;
149 par->i2c_stuff.algo.timeout = 20;
150 par->i2c_stuff.algo.data = &par->i2c_stuff;
151
152 i2c_set_adapdata(&par->i2c_stuff.adapter, &par->i2c_stuff);
153
154 /* Raise SCL and SDA */
155 par->i2c_stuff.i2c_port = I2CPORTINDEX;
156 via_i2c_setsda(&par->i2c_stuff, 1);
157 via_i2c_setscl(&par->i2c_stuff, 1);
158
159 par->i2c_stuff.i2c_port = GPIOPORTINDEX;
160 via_i2c_setsda(&par->i2c_stuff, 1);
161 via_i2c_setscl(&par->i2c_stuff, 1);
162 udelay(20);
163
164 ret = i2c_bit_add_bus(&par->i2c_stuff.adapter);
165 if (ret == 0)
166 DEBUG_MSG("I2C bus %s registered.\n",
167 par->i2c_stuff.adapter.name);
168 else
169 DEBUG_MSG("Failed to register I2C bus %s.\n",
170 par->i2c_stuff.adapter.name);
171 return ret;
172}
173
174void viafb_delete_i2c_buss(void *par)
175{
176 i2c_del_adapter(&((struct viafb_par *)par)->i2c_stuff.adapter);
177}
diff --git a/drivers/video/via/via_i2c.h b/drivers/video/via/via_i2c.h
new file mode 100644
index 000000000000..3a13242a3152
--- /dev/null
+++ b/drivers/video/via/via_i2c.h
@@ -0,0 +1,46 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#ifndef __VIA_I2C_H__
22#define __VIA_I2C_H__
23
24#include <linux/i2c.h>
25#include <linux/i2c-algo-bit.h>
26
27struct via_i2c_stuff {
28 u16 i2c_port; /* GPIO or I2C port */
29 struct i2c_adapter adapter;
30 struct i2c_algo_bit_data algo;
31};
32
33#define I2CPORT 0x3c4
34#define I2CPORTINDEX 0x31
35#define GPIOPORT 0x3C4
36#define GPIOPORTINDEX 0x2C
37#define I2C_BUS 1
38#define GPIO_BUS 2
39#define DELAYPORT 0x3C3
40
41int viafb_i2c_readbyte(u8 slave_addr, u8 index, u8 *pdata);
42int viafb_i2c_writebyte(u8 slave_addr, u8 index, u8 data);
43int viafb_i2c_readbytes(u8 slave_addr, u8 index, u8 *buff, int buff_len);
44int viafb_create_i2c_bus(void *par);
45void viafb_delete_i2c_buss(void *par);
46#endif /* __VIA_I2C_H__ */
diff --git a/drivers/video/via/via_utility.c b/drivers/video/via/via_utility.c
new file mode 100644
index 000000000000..d53c3d54ed8e
--- /dev/null
+++ b/drivers/video/via/via_utility.c
@@ -0,0 +1,253 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23
24void viafb_get_device_support_state(u32 *support_state)
25{
26 *support_state = CRT_Device;
27
28 if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name == VT1632_TMDS)
29 *support_state |= DVI_Device;
30
31 if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name == VT1631_LVDS)
32 *support_state |= LCD_Device;
33}
34
35void viafb_get_device_connect_state(u32 *connect_state)
36{
37 bool mobile = false;
38
39 *connect_state = CRT_Device;
40
41 if (viafb_dvi_sense())
42 *connect_state |= DVI_Device;
43
44 viafb_lcd_get_mobile_state(&mobile);
45 if (mobile)
46 *connect_state |= LCD_Device;
47}
48
49bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres)
50{
51 unsigned int support_state = 0;
52
53 switch (viafb_lcd_panel_id) {
54 case LCD_PANEL_ID0_640X480:
55 if ((xres < 640) && (yres < 480))
56 support_state = true;
57 break;
58
59 case LCD_PANEL_ID1_800X600:
60 if ((xres < 800) && (yres < 600))
61 support_state = true;
62 break;
63
64 case LCD_PANEL_ID2_1024X768:
65 if ((xres < 1024) && (yres < 768))
66 support_state = true;
67 break;
68
69 case LCD_PANEL_ID3_1280X768:
70 if ((xres < 1280) && (yres < 768))
71 support_state = true;
72 break;
73
74 case LCD_PANEL_ID4_1280X1024:
75 if ((xres < 1280) && (yres < 1024))
76 support_state = true;
77 break;
78
79 case LCD_PANEL_ID5_1400X1050:
80 if ((xres < 1400) && (yres < 1050))
81 support_state = true;
82 break;
83
84 case LCD_PANEL_ID6_1600X1200:
85 if ((xres < 1600) && (yres < 1200))
86 support_state = true;
87 break;
88
89 case LCD_PANEL_ID7_1366X768:
90 if ((xres < 1366) && (yres < 768))
91 support_state = true;
92 break;
93
94 case LCD_PANEL_ID8_1024X600:
95 if ((xres < 1024) && (yres < 600))
96 support_state = true;
97 break;
98
99 case LCD_PANEL_ID9_1280X800:
100 if ((xres < 1280) && (yres < 800))
101 support_state = true;
102 break;
103
104 case LCD_PANEL_IDA_800X480:
105 if ((xres < 800) && (yres < 480))
106 support_state = true;
107 break;
108
109 case LCD_PANEL_IDB_1360X768:
110 if ((xres < 1360) && (yres < 768))
111 support_state = true;
112 break;
113
114 case LCD_PANEL_IDC_480X640:
115 if ((xres < 480) && (yres < 640))
116 support_state = true;
117 break;
118
119 default:
120 support_state = false;
121 break;
122 }
123
124 return support_state;
125}
126
127/*====================================================================*/
128/* Gamma Function Implementation*/
129/*====================================================================*/
130
131void viafb_set_gamma_table(int bpp, unsigned int *gamma_table)
132{
133 int i, sr1a;
134 int active_device_amount = 0;
135 int device_status = viafb_DeviceStatus;
136
137 for (i = 0; i < sizeof(viafb_DeviceStatus) * 8; i++) {
138 if (device_status & 1)
139 active_device_amount++;
140 device_status >>= 1;
141 }
142
143 /* 8 bpp mode can't adjust gamma */
144 if (bpp == 8)
145 return ;
146
147 /* Enable Gamma */
148 switch (viaparinfo->chip_info->gfx_chip_name) {
149 case UNICHROME_CLE266:
150 case UNICHROME_K400:
151 viafb_write_reg_mask(SR16, VIASR, 0x80, BIT7);
152 break;
153
154 case UNICHROME_K800:
155 case UNICHROME_PM800:
156 case UNICHROME_CN700:
157 case UNICHROME_CX700:
158 case UNICHROME_K8M890:
159 case UNICHROME_P4M890:
160 case UNICHROME_P4M900:
161 viafb_write_reg_mask(CR33, VIACR, 0x80, BIT7);
162 break;
163 }
164 sr1a = (unsigned int)viafb_read_reg(VIASR, SR1A);
165 viafb_write_reg_mask(SR1A, VIASR, 0x0, BIT0);
166
167 /* Fill IGA1 Gamma Table */
168 outb(0, LUT_INDEX_WRITE);
169 for (i = 0; i < 256; i++) {
170 outb(gamma_table[i] >> 16, LUT_DATA);
171 outb(gamma_table[i] >> 8 & 0xFF, LUT_DATA);
172 outb(gamma_table[i] & 0xFF, LUT_DATA);
173 }
174
175 /* If adjust Gamma value in SAMM, fill IGA1,
176 IGA2 Gamma table simultanous. */
177 /* Switch to IGA2 Gamma Table */
178 if ((active_device_amount > 1) &&
179 !((viaparinfo->chip_info->gfx_chip_name ==
180 UNICHROME_CLE266) &&
181 (viaparinfo->chip_info->gfx_chip_revision < 15))) {
182 viafb_write_reg_mask(SR1A, VIASR, 0x01, BIT0);
183 viafb_write_reg_mask(CR6A, VIACR, 0x02, BIT1);
184
185 /* Fill IGA2 Gamma Table */
186 outb(0, LUT_INDEX_WRITE);
187 for (i = 0; i < 256; i++) {
188 outb(gamma_table[i] >> 16, LUT_DATA);
189 outb(gamma_table[i] >> 8 & 0xFF, LUT_DATA);
190 outb(gamma_table[i] & 0xFF, LUT_DATA);
191 }
192 }
193 viafb_write_reg(SR1A, VIASR, sr1a);
194}
195
196void viafb_get_gamma_table(unsigned int *gamma_table)
197{
198 unsigned char color_r, color_g, color_b;
199 unsigned char sr1a = 0;
200 int i;
201
202 /* Enable Gamma */
203 switch (viaparinfo->chip_info->gfx_chip_name) {
204 case UNICHROME_CLE266:
205 case UNICHROME_K400:
206 viafb_write_reg_mask(SR16, VIASR, 0x80, BIT7);
207 break;
208
209 case UNICHROME_K800:
210 case UNICHROME_PM800:
211 case UNICHROME_CN700:
212 case UNICHROME_CX700:
213 case UNICHROME_K8M890:
214 case UNICHROME_P4M890:
215 case UNICHROME_P4M900:
216 viafb_write_reg_mask(CR33, VIACR, 0x80, BIT7);
217 break;
218 }
219 sr1a = viafb_read_reg(VIASR, SR1A);
220 viafb_write_reg_mask(SR1A, VIASR, 0x0, BIT0);
221
222 /* Reading gamma table to get color value */
223 outb(0, LUT_INDEX_READ);
224 for (i = 0; i < 256; i++) {
225 color_r = inb(LUT_DATA);
226 color_g = inb(LUT_DATA);
227 color_b = inb(LUT_DATA);
228 gamma_table[i] =
229 ((((u32) color_r) << 16) |
230 (((u16) color_g) << 8)) | color_b;
231 }
232 viafb_write_reg(SR1A, VIASR, sr1a);
233}
234
235void viafb_get_gamma_support_state(int bpp, unsigned int *support_state)
236{
237 if (bpp == 8)
238 *support_state = None_Device;
239 else
240 *support_state = CRT_Device | DVI_Device | LCD_Device;
241}
242
243int viafb_input_parameter_converter(int parameter_value)
244{
245 int result;
246
247 if (parameter_value >= 1 && parameter_value <= 9)
248 result = 1 << (parameter_value - 1);
249 else
250 result = 1;
251
252 return result;
253}
diff --git a/drivers/video/via/via_utility.h b/drivers/video/via/via_utility.h
new file mode 100644
index 000000000000..2fd455202ebd
--- /dev/null
+++ b/drivers/video/via/via_utility.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#ifndef __VIAUTILITY_H__
22#define __VIAUTILITY_H__
23
24/* These functions are used to get infomation about device's state */
25void viafb_get_device_support_state(u32 *support_state);
26void viafb_get_device_connect_state(u32 *connect_state);
27bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres);
28
29/* These function are used to access gamma table */
30void viafb_set_gamma_table(int bpp, unsigned int *gamma_table);
31void viafb_get_gamma_table(unsigned int *gamma_table);
32void viafb_get_gamma_support_state(int bpp, unsigned int *support_state);
33int viafb_input_parameter_converter(int parameter_value);
34
35#endif /* __VIAUTILITY_H__ */
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
new file mode 100644
index 000000000000..0132eae06f55
--- /dev/null
+++ b/drivers/video/via/viafbdev.c
@@ -0,0 +1,2571 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include <linux/module.h>
23#define _MASTER_FILE
24
25#include "global.h"
26
27static int MAX_CURS = 32;
28static struct fb_var_screeninfo default_var;
29static char *viafb_name = "Via";
30static u32 pseudo_pal[17];
31
32/* video mode */
33static char *viafb_mode = "640x480";
34static char *viafb_mode1 = "640x480";
35static int viafb_resMode = VIA_RES_640X480;
36
37/* Added for specifying active devices.*/
38char *viafb_active_dev = "";
39
40/* Added for specifying video on devices.*/
41char *viafb_video_dev = "";
42
43/*Added for specify lcd output port*/
44char *viafb_lcd_port = "";
45char *viafb_dvi_port = "";
46
47static void viafb_set_device(struct device_t active_dev);
48static int apply_device_setting(struct viafb_ioctl_setting setting_info,
49 struct fb_info *info);
50static void apply_second_mode_setting(struct fb_var_screeninfo
51 *sec_var);
52static void retrieve_device_setting(struct viafb_ioctl_setting
53 *setting_info);
54static void viafb_set_video_device(u32 video_dev_info);
55static void viafb_get_video_device(u32 *video_dev_info);
56
57/* Mode information */
58static const struct viafb_modeinfo viafb_modentry[] = {
59 {480, 640, VIA_RES_480X640, "480x640"},
60 {640, 480, VIA_RES_640X480, "640x480"},
61 {800, 480, VIA_RES_800X480, "800x480"},
62 {800, 600, VIA_RES_800X600, "800x600"},
63 {1024, 768, VIA_RES_1024X768, "1024x768"},
64 {1152, 864, VIA_RES_1152X864, "1152x864"},
65 {1280, 1024, VIA_RES_1280X1024, "1280x1024"},
66 {1600, 1200, VIA_RES_1600X1200, "1600x1200"},
67 {1440, 1050, VIA_RES_1440X1050, "1440x1050"},
68 {1280, 768, VIA_RES_1280X768, "1280x768"},
69 {1280, 800, VIA_RES_1280X800, "1280x800"},
70 {1280, 960, VIA_RES_1280X960, "1280x960"},
71 {1920, 1440, VIA_RES_1920X1440, "1920x1440"},
72 {848, 480, VIA_RES_848X480, "848x480"},
73 {1400, 1050, VIA_RES_1400X1050, "1400x1050"},
74 {720, 480, VIA_RES_720X480, "720x480"},
75 {720, 576, VIA_RES_720X576, "720x576"},
76 {1024, 512, VIA_RES_1024X512, "1024x512"},
77 {1024, 576, VIA_RES_1024X576, "1024x576"},
78 {1024, 600, VIA_RES_1024X600, "1024x600"},
79 {1280, 720, VIA_RES_1280X720, "1280x720"},
80 {1920, 1080, VIA_RES_1920X1080, "1920x1080"},
81 {1366, 768, VIA_RES_1368X768, "1368x768"},
82 {1680, 1050, VIA_RES_1680X1050, "1680x1050"},
83 {960, 600, VIA_RES_960X600, "960x600"},
84 {1000, 600, VIA_RES_1000X600, "1000x600"},
85 {1024, 576, VIA_RES_1024X576, "1024x576"},
86 {1024, 600, VIA_RES_1024X600, "1024x600"},
87 {1088, 612, VIA_RES_1088X612, "1088x612"},
88 {1152, 720, VIA_RES_1152X720, "1152x720"},
89 {1200, 720, VIA_RES_1200X720, "1200x720"},
90 {1280, 600, VIA_RES_1280X600, "1280x600"},
91 {1360, 768, VIA_RES_1360X768, "1360x768"},
92 {1440, 900, VIA_RES_1440X900, "1440x900"},
93 {1600, 900, VIA_RES_1600X900, "1600x900"},
94 {1600, 1024, VIA_RES_1600X1024, "1600x1024"},
95 {1792, 1344, VIA_RES_1792X1344, "1792x1344"},
96 {1856, 1392, VIA_RES_1856X1392, "1856x1392"},
97 {1920, 1200, VIA_RES_1920X1200, "1920x1200"},
98 {2048, 1536, VIA_RES_2048X1536, "2048x1536"},
99 {0, 0, VIA_RES_INVALID, "640x480"}
100};
101
102static struct fb_ops viafb_ops;
103
104static int viafb_update_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
105{
106 struct viafb_par *ppar;
107 ppar = info->par;
108
109 DEBUG_MSG(KERN_INFO "viafb_update_fix!\n");
110
111 fix->visual =
112 ppar->bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
113 fix->line_length = ppar->linelength;
114
115 return 0;
116}
117
118
119static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
120 struct viafb_par *viaparinfo)
121{
122 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
123 strcpy(fix->id, viafb_name);
124
125 fix->smem_start = viaparinfo->fbmem;
126 fix->smem_len = viaparinfo->fbmem_free;
127 fix->mmio_start = viaparinfo->mmio_base;
128 fix->mmio_len = viaparinfo->mmio_len;
129
130 fix->type = FB_TYPE_PACKED_PIXELS;
131 fix->type_aux = 0;
132
133 fix->xpanstep = fix->ywrapstep = 0;
134 fix->ypanstep = 1;
135
136 /* Just tell the accel name */
137 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
138}
139static int viafb_open(struct fb_info *info, int user)
140{
141 DEBUG_MSG(KERN_INFO "viafb_open!\n");
142 return 0;
143}
144
145static int viafb_release(struct fb_info *info, int user)
146{
147 DEBUG_MSG(KERN_INFO "viafb_release!\n");
148 return 0;
149}
150
151static void viafb_update_viafb_par(struct fb_info *info)
152{
153 struct viafb_par *ppar;
154
155 ppar = info->par;
156 ppar->bpp = info->var.bits_per_pixel;
157 ppar->linelength = ((info->var.xres_virtual + 7) & ~7) * ppar->bpp / 8;
158 ppar->hres = info->var.xres;
159 ppar->vres = info->var.yres;
160 ppar->xoffset = info->var.xoffset;
161 ppar->yoffset = info->var.yoffset;
162}
163
164static int viafb_check_var(struct fb_var_screeninfo *var,
165 struct fb_info *info)
166{
167 int vmode_index, htotal, vtotal;
168 struct viafb_par *ppar;
169 u32 long_refresh;
170 struct viafb_par *p_viafb_par;
171 ppar = info->par;
172
173
174 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
175 /* Sanity check */
176 /* HW neither support interlacte nor double-scaned mode */
177 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
178 return -EINVAL;
179
180 vmode_index = viafb_get_mode_index(var->xres, var->yres, 0);
181 if (vmode_index == VIA_RES_INVALID) {
182 DEBUG_MSG(KERN_INFO
183 "viafb: Mode %dx%dx%d not supported!!\n",
184 var->xres, var->yres, var->bits_per_pixel);
185 return -EINVAL;
186 }
187
188 if (24 == var->bits_per_pixel)
189 var->bits_per_pixel = 32;
190
191 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 &&
192 var->bits_per_pixel != 32)
193 return -EINVAL;
194
195 if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F)
196 /*32 pixel alignment */
197 var->xres_virtual = (var->xres_virtual + 31) & ~31;
198 if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
199 ppar->memsize)
200 return -EINVAL;
201
202 /* Based on var passed in to calculate the refresh,
203 * because our driver use some modes special.
204 */
205 htotal = var->xres + var->left_margin +
206 var->right_margin + var->hsync_len;
207 vtotal = var->yres + var->upper_margin +
208 var->lower_margin + var->vsync_len;
209 long_refresh = 1000000000UL / var->pixclock * 1000;
210 long_refresh /= (htotal * vtotal);
211
212 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
213
214 /* Adjust var according to our driver's own table */
215 viafb_fill_var_timing_info(var, viafb_refresh, vmode_index);
216
217 /* This is indeed a patch for VT3353 */
218 if (!info->par)
219 return -1;
220 p_viafb_par = (struct viafb_par *)info->par;
221 if (p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX800)
222 var->accel_flags = 0;
223
224 return 0;
225}
226
227static int viafb_set_par(struct fb_info *info)
228{
229 int vmode_index;
230 int vmode_index1 = 0;
231 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
232
233 viafb_update_device_setting(info->var.xres, info->var.yres,
234 info->var.bits_per_pixel, viafb_refresh, 0);
235
236 vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres, 0);
237
238 if (viafb_SAMM_ON == 1) {
239 DEBUG_MSG(KERN_INFO
240 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
241 viafb_second_xres, viafb_second_yres, viafb_bpp1);
242 vmode_index1 = viafb_get_mode_index(viafb_second_xres,
243 viafb_second_yres, 1);
244 DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n",
245 vmode_index1);
246
247 viafb_update_device_setting(viafb_second_xres,
248 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
249 }
250
251 if (vmode_index != VIA_RES_INVALID) {
252 viafb_setmode(vmode_index, info->var.xres, info->var.yres,
253 info->var.bits_per_pixel, vmode_index1,
254 viafb_second_xres, viafb_second_yres, viafb_bpp1);
255
256 /*We should set memory offset according virtual_x */
257 /*Fix me:put this function into viafb_setmode */
258 viafb_memory_pitch_patch(info);
259
260 /* Update ***fb_par information */
261 viafb_update_viafb_par(info);
262
263 /* Update other fixed information */
264 viafb_update_fix(&info->fix, info);
265 viafb_bpp = info->var.bits_per_pixel;
266 /* Update viafb_accel, it is necessary to our 2D accelerate */
267 viafb_accel = info->var.accel_flags;
268
269 if (viafb_accel)
270 viafb_set_2d_color_depth(info->var.bits_per_pixel);
271 }
272
273 return 0;
274}
275
276/* Set one color register */
277static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
278unsigned blue, unsigned transp, struct fb_info *info)
279{
280 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
281 unsigned cmap_entries = (info->var.bits_per_pixel == 8) ? 256 : 16;
282 DEBUG_MSG(KERN_INFO "viafb_setcolreg!\n");
283 if (regno >= cmap_entries)
284 return 1;
285 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
286 /*
287 * Read PCI bus 0,dev 0,function 0,index 0xF6 to get chip rev.
288 */
289 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
290 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
291 }
292 switch (info->var.bits_per_pixel) {
293 case 8:
294 outb(0x1A, 0x3C4);
295 sr1a = inb(0x3C5);
296 outb(0x1B, 0x3C4);
297 sr1b = inb(0x3C5);
298 outb(0x67, 0x3D4);
299 cr67 = inb(0x3D5);
300 outb(0x6A, 0x3D4);
301 cr6a = inb(0x3D5);
302
303 /* Map the 3C6/7/8/9 to the IGA2 */
304 outb(0x1A, 0x3C4);
305 outb(sr1a | 0x01, 0x3C5);
306 /* Second Display Engine colck always on */
307 outb(0x1B, 0x3C4);
308 outb(sr1b | 0x80, 0x3C5);
309 /* Second Display Color Depth 8 */
310 outb(0x67, 0x3D4);
311 outb(cr67 & 0x3F, 0x3D5);
312 outb(0x6A, 0x3D4);
313 /* Second Display Channel Reset CR6A[6]) */
314 outb(cr6a & 0xBF, 0x3D5);
315 /* Second Display Channel Enable CR6A[7] */
316 outb(cr6a | 0x80, 0x3D5);
317 /* Second Display Channel stop reset) */
318 outb(cr6a | 0x40, 0x3D5);
319
320 /* Bit mask of palette */
321 outb(0xFF, 0x3c6);
322 /* Write one register of IGA2 */
323 outb(regno, 0x3C8);
324 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
325 rev >= 15) {
326 shift = 8;
327 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
328 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
329 } else {
330 shift = 10;
331 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
332 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
333 }
334 outb(red >> shift, 0x3C9);
335 outb(green >> shift, 0x3C9);
336 outb(blue >> shift, 0x3C9);
337
338 /* Map the 3C6/7/8/9 to the IGA1 */
339 outb(0x1A, 0x3C4);
340 outb(sr1a & 0xFE, 0x3C5);
341 /* Bit mask of palette */
342 outb(0xFF, 0x3c6);
343 /* Write one register of IGA1 */
344 outb(regno, 0x3C8);
345 outb(red >> shift, 0x3C9);
346 outb(green >> shift, 0x3C9);
347 outb(blue >> shift, 0x3C9);
348
349 outb(0x1A, 0x3C4);
350 outb(sr1a, 0x3C5);
351 outb(0x1B, 0x3C4);
352 outb(sr1b, 0x3C5);
353 outb(0x67, 0x3D4);
354 outb(cr67, 0x3D5);
355 outb(0x6A, 0x3D4);
356 outb(cr6a, 0x3D5);
357 break;
358 case 16:
359 ((u32 *) info->pseudo_palette)[regno] = (red & 0xF800) |
360 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
361 break;
362 case 32:
363 ((u32 *) info->pseudo_palette)[regno] =
364 ((transp & 0xFF00) << 16) |
365 ((red & 0xFF00) << 8) |
366 ((green & 0xFF00)) | ((blue & 0xFF00) >> 8);
367 break;
368 }
369
370 return 0;
371
372}
373
374/*CALLED BY: fb_set_cmap */
375/* fb_set_var, pass 256 colors */
376/*CALLED BY: fb_set_cmap */
377/* fbcon_set_palette, pass 16 colors */
378static int viafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
379{
380 u32 len = cmap->len;
381 u32 i;
382 u16 *pred = cmap->red;
383 u16 *pgreen = cmap->green;
384 u16 *pblue = cmap->blue;
385 u16 *ptransp = cmap->transp;
386 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
387 if (len > 256)
388 return 1;
389 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
390 /*
391 * Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip
392 * rev.
393 */
394 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
395 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
396 }
397 switch (info->var.bits_per_pixel) {
398 case 8:
399 outb(0x1A, 0x3C4);
400 sr1a = inb(0x3C5);
401 outb(0x1B, 0x3C4);
402 sr1b = inb(0x3C5);
403 outb(0x67, 0x3D4);
404 cr67 = inb(0x3D5);
405 outb(0x6A, 0x3D4);
406 cr6a = inb(0x3D5);
407 /* Map the 3C6/7/8/9 to the IGA2 */
408 outb(0x1A, 0x3C4);
409 outb(sr1a | 0x01, 0x3C5);
410 outb(0x1B, 0x3C4);
411 /* Second Display Engine colck always on */
412 outb(sr1b | 0x80, 0x3C5);
413 outb(0x67, 0x3D4);
414 /* Second Display Color Depth 8 */
415 outb(cr67 & 0x3F, 0x3D5);
416 outb(0x6A, 0x3D4);
417 /* Second Display Channel Reset CR6A[6]) */
418 outb(cr6a & 0xBF, 0x3D5);
419 /* Second Display Channel Enable CR6A[7] */
420 outb(cr6a | 0x80, 0x3D5);
421 /* Second Display Channel stop reset) */
422 outb(cr6a | 0xC0, 0x3D5);
423
424 /* Bit mask of palette */
425 outb(0xFF, 0x3c6);
426 outb(0x00, 0x3C8);
427 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
428 rev >= 15) {
429 shift = 8;
430 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
431 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
432 } else {
433 shift = 10;
434 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
435 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
436 }
437 for (i = 0; i < len; i++) {
438 outb((*(pred + i)) >> shift, 0x3C9);
439 outb((*(pgreen + i)) >> shift, 0x3C9);
440 outb((*(pblue + i)) >> shift, 0x3C9);
441 }
442
443 outb(0x1A, 0x3C4);
444 /* Map the 3C6/7/8/9 to the IGA1 */
445 outb(sr1a & 0xFE, 0x3C5);
446 /* Bit mask of palette */
447 outb(0xFF, 0x3c6);
448 outb(0x00, 0x3C8);
449 for (i = 0; i < len; i++) {
450 outb((*(pred + i)) >> shift, 0x3C9);
451 outb((*(pgreen + i)) >> shift, 0x3C9);
452 outb((*(pblue + i)) >> shift, 0x3C9);
453 }
454
455 outb(0x1A, 0x3C4);
456 outb(sr1a, 0x3C5);
457 outb(0x1B, 0x3C4);
458 outb(sr1b, 0x3C5);
459 outb(0x67, 0x3D4);
460 outb(cr67, 0x3D5);
461 outb(0x6A, 0x3D4);
462 outb(cr6a, 0x3D5);
463 break;
464 case 16:
465 if (len > 17)
466 return 0; /* Because static u32 pseudo_pal[17]; */
467 for (i = 0; i < len; i++)
468 ((u32 *) info->pseudo_palette)[i] =
469 (*(pred + i) & 0xF800) |
470 ((*(pgreen + i) & 0xFC00) >> 5) |
471 ((*(pblue + i) & 0xF800) >> 11);
472 break;
473 case 32:
474 if (len > 17)
475 return 0;
476 if (ptransp) {
477 for (i = 0; i < len; i++)
478 ((u32 *) info->pseudo_palette)[i] =
479 ((*(ptransp + i) & 0xFF00) << 16) |
480 ((*(pred + i) & 0xFF00) << 8) |
481 ((*(pgreen + i) & 0xFF00)) |
482 ((*(pblue + i) & 0xFF00) >> 8);
483 } else {
484 for (i = 0; i < len; i++)
485 ((u32 *) info->pseudo_palette)[i] =
486 0x00000000 |
487 ((*(pred + i) & 0xFF00) << 8) |
488 ((*(pgreen + i) & 0xFF00)) |
489 ((*(pblue + i) & 0xFF00) >> 8);
490 }
491 break;
492 }
493 return 0;
494}
495
496static int viafb_pan_display(struct fb_var_screeninfo *var,
497 struct fb_info *info)
498{
499 unsigned int offset;
500
501 DEBUG_MSG(KERN_INFO "viafb_pan_display!\n");
502
503 offset = (var->xoffset + (var->yoffset * var->xres_virtual)) *
504 var->bits_per_pixel / 16;
505
506 DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset);
507
508 viafb_write_reg_mask(0x48, 0x3d4, ((offset >> 24) & 0x3), 0x3);
509 viafb_write_reg_mask(0x34, 0x3d4, ((offset >> 16) & 0xff), 0xff);
510 viafb_write_reg_mask(0x0c, 0x3d4, ((offset >> 8) & 0xff), 0xff);
511 viafb_write_reg_mask(0x0d, 0x3d4, (offset & 0xff), 0xff);
512
513 return 0;
514}
515
516static int viafb_blank(int blank_mode, struct fb_info *info)
517{
518 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
519 /* clear DPMS setting */
520
521 switch (blank_mode) {
522 case FB_BLANK_UNBLANK:
523 /* Screen: On, HSync: On, VSync: On */
524 /* control CRT monitor power management */
525 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
526 break;
527 case FB_BLANK_HSYNC_SUSPEND:
528 /* Screen: Off, HSync: Off, VSync: On */
529 /* control CRT monitor power management */
530 viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);
531 break;
532 case FB_BLANK_VSYNC_SUSPEND:
533 /* Screen: Off, HSync: On, VSync: Off */
534 /* control CRT monitor power management */
535 viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);
536 break;
537 case FB_BLANK_POWERDOWN:
538 /* Screen: Off, HSync: Off, VSync: Off */
539 /* control CRT monitor power management */
540 viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);
541 break;
542 }
543
544 return 0;
545}
546
547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
548{
549 struct viafb_ioctl_mode viamode;
550 struct viafb_ioctl_samm viasamm;
551 struct viafb_driver_version driver_version;
552 struct fb_var_screeninfo sec_var;
553 struct _panel_size_pos_info panel_pos_size_para;
554 u32 state_info = 0;
555 u32 viainfo_size = sizeof(struct viafb_ioctl_info);
556 u32 *viafb_gamma_table;
557 char driver_name[] = "viafb";
558
559 u32 __user *argp = (u32 __user *) arg;
560 u32 gpu32;
561 u32 video_dev_info = 0;
562 struct viafb_ioctl_setting viafb_setting = {};
563 struct device_t active_dev = {};
564
565 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
566
567 switch (cmd) {
568 case VIAFB_GET_CHIP_INFO:
569 if (copy_to_user(argp, viaparinfo->chip_info,
570 sizeof(struct chip_information)))
571 return -EFAULT;
572 break;
573 case VIAFB_GET_INFO_SIZE:
574 return put_user(viainfo_size, argp);
575 case VIAFB_GET_INFO:
576 return viafb_ioctl_get_viafb_info(arg);
577 case VIAFB_HOTPLUG:
578 return put_user(viafb_ioctl_hotplug(info->var.xres,
579 info->var.yres,
580 info->var.bits_per_pixel), argp);
581 case VIAFB_SET_HOTPLUG_FLAG:
582 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
583 return -EFAULT;
584 viafb_hotplug = (gpu32) ? 1 : 0;
585 break;
586 case VIAFB_GET_RESOLUTION:
587 viamode.xres = (u32) viafb_hotplug_Xres;
588 viamode.yres = (u32) viafb_hotplug_Yres;
589 viamode.refresh = (u32) viafb_hotplug_refresh;
590 viamode.bpp = (u32) viafb_hotplug_bpp;
591 if (viafb_SAMM_ON == 1) {
592 viamode.xres_sec = viafb_second_xres;
593 viamode.yres_sec = viafb_second_yres;
594 viamode.virtual_xres_sec = viafb_second_virtual_xres;
595 viamode.virtual_yres_sec = viafb_second_virtual_yres;
596 viamode.refresh_sec = viafb_refresh1;
597 viamode.bpp_sec = viafb_bpp1;
598 } else {
599 viamode.xres_sec = 0;
600 viamode.yres_sec = 0;
601 viamode.virtual_xres_sec = 0;
602 viamode.virtual_yres_sec = 0;
603 viamode.refresh_sec = 0;
604 viamode.bpp_sec = 0;
605 }
606 if (copy_to_user(argp, &viamode, sizeof(viamode)))
607 return -EFAULT;
608 break;
609 case VIAFB_GET_SAMM_INFO:
610 viasamm.samm_status = viafb_SAMM_ON;
611
612 if (viafb_SAMM_ON == 1) {
613 if (viafb_dual_fb) {
614 viasamm.size_prim = viaparinfo->fbmem_free;
615 viasamm.size_sec = viaparinfo1->fbmem_free;
616 } else {
617 if (viafb_second_size) {
618 viasamm.size_prim =
619 viaparinfo->fbmem_free -
620 viafb_second_size * 1024 * 1024;
621 viasamm.size_sec =
622 viafb_second_size * 1024 * 1024;
623 } else {
624 viasamm.size_prim =
625 viaparinfo->fbmem_free >> 1;
626 viasamm.size_sec =
627 (viaparinfo->fbmem_free >> 1);
628 }
629 }
630 viasamm.mem_base = viaparinfo->fbmem;
631 viasamm.offset_sec = viafb_second_offset;
632 } else {
633 viasamm.size_prim =
634 viaparinfo->memsize - viaparinfo->fbmem_used;
635 viasamm.size_sec = 0;
636 viasamm.mem_base = viaparinfo->fbmem;
637 viasamm.offset_sec = 0;
638 }
639
640 if (copy_to_user(argp, &viasamm, sizeof(viasamm)))
641 return -EFAULT;
642
643 break;
644 case VIAFB_TURN_ON_OUTPUT_DEVICE:
645 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
646 return -EFAULT;
647 if (gpu32 & CRT_Device)
648 viafb_crt_enable();
649 if (gpu32 & DVI_Device)
650 viafb_dvi_enable();
651 if (gpu32 & LCD_Device)
652 viafb_lcd_enable();
653 break;
654 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
655 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
656 return -EFAULT;
657 if (gpu32 & CRT_Device)
658 viafb_crt_disable();
659 if (gpu32 & DVI_Device)
660 viafb_dvi_disable();
661 if (gpu32 & LCD_Device)
662 viafb_lcd_disable();
663 break;
664 case VIAFB_SET_DEVICE:
665 if (copy_from_user(&active_dev, (void *)argp,
666 sizeof(active_dev)))
667 return -EFAULT;
668 viafb_set_device(active_dev);
669 viafb_set_par(info);
670 break;
671 case VIAFB_GET_DEVICE:
672 active_dev.crt = viafb_CRT_ON;
673 active_dev.dvi = viafb_DVI_ON;
674 active_dev.lcd = viafb_LCD_ON;
675 active_dev.samm = viafb_SAMM_ON;
676 active_dev.primary_dev = viafb_primary_dev;
677
678 active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
679 active_dev.lcd_panel_id = viafb_lcd_panel_id;
680 active_dev.lcd_mode = viafb_lcd_mode;
681
682 active_dev.xres = viafb_hotplug_Xres;
683 active_dev.yres = viafb_hotplug_Yres;
684
685 active_dev.xres1 = viafb_second_xres;
686 active_dev.yres1 = viafb_second_yres;
687
688 active_dev.bpp = viafb_bpp;
689 active_dev.bpp1 = viafb_bpp1;
690 active_dev.refresh = viafb_refresh;
691 active_dev.refresh1 = viafb_refresh1;
692
693 active_dev.epia_dvi = viafb_platform_epia_dvi;
694 active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
695 active_dev.bus_width = viafb_bus_width;
696
697 if (copy_to_user(argp, &active_dev, sizeof(active_dev)))
698 return -EFAULT;
699 break;
700
701 case VIAFB_GET_DRIVER_VERSION:
702 driver_version.iMajorNum = VERSION_MAJOR;
703 driver_version.iKernelNum = VERSION_KERNEL;
704 driver_version.iOSNum = VERSION_OS;
705 driver_version.iMinorNum = VERSION_MINOR;
706
707 if (copy_to_user(argp, &driver_version,
708 sizeof(driver_version)))
709 return -EFAULT;
710
711 break;
712
713 case VIAFB_SET_DEVICE_INFO:
714 if (copy_from_user(&viafb_setting,
715 argp, sizeof(viafb_setting)))
716 return -EFAULT;
717 if (apply_device_setting(viafb_setting, info) < 0)
718 return -EINVAL;
719
720 break;
721
722 case VIAFB_SET_SECOND_MODE:
723 if (copy_from_user(&sec_var, argp, sizeof(sec_var)))
724 return -EFAULT;
725 apply_second_mode_setting(&sec_var);
726 break;
727
728 case VIAFB_GET_DEVICE_INFO:
729
730 retrieve_device_setting(&viafb_setting);
731
732 if (copy_to_user(argp, &viafb_setting, sizeof(viafb_setting)))
733 return -EFAULT;
734
735 break;
736
737 case VIAFB_GET_DEVICE_SUPPORT:
738 viafb_get_device_support_state(&state_info);
739 if (put_user(state_info, argp))
740 return -EFAULT;
741 break;
742
743 case VIAFB_GET_DEVICE_CONNECT:
744 viafb_get_device_connect_state(&state_info);
745 if (put_user(state_info, argp))
746 return -EFAULT;
747 break;
748
749 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
750 state_info =
751 viafb_lcd_get_support_expand_state(info->var.xres,
752 info->var.yres);
753 if (put_user(state_info, argp))
754 return -EFAULT;
755 break;
756
757 case VIAFB_GET_DRIVER_NAME:
758 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
759 return -EFAULT;
760 break;
761
762 case VIAFB_SET_GAMMA_LUT:
763 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
764 if (!viafb_gamma_table)
765 return -ENOMEM;
766 if (copy_from_user(viafb_gamma_table, argp,
767 sizeof(viafb_gamma_table))) {
768 kfree(viafb_gamma_table);
769 return -EFAULT;
770 }
771 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
772 kfree(viafb_gamma_table);
773 break;
774
775 case VIAFB_GET_GAMMA_LUT:
776 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
777 if (!viafb_gamma_table)
778 return -ENOMEM;
779 viafb_get_gamma_table(viafb_gamma_table);
780 if (copy_to_user(argp, viafb_gamma_table,
781 sizeof(viafb_gamma_table))) {
782 kfree(viafb_gamma_table);
783 return -EFAULT;
784 }
785 kfree(viafb_gamma_table);
786 break;
787
788 case VIAFB_GET_GAMMA_SUPPORT_STATE:
789 viafb_get_gamma_support_state(viafb_bpp, &state_info);
790 if (put_user(state_info, argp))
791 return -EFAULT;
792 break;
793 case VIAFB_SET_VIDEO_DEVICE:
794 get_user(video_dev_info, argp);
795 viafb_set_video_device(video_dev_info);
796 break;
797 case VIAFB_GET_VIDEO_DEVICE:
798 viafb_get_video_device(&video_dev_info);
799 if (put_user(video_dev_info, argp))
800 return -EFAULT;
801 break;
802 case VIAFB_SYNC_SURFACE:
803 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
804 break;
805 case VIAFB_GET_DRIVER_CAPS:
806 break;
807
808 case VIAFB_GET_PANEL_MAX_SIZE:
809 if (copy_from_user
810 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))
811 return -EFAULT;
812 panel_pos_size_para.x = panel_pos_size_para.y = 0;
813 if (copy_to_user(argp, &panel_pos_size_para,
814 sizeof(panel_pos_size_para)))
815 return -EFAULT;
816 break;
817 case VIAFB_GET_PANEL_MAX_POSITION:
818 if (copy_from_user
819 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))
820 return -EFAULT;
821 panel_pos_size_para.x = panel_pos_size_para.y = 0;
822 if (copy_to_user(argp, &panel_pos_size_para,
823 sizeof(panel_pos_size_para)))
824 return -EFAULT;
825 break;
826
827 case VIAFB_GET_PANEL_POSITION:
828 if (copy_from_user
829 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))
830 return -EFAULT;
831 panel_pos_size_para.x = panel_pos_size_para.y = 0;
832 if (copy_to_user(argp, &panel_pos_size_para,
833 sizeof(panel_pos_size_para)))
834 return -EFAULT;
835 break;
836 case VIAFB_GET_PANEL_SIZE:
837 if (copy_from_user
838 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))
839 return -EFAULT;
840 panel_pos_size_para.x = panel_pos_size_para.y = 0;
841 if (copy_to_user(argp, &panel_pos_size_para,
842 sizeof(panel_pos_size_para)))
843 return -EFAULT;
844 break;
845
846 case VIAFB_SET_PANEL_POSITION:
847 if (copy_from_user
848 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))
849 return -EFAULT;
850 break;
851 case VIAFB_SET_PANEL_SIZE:
852 if (copy_from_user
853 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))
854 return -EFAULT;
855 break;
856
857 default:
858 return -EINVAL;
859 }
860
861 return 0;
862}
863
864static void viafb_fillrect(struct fb_info *info,
865 const struct fb_fillrect *rect)
866{
867 u32 col = 0, rop = 0;
868 int pitch;
869
870 if (!viafb_accel)
871 return cfb_fillrect(info, rect);
872
873 if (!rect->width || !rect->height)
874 return;
875
876 switch (rect->rop) {
877 case ROP_XOR:
878 rop = 0x5A;
879 break;
880 case ROP_COPY:
881 default:
882 rop = 0xF0;
883 break;
884 }
885
886 switch (info->var.bits_per_pixel) {
887 case 8:
888 col = rect->color;
889 break;
890 case 16:
891 col = ((u32 *) (info->pseudo_palette))[rect->color];
892 break;
893 case 32:
894 col = ((u32 *) (info->pseudo_palette))[rect->color];
895 break;
896 }
897
898 /* BitBlt Source Address */
899 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
900 /* Source Base Address */
901 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
902 /* Destination Base Address */
903 writel(((unsigned long) (info->screen_base) -
904 (unsigned long) viafb_FB_MM) >> 3,
905 viaparinfo->io_virt + VIA_REG_DSTBASE);
906 /* Pitch */
907 pitch = (info->var.xres_virtual + 7) & ~7;
908 writel(VIA_PITCH_ENABLE |
909 (((pitch *
910 info->var.bits_per_pixel >> 3) >> 3) |
911 (((pitch * info->
912 var.bits_per_pixel >> 3) >> 3) << 16)),
913 viaparinfo->io_virt + VIA_REG_PITCH);
914 /* BitBlt Destination Address */
915 writel(((rect->dy << 16) | rect->dx),
916 viaparinfo->io_virt + VIA_REG_DSTPOS);
917 /* Dimension: width & height */
918 writel((((rect->height - 1) << 16) | (rect->width - 1)),
919 viaparinfo->io_virt + VIA_REG_DIMENSION);
920 /* Forground color or Destination color */
921 writel(col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
922 /* GE Command */
923 writel((0x01 | 0x2000 | (rop << 24)),
924 viaparinfo->io_virt + VIA_REG_GECMD);
925
926}
927
928static void viafb_copyarea(struct fb_info *info,
929 const struct fb_copyarea *area)
930{
931 u32 dy = area->dy, sy = area->sy, direction = 0x0;
932 u32 sx = area->sx, dx = area->dx, width = area->width;
933 int pitch;
934
935 DEBUG_MSG(KERN_INFO "viafb_copyarea!!\n");
936
937 if (!viafb_accel)
938 return cfb_copyarea(info, area);
939
940 if (!area->width || !area->height)
941 return;
942
943 if (sy < dy) {
944 dy += area->height - 1;
945 sy += area->height - 1;
946 direction |= 0x4000;
947 }
948
949 if (sx < dx) {
950 dx += width - 1;
951 sx += width - 1;
952 direction |= 0x8000;
953 }
954
955 /* Source Base Address */
956 writel(((unsigned long) (info->screen_base) -
957 (unsigned long) viafb_FB_MM) >> 3,
958 viaparinfo->io_virt + VIA_REG_SRCBASE);
959 /* Destination Base Address */
960 writel(((unsigned long) (info->screen_base) -
961 (unsigned long) viafb_FB_MM) >> 3,
962 viaparinfo->io_virt + VIA_REG_DSTBASE);
963 /* Pitch */
964 pitch = (info->var.xres_virtual + 7) & ~7;
965 /* VIA_PITCH_ENABLE can be omitted now. */
966 writel(VIA_PITCH_ENABLE |
967 (((pitch *
968 info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
969 info->var.
970 bits_per_pixel
971 >> 3) >> 3)
972 << 16)),
973 viaparinfo->io_virt + VIA_REG_PITCH);
974 /* BitBlt Source Address */
975 writel(((sy << 16) | sx), viaparinfo->io_virt + VIA_REG_SRCPOS);
976 /* BitBlt Destination Address */
977 writel(((dy << 16) | dx), viaparinfo->io_virt + VIA_REG_DSTPOS);
978 /* Dimension: width & height */
979 writel((((area->height - 1) << 16) | (area->width - 1)),
980 viaparinfo->io_virt + VIA_REG_DIMENSION);
981 /* GE Command */
982 writel((0x01 | direction | (0xCC << 24)),
983 viaparinfo->io_virt + VIA_REG_GECMD);
984
985}
986
987static void viafb_imageblit(struct fb_info *info,
988 const struct fb_image *image)
989{
990 u32 size, bg_col = 0, fg_col = 0, *udata;
991 int i;
992 int pitch;
993
994 if (!viafb_accel)
995 return cfb_imageblit(info, image);
996
997 udata = (u32 *) image->data;
998
999 switch (info->var.bits_per_pixel) {
1000 case 8:
1001 bg_col = image->bg_color;
1002 fg_col = image->fg_color;
1003 break;
1004 case 16:
1005 bg_col = ((u32 *) (info->pseudo_palette))[image->bg_color];
1006 fg_col = ((u32 *) (info->pseudo_palette))[image->fg_color];
1007 break;
1008 case 32:
1009 bg_col = ((u32 *) (info->pseudo_palette))[image->bg_color];
1010 fg_col = ((u32 *) (info->pseudo_palette))[image->fg_color];
1011 break;
1012 }
1013 size = image->width * image->height;
1014
1015 /* Source Base Address */
1016 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
1017 /* Destination Base Address */
1018 writel(((unsigned long) (info->screen_base) -
1019 (unsigned long) viafb_FB_MM) >> 3,
1020 viaparinfo->io_virt + VIA_REG_DSTBASE);
1021 /* Pitch */
1022 pitch = (info->var.xres_virtual + 7) & ~7;
1023 writel(VIA_PITCH_ENABLE |
1024 (((pitch *
1025 info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
1026 info->var.
1027 bits_per_pixel
1028 >> 3) >> 3)
1029 << 16)),
1030 viaparinfo->io_virt + VIA_REG_PITCH);
1031 /* BitBlt Source Address */
1032 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
1033 /* BitBlt Destination Address */
1034 writel(((image->dy << 16) | image->dx),
1035 viaparinfo->io_virt + VIA_REG_DSTPOS);
1036 /* Dimension: width & height */
1037 writel((((image->height - 1) << 16) | (image->width - 1)),
1038 viaparinfo->io_virt + VIA_REG_DIMENSION);
1039 /* fb color */
1040 writel(fg_col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
1041 /* bg color */
1042 writel(bg_col, viaparinfo->io_virt + VIA_REG_BGCOLOR);
1043 /* GE Command */
1044 writel(0xCC020142, viaparinfo->io_virt + VIA_REG_GECMD);
1045
1046 for (i = 0; i < size / 4; i++) {
1047 writel(*udata, viaparinfo->io_virt + VIA_MMIO_BLTBASE);
1048 udata++;
1049 }
1050
1051}
1052
1053static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1054{
1055 u8 data[CURSOR_SIZE / 8];
1056 u32 data_bak[CURSOR_SIZE / 32];
1057 u32 temp, xx, yy, bg_col = 0, fg_col = 0;
1058 int size, i, j = 0;
1059 static int hw_cursor;
1060 struct viafb_par *p_viafb_par;
1061
1062 if (viafb_accel)
1063 hw_cursor = 1;
1064
1065 if (!viafb_accel) {
1066 if (hw_cursor) {
1067 viafb_show_hw_cursor(info, HW_Cursor_OFF);
1068 hw_cursor = 0;
1069 }
1070 return -ENODEV;
1071 }
1072
1073 if ((((struct viafb_par *)(info->par))->iga_path == IGA2)
1074 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
1075 return -ENODEV;
1076
1077 /* When duoview and using lcd , use soft cursor */
1078 if (viafb_LCD_ON || ((struct viafb_par *)(info->par))->duoview)
1079 return -ENODEV;
1080
1081 viafb_show_hw_cursor(info, HW_Cursor_OFF);
1082 viacursor = *cursor;
1083
1084 if (cursor->set & FB_CUR_SETHOT) {
1085 viacursor.hot = cursor->hot;
1086 temp = ((viacursor.hot.x) << 16) + viacursor.hot.y;
1087 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_ORG);
1088 }
1089
1090 if (cursor->set & FB_CUR_SETPOS) {
1091 viacursor.image.dx = cursor->image.dx;
1092 viacursor.image.dy = cursor->image.dy;
1093 yy = cursor->image.dy - info->var.yoffset;
1094 xx = cursor->image.dx - info->var.xoffset;
1095 temp = yy & 0xFFFF;
1096 temp |= (xx << 16);
1097 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_POS);
1098 }
1099
1100 if (cursor->set & FB_CUR_SETSIZE) {
1101 temp = readl(viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
1102
1103 if ((cursor->image.width <= 32)
1104 && (cursor->image.height <= 32)) {
1105 MAX_CURS = 32;
1106 temp |= 0x2;
1107 } else if ((cursor->image.width <= 64)
1108 && (cursor->image.height <= 64)) {
1109 MAX_CURS = 64;
1110 temp &= 0xFFFFFFFD;
1111 } else {
1112 DEBUG_MSG(KERN_INFO
1113 "The cursor image is biger than 64x64 bits...\n");
1114 return -ENXIO;
1115 }
1116 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
1117
1118 viacursor.image.height = cursor->image.height;
1119 viacursor.image.width = cursor->image.width;
1120 }
1121
1122 if (cursor->set & FB_CUR_SETCMAP) {
1123 viacursor.image.fg_color = cursor->image.fg_color;
1124 viacursor.image.bg_color = cursor->image.bg_color;
1125
1126 switch (info->var.bits_per_pixel) {
1127 case 8:
1128 case 16:
1129 case 32:
1130 bg_col =
1131 (0xFF << 24) |
1132 (((info->cmap.red)[viacursor.image.bg_color] &
1133 0xFF00) << 8) |
1134 ((info->cmap.green)[viacursor.image.bg_color] &
1135 0xFF00) |
1136 (((info->cmap.blue)[viacursor.image.bg_color] &
1137 0xFF00) >> 8);
1138 fg_col =
1139 (0xFF << 24) |
1140 (((info->cmap.red)[viacursor.image.fg_color] &
1141 0xFF00) << 8) |
1142 ((info->cmap.green)[viacursor.image.fg_color] &
1143 0xFF00) |
1144 (((info->cmap.blue)[viacursor.image.fg_color] &
1145 0xFF00) >> 8);
1146 break;
1147 default:
1148 return 0;
1149 }
1150
1151 /* This is indeed a patch for VT3324/VT3353 */
1152 if (!info->par)
1153 return 0;
1154 p_viafb_par = (struct viafb_par *)info->par;
1155
1156 if ((p_viafb_par->chip_info->gfx_chip_name ==
1157 UNICHROME_CX700) ||
1158 ((p_viafb_par->chip_info->gfx_chip_name ==
1159 UNICHROME_VX800))) {
1160 bg_col =
1161 (((info->cmap.red)[viacursor.image.bg_color] &
1162 0xFFC0) << 14) |
1163 (((info->cmap.green)[viacursor.image.bg_color] &
1164 0xFFC0) << 4) |
1165 (((info->cmap.blue)[viacursor.image.bg_color] &
1166 0xFFC0) >> 6);
1167 fg_col =
1168 (((info->cmap.red)[viacursor.image.fg_color] &
1169 0xFFC0) << 14) |
1170 (((info->cmap.green)[viacursor.image.fg_color] &
1171 0xFFC0) << 4) |
1172 (((info->cmap.blue)[viacursor.image.fg_color] &
1173 0xFFC0) >> 6);
1174 }
1175
1176 writel(bg_col, viaparinfo->io_virt + VIA_REG_CURSOR_BG);
1177 writel(fg_col, viaparinfo->io_virt + VIA_REG_CURSOR_FG);
1178 }
1179
1180 if (cursor->set & FB_CUR_SETSHAPE) {
1181 size =
1182 ((viacursor.image.width + 7) >> 3) *
1183 viacursor.image.height;
1184
1185 if (MAX_CURS == 32) {
1186 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1187 data_bak[i] = 0x0;
1188 data_bak[i + 1] = 0xFFFFFFFF;
1189 i += 1;
1190 }
1191 } else if (MAX_CURS == 64) {
1192 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1193 data_bak[i] = 0x0;
1194 data_bak[i + 1] = 0x0;
1195 data_bak[i + 2] = 0xFFFFFFFF;
1196 data_bak[i + 3] = 0xFFFFFFFF;
1197 i += 3;
1198 }
1199 }
1200
1201 switch (viacursor.rop) {
1202 case ROP_XOR:
1203 for (i = 0; i < size; i++)
1204 data[i] = viacursor.mask[i];
1205 break;
1206 case ROP_COPY:
1207
1208 for (i = 0; i < size; i++)
1209 data[i] = viacursor.mask[i];
1210 break;
1211 default:
1212 break;
1213 }
1214
1215 if (MAX_CURS == 32) {
1216 for (i = 0; i < size; i++) {
1217 data_bak[j] = (u32) data[i];
1218 data_bak[j + 1] = ~data_bak[j];
1219 j += 2;
1220 }
1221 } else if (MAX_CURS == 64) {
1222 for (i = 0; i < size; i++) {
1223 data_bak[j] = (u32) data[i];
1224 data_bak[j + 1] = 0x0;
1225 data_bak[j + 2] = ~data_bak[j];
1226 data_bak[j + 3] = ~data_bak[j + 1];
1227 j += 4;
1228 }
1229 }
1230
1231 memcpy(((struct viafb_par *)(info->par))->fbmem_virt +
1232 ((struct viafb_par *)(info->par))->cursor_start,
1233 data_bak, CURSOR_SIZE);
1234 }
1235
1236 if (viacursor.enable)
1237 viafb_show_hw_cursor(info, HW_Cursor_ON);
1238
1239 return 0;
1240}
1241
1242static int viafb_sync(struct fb_info *info)
1243{
1244 if (viafb_accel)
1245 viafb_wait_engine_idle();
1246 return 0;
1247}
1248
1249int viafb_get_mode_index(int hres, int vres, int flag)
1250{
1251 u32 i;
1252 DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n");
1253
1254 for (i = 0; viafb_modentry[i].mode_index != VIA_RES_INVALID; i++)
1255 if (viafb_modentry[i].xres == hres &&
1256 viafb_modentry[i].yres == vres)
1257 break;
1258
1259 viafb_resMode = viafb_modentry[i].mode_index;
1260 if (flag)
1261 viafb_mode1 = viafb_modentry[i].mode_res;
1262 else
1263 viafb_mode = viafb_modentry[i].mode_res;
1264
1265 return viafb_resMode;
1266}
1267
1268static void check_available_device_to_enable(int device_id)
1269{
1270 int device_num = 0;
1271
1272 /* Initialize: */
1273 viafb_CRT_ON = STATE_OFF;
1274 viafb_DVI_ON = STATE_OFF;
1275 viafb_LCD_ON = STATE_OFF;
1276 viafb_LCD2_ON = STATE_OFF;
1277 viafb_DeviceStatus = None_Device;
1278
1279 if ((device_id & CRT_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1280 viafb_CRT_ON = STATE_ON;
1281 device_num++;
1282 viafb_DeviceStatus |= CRT_Device;
1283 }
1284
1285 if ((device_id & DVI_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1286 viafb_DVI_ON = STATE_ON;
1287 device_num++;
1288 viafb_DeviceStatus |= DVI_Device;
1289 }
1290
1291 if ((device_id & LCD_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1292 viafb_LCD_ON = STATE_ON;
1293 device_num++;
1294 viafb_DeviceStatus |= LCD_Device;
1295 }
1296
1297 if ((device_id & LCD2_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1298 viafb_LCD2_ON = STATE_ON;
1299 device_num++;
1300 viafb_DeviceStatus |= LCD2_Device;
1301 }
1302
1303 if (viafb_DeviceStatus == None_Device) {
1304 /* Use CRT as default active device: */
1305 viafb_CRT_ON = STATE_ON;
1306 viafb_DeviceStatus = CRT_Device;
1307 }
1308 DEBUG_MSG(KERN_INFO "Device Status:%x", viafb_DeviceStatus);
1309}
1310
1311static void viafb_set_device(struct device_t active_dev)
1312{
1313 /* Check available device to enable: */
1314 int device_id = None_Device;
1315 if (active_dev.crt)
1316 device_id |= CRT_Device;
1317 if (active_dev.dvi)
1318 device_id |= DVI_Device;
1319 if (active_dev.lcd)
1320 device_id |= LCD_Device;
1321
1322 check_available_device_to_enable(device_id);
1323
1324 /* Check property of LCD: */
1325 if (viafb_LCD_ON) {
1326 if (active_dev.lcd_dsp_cent) {
1327 viaparinfo->lvds_setting_info->display_method =
1328 viafb_lcd_dsp_method = LCD_CENTERING;
1329 } else {
1330 viaparinfo->lvds_setting_info->display_method =
1331 viafb_lcd_dsp_method = LCD_EXPANDSION;
1332 }
1333
1334 if (active_dev.lcd_mode == LCD_SPWG) {
1335 viaparinfo->lvds_setting_info->lcd_mode =
1336 viafb_lcd_mode = LCD_SPWG;
1337 } else {
1338 viaparinfo->lvds_setting_info->lcd_mode =
1339 viafb_lcd_mode = LCD_OPENLDI;
1340 }
1341
1342 if (active_dev.lcd_panel_id <= LCD_PANEL_ID_MAXIMUM) {
1343 viafb_lcd_panel_id = active_dev.lcd_panel_id;
1344 viafb_init_lcd_size();
1345 }
1346 }
1347
1348 /* Check property of mode: */
1349 if (!active_dev.xres1)
1350 viafb_second_xres = 640;
1351 else
1352 viafb_second_xres = active_dev.xres1;
1353 if (!active_dev.yres1)
1354 viafb_second_yres = 480;
1355 else
1356 viafb_second_yres = active_dev.yres1;
1357 if (active_dev.bpp != 0)
1358 viafb_bpp = active_dev.bpp;
1359 if (active_dev.bpp1 != 0)
1360 viafb_bpp1 = active_dev.bpp1;
1361 if (active_dev.refresh != 0)
1362 viafb_refresh = active_dev.refresh;
1363 if (active_dev.refresh1 != 0)
1364 viafb_refresh1 = active_dev.refresh1;
1365 if ((active_dev.samm == STATE_OFF) || (active_dev.samm == STATE_ON))
1366 viafb_SAMM_ON = active_dev.samm;
1367 viafb_primary_dev = active_dev.primary_dev;
1368
1369 viafb_set_start_addr();
1370 viafb_set_iga_path();
1371}
1372
1373static void viafb_set_video_device(u32 video_dev_info)
1374{
1375 viaparinfo->video_on_crt = STATE_OFF;
1376 viaparinfo->video_on_dvi = STATE_OFF;
1377 viaparinfo->video_on_lcd = STATE_OFF;
1378
1379 /* Check available device to enable: */
1380 if ((video_dev_info & CRT_Device) == CRT_Device)
1381 viaparinfo->video_on_crt = STATE_ON;
1382 else if ((video_dev_info & DVI_Device) == DVI_Device)
1383 viaparinfo->video_on_dvi = STATE_ON;
1384 else if ((video_dev_info & LCD_Device) == LCD_Device)
1385 viaparinfo->video_on_lcd = STATE_ON;
1386}
1387
1388static void viafb_get_video_device(u32 *video_dev_info)
1389{
1390 *video_dev_info = None_Device;
1391 if (viaparinfo->video_on_crt == STATE_ON)
1392 *video_dev_info |= CRT_Device;
1393 else if (viaparinfo->video_on_dvi == STATE_ON)
1394 *video_dev_info |= DVI_Device;
1395 else if (viaparinfo->video_on_lcd == STATE_ON)
1396 *video_dev_info |= LCD_Device;
1397}
1398
1399static int get_primary_device(void)
1400{
1401 int primary_device = 0;
1402 /* Rule: device on iga1 path are the primary device. */
1403 if (viafb_SAMM_ON) {
1404 if (viafb_CRT_ON) {
1405 if (viaparinfo->crt_setting_info->iga_path == IGA1) {
1406 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n",
1407 viaparinfo->
1408 crt_setting_info->iga_path);
1409 primary_device = CRT_Device;
1410 }
1411 }
1412 if (viafb_DVI_ON) {
1413 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
1414 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
1415 viaparinfo->
1416 tmds_setting_info->iga_path);
1417 primary_device = DVI_Device;
1418 }
1419 }
1420 if (viafb_LCD_ON) {
1421 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1422 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
1423 viaparinfo->
1424 lvds_setting_info->iga_path);
1425 primary_device = LCD_Device;
1426 }
1427 }
1428 if (viafb_LCD2_ON) {
1429 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
1430 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
1431 viaparinfo->
1432 lvds_setting_info2->iga_path);
1433 primary_device = LCD2_Device;
1434 }
1435 }
1436 }
1437 return primary_device;
1438}
1439
1440static u8 is_duoview(void)
1441{
1442 if (0 == viafb_SAMM_ON) {
1443 if (viafb_LCD_ON + viafb_LCD2_ON +
1444 viafb_DVI_ON + viafb_CRT_ON == 2)
1445 return true;
1446 return false;
1447 } else {
1448 return false;
1449 }
1450}
1451
1452static void apply_second_mode_setting(struct fb_var_screeninfo
1453 *sec_var)
1454{
1455 u32 htotal, vtotal, long_refresh;
1456
1457 htotal = sec_var->xres + sec_var->left_margin +
1458 sec_var->right_margin + sec_var->hsync_len;
1459 vtotal = sec_var->yres + sec_var->upper_margin +
1460 sec_var->lower_margin + sec_var->vsync_len;
1461 if ((sec_var->xres_virtual * (sec_var->bits_per_pixel >> 3)) & 0x1F) {
1462 /*Is 32 bytes alignment? */
1463 /*32 pixel alignment */
1464 sec_var->xres_virtual = (sec_var->xres_virtual + 31) & ~31;
1465 }
1466
1467 htotal = sec_var->xres + sec_var->left_margin +
1468 sec_var->right_margin + sec_var->hsync_len;
1469 vtotal = sec_var->yres + sec_var->upper_margin +
1470 sec_var->lower_margin + sec_var->vsync_len;
1471 long_refresh = 1000000000UL / sec_var->pixclock * 1000;
1472 long_refresh /= (htotal * vtotal);
1473
1474 viafb_second_xres = sec_var->xres;
1475 viafb_second_yres = sec_var->yres;
1476 viafb_second_virtual_xres = sec_var->xres_virtual;
1477 viafb_second_virtual_yres = sec_var->yres_virtual;
1478 viafb_bpp1 = sec_var->bits_per_pixel;
1479 viafb_refresh1 = viafb_get_refresh(sec_var->xres, sec_var->yres,
1480 long_refresh);
1481}
1482
1483static int apply_device_setting(struct viafb_ioctl_setting setting_info,
1484 struct fb_info *info)
1485{
1486 int need_set_mode = 0;
1487 DEBUG_MSG(KERN_INFO "apply_device_setting\n");
1488
1489 if (setting_info.device_flag) {
1490 need_set_mode = 1;
1491 check_available_device_to_enable(setting_info.device_status);
1492 }
1493
1494 /* Unlock LCD's operation according to LCD flag
1495 and check if the setting value is valid. */
1496 /* If the value is valid, apply the new setting value to the device. */
1497 if (viafb_LCD_ON) {
1498 if (setting_info.lcd_operation_flag & OP_LCD_CENTERING) {
1499 need_set_mode = 1;
1500 if (setting_info.lcd_attributes.display_center) {
1501 /* Centering */
1502 viaparinfo->lvds_setting_info->display_method =
1503 LCD_CENTERING;
1504 viafb_lcd_dsp_method = LCD_CENTERING;
1505 viaparinfo->lvds_setting_info2->display_method =
1506 viafb_lcd_dsp_method = LCD_CENTERING;
1507 } else {
1508 /* expandsion */
1509 viaparinfo->lvds_setting_info->display_method =
1510 LCD_EXPANDSION;
1511 viafb_lcd_dsp_method = LCD_EXPANDSION;
1512 viaparinfo->lvds_setting_info2->display_method =
1513 LCD_EXPANDSION;
1514 viafb_lcd_dsp_method = LCD_EXPANDSION;
1515 }
1516 }
1517
1518 if (setting_info.lcd_operation_flag & OP_LCD_MODE) {
1519 need_set_mode = 1;
1520 if (setting_info.lcd_attributes.lcd_mode ==
1521 LCD_SPWG) {
1522 viaparinfo->lvds_setting_info->lcd_mode =
1523 viafb_lcd_mode = LCD_SPWG;
1524 } else {
1525 viaparinfo->lvds_setting_info->lcd_mode =
1526 viafb_lcd_mode = LCD_OPENLDI;
1527 }
1528 viaparinfo->lvds_setting_info2->lcd_mode =
1529 viaparinfo->lvds_setting_info->lcd_mode;
1530 }
1531
1532 if (setting_info.lcd_operation_flag & OP_LCD_PANEL_ID) {
1533 need_set_mode = 1;
1534 if (setting_info.lcd_attributes.panel_id <=
1535 LCD_PANEL_ID_MAXIMUM) {
1536 viafb_lcd_panel_id =
1537 setting_info.lcd_attributes.panel_id;
1538 viafb_init_lcd_size();
1539 }
1540 }
1541 }
1542
1543 if (0 != (setting_info.samm_status & OP_SAMM)) {
1544 setting_info.samm_status =
1545 setting_info.samm_status & (~OP_SAMM);
1546 if (setting_info.samm_status == 0
1547 || setting_info.samm_status == 1) {
1548 viafb_SAMM_ON = setting_info.samm_status;
1549
1550 if (viafb_SAMM_ON)
1551 viafb_primary_dev = setting_info.primary_device;
1552
1553 viafb_set_start_addr();
1554 viafb_set_iga_path();
1555 }
1556 need_set_mode = 1;
1557 }
1558
1559 viaparinfo->duoview = is_duoview();
1560
1561 if (!need_set_mode) {
1562 ;
1563 } else {
1564 viafb_set_iga_path();
1565 viafb_set_par(info);
1566 }
1567 return true;
1568}
1569
1570static void retrieve_device_setting(struct viafb_ioctl_setting
1571 *setting_info)
1572{
1573
1574 /* get device status */
1575 if (viafb_CRT_ON == 1)
1576 setting_info->device_status = CRT_Device;
1577 if (viafb_DVI_ON == 1)
1578 setting_info->device_status |= DVI_Device;
1579 if (viafb_LCD_ON == 1)
1580 setting_info->device_status |= LCD_Device;
1581 if (viafb_LCD2_ON == 1)
1582 setting_info->device_status |= LCD2_Device;
1583 if ((viaparinfo->video_on_crt == 1) && (viafb_CRT_ON == 1)) {
1584 setting_info->video_device_status =
1585 viaparinfo->crt_setting_info->iga_path;
1586 } else if ((viaparinfo->video_on_dvi == 1) && (viafb_DVI_ON == 1)) {
1587 setting_info->video_device_status =
1588 viaparinfo->tmds_setting_info->iga_path;
1589 } else if ((viaparinfo->video_on_lcd == 1) && (viafb_LCD_ON == 1)) {
1590 setting_info->video_device_status =
1591 viaparinfo->lvds_setting_info->iga_path;
1592 } else {
1593 setting_info->video_device_status = 0;
1594 }
1595
1596 setting_info->samm_status = viafb_SAMM_ON;
1597 setting_info->primary_device = get_primary_device();
1598
1599 setting_info->first_dev_bpp = viafb_bpp;
1600 setting_info->second_dev_bpp = viafb_bpp1;
1601
1602 setting_info->first_dev_refresh = viafb_refresh;
1603 setting_info->second_dev_refresh = viafb_refresh1;
1604
1605 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
1606 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
1607 setting_info->second_dev_hor_res = viafb_second_xres;
1608 setting_info->second_dev_ver_res = viafb_second_yres;
1609
1610 /* Get lcd attributes */
1611 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
1612 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
1613 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
1614}
1615
1616static void parse_active_dev(void)
1617{
1618 viafb_CRT_ON = STATE_OFF;
1619 viafb_DVI_ON = STATE_OFF;
1620 viafb_LCD_ON = STATE_OFF;
1621 viafb_LCD2_ON = STATE_OFF;
1622 /* 1. Modify the active status of devices. */
1623 /* 2. Keep the order of devices, so we can set corresponding
1624 IGA path to devices in SAMM case. */
1625 /* Note: The previous of active_dev is primary device,
1626 and the following is secondary device. */
1627 if (!strncmp(viafb_active_dev, "CRT+DVI", 7)) {
1628 /* CRT+DVI */
1629 viafb_CRT_ON = STATE_ON;
1630 viafb_DVI_ON = STATE_ON;
1631 viafb_primary_dev = CRT_Device;
1632 } else if (!strncmp(viafb_active_dev, "DVI+CRT", 7)) {
1633 /* DVI+CRT */
1634 viafb_CRT_ON = STATE_ON;
1635 viafb_DVI_ON = STATE_ON;
1636 viafb_primary_dev = DVI_Device;
1637 } else if (!strncmp(viafb_active_dev, "CRT+LCD", 7)) {
1638 /* CRT+LCD */
1639 viafb_CRT_ON = STATE_ON;
1640 viafb_LCD_ON = STATE_ON;
1641 viafb_primary_dev = CRT_Device;
1642 } else if (!strncmp(viafb_active_dev, "LCD+CRT", 7)) {
1643 /* LCD+CRT */
1644 viafb_CRT_ON = STATE_ON;
1645 viafb_LCD_ON = STATE_ON;
1646 viafb_primary_dev = LCD_Device;
1647 } else if (!strncmp(viafb_active_dev, "DVI+LCD", 7)) {
1648 /* DVI+LCD */
1649 viafb_DVI_ON = STATE_ON;
1650 viafb_LCD_ON = STATE_ON;
1651 viafb_primary_dev = DVI_Device;
1652 } else if (!strncmp(viafb_active_dev, "LCD+DVI", 7)) {
1653 /* LCD+DVI */
1654 viafb_DVI_ON = STATE_ON;
1655 viafb_LCD_ON = STATE_ON;
1656 viafb_primary_dev = LCD_Device;
1657 } else if (!strncmp(viafb_active_dev, "LCD+LCD2", 8)) {
1658 viafb_LCD_ON = STATE_ON;
1659 viafb_LCD2_ON = STATE_ON;
1660 viafb_primary_dev = LCD_Device;
1661 } else if (!strncmp(viafb_active_dev, "LCD2+LCD", 8)) {
1662 viafb_LCD_ON = STATE_ON;
1663 viafb_LCD2_ON = STATE_ON;
1664 viafb_primary_dev = LCD2_Device;
1665 } else if (!strncmp(viafb_active_dev, "CRT", 3)) {
1666 /* CRT only */
1667 viafb_CRT_ON = STATE_ON;
1668 viafb_SAMM_ON = STATE_OFF;
1669 } else if (!strncmp(viafb_active_dev, "DVI", 3)) {
1670 /* DVI only */
1671 viafb_DVI_ON = STATE_ON;
1672 viafb_SAMM_ON = STATE_OFF;
1673 } else if (!strncmp(viafb_active_dev, "LCD", 3)) {
1674 /* LCD only */
1675 viafb_LCD_ON = STATE_ON;
1676 viafb_SAMM_ON = STATE_OFF;
1677 } else {
1678 viafb_CRT_ON = STATE_ON;
1679 viafb_SAMM_ON = STATE_OFF;
1680 }
1681 viaparinfo->duoview = is_duoview();
1682}
1683
1684static void parse_video_dev(void)
1685{
1686 viaparinfo->video_on_crt = STATE_OFF;
1687 viaparinfo->video_on_dvi = STATE_OFF;
1688 viaparinfo->video_on_lcd = STATE_OFF;
1689
1690 if (!strncmp(viafb_video_dev, "CRT", 3)) {
1691 /* Video on CRT */
1692 viaparinfo->video_on_crt = STATE_ON;
1693 } else if (!strncmp(viafb_video_dev, "DVI", 3)) {
1694 /* Video on DVI */
1695 viaparinfo->video_on_dvi = STATE_ON;
1696 } else if (!strncmp(viafb_video_dev, "LCD", 3)) {
1697 /* Video on LCD */
1698 viaparinfo->video_on_lcd = STATE_ON;
1699 }
1700}
1701
1702static int parse_port(char *opt_str, int *output_interface)
1703{
1704 if (!strncmp(opt_str, "DVP0", 4))
1705 *output_interface = INTERFACE_DVP0;
1706 else if (!strncmp(opt_str, "DVP1", 4))
1707 *output_interface = INTERFACE_DVP1;
1708 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1709 *output_interface = INTERFACE_DFP;
1710 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1711 *output_interface = INTERFACE_DFP_HIGH;
1712 else if (!strncmp(opt_str, "DFP_LOW", 7))
1713 *output_interface = INTERFACE_DFP_LOW;
1714 else
1715 *output_interface = INTERFACE_NONE;
1716 return 0;
1717}
1718
1719static void parse_lcd_port(void)
1720{
1721 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1722 output_interface);
1723 /*Initialize to avoid unexpected behavior */
1724 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1725 INTERFACE_NONE;
1726
1727 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1728 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1729 output_interface);
1730}
1731
1732static void parse_dvi_port(void)
1733{
1734 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1735 output_interface);
1736
1737 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1738 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1739 output_interface);
1740}
1741
1742/*
1743 * The proc filesystem read/write function, a simple proc implement to
1744 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1745 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1746 * CR9B, SR65, CR97, CR99
1747 */
1748static int viafb_dvp0_proc_read(char *buf, char **start, off_t offset,
1749int count, int *eof, void *data)
1750{
1751 int len = 0;
1752 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1753 dvp0_data_dri =
1754 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1755 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1756 dvp0_clk_dri =
1757 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1758 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1759 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
1760 len +=
1761 sprintf(buf + len, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1762 *eof = 1; /*Inform kernel end of data */
1763 return len;
1764}
1765static int viafb_dvp0_proc_write(struct file *file,
1766 const char __user *buffer, unsigned long count, void *data)
1767{
1768 char buf[20], *value, *pbuf;
1769 u8 reg_val = 0;
1770 unsigned long length, i;
1771 if (count < 1)
1772 return -EINVAL;
1773 length = count > 20 ? 20 : count;
1774 if (copy_from_user(&buf[0], buffer, length))
1775 return -EFAULT;
1776 buf[length - 1] = '\0'; /*Ensure end string */
1777 pbuf = &buf[0];
1778 for (i = 0; i < 3; i++) {
1779 value = strsep(&pbuf, " ");
1780 if (value != NULL) {
1781 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1782 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1783 reg_val);
1784 switch (i) {
1785 case 0:
1786 viafb_write_reg_mask(CR96, VIACR,
1787 reg_val, 0x0f);
1788 break;
1789 case 1:
1790 viafb_write_reg_mask(SR2A, VIASR,
1791 reg_val << 4, BIT5);
1792 viafb_write_reg_mask(SR1B, VIASR,
1793 reg_val << 1, BIT1);
1794 break;
1795 case 2:
1796 viafb_write_reg_mask(SR2A, VIASR,
1797 reg_val << 3, BIT4);
1798 viafb_write_reg_mask(SR1E, VIASR,
1799 reg_val << 2, BIT2);
1800 break;
1801 default:
1802 break;
1803 }
1804 } else {
1805 break;
1806 }
1807 }
1808 return count;
1809}
1810static int viafb_dvp1_proc_read(char *buf, char **start, off_t offset,
1811 int count, int *eof, void *data)
1812{
1813 int len = 0;
1814 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1815 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1816 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1817 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
1818 len +=
1819 sprintf(buf + len, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1820 *eof = 1; /*Inform kernel end of data */
1821 return len;
1822}
1823static int viafb_dvp1_proc_write(struct file *file,
1824 const char __user *buffer, unsigned long count, void *data)
1825{
1826 char buf[20], *value, *pbuf;
1827 u8 reg_val = 0;
1828 unsigned long length, i;
1829 if (count < 1)
1830 return -EINVAL;
1831 length = count > 20 ? 20 : count;
1832 if (copy_from_user(&buf[0], buffer, length))
1833 return -EFAULT;
1834 buf[length - 1] = '\0'; /*Ensure end string */
1835 pbuf = &buf[0];
1836 for (i = 0; i < 3; i++) {
1837 value = strsep(&pbuf, " ");
1838 if (value != NULL) {
1839 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1840 switch (i) {
1841 case 0:
1842 viafb_write_reg_mask(CR9B, VIACR,
1843 reg_val, 0x0f);
1844 break;
1845 case 1:
1846 viafb_write_reg_mask(SR65, VIASR,
1847 reg_val << 2, 0x0c);
1848 break;
1849 case 2:
1850 viafb_write_reg_mask(SR65, VIASR,
1851 reg_val, 0x03);
1852 break;
1853 default:
1854 break;
1855 }
1856 } else {
1857 break;
1858 }
1859 }
1860 return count;
1861}
1862
1863static int viafb_dfph_proc_read(char *buf, char **start, off_t offset,
1864 int count, int *eof, void *data)
1865{
1866 int len = 0;
1867 u8 dfp_high = 0;
1868 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
1869 len += sprintf(buf + len, "%x\n", dfp_high);
1870 *eof = 1; /*Inform kernel end of data */
1871 return len;
1872}
1873static int viafb_dfph_proc_write(struct file *file,
1874 const char __user *buffer, unsigned long count, void *data)
1875{
1876 char buf[20];
1877 u8 reg_val = 0;
1878 unsigned long length;
1879 if (count < 1)
1880 return -EINVAL;
1881 length = count > 20 ? 20 : count;
1882 if (copy_from_user(&buf[0], buffer, length))
1883 return -EFAULT;
1884 buf[length - 1] = '\0'; /*Ensure end string */
1885 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1886 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1887 return count;
1888}
1889static int viafb_dfpl_proc_read(char *buf, char **start, off_t offset,
1890 int count, int *eof, void *data)
1891{
1892 int len = 0;
1893 u8 dfp_low = 0;
1894 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
1895 len += sprintf(buf + len, "%x\n", dfp_low);
1896 *eof = 1; /*Inform kernel end of data */
1897 return len;
1898}
1899static int viafb_dfpl_proc_write(struct file *file,
1900 const char __user *buffer, unsigned long count, void *data)
1901{
1902 char buf[20];
1903 u8 reg_val = 0;
1904 unsigned long length;
1905 if (count < 1)
1906 return -EINVAL;
1907 length = count > 20 ? 20 : count;
1908 if (copy_from_user(&buf[0], buffer, length))
1909 return -EFAULT;
1910 buf[length - 1] = '\0'; /*Ensure end string */
1911 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1912 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1913 return count;
1914}
1915static int viafb_vt1636_proc_read(char *buf, char **start,
1916 off_t offset, int count, int *eof, void *data)
1917{
1918 int len = 0;
1919 u8 vt1636_08 = 0, vt1636_09 = 0;
1920 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1921 case VT1636_LVDS:
1922 vt1636_08 =
1923 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1924 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1925 vt1636_09 =
1926 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1927 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
1928 len += sprintf(buf + len, "%x %x\n", vt1636_08, vt1636_09);
1929 break;
1930 default:
1931 break;
1932 }
1933 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1934 case VT1636_LVDS:
1935 vt1636_08 =
1936 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1937 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1938 vt1636_09 =
1939 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1940 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
1941 len += sprintf(buf + len, " %x %x\n", vt1636_08, vt1636_09);
1942 break;
1943 default:
1944 break;
1945 }
1946 *eof = 1; /*Inform kernel end of data */
1947 return len;
1948}
1949static int viafb_vt1636_proc_write(struct file *file,
1950 const char __user *buffer, unsigned long count, void *data)
1951{
1952 char buf[30], *value, *pbuf;
1953 struct IODATA reg_val;
1954 unsigned long length, i;
1955 if (count < 1)
1956 return -EINVAL;
1957 length = count > 30 ? 30 : count;
1958 if (copy_from_user(&buf[0], buffer, length))
1959 return -EFAULT;
1960 buf[length - 1] = '\0'; /*Ensure end string */
1961 pbuf = &buf[0];
1962 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1963 case VT1636_LVDS:
1964 for (i = 0; i < 2; i++) {
1965 value = strsep(&pbuf, " ");
1966 if (value != NULL) {
1967 strict_strtoul(value, 0,
1968 (unsigned long *)&reg_val.Data);
1969 switch (i) {
1970 case 0:
1971 reg_val.Index = 0x08;
1972 reg_val.Mask = 0x0f;
1973 viafb_gpio_i2c_write_mask_lvds
1974 (viaparinfo->lvds_setting_info,
1975 &viaparinfo->
1976 chip_info->lvds_chip_info,
1977 reg_val);
1978 break;
1979 case 1:
1980 reg_val.Index = 0x09;
1981 reg_val.Mask = 0x1f;
1982 viafb_gpio_i2c_write_mask_lvds
1983 (viaparinfo->lvds_setting_info,
1984 &viaparinfo->
1985 chip_info->lvds_chip_info,
1986 reg_val);
1987 break;
1988 default:
1989 break;
1990 }
1991 } else {
1992 break;
1993 }
1994 }
1995 break;
1996 default:
1997 break;
1998 }
1999 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
2000 case VT1636_LVDS:
2001 for (i = 0; i < 2; i++) {
2002 value = strsep(&pbuf, " ");
2003 if (value != NULL) {
2004 strict_strtoul(value, 0,
2005 (unsigned long *)&reg_val.Data);
2006 switch (i) {
2007 case 0:
2008 reg_val.Index = 0x08;
2009 reg_val.Mask = 0x0f;
2010 viafb_gpio_i2c_write_mask_lvds
2011 (viaparinfo->lvds_setting_info2,
2012 &viaparinfo->
2013 chip_info->lvds_chip_info2,
2014 reg_val);
2015 break;
2016 case 1:
2017 reg_val.Index = 0x09;
2018 reg_val.Mask = 0x1f;
2019 viafb_gpio_i2c_write_mask_lvds
2020 (viaparinfo->lvds_setting_info2,
2021 &viaparinfo->
2022 chip_info->lvds_chip_info2,
2023 reg_val);
2024 break;
2025 default:
2026 break;
2027 }
2028 } else {
2029 break;
2030 }
2031 }
2032 break;
2033 default:
2034 break;
2035 }
2036 return count;
2037}
2038
2039static void viafb_init_proc(struct proc_dir_entry *viafb_entry)
2040{
2041 struct proc_dir_entry *entry;
2042 viafb_entry = proc_mkdir("viafb", NULL);
2043 if (viafb_entry) {
2044 entry = create_proc_entry("dvp0", 0, viafb_entry);
2045 if (entry) {
2046 entry->owner = THIS_MODULE;
2047 entry->read_proc = viafb_dvp0_proc_read;
2048 entry->write_proc = viafb_dvp0_proc_write;
2049 }
2050 entry = create_proc_entry("dvp1", 0, viafb_entry);
2051 if (entry) {
2052 entry->owner = THIS_MODULE;
2053 entry->read_proc = viafb_dvp1_proc_read;
2054 entry->write_proc = viafb_dvp1_proc_write;
2055 }
2056 entry = create_proc_entry("dfph", 0, viafb_entry);
2057 if (entry) {
2058 entry->owner = THIS_MODULE;
2059 entry->read_proc = viafb_dfph_proc_read;
2060 entry->write_proc = viafb_dfph_proc_write;
2061 }
2062 entry = create_proc_entry("dfpl", 0, viafb_entry);
2063 if (entry) {
2064 entry->owner = THIS_MODULE;
2065 entry->read_proc = viafb_dfpl_proc_read;
2066 entry->write_proc = viafb_dfpl_proc_write;
2067 }
2068 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
2069 lvds_chip_name || VT1636_LVDS ==
2070 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
2071 entry = create_proc_entry("vt1636", 0, viafb_entry);
2072 if (entry) {
2073 entry->owner = THIS_MODULE;
2074 entry->read_proc = viafb_vt1636_proc_read;
2075 entry->write_proc = viafb_vt1636_proc_write;
2076 }
2077 }
2078
2079 }
2080}
2081static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
2082{
2083 /* no problem if it was not registered */
2084 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
2085 remove_proc_entry("dvp1", viafb_entry);
2086 remove_proc_entry("dfph", viafb_entry);
2087 remove_proc_entry("dfpl", viafb_entry);
2088 remove_proc_entry("vt1636", viafb_entry);
2089 remove_proc_entry("vt1625", viafb_entry);
2090}
2091
2092static int __devinit via_pci_probe(void)
2093{
2094 unsigned int default_xres, default_yres;
2095 char *tmpc, *tmpm;
2096 char *tmpc_sec, *tmpm_sec;
2097 int vmode_index;
2098 u32 tmds_length, lvds_length, crt_length, chip_length, viafb_par_length;
2099
2100 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
2101
2102 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
2103 tmds_length = ALIGN(sizeof(struct tmds_setting_information),
2104 BITS_PER_LONG/8);
2105 lvds_length = ALIGN(sizeof(struct lvds_setting_information),
2106 BITS_PER_LONG/8);
2107 crt_length = ALIGN(sizeof(struct lvds_setting_information),
2108 BITS_PER_LONG/8);
2109 chip_length = ALIGN(sizeof(struct chip_information), BITS_PER_LONG/8);
2110
2111 /* Allocate fb_info and ***_par here, also including some other needed
2112 * variables
2113 */
2114 viafbinfo = framebuffer_alloc(viafb_par_length + 2 * lvds_length +
2115 tmds_length + crt_length + chip_length, NULL);
2116 if (!viafbinfo) {
2117 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
2118 return -ENODEV;
2119 }
2120
2121 viaparinfo = (struct viafb_par *)viafbinfo->par;
2122 viaparinfo->tmds_setting_info = (struct tmds_setting_information *)
2123 ((unsigned long)viaparinfo + viafb_par_length);
2124 viaparinfo->lvds_setting_info = (struct lvds_setting_information *)
2125 ((unsigned long)viaparinfo->tmds_setting_info + tmds_length);
2126 viaparinfo->lvds_setting_info2 = (struct lvds_setting_information *)
2127 ((unsigned long)viaparinfo->lvds_setting_info + lvds_length);
2128 viaparinfo->crt_setting_info = (struct crt_setting_information *)
2129 ((unsigned long)viaparinfo->lvds_setting_info2 + lvds_length);
2130 viaparinfo->chip_info = (struct chip_information *)
2131 ((unsigned long)viaparinfo->crt_setting_info + crt_length);
2132
2133 if (viafb_dual_fb)
2134 viafb_SAMM_ON = 1;
2135 parse_active_dev();
2136 parse_video_dev();
2137 parse_lcd_port();
2138 parse_dvi_port();
2139
2140 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
2141 if (!viafb_SAMM_ON)
2142 viafb_dual_fb = 0;
2143
2144 /* Set up I2C bus stuff */
2145 viafb_create_i2c_bus(viaparinfo);
2146
2147 viafb_init_chip_info();
2148 viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize);
2149 viaparinfo->fbmem_free = viaparinfo->memsize;
2150 viaparinfo->fbmem_used = 0;
2151 viaparinfo->fbmem_virt = ioremap_nocache(viaparinfo->fbmem,
2152 viaparinfo->memsize);
2153 viafbinfo->screen_base = (char *)viaparinfo->fbmem_virt;
2154
2155 if (!viaparinfo->fbmem_virt) {
2156 printk(KERN_INFO "ioremap failed\n");
2157 return -1;
2158 }
2159
2160 viafb_get_mmio_info(&viaparinfo->mmio_base, &viaparinfo->mmio_len);
2161 viaparinfo->io_virt = ioremap_nocache(viaparinfo->mmio_base,
2162 viaparinfo->mmio_len);
2163
2164 viafbinfo->node = 0;
2165 viafbinfo->fbops = &viafb_ops;
2166 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
2167
2168 viafbinfo->pseudo_palette = pseudo_pal;
2169 if (viafb_accel) {
2170 viafb_init_accel();
2171 viafb_init_2d_engine();
2172 viafb_hw_cursor_init();
2173 }
2174
2175 if (viafb_second_size && (viafb_second_size < 8)) {
2176 viafb_second_offset = viaparinfo->fbmem_free -
2177 viafb_second_size * 1024 * 1024;
2178 } else {
2179 viafb_second_size = 8;
2180 viafb_second_offset = viaparinfo->fbmem_free -
2181 viafb_second_size * 1024 * 1024;
2182 }
2183
2184 viafb_FB_MM = viaparinfo->fbmem_virt;
2185 tmpm = viafb_mode;
2186 tmpc = strsep(&tmpm, "x");
2187 strict_strtoul(tmpc, 0, (unsigned long *)&default_xres);
2188 strict_strtoul(tmpm, 0, (unsigned long *)&default_yres);
2189
2190 vmode_index = viafb_get_mode_index(default_xres, default_yres, 0);
2191 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
2192
2193 if (viafb_SAMM_ON == 1) {
2194 if (strcmp(viafb_mode, viafb_mode1)) {
2195 tmpm_sec = viafb_mode1;
2196 tmpc_sec = strsep(&tmpm_sec, "x");
2197 strict_strtoul(tmpc_sec, 0,
2198 (unsigned long *)&viafb_second_xres);
2199 strict_strtoul(tmpm_sec, 0,
2200 (unsigned long *)&viafb_second_yres);
2201 } else {
2202 viafb_second_xres = default_xres;
2203 viafb_second_yres = default_yres;
2204 }
2205 if (0 == viafb_second_virtual_xres) {
2206 switch (viafb_second_xres) {
2207 case 1400:
2208 viafb_second_virtual_xres = 1408;
2209 break;
2210 default:
2211 viafb_second_virtual_xres = viafb_second_xres;
2212 break;
2213 }
2214 }
2215 if (0 == viafb_second_virtual_yres)
2216 viafb_second_virtual_yres = viafb_second_yres;
2217 }
2218
2219 switch (viafb_bpp) {
2220 case 0 ... 8:
2221 viafb_bpp = 8;
2222 break;
2223 case 9 ... 16:
2224 viafb_bpp = 16;
2225 break;
2226 case 17 ... 32:
2227 viafb_bpp = 32;
2228 break;
2229 default:
2230 viafb_bpp = 8;
2231 }
2232 default_var.xres = default_xres;
2233 default_var.yres = default_yres;
2234 switch (default_xres) {
2235 case 1400:
2236 default_var.xres_virtual = 1408;
2237 break;
2238 default:
2239 default_var.xres_virtual = default_xres;
2240 break;
2241 }
2242 default_var.yres_virtual = default_yres;
2243 default_var.bits_per_pixel = viafb_bpp;
2244 if (default_var.bits_per_pixel == 15)
2245 default_var.bits_per_pixel = 16;
2246 default_var.pixclock =
2247 viafb_get_pixclock(default_xres, default_yres, viafb_refresh);
2248 default_var.left_margin = (default_xres >> 3) & 0xf8;
2249 default_var.right_margin = 32;
2250 default_var.upper_margin = 16;
2251 default_var.lower_margin = 4;
2252 default_var.hsync_len = default_var.left_margin;
2253 default_var.vsync_len = 4;
2254 default_var.accel_flags = 0;
2255
2256 if (viafb_accel) {
2257 viafbinfo->flags |=
2258 (FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
2259 FBINFO_HWACCEL_IMAGEBLIT);
2260 default_var.accel_flags |= FB_ACCELF_TEXT;
2261 } else
2262 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
2263
2264 if (viafb_dual_fb) {
2265 viafbinfo1 = framebuffer_alloc(viafb_par_length, NULL);
2266 if (!viafbinfo1) {
2267 printk(KERN_ERR
2268 "allocate the second framebuffer struct error\n");
2269 framebuffer_release(viafbinfo);
2270 return -ENOMEM;
2271 }
2272 viaparinfo1 = viafbinfo1->par;
2273 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
2274 viaparinfo1->memsize = viaparinfo->memsize -
2275 viafb_second_offset;
2276 viaparinfo->memsize = viafb_second_offset;
2277 viaparinfo1->fbmem_virt = viaparinfo->fbmem_virt +
2278 viafb_second_offset;
2279 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
2280
2281 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
2282 viaparinfo1->fbmem_free = viaparinfo1->memsize -
2283 viaparinfo1->fbmem_used;
2284 viaparinfo->fbmem_free = viaparinfo->memsize;
2285 viaparinfo->fbmem_used = 0;
2286 if (viafb_accel) {
2287 viaparinfo1->cursor_start =
2288 viaparinfo->cursor_start - viafb_second_offset;
2289 viaparinfo1->VQ_start = viaparinfo->VQ_start -
2290 viafb_second_offset;
2291 viaparinfo1->VQ_end = viaparinfo->VQ_end -
2292 viafb_second_offset;
2293 }
2294
2295 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
2296 viafbinfo1->screen_base = viafbinfo->screen_base +
2297 viafb_second_offset;
2298 viafbinfo1->fix.smem_start = viaparinfo1->fbmem;
2299 viafbinfo1->fix.smem_len = viaparinfo1->fbmem_free;
2300
2301 default_var.xres = viafb_second_xres;
2302 default_var.yres = viafb_second_yres;
2303 default_var.xres_virtual = viafb_second_virtual_xres;
2304 default_var.yres_virtual = viafb_second_virtual_yres;
2305 if (viafb_bpp1 != viafb_bpp)
2306 viafb_bpp1 = viafb_bpp;
2307 default_var.bits_per_pixel = viafb_bpp1;
2308 default_var.pixclock =
2309 viafb_get_pixclock(viafb_second_xres, viafb_second_yres,
2310 viafb_refresh);
2311 default_var.left_margin = (viafb_second_xres >> 3) & 0xf8;
2312 default_var.right_margin = 32;
2313 default_var.upper_margin = 16;
2314 default_var.lower_margin = 4;
2315 default_var.hsync_len = default_var.left_margin;
2316 default_var.vsync_len = 4;
2317
2318 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
2319 viafb_check_var(&default_var, viafbinfo1);
2320 viafbinfo1->var = default_var;
2321 viafb_update_viafb_par(viafbinfo);
2322 viafb_update_fix(&viafbinfo1->fix, viafbinfo1);
2323 }
2324
2325 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
2326 viafb_check_var(&default_var, viafbinfo);
2327 viafbinfo->var = default_var;
2328 viafb_update_viafb_par(viafbinfo);
2329 viafb_update_fix(&viafbinfo->fix, viafbinfo);
2330 default_var.activate = FB_ACTIVATE_NOW;
2331 fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
2332
2333 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
2334 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
2335 if (register_framebuffer(viafbinfo1) < 0)
2336 return -EINVAL;
2337 }
2338 if (register_framebuffer(viafbinfo) < 0)
2339 return -EINVAL;
2340
2341 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
2342 || (viaparinfo->chip_info->gfx_chip_name !=
2343 UNICHROME_CLE266))) {
2344 if (register_framebuffer(viafbinfo1) < 0)
2345 return -EINVAL;
2346 }
2347 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
2348 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
2349 default_var.yres, default_var.bits_per_pixel);
2350
2351 viafb_init_proc(viaparinfo->proc_entry);
2352 viafb_init_dac(IGA2);
2353 return 0;
2354}
2355
2356static void __devexit via_pci_remove(void)
2357{
2358 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
2359 fb_dealloc_cmap(&viafbinfo->cmap);
2360 unregister_framebuffer(viafbinfo);
2361 if (viafb_dual_fb)
2362 unregister_framebuffer(viafbinfo1);
2363 iounmap((void *)viaparinfo->fbmem_virt);
2364 iounmap(viaparinfo->io_virt);
2365
2366 viafb_delete_i2c_buss(viaparinfo);
2367
2368 framebuffer_release(viafbinfo);
2369 if (viafb_dual_fb)
2370 framebuffer_release(viafbinfo1);
2371
2372 viafb_remove_proc(viaparinfo->proc_entry);
2373}
2374
2375#ifndef MODULE
2376static int __init viafb_setup(char *options)
2377{
2378 char *this_opt;
2379 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
2380
2381 if (!options || !*options)
2382 return 0;
2383
2384 while ((this_opt = strsep(&options, ",")) != NULL) {
2385 if (!*this_opt)
2386 continue;
2387
2388 if (!strncmp(this_opt, "viafb_mode1=", 12))
2389 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
2390 else if (!strncmp(this_opt, "viafb_mode=", 11))
2391 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
2392 else if (!strncmp(this_opt, "viafb_bpp1=", 11))
2393 strict_strtoul(this_opt + 11, 0,
2394 (unsigned long *)&viafb_bpp1);
2395 else if (!strncmp(this_opt, "viafb_bpp=", 10))
2396 strict_strtoul(this_opt + 10, 0,
2397 (unsigned long *)&viafb_bpp);
2398 else if (!strncmp(this_opt, "viafb_refresh1=", 15))
2399 strict_strtoul(this_opt + 15, 0,
2400 (unsigned long *)&viafb_refresh1);
2401 else if (!strncmp(this_opt, "viafb_refresh=", 14))
2402 strict_strtoul(this_opt + 14, 0,
2403 (unsigned long *)&viafb_refresh);
2404 else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
2405 strict_strtoul(this_opt + 21, 0,
2406 (unsigned long *)&viafb_lcd_dsp_method);
2407 else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
2408 strict_strtoul(this_opt + 19, 0,
2409 (unsigned long *)&viafb_lcd_panel_id);
2410 else if (!strncmp(this_opt, "viafb_accel=", 12))
2411 strict_strtoul(this_opt + 12, 0,
2412 (unsigned long *)&viafb_accel);
2413 else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
2414 strict_strtoul(this_opt + 14, 0,
2415 (unsigned long *)&viafb_SAMM_ON);
2416 else if (!strncmp(this_opt, "viafb_active_dev=", 17))
2417 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2418 else if (!strncmp(this_opt,
2419 "viafb_display_hardware_layout=", 30))
2420 strict_strtoul(this_opt + 30, 0,
2421 (unsigned long *)&viafb_display_hardware_layout);
2422 else if (!strncmp(this_opt, "viafb_second_size=", 18))
2423 strict_strtoul(this_opt + 18, 0,
2424 (unsigned long *)&viafb_second_size);
2425 else if (!strncmp(this_opt,
2426 "viafb_platform_epia_dvi=", 24))
2427 strict_strtoul(this_opt + 24, 0,
2428 (unsigned long *)&viafb_platform_epia_dvi);
2429 else if (!strncmp(this_opt,
2430 "viafb_device_lcd_dualedge=", 26))
2431 strict_strtoul(this_opt + 26, 0,
2432 (unsigned long *)&viafb_device_lcd_dualedge);
2433 else if (!strncmp(this_opt, "viafb_bus_width=", 16))
2434 strict_strtoul(this_opt + 16, 0,
2435 (unsigned long *)&viafb_bus_width);
2436 else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
2437 strict_strtoul(this_opt + 15, 0,
2438 (unsigned long *)&viafb_lcd_mode);
2439 else if (!strncmp(this_opt, "viafb_video_dev=", 16))
2440 viafb_video_dev = kstrdup(this_opt + 16, GFP_KERNEL);
2441 else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
2442 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2443 else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
2444 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2445 }
2446 return 0;
2447}
2448#endif
2449
2450static int __init viafb_init(void)
2451{
2452#ifndef MODULE
2453 char *option = NULL;
2454 if (fb_get_options("viafb", &option))
2455 return -ENODEV;
2456 viafb_setup(option);
2457#endif
2458 printk(KERN_INFO
2459 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2460 VERSION_MAJOR, VERSION_MINOR);
2461 return via_pci_probe();
2462}
2463
2464static void __exit viafb_exit(void)
2465{
2466 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
2467 via_pci_remove();
2468}
2469
2470static struct fb_ops viafb_ops = {
2471 .owner = THIS_MODULE,
2472 .fb_open = viafb_open,
2473 .fb_release = viafb_release,
2474 .fb_check_var = viafb_check_var,
2475 .fb_set_par = viafb_set_par,
2476 .fb_setcolreg = viafb_setcolreg,
2477 .fb_pan_display = viafb_pan_display,
2478 .fb_blank = viafb_blank,
2479 .fb_fillrect = viafb_fillrect,
2480 .fb_copyarea = viafb_copyarea,
2481 .fb_imageblit = viafb_imageblit,
2482 .fb_cursor = viafb_cursor,
2483 .fb_ioctl = viafb_ioctl,
2484 .fb_sync = viafb_sync,
2485 .fb_setcmap = viafb_setcmap,
2486};
2487
2488module_init(viafb_init);
2489module_exit(viafb_exit);
2490
2491#ifdef MODULE
2492module_param(viafb_memsize, int, 0);
2493
2494module_param(viafb_mode, charp, 0);
2495MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2496
2497module_param(viafb_mode1, charp, 0);
2498MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2499
2500module_param(viafb_bpp, int, 0);
2501MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2502
2503module_param(viafb_bpp1, int, 0);
2504MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2505
2506module_param(viafb_refresh, int, 0);
2507MODULE_PARM_DESC(viafb_refresh,
2508 "Set CRT viafb_refresh rate (default = 60)");
2509
2510module_param(viafb_refresh1, int, 0);
2511MODULE_PARM_DESC(viafb_refresh1,
2512 "Set CRT refresh rate (default = 60)");
2513
2514module_param(viafb_lcd_panel_id, int, 0);
2515MODULE_PARM_DESC(viafb_lcd_panel_id,
2516 "Set Flat Panel type(Default=1024x768)");
2517
2518module_param(viafb_lcd_dsp_method, int, 0);
2519MODULE_PARM_DESC(viafb_lcd_dsp_method,
2520 "Set Flat Panel display scaling method.(Default=Expandsion)");
2521
2522module_param(viafb_SAMM_ON, int, 0);
2523MODULE_PARM_DESC(viafb_SAMM_ON,
2524 "Turn on/off flag of SAMM(Default=OFF)");
2525
2526module_param(viafb_accel, int, 0);
2527MODULE_PARM_DESC(viafb_accel,
2528 "Set 2D Hardware Acceleration.(Default = OFF)");
2529
2530module_param(viafb_active_dev, charp, 0);
2531MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2532
2533module_param(viafb_display_hardware_layout, int, 0);
2534MODULE_PARM_DESC(viafb_display_hardware_layout,
2535 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2536
2537module_param(viafb_second_size, int, 0);
2538MODULE_PARM_DESC(viafb_second_size,
2539 "Set secondary device memory size");
2540
2541module_param(viafb_dual_fb, int, 0);
2542MODULE_PARM_DESC(viafb_dual_fb,
2543 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2544
2545module_param(viafb_platform_epia_dvi, int, 0);
2546MODULE_PARM_DESC(viafb_platform_epia_dvi,
2547 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2548
2549module_param(viafb_device_lcd_dualedge, int, 0);
2550MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2551 "Turn on/off flag of dual edge panel.(Default = OFF)");
2552
2553module_param(viafb_bus_width, int, 0);
2554MODULE_PARM_DESC(viafb_bus_width,
2555 "Set bus width of panel.(Default = 12)");
2556
2557module_param(viafb_lcd_mode, int, 0);
2558MODULE_PARM_DESC(viafb_lcd_mode,
2559 "Set Flat Panel mode(Default=OPENLDI)");
2560
2561module_param(viafb_video_dev, charp, 0);
2562MODULE_PARM_DESC(viafb_video_dev, "Specify video devices.");
2563
2564module_param(viafb_lcd_port, charp, 0);
2565MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2566
2567module_param(viafb_dvi_port, charp, 0);
2568MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2569
2570MODULE_LICENSE("GPL");
2571#endif
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
new file mode 100644
index 000000000000..a4158e872878
--- /dev/null
+++ b/drivers/video/via/viafbdev.h
@@ -0,0 +1,112 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __VIAFBDEV_H__
23#define __VIAFBDEV_H__
24
25#include <linux/proc_fs.h>
26#include <linux/fb.h>
27
28#include "ioctl.h"
29#include "share.h"
30#include "chip.h"
31#include "hw.h"
32#include "via_i2c.h"
33
34#define VERSION_MAJOR 2
35#define VERSION_KERNEL 6 /* For kernel 2.6 */
36
37#define VERSION_OS 0 /* 0: for 32 bits OS, 1: for 64 bits OS */
38#define VERSION_MINOR 4
39
40struct viafb_par {
41 int bpp;
42 int hres;
43 int vres;
44 int linelength;
45 u32 xoffset;
46 u32 yoffset;
47
48 void __iomem *fbmem_virt; /*framebuffer virtual memory address */
49 void __iomem *io_virt; /*iospace virtual memory address */
50 unsigned int fbmem; /*framebuffer physical memory address */
51 unsigned int memsize; /*size of fbmem */
52 unsigned int io; /*io space address */
53 unsigned long mmio_base; /*mmio base address */
54 unsigned long mmio_len; /*mmio base length */
55 u32 fbmem_free; /* Free FB memory */
56 u32 fbmem_used; /* Use FB memory size */
57 u32 cursor_start; /* Cursor Start Address */
58 u32 VQ_start; /* Virtual Queue Start Address */
59 u32 VQ_end; /* Virtual Queue End Address */
60 u32 iga_path;
61 struct proc_dir_entry *proc_entry; /*viafb proc entry */
62 u8 duoview; /*Is working in duoview mode? */
63
64 /* I2C stuff */
65 struct via_i2c_stuff i2c_stuff;
66
67 /* All the information will be needed to set engine */
68 struct tmds_setting_information *tmds_setting_info;
69 struct crt_setting_information *crt_setting_info;
70 struct lvds_setting_information *lvds_setting_info;
71 struct lvds_setting_information *lvds_setting_info2;
72 struct chip_information *chip_info;
73
74 /* some information related to video playing */
75 int video_on_crt;
76 int video_on_dvi;
77 int video_on_lcd;
78
79};
80struct viafb_modeinfo {
81 u32 xres;
82 u32 yres;
83 int mode_index;
84 char *mode_res;
85};
86extern unsigned int viafb_second_virtual_yres;
87extern unsigned int viafb_second_virtual_xres;
88extern unsigned int viafb_second_offset;
89extern int viafb_second_size;
90extern int viafb_SAMM_ON;
91extern int viafb_dual_fb;
92extern int viafb_LCD2_ON;
93extern int viafb_LCD_ON;
94extern int viafb_DVI_ON;
95extern int viafb_accel;
96extern int viafb_hotplug;
97extern int viafb_memsize;
98
99extern int strict_strtoul(const char *cp, unsigned int base,
100 unsigned long *res);
101
102void viafb_memory_pitch_patch(struct fb_info *info);
103void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
104 int mode_index);
105int viafb_get_mode_index(int hres, int vres, int flag);
106u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
107 *plvds_setting_info, struct lvds_chip_information
108 *plvds_chip_info, u8 index);
109void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information
110 *plvds_setting_info, struct lvds_chip_information
111 *plvds_chip_info, struct IODATA io_data);
112#endif /* __VIAFBDEV_H__ */
diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c
new file mode 100644
index 000000000000..6dcf583a837d
--- /dev/null
+++ b/drivers/video/via/viamode.c
@@ -0,0 +1,1086 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23struct res_map_refresh res_map_refresh_tbl[] = {
24/*hres, vres, vclock, vmode_refresh*/
25 {480, 640, RES_480X640_60HZ_PIXCLOCK, 60},
26 {640, 480, RES_640X480_60HZ_PIXCLOCK, 60},
27 {640, 480, RES_640X480_75HZ_PIXCLOCK, 75},
28 {640, 480, RES_640X480_85HZ_PIXCLOCK, 85},
29 {640, 480, RES_640X480_100HZ_PIXCLOCK, 100},
30 {640, 480, RES_640X480_120HZ_PIXCLOCK, 120},
31 {720, 480, RES_720X480_60HZ_PIXCLOCK, 60},
32 {720, 576, RES_720X576_60HZ_PIXCLOCK, 60},
33 {800, 480, RES_800X480_60HZ_PIXCLOCK, 60},
34 {800, 600, RES_800X600_60HZ_PIXCLOCK, 60},
35 {800, 600, RES_800X600_75HZ_PIXCLOCK, 75},
36 {800, 600, RES_800X600_85HZ_PIXCLOCK, 85},
37 {800, 600, RES_800X600_100HZ_PIXCLOCK, 100},
38 {800, 600, RES_800X600_120HZ_PIXCLOCK, 120},
39 {848, 480, RES_848X480_60HZ_PIXCLOCK, 60},
40 {856, 480, RES_856X480_60HZ_PIXCLOCK, 60},
41 {1024, 512, RES_1024X512_60HZ_PIXCLOCK, 60},
42 {1024, 600, RES_1024X600_60HZ_PIXCLOCK, 60},
43 {1024, 768, RES_1024X768_60HZ_PIXCLOCK, 60},
44 {1024, 768, RES_1024X768_75HZ_PIXCLOCK, 75},
45 {1024, 768, RES_1024X768_85HZ_PIXCLOCK, 85},
46 {1024, 768, RES_1024X768_100HZ_PIXCLOCK, 100},
47/* {1152,864, RES_1152X864_70HZ_PIXCLOCK, 70},*/
48 {1152, 864, RES_1152X864_75HZ_PIXCLOCK, 75},
49 {1280, 768, RES_1280X768_60HZ_PIXCLOCK, 60},
50 {1280, 800, RES_1280X800_60HZ_PIXCLOCK, 60},
51 {1280, 960, RES_1280X960_60HZ_PIXCLOCK, 60},
52 {1280, 1024, RES_1280X1024_60HZ_PIXCLOCK, 60},
53 {1280, 1024, RES_1280X1024_75HZ_PIXCLOCK, 75},
54 {1280, 1024, RES_1280X768_85HZ_PIXCLOCK, 85},
55 {1440, 1050, RES_1440X1050_60HZ_PIXCLOCK, 60},
56 {1600, 1200, RES_1600X1200_60HZ_PIXCLOCK, 60},
57 {1600, 1200, RES_1600X1200_75HZ_PIXCLOCK, 75},
58 {1280, 720, RES_1280X720_60HZ_PIXCLOCK, 60},
59 {1920, 1080, RES_1920X1080_60HZ_PIXCLOCK, 60},
60 {1400, 1050, RES_1400X1050_60HZ_PIXCLOCK, 60},
61 {1400, 1050, RES_1400X1050_75HZ_PIXCLOCK, 75},
62 {1368, 768, RES_1368X768_60HZ_PIXCLOCK, 60},
63 {960, 600, RES_960X600_60HZ_PIXCLOCK, 60},
64 {1000, 600, RES_1000X600_60HZ_PIXCLOCK, 60},
65 {1024, 576, RES_1024X576_60HZ_PIXCLOCK, 60},
66 {1088, 612, RES_1088X612_60HZ_PIXCLOCK, 60},
67 {1152, 720, RES_1152X720_60HZ_PIXCLOCK, 60},
68 {1200, 720, RES_1200X720_60HZ_PIXCLOCK, 60},
69 {1280, 600, RES_1280X600_60HZ_PIXCLOCK, 60},
70 {1280, 720, RES_1280X720_50HZ_PIXCLOCK, 50},
71 {1280, 768, RES_1280X768_50HZ_PIXCLOCK, 50},
72 {1360, 768, RES_1360X768_60HZ_PIXCLOCK, 60},
73 {1366, 768, RES_1366X768_50HZ_PIXCLOCK, 50},
74 {1366, 768, RES_1366X768_60HZ_PIXCLOCK, 60},
75 {1440, 900, RES_1440X900_60HZ_PIXCLOCK, 60},
76 {1440, 900, RES_1440X900_75HZ_PIXCLOCK, 75},
77 {1600, 900, RES_1600X900_60HZ_PIXCLOCK, 60},
78 {1600, 1024, RES_1600X1024_60HZ_PIXCLOCK, 60},
79 {1680, 1050, RES_1680X1050_60HZ_PIXCLOCK, 60},
80 {1680, 1050, RES_1680X1050_75HZ_PIXCLOCK, 75},
81 {1792, 1344, RES_1792X1344_60HZ_PIXCLOCK, 60},
82 {1856, 1392, RES_1856X1392_60HZ_PIXCLOCK, 60},
83 {1920, 1200, RES_1920X1200_60HZ_PIXCLOCK, 60},
84 {1920, 1440, RES_1920X1440_60HZ_PIXCLOCK, 60},
85 {1920, 1440, RES_1920X1440_75HZ_PIXCLOCK, 75},
86 {2048, 1536, RES_2048X1536_60HZ_PIXCLOCK, 60}
87};
88
89struct io_reg CN400_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
90{VIASR, SR15, 0x02, 0x02},
91{VIASR, SR16, 0xBF, 0x08},
92{VIASR, SR17, 0xFF, 0x1F},
93{VIASR, SR18, 0xFF, 0x4E},
94{VIASR, SR1A, 0xFB, 0x08},
95{VIASR, SR1E, 0x0F, 0x01},
96{VIASR, SR2A, 0xFF, 0x00},
97{VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */
98{VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */
99{VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */
100{VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */
101{VIACR, CR32, 0xFF, 0x00},
102{VIACR, CR33, 0xFF, 0x00},
103{VIACR, CR34, 0xFF, 0x00},
104{VIACR, CR35, 0xFF, 0x00},
105{VIACR, CR36, 0x08, 0x00},
106{VIACR, CR62, 0xFF, 0x00}, /* Secondary Display Starting Address */
107{VIACR, CR63, 0xFF, 0x00}, /* Secondary Display Starting Address */
108{VIACR, CR64, 0xFF, 0x00}, /* Secondary Display Starting Address */
109{VIACR, CR69, 0xFF, 0x00},
110{VIACR, CR6A, 0xFF, 0x40},
111{VIACR, CR6B, 0xFF, 0x00},
112{VIACR, CR6C, 0xFF, 0x00},
113{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */
114{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */
115{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */
116{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */
117{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */
118{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */
119{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */
120{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */
121{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */
122{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */
123{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */
124{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */
125{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */
126{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */
127{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */
128{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */
129{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */
130{VIACR, CR8B, 0xFF, 0x69}, /* LCD Power Sequence Control 0 */
131{VIACR, CR8C, 0xFF, 0x57}, /* LCD Power Sequence Control 1 */
132{VIACR, CR8D, 0xFF, 0x00}, /* LCD Power Sequence Control 2 */
133{VIACR, CR8E, 0xFF, 0x7B}, /* LCD Power Sequence Control 3 */
134{VIACR, CR8F, 0xFF, 0x03}, /* LCD Power Sequence Control 4 */
135{VIACR, CR90, 0xFF, 0x30}, /* LCD Power Sequence Control 5 */
136{VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */
137{VIACR, CR96, 0xFF, 0x00},
138{VIACR, CR97, 0xFF, 0x00},
139{VIACR, CR99, 0xFF, 0x00},
140{VIACR, CR9B, 0xFF, 0x00}
141};
142
143/* Video Mode Table for VT3314 chipset*/
144/* Common Setting for Video Mode */
145struct io_reg CN700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
146{VIASR, SR15, 0x02, 0x02},
147{VIASR, SR16, 0xBF, 0x08},
148{VIASR, SR17, 0xFF, 0x1F},
149{VIASR, SR18, 0xFF, 0x4E},
150{VIASR, SR1A, 0xFB, 0x82},
151{VIASR, SR1B, 0xFF, 0xF0},
152{VIASR, SR1F, 0xFF, 0x00},
153{VIASR, SR1E, 0xFF, 0x01},
154{VIASR, SR22, 0xFF, 0x1F},
155{VIASR, SR2A, 0x0F, 0x00},
156{VIASR, SR2E, 0xFF, 0xFF},
157{VIASR, SR3F, 0xFF, 0xFF},
158{VIASR, SR40, 0xF7, 0x00},
159{VIASR, CR30, 0xFF, 0x04},
160{VIACR, CR32, 0xFF, 0x00},
161{VIACR, CR33, 0x7F, 0x00},
162{VIACR, CR34, 0xFF, 0x00},
163{VIACR, CR35, 0xFF, 0x00},
164{VIACR, CR36, 0xFF, 0x31},
165{VIACR, CR41, 0xFF, 0x80},
166{VIACR, CR42, 0xFF, 0x00},
167{VIACR, CR55, 0x80, 0x00},
168{VIACR, CR5D, 0x80, 0x00}, /*Horizontal Retrace Start bit[11] should be 0*/
169{VIACR, CR62, 0xFF, 0x00}, /* Secondary Display Starting Address */
170{VIACR, CR63, 0xFF, 0x00}, /* Secondary Display Starting Address */
171{VIACR, CR64, 0xFF, 0x00}, /* Secondary Display Starting Address */
172{VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */
173{VIACR, CR69, 0xFF, 0x00},
174{VIACR, CR6A, 0xFD, 0x40},
175{VIACR, CR6B, 0xFF, 0x00},
176{VIACR, CR6C, 0xFF, 0x00},
177{VIACR, CR77, 0xFF, 0x00}, /* LCD scaling Factor */
178{VIACR, CR78, 0xFF, 0x00}, /* LCD scaling Factor */
179{VIACR, CR79, 0xFF, 0x00}, /* LCD scaling Factor */
180{VIACR, CR9F, 0x03, 0x00}, /* LCD scaling Factor */
181{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */
182{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */
183{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */
184{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */
185{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */
186{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */
187{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */
188{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */
189{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */
190{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */
191{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */
192{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */
193{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */
194{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */
195{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */
196{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */
197{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */
198{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */
199{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */
200{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */
201{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */
202{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */
203{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */
204{VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */
205{VIACR, CR96, 0xFF, 0x00},
206{VIACR, CR97, 0xFF, 0x00},
207{VIACR, CR99, 0xFF, 0x00},
208{VIACR, CR9B, 0xFF, 0x00},
209{VIACR, CR9D, 0xFF, 0x80},
210{VIACR, CR9E, 0xFF, 0x80}
211};
212
213struct io_reg KM400_ModeXregs[] = {
214 {VIASR, SR10, 0xFF, 0x01}, /* Unlock Register */
215 {VIASR, SR16, 0xFF, 0x08}, /* Display FIFO threshold Control */
216 {VIASR, SR17, 0xFF, 0x1F}, /* Display FIFO Control */
217 {VIASR, SR18, 0xFF, 0x4E}, /* GFX PREQ threshold */
218 {VIASR, SR1A, 0xFF, 0x0a}, /* GFX PREQ threshold */
219 {VIASR, SR1F, 0xFF, 0x00}, /* Memory Control 0 */
220 {VIASR, SR1B, 0xFF, 0xF0}, /* Power Management Control 0 */
221 {VIASR, SR1E, 0xFF, 0x01}, /* Power Management Control */
222 {VIASR, SR20, 0xFF, 0x00}, /* Sequencer Arbiter Control 0 */
223 {VIASR, SR21, 0xFF, 0x00}, /* Sequencer Arbiter Control 1 */
224 {VIASR, SR22, 0xFF, 0x1F}, /* Display Arbiter Control 1 */
225 {VIASR, SR2A, 0xFF, 0x00}, /* Power Management Control 5 */
226 {VIASR, SR2D, 0xFF, 0xFF}, /* Power Management Control 1 */
227 {VIASR, SR2E, 0xFF, 0xFF}, /* Power Management Control 2 */
228 {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */
229 {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */
230 {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */
231 {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */
232 {VIACR, CR33, 0xFF, 0x00},
233 {VIACR, CR55, 0x80, 0x00},
234 {VIACR, CR5D, 0x80, 0x00},
235 {VIACR, CR36, 0xFF, 0x01}, /* Power Mangement 3 */
236 {VIACR, CR62, 0xFF, 0x00}, /* Secondary Display Starting Address */
237 {VIACR, CR63, 0xFF, 0x00}, /* Secondary Display Starting Address */
238 {VIACR, CR64, 0xFF, 0x00}, /* Secondary Display Starting Address */
239 {VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */
240 {VIACR, CR6A, 0x20, 0x20}, /* Extended FIFO On */
241 {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */
242 {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */
243 {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */
244 {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */
245 {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */
246 {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */
247 {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */
248 {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */
249 {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */
250 {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */
251 {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */
252 {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */
253 {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */
254 {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */
255 {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */
256 {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */
257 {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */
258 {VIACR, CR8B, 0xFF, 0x2D}, /* LCD Power Sequence Control 0 */
259 {VIACR, CR8C, 0xFF, 0x2D}, /* LCD Power Sequence Control 1 */
260 {VIACR, CR8D, 0xFF, 0xC8}, /* LCD Power Sequence Control 2 */
261 {VIACR, CR8E, 0xFF, 0x36}, /* LCD Power Sequence Control 3 */
262 {VIACR, CR8F, 0xFF, 0x00}, /* LCD Power Sequence Control 4 */
263 {VIACR, CR90, 0xFF, 0x10}, /* LCD Power Sequence Control 5 */
264 {VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */
265 {VIACR, CR96, 0xFF, 0x03}, /* DVP0 ; DVP0 Clock Skew */
266 {VIACR, CR97, 0xFF, 0x03}, /* DFP high ; DFPH Clock Skew */
267 {VIACR, CR99, 0xFF, 0x03}, /* DFP low ; DFPL Clock Skew*/
268 {VIACR, CR9B, 0xFF, 0x07} /* DVI on DVP1 ; DVP1 Clock Skew*/
269};
270
271/* For VT3324: Common Setting for Video Mode */
272struct io_reg CX700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
273{VIASR, SR15, 0x02, 0x02},
274{VIASR, SR16, 0xBF, 0x08},
275{VIASR, SR17, 0xFF, 0x1F},
276{VIASR, SR18, 0xFF, 0x4E},
277{VIASR, SR1A, 0xFB, 0x08},
278{VIASR, SR1B, 0xFF, 0xF0},
279{VIASR, SR1E, 0xFF, 0x01},
280{VIASR, SR2A, 0xFF, 0x00},
281{VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */
282{VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */
283{VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */
284{VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */
285{VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */
286{VIACR, CR32, 0xFF, 0x00},
287{VIACR, CR33, 0xFF, 0x00},
288{VIACR, CR34, 0xFF, 0x00},
289{VIACR, CR35, 0xFF, 0x00},
290{VIACR, CR36, 0x08, 0x00},
291{VIACR, CR47, 0xC8, 0x00}, /* Clear VCK Plus. */
292{VIACR, CR62, 0xFF, 0x00}, /* Secondary Display Starting Address */
293{VIACR, CR63, 0xFF, 0x00}, /* Secondary Display Starting Address */
294{VIACR, CR64, 0xFF, 0x00}, /* Secondary Display Starting Address */
295{VIACR, CRA3, 0xFF, 0x00}, /* Secondary Display Starting Address */
296{VIACR, CR69, 0xFF, 0x00},
297{VIACR, CR6A, 0xFF, 0x40},
298{VIACR, CR6B, 0xFF, 0x00},
299{VIACR, CR6C, 0xFF, 0x00},
300{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */
301{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */
302{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */
303{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */
304{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */
305{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */
306{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */
307{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */
308{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */
309{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */
310{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */
311{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */
312{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */
313{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */
314{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */
315{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */
316{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */
317{VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */
318{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */
319{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */
320{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */
321{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */
322{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */
323{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */
324{VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */
325{VIACR, CR96, 0xFF, 0x00},
326{VIACR, CR97, 0xFF, 0x00},
327{VIACR, CR99, 0xFF, 0x00},
328{VIACR, CR9B, 0xFF, 0x00},
329{VIACR, CRD2, 0xFF, 0xFF} /* TMDS/LVDS control register. */
330};
331
332/* For VT3353: Common Setting for Video Mode */
333struct io_reg VX800_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01},
334{VIASR, SR15, 0x02, 0x02},
335{VIASR, SR16, 0xBF, 0x08},
336{VIASR, SR17, 0xFF, 0x1F},
337{VIASR, SR18, 0xFF, 0x4E},
338{VIASR, SR1A, 0xFB, 0x08},
339{VIASR, SR1B, 0xFF, 0xF0},
340{VIASR, SR1E, 0xFF, 0x01},
341{VIASR, SR2A, 0xFF, 0x00},
342{VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */
343{VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */
344{VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */
345{VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */
346{VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */
347{VIACR, CR32, 0xFF, 0x00},
348{VIACR, CR33, 0xFF, 0x00},
349{VIACR, CR34, 0xFF, 0x00},
350{VIACR, CR35, 0xFF, 0x00},
351{VIACR, CR36, 0x08, 0x00},
352{VIACR, CR47, 0xC8, 0x00}, /* Clear VCK Plus. */
353{VIACR, CR62, 0xFF, 0x00}, /* Secondary Display Starting Address */
354{VIACR, CR63, 0xFF, 0x00}, /* Secondary Display Starting Address */
355{VIACR, CR64, 0xFF, 0x00}, /* Secondary Display Starting Address */
356{VIACR, CRA3, 0xFF, 0x00}, /* Secondary Display Starting Address */
357{VIACR, CR69, 0xFF, 0x00},
358{VIACR, CR6A, 0xFF, 0x40},
359{VIACR, CR6B, 0xFF, 0x00},
360{VIACR, CR6C, 0xFF, 0x00},
361{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */
362{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */
363{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */
364{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */
365{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */
366{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */
367{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */
368{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */
369{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */
370{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */
371{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */
372{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */
373{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */
374{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */
375{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */
376{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */
377{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */
378{VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */
379{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */
380{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */
381{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */
382{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */
383{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */
384{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */
385{VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */
386{VIACR, CR96, 0xFF, 0x00},
387{VIACR, CR97, 0xFF, 0x00},
388{VIACR, CR99, 0xFF, 0x00},
389{VIACR, CR9B, 0xFF, 0x00},
390{VIACR, CRD2, 0xFF, 0xFF} /* TMDS/LVDS control register. */
391};
392
393/* Video Mode Table */
394/* Common Setting for Video Mode */
395struct io_reg CLE266_ModeXregs[] = { {VIASR, SR1E, 0xF0, 0x00},
396{VIASR, SR2A, 0x0F, 0x00},
397{VIASR, SR15, 0x02, 0x02},
398{VIASR, SR16, 0xBF, 0x08},
399{VIASR, SR17, 0xFF, 0x1F},
400{VIASR, SR18, 0xFF, 0x4E},
401{VIASR, SR1A, 0xFB, 0x08},
402
403{VIACR, CR32, 0xFF, 0x00},
404{VIACR, CR34, 0xFF, 0x00},
405{VIACR, CR35, 0xFF, 0x00},
406{VIACR, CR36, 0x08, 0x00},
407{VIACR, CR6A, 0xFF, 0x80},
408{VIACR, CR6A, 0xFF, 0xC0},
409
410{VIACR, CR55, 0x80, 0x00},
411{VIACR, CR5D, 0x80, 0x00},
412
413{VIAGR, GR20, 0xFF, 0x00},
414{VIAGR, GR21, 0xFF, 0x00},
415{VIAGR, GR22, 0xFF, 0x00},
416 /* LCD Parameters */
417{VIACR, CR7A, 0xFF, 0x01}, /* LCD Parameter 1 */
418{VIACR, CR7B, 0xFF, 0x02}, /* LCD Parameter 2 */
419{VIACR, CR7C, 0xFF, 0x03}, /* LCD Parameter 3 */
420{VIACR, CR7D, 0xFF, 0x04}, /* LCD Parameter 4 */
421{VIACR, CR7E, 0xFF, 0x07}, /* LCD Parameter 5 */
422{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Parameter 6 */
423{VIACR, CR80, 0xFF, 0x0D}, /* LCD Parameter 7 */
424{VIACR, CR81, 0xFF, 0x13}, /* LCD Parameter 8 */
425{VIACR, CR82, 0xFF, 0x16}, /* LCD Parameter 9 */
426{VIACR, CR83, 0xFF, 0x19}, /* LCD Parameter 10 */
427{VIACR, CR84, 0xFF, 0x1C}, /* LCD Parameter 11 */
428{VIACR, CR85, 0xFF, 0x1D}, /* LCD Parameter 12 */
429{VIACR, CR86, 0xFF, 0x1E}, /* LCD Parameter 13 */
430{VIACR, CR87, 0xFF, 0x1F}, /* LCD Parameter 14 */
431
432};
433
434/* Mode:1024X768 */
435struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C},
436{VIASR, 0x18, 0xFF, 0x4C}
437};
438
439struct patch_table res_patch_table[] = {
440 {VIA_RES_1024X768, ARRAY_SIZE(PM1024x768), PM1024x768}
441};
442
443/* struct VPITTable {
444 unsigned char Misc;
445 unsigned char SR[StdSR];
446 unsigned char CR[StdCR];
447 unsigned char GR[StdGR];
448 unsigned char AR[StdAR];
449 };*/
450
451struct VPITTable VPIT = {
452 /* Msic */
453 0xC7,
454 /* Sequencer */
455 {0x01, 0x0F, 0x00, 0x0E},
456 /* Graphic Controller */
457 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
458 /* Attribute Controller */
459 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
460 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
461 0x01, 0x00, 0x0F, 0x00}
462};
463
464/********************/
465/* Mode Table */
466/********************/
467
468/* 480x640 */
469struct crt_mode_table CRTM480x640[] = {
470 /* r_rate, vclk, hsp, vsp */
471 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
472 {REFRESH_60, CLK_25_175M, M480X640_R60_HSP, M480X640_R60_VSP,
473 {624, 480, 480, 144, 504, 48, 663, 640, 640, 23, 641, 3} } /* GTF*/
474};
475
476/* 640x480*/
477struct crt_mode_table CRTM640x480[] = {
478 /*r_rate,vclk,hsp,vsp */
479 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
480 {REFRESH_60, CLK_25_175M, M640X480_R60_HSP, M640X480_R60_VSP,
481 {800, 640, 648, 144, 656, 96, 525, 480, 480, 45, 490, 2} },
482 {REFRESH_75, CLK_31_500M, M640X480_R75_HSP, M640X480_R75_VSP,
483 {840, 640, 640, 200, 656, 64, 500, 480, 480, 20, 481, 3} },
484 {REFRESH_85, CLK_36_000M, M640X480_R85_HSP, M640X480_R85_VSP,
485 {832, 640, 640, 192, 696, 56, 509, 480, 480, 29, 481, 3} },
486 {REFRESH_100, CLK_43_163M, M640X480_R100_HSP, M640X480_R100_VSP,
487 {848, 640, 640, 208, 680, 64, 509, 480, 480, 29, 481, 3} }, /*GTF*/
488 {REFRESH_120, CLK_52_406M, M640X480_R120_HSP,
489 M640X480_R120_VSP,
490 {848, 640, 640, 208, 680, 64, 515, 480, 480, 35, 481,
491 3} } /*GTF*/
492};
493
494/*720x480 (GTF)*/
495struct crt_mode_table CRTM720x480[] = {
496 /*r_rate,vclk,hsp,vsp */
497 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
498 {REFRESH_60, CLK_26_880M, M720X480_R60_HSP, M720X480_R60_VSP,
499 {896, 720, 720, 176, 736, 72, 497, 480, 480, 17, 481, 3} }
500
501};
502
503/*720x576 (GTF)*/
504struct crt_mode_table CRTM720x576[] = {
505 /*r_rate,vclk,hsp,vsp */
506 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
507 {REFRESH_60, CLK_32_668M, M720X576_R60_HSP, M720X576_R60_VSP,
508 {912, 720, 720, 192, 744, 72, 597, 576, 576, 21, 577, 3} }
509};
510
511/* 800x480 (CVT) */
512struct crt_mode_table CRTM800x480[] = {
513 /* r_rate, vclk, hsp, vsp */
514 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
515 {REFRESH_60, CLK_29_581M, M800X480_R60_HSP, M800X480_R60_VSP,
516 {992, 800, 800, 192, 824, 72, 500, 480, 480, 20, 483, 7} }
517};
518
519/* 800x600*/
520struct crt_mode_table CRTM800x600[] = {
521 /*r_rate,vclk,hsp,vsp */
522 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
523 {REFRESH_60, CLK_40_000M, M800X600_R60_HSP, M800X600_R60_VSP,
524 {1056, 800, 800, 256, 840, 128, 628, 600, 600, 28, 601, 4} },
525 {REFRESH_75, CLK_49_500M, M800X600_R75_HSP, M800X600_R75_VSP,
526 {1056, 800, 800, 256, 816, 80, 625, 600, 600, 25, 601, 3} },
527 {REFRESH_85, CLK_56_250M, M800X600_R85_HSP, M800X600_R85_VSP,
528 {1048, 800, 800, 248, 832, 64, 631, 600, 600, 31, 601, 3} },
529 {REFRESH_100, CLK_68_179M, M800X600_R100_HSP, M800X600_R100_VSP,
530 {1072, 800, 800, 272, 848, 88, 636, 600, 600, 36, 601, 3} },
531 {REFRESH_120, CLK_83_950M, M800X600_R120_HSP,
532 M800X600_R120_VSP,
533 {1088, 800, 800, 288, 856, 88, 643, 600, 600, 43, 601,
534 3} }
535};
536
537/* 848x480 (CVT) */
538struct crt_mode_table CRTM848x480[] = {
539 /* r_rate, vclk, hsp, vsp */
540 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
541 {REFRESH_60, CLK_31_500M, M848X480_R60_HSP, M848X480_R60_VSP,
542 {1056, 848, 848, 208, 872, 80, 500, 480, 480, 20, 483, 5} }
543};
544
545/*856x480 (GTF) convert to 852x480*/
546struct crt_mode_table CRTM852x480[] = {
547 /*r_rate,vclk,hsp,vsp */
548 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
549 {REFRESH_60, CLK_31_728M, M852X480_R60_HSP, M852X480_R60_VSP,
550 {1064, 856, 856, 208, 872, 88, 497, 480, 480, 17, 481, 3} }
551};
552
553/*1024x512 (GTF)*/
554struct crt_mode_table CRTM1024x512[] = {
555 /*r_rate,vclk,hsp,vsp */
556 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
557 {REFRESH_60, CLK_41_291M, M1024X512_R60_HSP, M1024X512_R60_VSP,
558 {1296, 1024, 1024, 272, 1056, 104, 531, 512, 512, 19, 513, 3} }
559
560};
561
562/* 1024x600*/
563struct crt_mode_table CRTM1024x600[] = {
564 /*r_rate,vclk,hsp,vsp */
565 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
566 {REFRESH_60, CLK_48_875M, M1024X600_R60_HSP, M1024X600_R60_VSP,
567 {1312, 1024, 1024, 288, 1064, 104, 622, 600, 600, 22, 601, 3} },
568};
569
570/* 1024x768*/
571struct crt_mode_table CRTM1024x768[] = {
572 /*r_rate,vclk,hsp,vsp */
573 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
574 {REFRESH_60, CLK_65_000M, M1024X768_R60_HSP, M1024X768_R60_VSP,
575 {1344, 1024, 1024, 320, 1048, 136, 806, 768, 768, 38, 771, 6} },
576 {REFRESH_75, CLK_78_750M, M1024X768_R75_HSP, M1024X768_R75_VSP,
577 {1312, 1024, 1024, 288, 1040, 96, 800, 768, 768, 32, 769, 3} },
578 {REFRESH_85, CLK_94_500M, M1024X768_R85_HSP, M1024X768_R85_VSP,
579 {1376, 1024, 1024, 352, 1072, 96, 808, 768, 768, 40, 769, 3} },
580 {REFRESH_100, CLK_113_309M, M1024X768_R100_HSP, M1024X768_R100_VSP,
581 {1392, 1024, 1024, 368, 1096, 112, 814, 768, 768, 46, 769, 3} }
582};
583
584/* 1152x864*/
585struct crt_mode_table CRTM1152x864[] = {
586 /*r_rate,vclk,hsp,vsp */
587 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
588 {REFRESH_75, CLK_108_000M, M1152X864_R75_HSP, M1152X864_R75_VSP,
589 {1600, 1152, 1152, 448, 1216, 128, 900, 864, 864, 36, 865, 3} }
590
591};
592
593/* 1280x720 (HDMI 720P)*/
594struct crt_mode_table CRTM1280x720[] = {
595 /*r_rate,vclk,hsp,vsp */
596 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
597 {REFRESH_60, CLK_74_481M, M1280X720_R60_HSP, M1280X720_R60_VSP,
598 {1648, 1280, 1280, 368, 1392, 40, 750, 720, 720, 30, 725, 5} },
599 {REFRESH_50, CLK_60_466M, M1280X720_R50_HSP, M1280X720_R50_VSP,
600 {1632, 1280, 1280, 352, 1328, 128, 741, 720, 720, 21, 721, 3} }
601};
602
603/*1280x768 (GTF)*/
604struct crt_mode_table CRTM1280x768[] = {
605 /*r_rate,vclk,hsp,vsp */
606 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
607 {REFRESH_60, CLK_80_136M, M1280X768_R60_HSP, M1280X768_R60_VSP,
608 {1680, 1280, 1280, 400, 1344, 136, 795, 768, 768, 27, 769, 3} },
609 {REFRESH_50, CLK_65_178M, M1280X768_R50_HSP, M1280X768_R50_VSP,
610 {1648, 1280, 1280, 368, 1336, 128, 791, 768, 768, 23, 769, 3} }
611};
612
613/* 1280x800 (CVT) */
614struct crt_mode_table CRTM1280x800[] = {
615 /* r_rate, vclk, hsp, vsp */
616 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
617 {REFRESH_60, CLK_83_375M, M1280X800_R60_HSP, M1280X800_R60_VSP,
618 {1680, 1280, 1280, 400, 1352, 128, 831, 800, 800, 31, 803, 6} }
619};
620
621/*1280x960*/
622struct crt_mode_table CRTM1280x960[] = {
623 /*r_rate,vclk,hsp,vsp */
624 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
625 {REFRESH_60, CLK_108_000M, M1280X960_R60_HSP, M1280X960_R60_VSP,
626 {1800, 1280, 1280, 520, 1376, 112, 1000, 960, 960, 40, 961, 3} }
627};
628
629/* 1280x1024*/
630struct crt_mode_table CRTM1280x1024[] = {
631 /*r_rate,vclk,,hsp,vsp */
632 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
633 {REFRESH_60, CLK_108_000M, M1280X1024_R60_HSP, M1280X1024_R60_VSP,
634 {1688, 1280, 1280, 408, 1328, 112, 1066, 1024, 1024, 42, 1025,
635 3} },
636 {REFRESH_75, CLK_135_000M, M1280X1024_R75_HSP, M1280X1024_R75_VSP,
637 {1688, 1280, 1280, 408, 1296, 144, 1066, 1024, 1024, 42, 1025,
638 3} },
639 {REFRESH_85, CLK_157_500M, M1280X1024_R85_HSP, M1280X1024_R85_VSP,
640 {1728, 1280, 1280, 448, 1344, 160, 1072, 1024, 1024, 48, 1025, 3} }
641};
642
643/* 1368x768 (GTF) */
644struct crt_mode_table CRTM1368x768[] = {
645 /* r_rate, vclk, hsp, vsp */
646 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
647 {REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP,
648 {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} }
649};
650
651/*1440x1050 (GTF)*/
652struct crt_mode_table CRTM1440x1050[] = {
653 /*r_rate,vclk,hsp,vsp */
654 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
655 {REFRESH_60, CLK_125_104M, M1440X1050_R60_HSP, M1440X1050_R60_VSP,
656 {1936, 1440, 1440, 496, 1536, 152, 1077, 1040, 1040, 37, 1041, 3} }
657};
658
659/* 1600x1200*/
660struct crt_mode_table CRTM1600x1200[] = {
661 /*r_rate,vclk,hsp,vsp */
662 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
663 {REFRESH_60, CLK_162_000M, M1600X1200_R60_HSP, M1600X1200_R60_VSP,
664 {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201,
665 3} },
666 {REFRESH_75, CLK_202_500M, M1600X1200_R75_HSP, M1600X1200_R75_VSP,
667 {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201, 3} }
668
669};
670
671/* 1680x1050 (CVT) */
672struct crt_mode_table CRTM1680x1050[] = {
673 /* r_rate, vclk, hsp, vsp */
674 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
675 {REFRESH_60, CLK_146_760M, M1680x1050_R60_HSP, M1680x1050_R60_VSP,
676 {2240, 1680, 1680, 560, 1784, 176, 1089, 1050, 1050, 39, 1053,
677 6} },
678 {REFRESH_75, CLK_187_000M, M1680x1050_R75_HSP, M1680x1050_R75_VSP,
679 {2272, 1680, 1680, 592, 1800, 176, 1099, 1050, 1050, 49, 1053, 6} }
680};
681
682/* 1680x1050 (CVT Reduce Blanking) */
683struct crt_mode_table CRTM1680x1050_RB[] = {
684 /* r_rate, vclk, hsp, vsp */
685 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
686 {REFRESH_60, CLK_119_000M, M1680x1050_RB_R60_HSP,
687 M1680x1050_RB_R60_VSP,
688 {1840, 1680, 1680, 160, 1728, 32, 1080, 1050, 1050, 30, 1053, 6} }
689};
690
691/* 1920x1080 (CVT)*/
692struct crt_mode_table CRTM1920x1080[] = {
693 /*r_rate,vclk,hsp,vsp */
694 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
695 {REFRESH_60, CLK_172_798M, M1920X1080_R60_HSP, M1920X1080_R60_VSP,
696 {2576, 1920, 1920, 656, 2048, 200, 1120, 1080, 1080, 40, 1083, 5} }
697};
698
699/* 1920x1080 (CVT with Reduce Blanking) */
700struct crt_mode_table CRTM1920x1080_RB[] = {
701 /* r_rate, vclk, hsp, vsp */
702 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
703 {REFRESH_60, CLK_138_400M, M1920X1080_RB_R60_HSP,
704 M1920X1080_RB_R60_VSP,
705 {2080, 1920, 1920, 160, 1968, 32, 1111, 1080, 1080, 31, 1083, 5} }
706};
707
708/* 1920x1440*/
709struct crt_mode_table CRTM1920x1440[] = {
710 /*r_rate,vclk,hsp,vsp */
711 /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
712 {REFRESH_60, CLK_234_000M, M1920X1440_R60_HSP, M1920X1440_R60_VSP,
713 {2600, 1920, 1920, 680, 2048, 208, 1500, 1440, 1440, 60, 1441,
714 3} },
715 {REFRESH_75, CLK_297_500M, M1920X1440_R75_HSP, M1920X1440_R75_VSP,
716 {2640, 1920, 1920, 720, 2064, 224, 1500, 1440, 1440, 60, 1441, 3} }
717};
718
719/* 1400x1050 (CVT) */
720struct crt_mode_table CRTM1400x1050[] = {
721 /* r_rate, vclk, hsp, vsp */
722 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
723 {REFRESH_60, CLK_121_750M, M1400X1050_R60_HSP, M1400X1050_R60_VSP,
724 {1864, 1400, 1400, 464, 1488, 144, 1089, 1050, 1050, 39, 1053,
725 4} },
726 {REFRESH_75, CLK_156_000M, M1400X1050_R75_HSP, M1400X1050_R75_VSP,
727 {1896, 1400, 1400, 496, 1504, 144, 1099, 1050, 1050, 49, 1053, 4} }
728};
729
730/* 1400x1050 (CVT Reduce Blanking) */
731struct crt_mode_table CRTM1400x1050_RB[] = {
732 /* r_rate, vclk, hsp, vsp */
733 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
734 {REFRESH_60, CLK_101_000M, M1400X1050_RB_R60_HSP,
735 M1400X1050_RB_R60_VSP,
736 {1560, 1400, 1400, 160, 1448, 32, 1080, 1050, 1050, 30, 1053, 4} }
737};
738
739/* 960x600 (CVT) */
740struct crt_mode_table CRTM960x600[] = {
741 /* r_rate, vclk, hsp, vsp */
742 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
743 {REFRESH_60, CLK_45_250M, M960X600_R60_HSP, M960X600_R60_VSP,
744 {1216, 960, 960, 256, 992, 96, 624, 600, 600, 24, 603, 6} }
745};
746
747/* 1000x600 (GTF) */
748struct crt_mode_table CRTM1000x600[] = {
749 /* r_rate, vclk, hsp, vsp */
750 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
751 {REFRESH_60, CLK_48_000M, M1000X600_R60_HSP, M1000X600_R60_VSP,
752 {1288, 1000, 1000, 288, 1040, 104, 622, 600, 600, 22, 601, 3} }
753};
754
755/* 1024x576 (GTF) */
756struct crt_mode_table CRTM1024x576[] = {
757 /* r_rate, vclk, hsp, vsp */
758 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
759 {REFRESH_60, CLK_46_996M, M1024X576_R60_HSP, M1024X576_R60_VSP,
760 {1312, 1024, 1024, 288, 1064, 104, 597, 576, 576, 21, 577, 3} }
761};
762
763/* 1088x612 (CVT) */
764struct crt_mode_table CRTM1088x612[] = {
765 /* r_rate, vclk, hsp, vsp */
766 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
767 {REFRESH_60, CLK_52_977M, M1088X612_R60_HSP, M1088X612_R60_VSP,
768 {1392, 1088, 1088, 304, 1136, 104, 636, 612, 612, 24, 615, 5} }
769};
770
771/* 1152x720 (CVT) */
772struct crt_mode_table CRTM1152x720[] = {
773 /* r_rate, vclk, hsp, vsp */
774 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
775 {REFRESH_60, CLK_66_750M, M1152X720_R60_HSP, M1152X720_R60_VSP,
776 {1488, 1152, 1152, 336, 1208, 112, 748, 720, 720, 28, 723, 6} }
777};
778
779/* 1200x720 (GTF) */
780struct crt_mode_table CRTM1200x720[] = {
781 /* r_rate, vclk, hsp, vsp */
782 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
783 {REFRESH_60, CLK_70_159M, M1200X720_R60_HSP, M1200X720_R60_VSP,
784 {1568, 1200, 1200, 368, 1256, 128, 746, 720, 720, 26, 721, 3} }
785};
786
787/* 1280x600 (GTF) */
788struct crt_mode_table CRTM1280x600[] = {
789 /* r_rate, vclk, hsp, vsp */
790 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
791 {REFRESH_60, CLK_61_500M, M1280x600_R60_HSP, M1280x600_R60_VSP,
792 {1648, 1280, 1280, 368, 1336, 128, 622, 600, 600, 22, 601, 3} }
793};
794
795/* 1360x768 (CVT) */
796struct crt_mode_table CRTM1360x768[] = {
797 /* r_rate, vclk, hsp, vsp */
798 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
799 {REFRESH_60, CLK_84_750M, M1360X768_R60_HSP, M1360X768_R60_VSP,
800 {1776, 1360, 1360, 416, 1432, 136, 798, 768, 768, 30, 771, 5} }
801};
802
803/* 1360x768 (CVT Reduce Blanking) */
804struct crt_mode_table CRTM1360x768_RB[] = {
805 /* r_rate, vclk, hsp, vsp */
806 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
807 {REFRESH_60, CLK_72_000M, M1360X768_RB_R60_HSP,
808 M1360X768_RB_R60_VSP,
809 {1520, 1360, 1360, 160, 1408, 32, 790, 768, 768, 22, 771, 5} }
810};
811
812/* 1366x768 (GTF) */
813struct crt_mode_table CRTM1366x768[] = {
814 /* r_rate, vclk, hsp, vsp */
815 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
816 {REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP,
817 {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} },
818 {REFRESH_50, CLK_69_924M, M1368X768_R50_HSP, M1368X768_R50_VSP,
819 {1768, 1368, 1368, 400, 1424, 144, 791, 768, 768, 23, 769, 3} }
820};
821
822/* 1440x900 (CVT) */
823struct crt_mode_table CRTM1440x900[] = {
824 /* r_rate, vclk, hsp, vsp */
825 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
826 {REFRESH_60, CLK_106_500M, M1440X900_R60_HSP, M1440X900_R60_VSP,
827 {1904, 1440, 1440, 464, 1520, 152, 934, 900, 900, 34, 903, 6} },
828 {REFRESH_75, CLK_136_700M, M1440X900_R75_HSP, M1440X900_R75_VSP,
829 {1936, 1440, 1440, 496, 1536, 152, 942, 900, 900, 42, 903, 6} }
830};
831
832/* 1440x900 (CVT Reduce Blanking) */
833struct crt_mode_table CRTM1440x900_RB[] = {
834 /* r_rate, vclk, hsp, vsp */
835 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
836 {REFRESH_60, CLK_88_750M, M1440X900_RB_R60_HSP,
837 M1440X900_RB_R60_VSP,
838 {1600, 1440, 1440, 160, 1488, 32, 926, 900, 900, 26, 903, 6} }
839};
840
841/* 1600x900 (CVT) */
842struct crt_mode_table CRTM1600x900[] = {
843 /* r_rate, vclk, hsp, vsp */
844 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
845 {REFRESH_60, CLK_118_840M, M1600X900_R60_HSP, M1600X900_R60_VSP,
846 {2112, 1600, 1600, 512, 1688, 168, 934, 900, 900, 34, 903, 5} }
847};
848
849/* 1600x900 (CVT Reduce Blanking) */
850struct crt_mode_table CRTM1600x900_RB[] = {
851 /* r_rate, vclk, hsp, vsp */
852 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
853 {REFRESH_60, CLK_97_750M, M1600X900_RB_R60_HSP,
854 M1600X900_RB_R60_VSP,
855 {1760, 1600, 1600, 160, 1648, 32, 926, 900, 900, 26, 903, 5} }
856};
857
858/* 1600x1024 (GTF) */
859struct crt_mode_table CRTM1600x1024[] = {
860 /* r_rate, vclk, hsp, vsp */
861 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
862 {REFRESH_60, CLK_136_700M, M1600X1024_R60_HSP, M1600X1024_R60_VSP,
863 {2144, 1600, 1600, 544, 1704, 168, 1060, 1024, 1024, 36, 1025, 3} }
864};
865
866/* 1792x1344 (DMT) */
867struct crt_mode_table CRTM1792x1344[] = {
868 /* r_rate, vclk, hsp, vsp */
869 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
870 {REFRESH_60, CLK_204_000M, M1792x1344_R60_HSP, M1792x1344_R60_VSP,
871 {2448, 1792, 1792, 656, 1920, 200, 1394, 1344, 1344, 50, 1345, 3} }
872};
873
874/* 1856x1392 (DMT) */
875struct crt_mode_table CRTM1856x1392[] = {
876 /* r_rate, vclk, hsp, vsp */
877 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
878 {REFRESH_60, CLK_218_500M, M1856x1392_R60_HSP, M1856x1392_R60_VSP,
879 {2528, 1856, 1856, 672, 1952, 224, 1439, 1392, 1392, 47, 1393, 3} }
880};
881
882/* 1920x1200 (CVT) */
883struct crt_mode_table CRTM1920x1200[] = {
884 /* r_rate, vclk, hsp, vsp */
885 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
886 {REFRESH_60, CLK_193_295M, M1920X1200_R60_HSP, M1920X1200_R60_VSP,
887 {2592, 1920, 1920, 672, 2056, 200, 1245, 1200, 1200, 45, 1203, 6} }
888};
889
890/* 1920x1200 (CVT with Reduce Blanking) */
891struct crt_mode_table CRTM1920x1200_RB[] = {
892 /* r_rate, vclk, hsp, vsp */
893 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
894 {REFRESH_60, CLK_153_920M, M1920X1200_RB_R60_HSP,
895 M1920X1200_RB_R60_VSP,
896 {2080, 1920, 1920, 160, 1968, 32, 1235, 1200, 1200, 35, 1203, 6} }
897};
898
899/* 2048x1536 (CVT) */
900struct crt_mode_table CRTM2048x1536[] = {
901 /* r_rate, vclk, hsp, vsp */
902 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
903 {REFRESH_60, CLK_267_250M, M2048x1536_R60_HSP, M2048x1536_R60_VSP,
904 {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} }
905};
906
907/* Video Mode Table */
908/* struct VideoModeTable {*/
909/* int ModeIndex;*/
910/* struct crt_mode_table *crtc;*/
911/* int mode_array;*/
912/* };*/
913struct VideoModeTable CLE266Modes[] = {
914 /* Display : 480x640 (GTF) */
915 {VIA_RES_480X640, CRTM480x640, ARRAY_SIZE(CRTM480x640)},
916
917 /* Display : 640x480 */
918 {VIA_RES_640X480, CRTM640x480, ARRAY_SIZE(CRTM640x480)},
919
920 /* Display : 720x480 (GTF) */
921 {VIA_RES_720X480, CRTM720x480, ARRAY_SIZE(CRTM720x480)},
922
923 /* Display : 720x576 (GTF) */
924 {VIA_RES_720X576, CRTM720x576, ARRAY_SIZE(CRTM720x576)},
925
926 /* Display : 800x600 */
927 {VIA_RES_800X600, CRTM800x600, ARRAY_SIZE(CRTM800x600)},
928
929 /* Display : 800x480 (CVT) */
930 {VIA_RES_800X480, CRTM800x480, ARRAY_SIZE(CRTM800x480)},
931
932 /* Display : 848x480 (CVT) */
933 {VIA_RES_848X480, CRTM848x480, ARRAY_SIZE(CRTM848x480)},
934
935 /* Display : 852x480 (GTF) */
936 {VIA_RES_856X480, CRTM852x480, ARRAY_SIZE(CRTM852x480)},
937
938 /* Display : 1024x512 (GTF) */
939 {VIA_RES_1024X512, CRTM1024x512, ARRAY_SIZE(CRTM1024x512)},
940
941 /* Display : 1024x600 */
942 {VIA_RES_1024X600, CRTM1024x600, ARRAY_SIZE(CRTM1024x600)},
943
944 /* Display : 1024x576 (GTF) */
945 /*{ VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, */
946
947 /* Display : 1024x768 */
948 {VIA_RES_1024X768, CRTM1024x768, ARRAY_SIZE(CRTM1024x768)},
949
950 /* Display : 1152x864 */
951 {VIA_RES_1152X864, CRTM1152x864, ARRAY_SIZE(CRTM1152x864)},
952
953 /* Display : 1280x768 (GTF) */
954 {VIA_RES_1280X768, CRTM1280x768, ARRAY_SIZE(CRTM1280x768)},
955
956 /* Display : 960x600 (CVT) */
957 {VIA_RES_960X600, CRTM960x600, ARRAY_SIZE(CRTM960x600)},
958
959 /* Display : 1000x600 (GTF) */
960 {VIA_RES_1000X600, CRTM1000x600, ARRAY_SIZE(CRTM1000x600)},
961
962 /* Display : 1024x576 (GTF) */
963 {VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)},
964
965 /* Display : 1088x612 (GTF) */
966 {VIA_RES_1088X612, CRTM1088x612, ARRAY_SIZE(CRTM1088x612)},
967
968 /* Display : 1152x720 (CVT) */
969 {VIA_RES_1152X720, CRTM1152x720, ARRAY_SIZE(CRTM1152x720)},
970
971 /* Display : 1200x720 (GTF) */
972 {VIA_RES_1200X720, CRTM1200x720, ARRAY_SIZE(CRTM1200x720)},
973
974 /* Display : 1280x600 (GTF) */
975 {VIA_RES_1280X600, CRTM1280x600, ARRAY_SIZE(CRTM1280x600)},
976
977 /* Display : 1280x800 (CVT) */
978 {VIA_RES_1280X800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)},
979
980 /* Display : 1280x800 (GTF) */
981 /*{ M1280x800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, */
982
983 /* Display : 1280x960 */
984 {VIA_RES_1280X960, CRTM1280x960, ARRAY_SIZE(CRTM1280x960)},
985
986 /* Display : 1280x1024 */
987 {VIA_RES_1280X1024, CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)},
988
989 /* Display : 1360x768 (CVT) */
990 {VIA_RES_1360X768, CRTM1360x768, ARRAY_SIZE(CRTM1360x768)},
991
992 /* Display : 1360x768 (CVT Reduce Blanking) */
993 {VIA_RES_1360X768_RB, CRTM1360x768_RB,
994 ARRAY_SIZE(CRTM1360x768_RB)},
995
996 /* Display : 1366x768 */
997 {VIA_RES_1366X768, CRTM1366x768, ARRAY_SIZE(CRTM1366x768)},
998
999 /* Display : 1368x768 (GTF) */
1000 /*{ M1368x768,CRTM1368x768,ARRAY_SIZE(CRTM1368x768)}, */
1001 /* Display : 1368x768 (GTF) */
1002 {VIA_RES_1368X768, CRTM1368x768, ARRAY_SIZE(CRTM1368x768)},
1003
1004 /* Display : 1440x900 (CVT) */
1005 {VIA_RES_1440X900, CRTM1440x900, ARRAY_SIZE(CRTM1440x900)},
1006
1007 /* Display : 1440x900 (CVT Reduce Blanking) */
1008 {VIA_RES_1440X900_RB, CRTM1440x900_RB,
1009 ARRAY_SIZE(CRTM1440x900_RB)},
1010
1011 /* Display : 1440x1050 (GTF) */
1012 {VIA_RES_1440X1050, CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)},
1013
1014 /* Display : 1400x1050 (CVT Reduce Blanking) */
1015 {VIA_RES_1400X1050_RB, CRTM1400x1050_RB,
1016 ARRAY_SIZE(CRTM1400x1050_RB)},
1017
1018 /* Display : 1600x900 (CVT) */
1019 {VIA_RES_1600X900, CRTM1600x900, ARRAY_SIZE(CRTM1600x900)},
1020
1021 /* Display : 1600x900 (CVT Reduce Blanking) */
1022 {VIA_RES_1600X900_RB, CRTM1600x900_RB,
1023 ARRAY_SIZE(CRTM1600x900_RB)},
1024
1025 /* Display : 1600x1024 (GTF) */
1026 {VIA_RES_1600X1024, CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)},
1027
1028 /* Display : 1600x1200 */
1029 {VIA_RES_1600X1200, CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)},
1030
1031 /* Display : 1680x1050 (CVT) */
1032 {VIA_RES_1680X1050, CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)},
1033
1034 /* Display : 1680x1050 (CVT Reduce Blanking) */
1035 {VIA_RES_1680X1050_RB, CRTM1680x1050_RB,
1036 ARRAY_SIZE(CRTM1680x1050_RB)},
1037
1038 /* Display : 1792x1344 (DMT) */
1039 {VIA_RES_1792X1344, CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)},
1040
1041 /* Display : 1856x1392 (DMT) */
1042 {VIA_RES_1856X1392, CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)},
1043
1044 /* Display : 1920x1440 */
1045 {VIA_RES_1920X1440, CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)},
1046
1047 /* Display : 2048x1536 */
1048 {VIA_RES_2048X1536, CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)},
1049
1050 /* Display : 1280x720 */
1051 {VIA_RES_1280X720, CRTM1280x720, ARRAY_SIZE(CRTM1280x720)},
1052
1053 /* Display : 1920x1080 (CVT) */
1054 {VIA_RES_1920X1080, CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)},
1055
1056 /* Display : 1920x1080 (CVT Reduce Blanking) */
1057 {VIA_RES_1920X1080_RB, CRTM1920x1080_RB,
1058 ARRAY_SIZE(CRTM1920x1080_RB)},
1059
1060 /* Display : 1920x1200 (CVT) */
1061 {VIA_RES_1920X1200, CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)},
1062
1063 /* Display : 1920x1200 (CVT Reduce Blanking) */
1064 {VIA_RES_1920X1200_RB, CRTM1920x1200_RB,
1065 ARRAY_SIZE(CRTM1920x1200_RB)},
1066
1067 /* Display : 1400x1050 (CVT) */
1068 {VIA_RES_1400X1050, CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)}
1069};
1070struct crt_mode_table CEAM1280x720[] = {
1071 {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP,
1072 M1280X720_CEA_R60_VSP,
1073 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
1074 {1650, 1280, 1280, 370, 1390, 40, 750, 720, 720, 30, 725, 5} }
1075};
1076struct crt_mode_table CEAM1920x1080[] = {
1077 {REFRESH_60, CLK_148_500M, M1920X1080_CEA_R60_HSP,
1078 M1920X1080_CEA_R60_VSP,
1079 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */
1080 {2200, 1920, 1920, 300, 2008, 44, 1125, 1080, 1080, 45, 1084, 5} }
1081};
1082struct VideoModeTable CEA_HDMI_Modes[] = {
1083 /* Display : 1280x720 */
1084 {VIA_RES_1280X720, CEAM1280x720, ARRAY_SIZE(CEAM1280x720)},
1085 {VIA_RES_1920X1080, CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)}
1086};
diff --git a/drivers/video/via/viamode.h b/drivers/video/via/viamode.h
new file mode 100644
index 000000000000..1a5de50a23a2
--- /dev/null
+++ b/drivers/video/via/viamode.h
@@ -0,0 +1,177 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __VIAMODE_H__
23#define __VIAMODE_H__
24
25#include "global.h"
26
27struct VPITTable {
28 unsigned char Misc;
29 unsigned char SR[StdSR];
30 unsigned char GR[StdGR];
31 unsigned char AR[StdAR];
32};
33
34struct VideoModeTable {
35 int ModeIndex;
36 struct crt_mode_table *crtc;
37 int mode_array;
38};
39
40struct patch_table {
41 int mode_index;
42 int table_length;
43 struct io_reg *io_reg_table;
44};
45
46struct res_map_refresh {
47 int hres;
48 int vres;
49 int pixclock;
50 int vmode_refresh;
51};
52
53#define NUM_TOTAL_RES_MAP_REFRESH ARRAY_SIZE(res_map_refresh_tbl)
54#define NUM_TOTAL_CEA_MODES ARRAY_SIZE(CEA_HDMI_Modes)
55#define NUM_TOTAL_CN400_ModeXregs ARRAY_SIZE(CN400_ModeXregs)
56#define NUM_TOTAL_CN700_ModeXregs ARRAY_SIZE(CN700_ModeXregs)
57#define NUM_TOTAL_KM400_ModeXregs ARRAY_SIZE(KM400_ModeXregs)
58#define NUM_TOTAL_CX700_ModeXregs ARRAY_SIZE(CX700_ModeXregs)
59#define NUM_TOTAL_VX800_ModeXregs ARRAY_SIZE(VX800_ModeXregs)
60#define NUM_TOTAL_CLE266_ModeXregs ARRAY_SIZE(CLE266_ModeXregs)
61#define NUM_TOTAL_PATCH_MODE ARRAY_SIZE(res_patch_table)
62#define NUM_TOTAL_MODETABLE ARRAY_SIZE(CLE266Modes)
63
64/********************/
65/* Mode Table */
66/********************/
67
68/* 480x640 */
69extern struct crt_mode_table CRTM480x640[1];
70/* 640x480*/
71extern struct crt_mode_table CRTM640x480[5];
72/*720x480 (GTF)*/
73extern struct crt_mode_table CRTM720x480[1];
74/*720x576 (GTF)*/
75extern struct crt_mode_table CRTM720x576[1];
76/* 800x480 (CVT) */
77extern struct crt_mode_table CRTM800x480[1];
78/* 800x600*/
79extern struct crt_mode_table CRTM800x600[5];
80/* 848x480 (CVT) */
81extern struct crt_mode_table CRTM848x480[1];
82/*856x480 (GTF) convert to 852x480*/
83extern struct crt_mode_table CRTM852x480[1];
84/*1024x512 (GTF)*/
85extern struct crt_mode_table CRTM1024x512[1];
86/* 1024x600*/
87extern struct crt_mode_table CRTM1024x600[1];
88/* 1024x768*/
89extern struct crt_mode_table CRTM1024x768[4];
90/* 1152x864*/
91extern struct crt_mode_table CRTM1152x864[1];
92/* 1280x720 (HDMI 720P)*/
93extern struct crt_mode_table CRTM1280x720[2];
94/*1280x768 (GTF)*/
95extern struct crt_mode_table CRTM1280x768[2];
96/* 1280x800 (CVT) */
97extern struct crt_mode_table CRTM1280x800[1];
98/*1280x960*/
99extern struct crt_mode_table CRTM1280x960[1];
100/* 1280x1024*/
101extern struct crt_mode_table CRTM1280x1024[3];
102/* 1368x768 (GTF) */
103extern struct crt_mode_table CRTM1368x768[1];
104/*1440x1050 (GTF)*/
105extern struct crt_mode_table CRTM1440x1050[1];
106/* 1600x1200*/
107extern struct crt_mode_table CRTM1600x1200[2];
108/* 1680x1050 (CVT) */
109extern struct crt_mode_table CRTM1680x1050[2];
110/* 1680x1050 (CVT Reduce Blanking) */
111extern struct crt_mode_table CRTM1680x1050_RB[1];
112/* 1920x1080 (CVT)*/
113extern struct crt_mode_table CRTM1920x1080[1];
114/* 1920x1080 (CVT with Reduce Blanking) */
115extern struct crt_mode_table CRTM1920x1080_RB[1];
116/* 1920x1440*/
117extern struct crt_mode_table CRTM1920x1440[2];
118/* 1400x1050 (CVT) */
119extern struct crt_mode_table CRTM1400x1050[2];
120/* 1400x1050 (CVT Reduce Blanking) */
121extern struct crt_mode_table CRTM1400x1050_RB[1];
122/* 960x600 (CVT) */
123extern struct crt_mode_table CRTM960x600[1];
124/* 1000x600 (GTF) */
125extern struct crt_mode_table CRTM1000x600[1];
126/* 1024x576 (GTF) */
127extern struct crt_mode_table CRTM1024x576[1];
128/* 1088x612 (CVT) */
129extern struct crt_mode_table CRTM1088x612[1];
130/* 1152x720 (CVT) */
131extern struct crt_mode_table CRTM1152x720[1];
132/* 1200x720 (GTF) */
133extern struct crt_mode_table CRTM1200x720[1];
134/* 1280x600 (GTF) */
135extern struct crt_mode_table CRTM1280x600[1];
136/* 1360x768 (CVT) */
137extern struct crt_mode_table CRTM1360x768[1];
138/* 1360x768 (CVT Reduce Blanking) */
139extern struct crt_mode_table CRTM1360x768_RB[1];
140/* 1366x768 (GTF) */
141extern struct crt_mode_table CRTM1366x768[2];
142/* 1440x900 (CVT) */
143extern struct crt_mode_table CRTM1440x900[2];
144/* 1440x900 (CVT Reduce Blanking) */
145extern struct crt_mode_table CRTM1440x900_RB[1];
146/* 1600x900 (CVT) */
147extern struct crt_mode_table CRTM1600x900[1];
148/* 1600x900 (CVT Reduce Blanking) */
149extern struct crt_mode_table CRTM1600x900_RB[1];
150/* 1600x1024 (GTF) */
151extern struct crt_mode_table CRTM1600x1024[1];
152/* 1792x1344 (DMT) */
153extern struct crt_mode_table CRTM1792x1344[1];
154/* 1856x1392 (DMT) */
155extern struct crt_mode_table CRTM1856x1392[1];
156/* 1920x1200 (CVT) */
157extern struct crt_mode_table CRTM1920x1200[1];
158/* 1920x1200 (CVT with Reduce Blanking) */
159extern struct crt_mode_table CRTM1920x1200_RB[1];
160/* 2048x1536 (CVT) */
161extern struct crt_mode_table CRTM2048x1536[1];
162extern struct VideoModeTable CLE266Modes[47];
163extern struct crt_mode_table CEAM1280x720[1];
164extern struct crt_mode_table CEAM1920x1080[1];
165extern struct VideoModeTable CEA_HDMI_Modes[2];
166
167extern struct res_map_refresh res_map_refresh_tbl[61];
168extern struct io_reg CN400_ModeXregs[52];
169extern struct io_reg CN700_ModeXregs[66];
170extern struct io_reg KM400_ModeXregs[55];
171extern struct io_reg CX700_ModeXregs[58];
172extern struct io_reg VX800_ModeXregs[58];
173extern struct io_reg CLE266_ModeXregs[32];
174extern struct io_reg PM1024x768[2];
175extern struct patch_table res_patch_table[1];
176extern struct VPITTable VPIT;
177#endif /* __VIAMODE_H__ */
diff --git a/drivers/video/via/vt1636.c b/drivers/video/via/vt1636.c
new file mode 100644
index 000000000000..322a9f993550
--- /dev/null
+++ b/drivers/video/via/vt1636.c
@@ -0,0 +1,306 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include "global.h"
23
24u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
25 *plvds_setting_info, struct lvds_chip_information *plvds_chip_info,
26 u8 index)
27{
28 u8 data;
29
30 viaparinfo->i2c_stuff.i2c_port = plvds_chip_info->i2c_port;
31 viafb_i2c_readbyte(plvds_chip_info->lvds_chip_slave_addr, index, &data);
32
33 return data;
34}
35
36void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information
37 *plvds_setting_info, struct lvds_chip_information
38 *plvds_chip_info, struct IODATA io_data)
39{
40 int index, data;
41
42 viaparinfo->i2c_stuff.i2c_port = plvds_chip_info->i2c_port;
43
44 index = io_data.Index;
45 data = viafb_gpio_i2c_read_lvds(plvds_setting_info, plvds_chip_info,
46 index);
47 data = (data & (~io_data.Mask)) | io_data.Data;
48
49 viafb_i2c_writebyte(plvds_chip_info->lvds_chip_slave_addr, index, data);
50}
51
52void viafb_init_lvds_vt1636(struct lvds_setting_information
53 *plvds_setting_info, struct lvds_chip_information *plvds_chip_info)
54{
55 int reg_num, i;
56
57 /* Common settings: */
58 reg_num = ARRAY_SIZE(COMMON_INIT_TBL_VT1636);
59
60 for (i = 0; i < reg_num; i++) {
61 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info,
62 plvds_chip_info,
63 COMMON_INIT_TBL_VT1636[i]);
64 }
65
66 /* Input Data Mode Select */
67 if (plvds_setting_info->device_lcd_dualedge) {
68 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info,
69 plvds_chip_info,
70 DUAL_CHANNEL_ENABLE_TBL_VT1636[0]);
71 } else {
72 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info,
73 plvds_chip_info,
74 SINGLE_CHANNEL_ENABLE_TBL_VT1636[0]);
75 }
76
77 if (plvds_setting_info->LCDDithering) {
78 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info,
79 plvds_chip_info,
80 DITHERING_ENABLE_TBL_VT1636[0]);
81 } else {
82 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info,
83 plvds_chip_info,
84 DITHERING_DISABLE_TBL_VT1636[0]);
85 }
86}
87
88void viafb_enable_lvds_vt1636(struct lvds_setting_information
89 *plvds_setting_info,
90 struct lvds_chip_information *plvds_chip_info)
91{
92
93 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info,
94 VDD_ON_TBL_VT1636[0]);
95
96 /* Pad on: */
97 switch (plvds_chip_info->output_interface) {
98 case INTERFACE_DVP0:
99 {
100 viafb_write_reg_mask(SR1E, VIASR, 0xC0, 0xC0);
101 break;
102 }
103
104 case INTERFACE_DVP1:
105 {
106 viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30);
107 break;
108 }
109
110 case INTERFACE_DFP_LOW:
111 {
112 viafb_write_reg_mask(SR2A, VIASR, 0x03, 0x03);
113 break;
114 }
115
116 case INTERFACE_DFP_HIGH:
117 {
118 viafb_write_reg_mask(SR2A, VIASR, 0x03, 0x0C);
119 break;
120 }
121
122 }
123}
124
125void viafb_disable_lvds_vt1636(struct lvds_setting_information
126 *plvds_setting_info,
127 struct lvds_chip_information *plvds_chip_info)
128{
129
130 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info,
131 VDD_OFF_TBL_VT1636[0]);
132
133 /* Pad off: */
134 switch (plvds_chip_info->output_interface) {
135 case INTERFACE_DVP0:
136 {
137 viafb_write_reg_mask(SR1E, VIASR, 0x00, 0xC0);
138 break;
139 }
140
141 case INTERFACE_DVP1:
142 {
143 viafb_write_reg_mask(SR1E, VIASR, 0x00, 0x30);
144 break;
145 }
146
147 case INTERFACE_DFP_LOW:
148 {
149 viafb_write_reg_mask(SR2A, VIASR, 0x00, 0x03);
150 break;
151 }
152
153 case INTERFACE_DFP_HIGH:
154 {
155 viafb_write_reg_mask(SR2A, VIASR, 0x00, 0x0C);
156 break;
157 }
158
159 }
160}
161
162bool viafb_lvds_identify_vt1636(void)
163{
164 u8 Buffer[2];
165
166 DEBUG_MSG(KERN_INFO "viafb_lvds_identify_vt1636.\n");
167
168 /* Sense VT1636 LVDS Transmiter */
169 viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr =
170 VT1636_LVDS_I2C_ADDR;
171
172 /* Check vendor ID first: */
173 viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
174 lvds_chip_slave_addr,
175 0x00, &Buffer[0]);
176 viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
177 lvds_chip_slave_addr,
178 0x01, &Buffer[1]);
179
180 if (!((Buffer[0] == 0x06) && (Buffer[1] == 0x11)))
181 return false;
182
183 /* Check Chip ID: */
184 viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
185 lvds_chip_slave_addr,
186 0x02, &Buffer[0]);
187 viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
188 lvds_chip_slave_addr,
189 0x03, &Buffer[1]);
190 if ((Buffer[0] == 0x45) && (Buffer[1] == 0x33)) {
191 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
192 VT1636_LVDS;
193 return true;
194 }
195
196 return false;
197}
198
199static int get_clk_range_index(u32 Clk)
200{
201 if (Clk < DPA_CLK_30M)
202 return DPA_CLK_RANGE_30M;
203 else if (Clk < DPA_CLK_50M)
204 return DPA_CLK_RANGE_30_50M;
205 else if (Clk < DPA_CLK_70M)
206 return DPA_CLK_RANGE_50_70M;
207 else if (Clk < DPA_CLK_100M)
208 return DPA_CLK_RANGE_70_100M;
209 else if (Clk < DPA_CLK_150M)
210 return DPA_CLK_RANGE_100_150M;
211 else
212 return DPA_CLK_RANGE_150M;
213}
214
215static int get_lvds_dpa_setting_index(int panel_size_id,
216 struct VT1636_DPA_SETTING *p_vt1636_dpasetting_tbl,
217 int tbl_size)
218{
219 int i;
220
221 for (i = 0; i < tbl_size; i++) {
222 if (panel_size_id == p_vt1636_dpasetting_tbl->PanelSizeID)
223 return i;
224
225 p_vt1636_dpasetting_tbl++;
226 }
227
228 return 0;
229}
230
231static void set_dpa_vt1636(struct lvds_setting_information
232 *plvds_setting_info, struct lvds_chip_information *plvds_chip_info,
233 struct VT1636_DPA_SETTING *p_vt1636_dpa_setting)
234{
235 struct IODATA io_data;
236
237 io_data.Index = 0x09;
238 io_data.Mask = 0x1F;
239 io_data.Data = p_vt1636_dpa_setting->CLK_SEL_ST1;
240 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info,
241 plvds_chip_info, io_data);
242
243 io_data.Index = 0x08;
244 io_data.Mask = 0x0F;
245 io_data.Data = p_vt1636_dpa_setting->CLK_SEL_ST2;
246 viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info,
247 io_data);
248}
249
250void viafb_vt1636_patch_skew_on_vt3324(
251 struct lvds_setting_information *plvds_setting_info,
252 struct lvds_chip_information *plvds_chip_info)
253{
254 int index, size;
255
256 DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3324.\n");
257
258 /* Graphics DPA settings: */
259 index = get_clk_range_index(plvds_setting_info->vclk);
260 viafb_set_dpa_gfx(plvds_chip_info->output_interface,
261 &GFX_DPA_SETTING_TBL_VT3324[index]);
262
263 /* LVDS Transmitter DPA settings: */
264 size = ARRAY_SIZE(VT1636_DPA_SETTING_TBL_VT3324);
265 index =
266 get_lvds_dpa_setting_index(plvds_setting_info->lcd_panel_id,
267 VT1636_DPA_SETTING_TBL_VT3324, size);
268 set_dpa_vt1636(plvds_setting_info, plvds_chip_info,
269 &VT1636_DPA_SETTING_TBL_VT3324[index]);
270}
271
272void viafb_vt1636_patch_skew_on_vt3327(
273 struct lvds_setting_information *plvds_setting_info,
274 struct lvds_chip_information *plvds_chip_info)
275{
276 int index, size;
277
278 DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3327.\n");
279
280 /* Graphics DPA settings: */
281 index = get_clk_range_index(plvds_setting_info->vclk);
282 viafb_set_dpa_gfx(plvds_chip_info->output_interface,
283 &GFX_DPA_SETTING_TBL_VT3327[index]);
284
285 /* LVDS Transmitter DPA settings: */
286 size = ARRAY_SIZE(VT1636_DPA_SETTING_TBL_VT3327);
287 index =
288 get_lvds_dpa_setting_index(plvds_setting_info->lcd_panel_id,
289 VT1636_DPA_SETTING_TBL_VT3327, size);
290 set_dpa_vt1636(plvds_setting_info, plvds_chip_info,
291 &VT1636_DPA_SETTING_TBL_VT3327[index]);
292}
293
294void viafb_vt1636_patch_skew_on_vt3364(
295 struct lvds_setting_information *plvds_setting_info,
296 struct lvds_chip_information *plvds_chip_info)
297{
298 int index;
299
300 DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3364.\n");
301
302 /* Graphics DPA settings: */
303 index = get_clk_range_index(plvds_setting_info->vclk);
304 viafb_set_dpa_gfx(plvds_chip_info->output_interface,
305 &GFX_DPA_SETTING_TBL_VT3364[index]);
306}
diff --git a/drivers/video/via/vt1636.h b/drivers/video/via/vt1636.h
new file mode 100644
index 000000000000..2a150c58c7ed
--- /dev/null
+++ b/drivers/video/via/vt1636.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef _VT1636_H_
23#define _VT1636_H_
24#include "chip.h"
25bool viafb_lvds_identify_vt1636(void);
26void viafb_init_lvds_vt1636(struct lvds_setting_information
27 *plvds_setting_info, struct lvds_chip_information *plvds_chip_info);
28void viafb_enable_lvds_vt1636(struct lvds_setting_information
29 *plvds_setting_info,
30 struct lvds_chip_information *plvds_chip_info);
31void viafb_disable_lvds_vt1636(struct lvds_setting_information
32 *plvds_setting_info,
33 struct lvds_chip_information *plvds_chip_info);
34void viafb_vt1636_patch_skew_on_vt3324(
35 struct lvds_setting_information *plvds_setting_info,
36 struct lvds_chip_information *plvds_chip_info);
37void viafb_vt1636_patch_skew_on_vt3327(
38 struct lvds_setting_information *plvds_setting_info,
39 struct lvds_chip_information *plvds_chip_info);
40void viafb_vt1636_patch_skew_on_vt3364(
41 struct lvds_setting_information *plvds_setting_info,
42 struct lvds_chip_information *plvds_chip_info);
43
44#endif
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index 10211e493001..29e144f81cbe 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -160,8 +160,10 @@ static int ds1wm_reset(struct ds1wm_data *ds1wm_data)
160 * 625 us - 60 us - 240 us - 100 ns = 324.9 us 160 * 625 us - 60 us - 240 us - 100 ns = 324.9 us
161 * 161 *
162 * We'll wait a bit longer just to be sure. 162 * We'll wait a bit longer just to be sure.
163 * Was udelay(500), but if it is going to busywait the cpu that long,
164 * might as well come back later.
163 */ 165 */
164 udelay(500); 166 msleep(1);
165 167
166 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN, 168 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
167 DS1WM_INTEN_ERBF | DS1WM_INTEN_ETMT | DS1WM_INTEN_EPD | 169 DS1WM_INTEN_ERBF | DS1WM_INTEN_ETMT | DS1WM_INTEN_EPD |
@@ -274,8 +276,8 @@ static u8 ds1wm_reset_bus(void *data)
274 return 0; 276 return 0;
275} 277}
276 278
277static void ds1wm_search(void *data, u8 search_type, 279static void ds1wm_search(void *data, struct w1_master *master_dev,
278 w1_slave_found_callback slave_found) 280 u8 search_type, w1_slave_found_callback slave_found)
279{ 281{
280 struct ds1wm_data *ds1wm_data = data; 282 struct ds1wm_data *ds1wm_data = data;
281 int i; 283 int i;
@@ -313,7 +315,7 @@ static void ds1wm_search(void *data, u8 search_type,
313 ds1wm_write_register(ds1wm_data, DS1WM_CMD, ~DS1WM_CMD_SRA); 315 ds1wm_write_register(ds1wm_data, DS1WM_CMD, ~DS1WM_CMD_SRA);
314 ds1wm_reset(ds1wm_data); 316 ds1wm_reset(ds1wm_data);
315 317
316 slave_found(ds1wm_data, rom_id); 318 slave_found(master_dev, rom_id);
317} 319}
318 320
319/* --------------------------------------------------------------------- */ 321/* --------------------------------------------------------------------- */
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index b63b5e044a4c..59ad6e95af8f 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -88,7 +88,7 @@
88#define COMM_DT 0x2000 88#define COMM_DT 0x2000
89#define COMM_SPU 0x1000 89#define COMM_SPU 0x1000
90#define COMM_F 0x0800 90#define COMM_F 0x0800
91#define COMM_NTP 0x0400 91#define COMM_NTF 0x0400
92#define COMM_ICP 0x0200 92#define COMM_ICP 0x0200
93#define COMM_RST 0x0100 93#define COMM_RST 0x0100
94 94
@@ -98,11 +98,6 @@
98#define BRANCH_MAIN 0xCC 98#define BRANCH_MAIN 0xCC
99#define BRANCH_AUX 0x33 99#define BRANCH_AUX 0x33
100 100
101/*
102 * Duration of the strong pull-up pulse in milliseconds.
103 */
104#define PULLUP_PULSE_DURATION 750
105
106/* Status flags */ 101/* Status flags */
107#define ST_SPUA 0x01 /* Strong Pull-up is active */ 102#define ST_SPUA 0x01 /* Strong Pull-up is active */
108#define ST_PRGA 0x02 /* 12V programming pulse is being generated */ 103#define ST_PRGA 0x02 /* 12V programming pulse is being generated */
@@ -112,6 +107,17 @@
112#define ST_IDLE 0x20 /* DS2490 is currently idle */ 107#define ST_IDLE 0x20 /* DS2490 is currently idle */
113#define ST_EPOF 0x80 108#define ST_EPOF 0x80
114 109
110/* Result Register flags */
111#define RR_DETECT 0xA5 /* New device detected */
112#define RR_NRS 0x01 /* Reset no presence or ... */
113#define RR_SH 0x02 /* short on reset or set path */
114#define RR_APP 0x04 /* alarming presence on reset */
115#define RR_VPP 0x08 /* 12V expected not seen */
116#define RR_CMP 0x10 /* compare error */
117#define RR_CRC 0x20 /* CRC error detected */
118#define RR_RDP 0x40 /* redirected page */
119#define RR_EOS 0x80 /* end of search error */
120
115#define SPEED_NORMAL 0x00 121#define SPEED_NORMAL 0x00
116#define SPEED_FLEXIBLE 0x01 122#define SPEED_FLEXIBLE 0x01
117#define SPEED_OVERDRIVE 0x02 123#define SPEED_OVERDRIVE 0x02
@@ -131,6 +137,15 @@ struct ds_device
131 137
132 int ep[NUM_EP]; 138 int ep[NUM_EP];
133 139
140 /* Strong PullUp
141 * 0: pullup not active, else duration in milliseconds
142 */
143 int spu_sleep;
144 /* spu_bit contains COMM_SPU or 0 depending on if the strong pullup
145 * should be active or not for writes.
146 */
147 u16 spu_bit;
148
134 struct w1_bus_master master; 149 struct w1_bus_master master;
135}; 150};
136 151
@@ -164,7 +179,6 @@ MODULE_DEVICE_TABLE(usb, ds_id_table);
164static int ds_probe(struct usb_interface *, const struct usb_device_id *); 179static int ds_probe(struct usb_interface *, const struct usb_device_id *);
165static void ds_disconnect(struct usb_interface *); 180static void ds_disconnect(struct usb_interface *);
166 181
167static inline void ds_dump_status(unsigned char *, unsigned char *, int);
168static int ds_send_control(struct ds_device *, u16, u16); 182static int ds_send_control(struct ds_device *, u16, u16);
169static int ds_send_control_cmd(struct ds_device *, u16, u16); 183static int ds_send_control_cmd(struct ds_device *, u16, u16);
170 184
@@ -192,7 +206,7 @@ static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index)
192 206
193 return err; 207 return err;
194} 208}
195#if 0 209
196static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) 210static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index)
197{ 211{
198 int err; 212 int err;
@@ -207,7 +221,7 @@ static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index)
207 221
208 return err; 222 return err;
209} 223}
210#endif 224
211static int ds_send_control(struct ds_device *dev, u16 value, u16 index) 225static int ds_send_control(struct ds_device *dev, u16 value, u16 index)
212{ 226{
213 int err; 227 int err;
@@ -223,11 +237,6 @@ static int ds_send_control(struct ds_device *dev, u16 value, u16 index)
223 return err; 237 return err;
224} 238}
225 239
226static inline void ds_dump_status(unsigned char *buf, unsigned char *str, int off)
227{
228 printk("%45s: %8x\n", str, buf[off]);
229}
230
231static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st, 240static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st,
232 unsigned char *buf, int size) 241 unsigned char *buf, int size)
233{ 242{
@@ -248,62 +257,81 @@ static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st,
248 return count; 257 return count;
249} 258}
250 259
251static int ds_recv_status(struct ds_device *dev, struct ds_status *st) 260static inline void ds_print_msg(unsigned char *buf, unsigned char *str, int off)
252{ 261{
253 unsigned char buf[64]; 262 printk(KERN_INFO "%45s: %8x\n", str, buf[off]);
254 int count, err = 0, i; 263}
255
256 memcpy(st, buf, sizeof(*st));
257 264
258 count = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); 265static void ds_dump_status(struct ds_device *dev, unsigned char *buf, int count)
259 if (count < 0) 266{
260 return err; 267 int i;
261 268
262 printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], count); 269 printk(KERN_INFO "0x%x: count=%d, status: ", dev->ep[EP_STATUS], count);
263 for (i=0; i<count; ++i) 270 for (i=0; i<count; ++i)
264 printk("%02x ", buf[i]); 271 printk("%02x ", buf[i]);
265 printk("\n"); 272 printk(KERN_INFO "\n");
266 273
267 if (count >= 16) { 274 if (count >= 16) {
268 ds_dump_status(buf, "enable flag", 0); 275 ds_print_msg(buf, "enable flag", 0);
269 ds_dump_status(buf, "1-wire speed", 1); 276 ds_print_msg(buf, "1-wire speed", 1);
270 ds_dump_status(buf, "strong pullup duration", 2); 277 ds_print_msg(buf, "strong pullup duration", 2);
271 ds_dump_status(buf, "programming pulse duration", 3); 278 ds_print_msg(buf, "programming pulse duration", 3);
272 ds_dump_status(buf, "pulldown slew rate control", 4); 279 ds_print_msg(buf, "pulldown slew rate control", 4);
273 ds_dump_status(buf, "write-1 low time", 5); 280 ds_print_msg(buf, "write-1 low time", 5);
274 ds_dump_status(buf, "data sample offset/write-0 recovery time", 6); 281 ds_print_msg(buf, "data sample offset/write-0 recovery time",
275 ds_dump_status(buf, "reserved (test register)", 7); 282 6);
276 ds_dump_status(buf, "device status flags", 8); 283 ds_print_msg(buf, "reserved (test register)", 7);
277 ds_dump_status(buf, "communication command byte 1", 9); 284 ds_print_msg(buf, "device status flags", 8);
278 ds_dump_status(buf, "communication command byte 2", 10); 285 ds_print_msg(buf, "communication command byte 1", 9);
279 ds_dump_status(buf, "communication command buffer status", 11); 286 ds_print_msg(buf, "communication command byte 2", 10);
280 ds_dump_status(buf, "1-wire data output buffer status", 12); 287 ds_print_msg(buf, "communication command buffer status", 11);
281 ds_dump_status(buf, "1-wire data input buffer status", 13); 288 ds_print_msg(buf, "1-wire data output buffer status", 12);
282 ds_dump_status(buf, "reserved", 14); 289 ds_print_msg(buf, "1-wire data input buffer status", 13);
283 ds_dump_status(buf, "reserved", 15); 290 ds_print_msg(buf, "reserved", 14);
291 ds_print_msg(buf, "reserved", 15);
284 } 292 }
285 293 for (i = 16; i < count; ++i) {
286 memcpy(st, buf, sizeof(*st)); 294 if (buf[i] == RR_DETECT) {
287 295 ds_print_msg(buf, "new device detect", i);
288 if (st->status & ST_EPOF) { 296 continue;
289 printk(KERN_INFO "Resetting device after ST_EPOF.\n"); 297 }
290 err = ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0); 298 ds_print_msg(buf, "Result Register Value: ", i);
291 if (err) 299 if (buf[i] & RR_NRS)
292 return err; 300 printk(KERN_INFO "NRS: Reset no presence or ...\n");
293 count = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); 301 if (buf[i] & RR_SH)
294 if (count < 0) 302 printk(KERN_INFO "SH: short on reset or set path\n");
295 return err; 303 if (buf[i] & RR_APP)
296 } 304 printk(KERN_INFO "APP: alarming presence on reset\n");
297#if 0 305 if (buf[i] & RR_VPP)
298 if (st->status & ST_IDLE) { 306 printk(KERN_INFO "VPP: 12V expected not seen\n");
299 printk(KERN_INFO "Resetting pulse after ST_IDLE.\n"); 307 if (buf[i] & RR_CMP)
300 err = ds_start_pulse(dev, PULLUP_PULSE_DURATION); 308 printk(KERN_INFO "CMP: compare error\n");
301 if (err) 309 if (buf[i] & RR_CRC)
302 return err; 310 printk(KERN_INFO "CRC: CRC error detected\n");
311 if (buf[i] & RR_RDP)
312 printk(KERN_INFO "RDP: redirected page\n");
313 if (buf[i] & RR_EOS)
314 printk(KERN_INFO "EOS: end of search error\n");
303 } 315 }
304#endif 316}
305 317
306 return err; 318static void ds_reset_device(struct ds_device *dev)
319{
320 ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0);
321 /* Always allow strong pullup which allow individual writes to use
322 * the strong pullup.
323 */
324 if (ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE))
325 printk(KERN_ERR "ds_reset_device: "
326 "Error allowing strong pullup\n");
327 /* Chip strong pullup time was cleared. */
328 if (dev->spu_sleep) {
329 /* lower 4 bits are 0, see ds_set_pullup */
330 u8 del = dev->spu_sleep>>4;
331 if (ds_send_control(dev, COMM_SET_DURATION | COMM_IM, del))
332 printk(KERN_ERR "ds_reset_device: "
333 "Error setting duration\n");
334 }
307} 335}
308 336
309static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size) 337static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
@@ -311,13 +339,27 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
311 int count, err; 339 int count, err;
312 struct ds_status st; 340 struct ds_status st;
313 341
342 /* Careful on size. If size is less than what is available in
343 * the input buffer, the device fails the bulk transfer and
344 * clears the input buffer. It could read the maximum size of
345 * the data buffer, but then do you return the first, last, or
346 * some set of the middle size bytes? As long as the rest of
347 * the code is correct there will be size bytes waiting. A
348 * call to ds_wait_status will wait until the device is idle
349 * and any data to be received would have been available.
350 */
314 count = 0; 351 count = 0;
315 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), 352 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]),
316 buf, size, &count, 1000); 353 buf, size, &count, 1000);
317 if (err < 0) { 354 if (err < 0) {
355 u8 buf[0x20];
356 int count;
357
318 printk(KERN_INFO "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); 358 printk(KERN_INFO "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]);
319 usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN])); 359 usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]));
320 ds_recv_status(dev, &st); 360
361 count = ds_recv_status_nodump(dev, &st, buf, sizeof(buf));
362 ds_dump_status(dev, buf, count);
321 return err; 363 return err;
322 } 364 }
323 365
@@ -341,7 +383,8 @@ static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len)
341 count = 0; 383 count = 0;
342 err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, 1000); 384 err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, 1000);
343 if (err < 0) { 385 if (err < 0) {
344 printk(KERN_ERR "Failed to read 1-wire data from 0x02: err=%d.\n", err); 386 printk(KERN_ERR "Failed to write 1-wire data to ep0x%x: "
387 "err=%d.\n", dev->ep[EP_DATA_OUT], err);
345 return err; 388 return err;
346 } 389 }
347 390
@@ -397,7 +440,7 @@ int ds_detect(struct ds_device *dev, struct ds_status *st)
397 if (err) 440 if (err)
398 return err; 441 return err;
399 442
400 err = ds_recv_status(dev, st); 443 err = ds_dump_status(dev, st);
401 444
402 return err; 445 return err;
403} 446}
@@ -420,33 +463,49 @@ static int ds_wait_status(struct ds_device *dev, struct ds_status *st)
420 printk("\n"); 463 printk("\n");
421 } 464 }
422#endif 465#endif
423 } while(!(buf[0x08] & 0x20) && !(err < 0) && ++count < 100); 466 } while (!(buf[0x08] & ST_IDLE) && !(err < 0) && ++count < 100);
467
468 if (err >= 16 && st->status & ST_EPOF) {
469 printk(KERN_INFO "Resetting device after ST_EPOF.\n");
470 ds_reset_device(dev);
471 /* Always dump the device status. */
472 count = 101;
473 }
424 474
475 /* Dump the status for errors or if there is extended return data.
476 * The extended status includes new device detection (maybe someone
477 * can do something with it).
478 */
479 if (err > 16 || count >= 100 || err < 0)
480 ds_dump_status(dev, buf, err);
425 481
426 if (((err > 16) && (buf[0x10] & 0x01)) || count >= 100 || err < 0) { 482 /* Extended data isn't an error. Well, a short is, but the dump
427 ds_recv_status(dev, st); 483 * would have already told the user that and we can't do anything
484 * about it in software anyway.
485 */
486 if (count >= 100 || err < 0)
428 return -1; 487 return -1;
429 } else 488 else
430 return 0; 489 return 0;
431} 490}
432 491
433static int ds_reset(struct ds_device *dev, struct ds_status *st) 492static int ds_reset(struct ds_device *dev)
434{ 493{
435 int err; 494 int err;
436 495
437 //err = ds_send_control(dev, COMM_1_WIRE_RESET | COMM_F | COMM_IM | COMM_SE, SPEED_FLEXIBLE); 496 /* Other potentionally interesting flags for reset.
438 err = ds_send_control(dev, 0x43, SPEED_NORMAL); 497 *
498 * COMM_NTF: Return result register feedback. This could be used to
499 * detect some conditions such as short, alarming presence, or
500 * detect if a new device was detected.
501 *
502 * COMM_SE which allows SPEED_NORMAL, SPEED_FLEXIBLE, SPEED_OVERDRIVE:
503 * Select the data transfer rate.
504 */
505 err = ds_send_control(dev, COMM_1_WIRE_RESET | COMM_IM, SPEED_NORMAL);
439 if (err) 506 if (err)
440 return err; 507 return err;
441 508
442 ds_wait_status(dev, st);
443#if 0
444 if (st->command_buffer_status) {
445 printk(KERN_INFO "Short circuit.\n");
446 return -EIO;
447 }
448#endif
449
450 return 0; 509 return 0;
451} 510}
452 511
@@ -471,60 +530,43 @@ static int ds_set_speed(struct ds_device *dev, int speed)
471} 530}
472#endif /* 0 */ 531#endif /* 0 */
473 532
474static int ds_start_pulse(struct ds_device *dev, int delay) 533static int ds_set_pullup(struct ds_device *dev, int delay)
475{ 534{
476 int err; 535 int err = 0;
477 u8 del = 1 + (u8)(delay >> 4); 536 u8 del = 1 + (u8)(delay >> 4);
478 struct ds_status st; 537 /* Just storing delay would not get the trunication and roundup. */
479 538 int ms = del<<4;
480#if 0 539
481 err = ds_stop_pulse(dev, 10); 540 /* Enable spu_bit if a delay is set. */
482 if (err) 541 dev->spu_bit = delay ? COMM_SPU : 0;
542 /* If delay is zero, it has already been disabled, if the time is
543 * the same as the hardware was last programmed to, there is also
544 * nothing more to do. Compare with the recalculated value ms
545 * rather than del or delay which can have a different value.
546 */
547 if (delay == 0 || ms == dev->spu_sleep)
483 return err; 548 return err;
484 549
485 err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE);
486 if (err)
487 return err;
488#endif
489 err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, del); 550 err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, del);
490 if (err) 551 if (err)
491 return err; 552 return err;
492 553
493 err = ds_send_control(dev, COMM_PULSE | COMM_IM | COMM_F, 0); 554 dev->spu_sleep = ms;
494 if (err)
495 return err;
496
497 mdelay(delay);
498
499 ds_wait_status(dev, &st);
500 555
501 return err; 556 return err;
502} 557}
503 558
504static int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit) 559static int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit)
505{ 560{
506 int err, count; 561 int err;
507 struct ds_status st; 562 struct ds_status st;
508 u16 value = (COMM_BIT_IO | COMM_IM) | ((bit) ? COMM_D : 0);
509 u16 cmd;
510 563
511 err = ds_send_control(dev, value, 0); 564 err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | (bit ? COMM_D : 0),
565 0);
512 if (err) 566 if (err)
513 return err; 567 return err;
514 568
515 count = 0; 569 ds_wait_status(dev, &st);
516 do {
517 err = ds_wait_status(dev, &st);
518 if (err)
519 return err;
520
521 cmd = st.command0 | (st.command1 << 8);
522 } while (cmd != value && ++count < 10);
523
524 if (err < 0 || count >= 10) {
525 printk(KERN_ERR "Failed to obtain status.\n");
526 return -EINVAL;
527 }
528 570
529 err = ds_recv_data(dev, tbit, sizeof(*tbit)); 571 err = ds_recv_data(dev, tbit, sizeof(*tbit));
530 if (err < 0) 572 if (err < 0)
@@ -533,12 +575,18 @@ static int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit)
533 return 0; 575 return 0;
534} 576}
535 577
578#if 0
536static int ds_write_bit(struct ds_device *dev, u8 bit) 579static int ds_write_bit(struct ds_device *dev, u8 bit)
537{ 580{
538 int err; 581 int err;
539 struct ds_status st; 582 struct ds_status st;
540 583
541 err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | (bit) ? COMM_D : 0, 0); 584 /* Set COMM_ICP to write without a readback. Note, this will
585 * produce one time slot, a down followed by an up with COMM_D
586 * only determing the timing.
587 */
588 err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | COMM_ICP |
589 (bit ? COMM_D : 0), 0);
542 if (err) 590 if (err)
543 return err; 591 return err;
544 592
@@ -546,6 +594,7 @@ static int ds_write_bit(struct ds_device *dev, u8 bit)
546 594
547 return 0; 595 return 0;
548} 596}
597#endif
549 598
550static int ds_write_byte(struct ds_device *dev, u8 byte) 599static int ds_write_byte(struct ds_device *dev, u8 byte)
551{ 600{
@@ -553,10 +602,13 @@ static int ds_write_byte(struct ds_device *dev, u8 byte)
553 struct ds_status st; 602 struct ds_status st;
554 u8 rbyte; 603 u8 rbyte;
555 604
556 err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | COMM_SPU, byte); 605 err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | dev->spu_bit, byte);
557 if (err) 606 if (err)
558 return err; 607 return err;
559 608
609 if (dev->spu_bit)
610 msleep(dev->spu_sleep);
611
560 err = ds_wait_status(dev, &st); 612 err = ds_wait_status(dev, &st);
561 if (err) 613 if (err)
562 return err; 614 return err;
@@ -565,8 +617,6 @@ static int ds_write_byte(struct ds_device *dev, u8 byte)
565 if (err < 0) 617 if (err < 0)
566 return err; 618 return err;
567 619
568 ds_start_pulse(dev, PULLUP_PULSE_DURATION);
569
570 return !(byte == rbyte); 620 return !(byte == rbyte);
571} 621}
572 622
@@ -602,7 +652,7 @@ static int ds_read_block(struct ds_device *dev, u8 *buf, int len)
602 if (err < 0) 652 if (err < 0)
603 return err; 653 return err;
604 654
605 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); 655 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM, len);
606 if (err) 656 if (err)
607 return err; 657 return err;
608 658
@@ -623,20 +673,19 @@ static int ds_write_block(struct ds_device *dev, u8 *buf, int len)
623 if (err < 0) 673 if (err < 0)
624 return err; 674 return err;
625 675
626 ds_wait_status(dev, &st); 676 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | dev->spu_bit, len);
627
628 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len);
629 if (err) 677 if (err)
630 return err; 678 return err;
631 679
680 if (dev->spu_bit)
681 msleep(dev->spu_sleep);
682
632 ds_wait_status(dev, &st); 683 ds_wait_status(dev, &st);
633 684
634 err = ds_recv_data(dev, buf, len); 685 err = ds_recv_data(dev, buf, len);
635 if (err < 0) 686 if (err < 0)
636 return err; 687 return err;
637 688
638 ds_start_pulse(dev, PULLUP_PULSE_DURATION);
639
640 return !(err == len); 689 return !(err == len);
641} 690}
642 691
@@ -728,6 +777,7 @@ static u8 ds9490r_touch_bit(void *data, u8 bit)
728 return ret; 777 return ret;
729} 778}
730 779
780#if 0
731static void ds9490r_write_bit(void *data, u8 bit) 781static void ds9490r_write_bit(void *data, u8 bit)
732{ 782{
733 struct ds_device *dev = data; 783 struct ds_device *dev = data;
@@ -735,13 +785,6 @@ static void ds9490r_write_bit(void *data, u8 bit)
735 ds_write_bit(dev, bit); 785 ds_write_bit(dev, bit);
736} 786}
737 787
738static void ds9490r_write_byte(void *data, u8 byte)
739{
740 struct ds_device *dev = data;
741
742 ds_write_byte(dev, byte);
743}
744
745static u8 ds9490r_read_bit(void *data) 788static u8 ds9490r_read_bit(void *data)
746{ 789{
747 struct ds_device *dev = data; 790 struct ds_device *dev = data;
@@ -754,6 +797,14 @@ static u8 ds9490r_read_bit(void *data)
754 797
755 return bit & 1; 798 return bit & 1;
756} 799}
800#endif
801
802static void ds9490r_write_byte(void *data, u8 byte)
803{
804 struct ds_device *dev = data;
805
806 ds_write_byte(dev, byte);
807}
757 808
758static u8 ds9490r_read_byte(void *data) 809static u8 ds9490r_read_byte(void *data)
759{ 810{
@@ -790,31 +841,58 @@ static u8 ds9490r_read_block(void *data, u8 *buf, int len)
790static u8 ds9490r_reset(void *data) 841static u8 ds9490r_reset(void *data)
791{ 842{
792 struct ds_device *dev = data; 843 struct ds_device *dev = data;
793 struct ds_status st;
794 int err; 844 int err;
795 845
796 memset(&st, 0, sizeof(st)); 846 err = ds_reset(dev);
797
798 err = ds_reset(dev, &st);
799 if (err) 847 if (err)
800 return 1; 848 return 1;
801 849
802 return 0; 850 return 0;
803} 851}
804 852
853static u8 ds9490r_set_pullup(void *data, int delay)
854{
855 struct ds_device *dev = data;
856
857 if (ds_set_pullup(dev, delay))
858 return 1;
859
860 return 0;
861}
862
805static int ds_w1_init(struct ds_device *dev) 863static int ds_w1_init(struct ds_device *dev)
806{ 864{
807 memset(&dev->master, 0, sizeof(struct w1_bus_master)); 865 memset(&dev->master, 0, sizeof(struct w1_bus_master));
808 866
867 /* Reset the device as it can be in a bad state.
868 * This is necessary because a block write will wait for data
869 * to be placed in the output buffer and block any later
870 * commands which will keep accumulating and the device will
871 * not be idle. Another case is removing the ds2490 module
872 * while a bus search is in progress, somehow a few commands
873 * get through, but the input transfers fail leaving data in
874 * the input buffer. This will cause the next read to fail
875 * see the note in ds_recv_data.
876 */
877 ds_reset_device(dev);
878
809 dev->master.data = dev; 879 dev->master.data = dev;
810 dev->master.touch_bit = &ds9490r_touch_bit; 880 dev->master.touch_bit = &ds9490r_touch_bit;
881 /* read_bit and write_bit in w1_bus_master are expected to set and
882 * sample the line level. For write_bit that means it is expected to
883 * set it to that value and leave it there. ds2490 only supports an
884 * individual time slot at the lowest level. The requirement from
885 * pulling the bus state down to reading the state is 15us, something
886 * that isn't realistic on the USB bus anyway.
811 dev->master.read_bit = &ds9490r_read_bit; 887 dev->master.read_bit = &ds9490r_read_bit;
812 dev->master.write_bit = &ds9490r_write_bit; 888 dev->master.write_bit = &ds9490r_write_bit;
889 */
813 dev->master.read_byte = &ds9490r_read_byte; 890 dev->master.read_byte = &ds9490r_read_byte;
814 dev->master.write_byte = &ds9490r_write_byte; 891 dev->master.write_byte = &ds9490r_write_byte;
815 dev->master.read_block = &ds9490r_read_block; 892 dev->master.read_block = &ds9490r_read_block;
816 dev->master.write_block = &ds9490r_write_block; 893 dev->master.write_block = &ds9490r_write_block;
817 dev->master.reset_bus = &ds9490r_reset; 894 dev->master.reset_bus = &ds9490r_reset;
895 dev->master.set_pullup = &ds9490r_set_pullup;
818 896
819 return w1_add_master_device(&dev->master); 897 return w1_add_master_device(&dev->master);
820} 898}
@@ -838,6 +916,8 @@ static int ds_probe(struct usb_interface *intf,
838 printk(KERN_INFO "Failed to allocate new DS9490R structure.\n"); 916 printk(KERN_INFO "Failed to allocate new DS9490R structure.\n");
839 return -ENOMEM; 917 return -ENOMEM;
840 } 918 }
919 dev->spu_sleep = 0;
920 dev->spu_bit = 0;
841 dev->udev = usb_get_dev(udev); 921 dev->udev = usb_get_dev(udev);
842 if (!dev->udev) { 922 if (!dev->udev) {
843 err = -ENOMEM; 923 err = -ENOMEM;
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
new file mode 100644
index 000000000000..2c6c0cf6a20f
--- /dev/null
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -0,0 +1,312 @@
1/*
2 * w1_ds2431.c - w1 family 2d (DS2431) driver
3 *
4 * Copyright (c) 2008 Bernhard Weirich <bernhard.weirich@riedel.net>
5 *
6 * Heavily inspired by w1_DS2433 driver from Ben Gardner <bgardner@wabtec.com>
7 *
8 * This source code is licensed under the GNU General Public License,
9 * Version 2. See the file COPYING for more details.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/device.h>
16#include <linux/types.h>
17#include <linux/delay.h>
18
19#include "../w1.h"
20#include "../w1_int.h"
21#include "../w1_family.h"
22
23#define W1_F2D_EEPROM_SIZE 128
24#define W1_F2D_PAGE_COUNT 4
25#define W1_F2D_PAGE_BITS 5
26#define W1_F2D_PAGE_SIZE (1<<W1_F2D_PAGE_BITS)
27#define W1_F2D_PAGE_MASK 0x1F
28
29#define W1_F2D_SCRATCH_BITS 3
30#define W1_F2D_SCRATCH_SIZE (1<<W1_F2D_SCRATCH_BITS)
31#define W1_F2D_SCRATCH_MASK (W1_F2D_SCRATCH_SIZE-1)
32
33#define W1_F2D_READ_EEPROM 0xF0
34#define W1_F2D_WRITE_SCRATCH 0x0F
35#define W1_F2D_READ_SCRATCH 0xAA
36#define W1_F2D_COPY_SCRATCH 0x55
37
38
39#define W1_F2D_TPROG_MS 11
40
41#define W1_F2D_READ_RETRIES 10
42#define W1_F2D_READ_MAXLEN 8
43
44/*
45 * Check the file size bounds and adjusts count as needed.
46 * This would not be needed if the file size didn't reset to 0 after a write.
47 */
48static inline size_t w1_f2d_fix_count(loff_t off, size_t count, size_t size)
49{
50 if (off > size)
51 return 0;
52
53 if ((off + count) > size)
54 return size - off;
55
56 return count;
57}
58
59/*
60 * Read a block from W1 ROM two times and compares the results.
61 * If they are equal they are returned, otherwise the read
62 * is repeated W1_F2D_READ_RETRIES times.
63 *
64 * count must not exceed W1_F2D_READ_MAXLEN.
65 */
66static int w1_f2d_readblock(struct w1_slave *sl, int off, int count, char *buf)
67{
68 u8 wrbuf[3];
69 u8 cmp[W1_F2D_READ_MAXLEN];
70 int tries = W1_F2D_READ_RETRIES;
71
72 do {
73 wrbuf[0] = W1_F2D_READ_EEPROM;
74 wrbuf[1] = off & 0xff;
75 wrbuf[2] = off >> 8;
76
77 if (w1_reset_select_slave(sl))
78 return -1;
79
80 w1_write_block(sl->master, wrbuf, 3);
81 w1_read_block(sl->master, buf, count);
82
83 if (w1_reset_select_slave(sl))
84 return -1;
85
86 w1_write_block(sl->master, wrbuf, 3);
87 w1_read_block(sl->master, cmp, count);
88
89 if (!memcmp(cmp, buf, count))
90 return 0;
91 } while (--tries);
92
93 dev_err(&sl->dev, "proof reading failed %d times\n",
94 W1_F2D_READ_RETRIES);
95
96 return -1;
97}
98
99static ssize_t w1_f2d_read_bin(struct kobject *kobj,
100 struct bin_attribute *bin_attr,
101 char *buf, loff_t off, size_t count)
102{
103 struct w1_slave *sl = kobj_to_w1_slave(kobj);
104 int todo = count;
105
106 count = w1_f2d_fix_count(off, count, W1_F2D_EEPROM_SIZE);
107 if (count == 0)
108 return 0;
109
110 mutex_lock(&sl->master->mutex);
111
112 /* read directly from the EEPROM in chunks of W1_F2D_READ_MAXLEN */
113 while (todo > 0) {
114 int block_read;
115
116 if (todo >= W1_F2D_READ_MAXLEN)
117 block_read = W1_F2D_READ_MAXLEN;
118 else
119 block_read = todo;
120
121 if (w1_f2d_readblock(sl, off, block_read, buf) < 0)
122 count = -EIO;
123
124 todo -= W1_F2D_READ_MAXLEN;
125 buf += W1_F2D_READ_MAXLEN;
126 off += W1_F2D_READ_MAXLEN;
127 }
128
129 mutex_unlock(&sl->master->mutex);
130
131 return count;
132}
133
134/*
135 * Writes to the scratchpad and reads it back for verification.
136 * Then copies the scratchpad to EEPROM.
137 * The data must be aligned at W1_F2D_SCRATCH_SIZE bytes and
138 * must be W1_F2D_SCRATCH_SIZE bytes long.
139 * The master must be locked.
140 *
141 * @param sl The slave structure
142 * @param addr Address for the write
143 * @param len length must be <= (W1_F2D_PAGE_SIZE - (addr & W1_F2D_PAGE_MASK))
144 * @param data The data to write
145 * @return 0=Success -1=failure
146 */
147static int w1_f2d_write(struct w1_slave *sl, int addr, int len, const u8 *data)
148{
149 int tries = W1_F2D_READ_RETRIES;
150 u8 wrbuf[4];
151 u8 rdbuf[W1_F2D_SCRATCH_SIZE + 3];
152 u8 es = (addr + len - 1) % W1_F2D_SCRATCH_SIZE;
153
154retry:
155
156 /* Write the data to the scratchpad */
157 if (w1_reset_select_slave(sl))
158 return -1;
159
160 wrbuf[0] = W1_F2D_WRITE_SCRATCH;
161 wrbuf[1] = addr & 0xff;
162 wrbuf[2] = addr >> 8;
163
164 w1_write_block(sl->master, wrbuf, 3);
165 w1_write_block(sl->master, data, len);
166
167 /* Read the scratchpad and verify */
168 if (w1_reset_select_slave(sl))
169 return -1;
170
171 w1_write_8(sl->master, W1_F2D_READ_SCRATCH);
172 w1_read_block(sl->master, rdbuf, len + 3);
173
174 /* Compare what was read against the data written */
175 if ((rdbuf[0] != wrbuf[1]) || (rdbuf[1] != wrbuf[2]) ||
176 (rdbuf[2] != es) || (memcmp(data, &rdbuf[3], len) != 0)) {
177
178 if (--tries)
179 goto retry;
180
181 dev_err(&sl->dev,
182 "could not write to eeprom, scratchpad compare failed %d times\n",
183 W1_F2D_READ_RETRIES);
184
185 return -1;
186 }
187
188 /* Copy the scratchpad to EEPROM */
189 if (w1_reset_select_slave(sl))
190 return -1;
191
192 wrbuf[0] = W1_F2D_COPY_SCRATCH;
193 wrbuf[3] = es;
194 w1_write_block(sl->master, wrbuf, 4);
195
196 /* Sleep for tprog ms to wait for the write to complete */
197 msleep(W1_F2D_TPROG_MS);
198
199 /* Reset the bus to wake up the EEPROM */
200 w1_reset_bus(sl->master);
201
202 return 0;
203}
204
205static ssize_t w1_f2d_write_bin(struct kobject *kobj,
206 struct bin_attribute *bin_attr,
207 char *buf, loff_t off, size_t count)
208{
209 struct w1_slave *sl = kobj_to_w1_slave(kobj);
210 int addr, len;
211 int copy;
212
213 count = w1_f2d_fix_count(off, count, W1_F2D_EEPROM_SIZE);
214 if (count == 0)
215 return 0;
216
217 mutex_lock(&sl->master->mutex);
218
219 /* Can only write data in blocks of the size of the scratchpad */
220 addr = off;
221 len = count;
222 while (len > 0) {
223
224 /* if len too short or addr not aligned */
225 if (len < W1_F2D_SCRATCH_SIZE || addr & W1_F2D_SCRATCH_MASK) {
226 char tmp[W1_F2D_SCRATCH_SIZE];
227
228 /* read the block and update the parts to be written */
229 if (w1_f2d_readblock(sl, addr & ~W1_F2D_SCRATCH_MASK,
230 W1_F2D_SCRATCH_SIZE, tmp)) {
231 count = -EIO;
232 goto out_up;
233 }
234
235 /* copy at most to the boundary of the PAGE or len */
236 copy = W1_F2D_SCRATCH_SIZE -
237 (addr & W1_F2D_SCRATCH_MASK);
238
239 if (copy > len)
240 copy = len;
241
242 memcpy(&tmp[addr & W1_F2D_SCRATCH_MASK], buf, copy);
243 if (w1_f2d_write(sl, addr & ~W1_F2D_SCRATCH_MASK,
244 W1_F2D_SCRATCH_SIZE, tmp) < 0) {
245 count = -EIO;
246 goto out_up;
247 }
248 } else {
249
250 copy = W1_F2D_SCRATCH_SIZE;
251 if (w1_f2d_write(sl, addr, copy, buf) < 0) {
252 count = -EIO;
253 goto out_up;
254 }
255 }
256 buf += copy;
257 addr += copy;
258 len -= copy;
259 }
260
261out_up:
262 mutex_unlock(&sl->master->mutex);
263
264 return count;
265}
266
267static struct bin_attribute w1_f2d_bin_attr = {
268 .attr = {
269 .name = "eeprom",
270 .mode = S_IRUGO | S_IWUSR,
271 },
272 .size = W1_F2D_EEPROM_SIZE,
273 .read = w1_f2d_read_bin,
274 .write = w1_f2d_write_bin,
275};
276
277static int w1_f2d_add_slave(struct w1_slave *sl)
278{
279 return sysfs_create_bin_file(&sl->dev.kobj, &w1_f2d_bin_attr);
280}
281
282static void w1_f2d_remove_slave(struct w1_slave *sl)
283{
284 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f2d_bin_attr);
285}
286
287static struct w1_family_ops w1_f2d_fops = {
288 .add_slave = w1_f2d_add_slave,
289 .remove_slave = w1_f2d_remove_slave,
290};
291
292static struct w1_family w1_family_2d = {
293 .fid = W1_EEPROM_DS2431,
294 .fops = &w1_f2d_fops,
295};
296
297static int __init w1_f2d_init(void)
298{
299 return w1_register_family(&w1_family_2d);
300}
301
302static void __exit w1_f2d_fini(void)
303{
304 w1_unregister_family(&w1_family_2d);
305}
306
307module_init(w1_f2d_init);
308module_exit(w1_f2d_fini);
309
310MODULE_LICENSE("GPL");
311MODULE_AUTHOR("Bernhard Weirich <bernhard.weirich@riedel.net>");
312MODULE_DESCRIPTION("w1 family 2d driver for DS2431, 1kb EEPROM");
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index fb28acaeed6c..2c8dff9f77da 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -37,31 +37,33 @@ MODULE_LICENSE("GPL");
37MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 37MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family."); 38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");
39 39
40/* Allow the strong pullup to be disabled, but default to enabled.
41 * If it was disabled a parasite powered device might not get the require
42 * current to do a temperature conversion. If it is enabled parasite powered
43 * devices have a better chance of getting the current required.
44 */
45static int w1_strong_pullup = 1;
46module_param_named(strong_pullup, w1_strong_pullup, int, 0);
47
40static u8 bad_roms[][9] = { 48static u8 bad_roms[][9] = {
41 {0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87}, 49 {0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87},
42 {} 50 {}
43 }; 51 };
44 52
45static ssize_t w1_therm_read_bin(struct kobject *, struct bin_attribute *, 53static ssize_t w1_therm_read(struct device *device,
46 char *, loff_t, size_t); 54 struct device_attribute *attr, char *buf);
47 55
48static struct bin_attribute w1_therm_bin_attr = { 56static struct device_attribute w1_therm_attr =
49 .attr = { 57 __ATTR(w1_slave, S_IRUGO, w1_therm_read, NULL);
50 .name = "w1_slave",
51 .mode = S_IRUGO,
52 },
53 .size = W1_SLAVE_DATA_SIZE,
54 .read = w1_therm_read_bin,
55};
56 58
57static int w1_therm_add_slave(struct w1_slave *sl) 59static int w1_therm_add_slave(struct w1_slave *sl)
58{ 60{
59 return sysfs_create_bin_file(&sl->dev.kobj, &w1_therm_bin_attr); 61 return device_create_file(&sl->dev, &w1_therm_attr);
60} 62}
61 63
62static void w1_therm_remove_slave(struct w1_slave *sl) 64static void w1_therm_remove_slave(struct w1_slave *sl)
63{ 65{
64 sysfs_remove_bin_file(&sl->dev.kobj, &w1_therm_bin_attr); 66 device_remove_file(&sl->dev, &w1_therm_attr);
65} 67}
66 68
67static struct w1_family_ops w1_therm_fops = { 69static struct w1_family_ops w1_therm_fops = {
@@ -160,30 +162,19 @@ static int w1_therm_check_rom(u8 rom[9])
160 return 0; 162 return 0;
161} 163}
162 164
163static ssize_t w1_therm_read_bin(struct kobject *kobj, 165static ssize_t w1_therm_read(struct device *device,
164 struct bin_attribute *bin_attr, 166 struct device_attribute *attr, char *buf)
165 char *buf, loff_t off, size_t count)
166{ 167{
167 struct w1_slave *sl = kobj_to_w1_slave(kobj); 168 struct w1_slave *sl = dev_to_w1_slave(device);
168 struct w1_master *dev = sl->master; 169 struct w1_master *dev = sl->master;
169 u8 rom[9], crc, verdict; 170 u8 rom[9], crc, verdict;
170 int i, max_trying = 10; 171 int i, max_trying = 10;
172 ssize_t c = PAGE_SIZE;
171 173
172 mutex_lock(&sl->master->mutex); 174 mutex_lock(&dev->mutex);
173 175
174 if (off > W1_SLAVE_DATA_SIZE) {
175 count = 0;
176 goto out;
177 }
178 if (off + count > W1_SLAVE_DATA_SIZE) {
179 count = 0;
180 goto out;
181 }
182
183 memset(buf, 0, count);
184 memset(rom, 0, sizeof(rom)); 176 memset(rom, 0, sizeof(rom));
185 177
186 count = 0;
187 verdict = 0; 178 verdict = 0;
188 crc = 0; 179 crc = 0;
189 180
@@ -192,15 +183,20 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj,
192 int count = 0; 183 int count = 0;
193 unsigned int tm = 750; 184 unsigned int tm = 750;
194 185
186 /* 750ms strong pullup (or delay) after the convert */
187 if (w1_strong_pullup)
188 w1_next_pullup(dev, tm);
195 w1_write_8(dev, W1_CONVERT_TEMP); 189 w1_write_8(dev, W1_CONVERT_TEMP);
196 190 if (!w1_strong_pullup)
197 msleep(tm); 191 msleep(tm);
198 192
199 if (!w1_reset_select_slave(sl)) { 193 if (!w1_reset_select_slave(sl)) {
200 194
201 w1_write_8(dev, W1_READ_SCRATCHPAD); 195 w1_write_8(dev, W1_READ_SCRATCHPAD);
202 if ((count = w1_read_block(dev, rom, 9)) != 9) { 196 if ((count = w1_read_block(dev, rom, 9)) != 9) {
203 dev_warn(&dev->dev, "w1_read_block() returned %d instead of 9.\n", count); 197 dev_warn(device, "w1_read_block() "
198 "returned %u instead of 9.\n",
199 count);
204 } 200 }
205 201
206 crc = w1_calc_crc8(rom, 8); 202 crc = w1_calc_crc8(rom, 8);
@@ -215,22 +211,22 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj,
215 } 211 }
216 212
217 for (i = 0; i < 9; ++i) 213 for (i = 0; i < 9; ++i)
218 count += sprintf(buf + count, "%02x ", rom[i]); 214 c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", rom[i]);
219 count += sprintf(buf + count, ": crc=%02x %s\n", 215 c -= snprintf(buf + PAGE_SIZE - c, c, ": crc=%02x %s\n",
220 crc, (verdict) ? "YES" : "NO"); 216 crc, (verdict) ? "YES" : "NO");
221 if (verdict) 217 if (verdict)
222 memcpy(sl->rom, rom, sizeof(sl->rom)); 218 memcpy(sl->rom, rom, sizeof(sl->rom));
223 else 219 else
224 dev_warn(&dev->dev, "18S20 doesn't respond to CONVERT_TEMP.\n"); 220 dev_warn(device, "18S20 doesn't respond to CONVERT_TEMP.\n");
225 221
226 for (i = 0; i < 9; ++i) 222 for (i = 0; i < 9; ++i)
227 count += sprintf(buf + count, "%02x ", sl->rom[i]); 223 c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", sl->rom[i]);
228 224
229 count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid)); 225 c -= snprintf(buf + PAGE_SIZE - c, c, "t=%d\n",
230out: 226 w1_convert_temp(rom, sl->family->fid));
231 mutex_unlock(&dev->mutex); 227 mutex_unlock(&dev->mutex);
232 228
233 return count; 229 return PAGE_SIZE - c;
234} 230}
235 231
236static int __init w1_therm_init(void) 232static int __init w1_therm_init(void)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 7293c9b11f91..3b615d4022ee 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,19 +46,17 @@ MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
46MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); 46MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
47 47
48static int w1_timeout = 10; 48static int w1_timeout = 10;
49static int w1_control_timeout = 1;
50int w1_max_slave_count = 10; 49int w1_max_slave_count = 10;
51int w1_max_slave_ttl = 10; 50int w1_max_slave_ttl = 10;
52 51
53module_param_named(timeout, w1_timeout, int, 0); 52module_param_named(timeout, w1_timeout, int, 0);
54module_param_named(control_timeout, w1_control_timeout, int, 0);
55module_param_named(max_slave_count, w1_max_slave_count, int, 0); 53module_param_named(max_slave_count, w1_max_slave_count, int, 0);
56module_param_named(slave_ttl, w1_max_slave_ttl, int, 0); 54module_param_named(slave_ttl, w1_max_slave_ttl, int, 0);
57 55
58DEFINE_MUTEX(w1_mlock); 56DEFINE_MUTEX(w1_mlock);
59LIST_HEAD(w1_masters); 57LIST_HEAD(w1_masters);
60 58
61static struct task_struct *w1_control_thread; 59static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn);
62 60
63static int w1_master_match(struct device *dev, struct device_driver *drv) 61static int w1_master_match(struct device *dev, struct device_driver *drv)
64{ 62{
@@ -83,10 +81,10 @@ static void w1_slave_release(struct device *dev)
83{ 81{
84 struct w1_slave *sl = dev_to_w1_slave(dev); 82 struct w1_slave *sl = dev_to_w1_slave(dev);
85 83
86 printk("%s: Releasing %s.\n", __func__, sl->name); 84 dev_dbg(dev, "%s: Releasing %s.\n", __func__, sl->name);
87 85
88 while (atomic_read(&sl->refcnt)) { 86 while (atomic_read(&sl->refcnt)) {
89 printk("Waiting for %s to become free: refcnt=%d.\n", 87 dev_dbg(dev, "Waiting for %s to become free: refcnt=%d.\n",
90 sl->name, atomic_read(&sl->refcnt)); 88 sl->name, atomic_read(&sl->refcnt));
91 if (msleep_interruptible(1000)) 89 if (msleep_interruptible(1000))
92 flush_signals(current); 90 flush_signals(current);
@@ -105,35 +103,20 @@ static ssize_t w1_slave_read_name(struct device *dev, struct device_attribute *a
105 return sprintf(buf, "%s\n", sl->name); 103 return sprintf(buf, "%s\n", sl->name);
106} 104}
107 105
108static ssize_t w1_slave_read_id(struct kobject *kobj, 106static ssize_t w1_slave_read_id(struct device *dev,
109 struct bin_attribute *bin_attr, 107 struct device_attribute *attr, char *buf)
110 char *buf, loff_t off, size_t count)
111{ 108{
112 struct w1_slave *sl = kobj_to_w1_slave(kobj); 109 struct w1_slave *sl = dev_to_w1_slave(dev);
113 110 ssize_t count = sizeof(sl->reg_num);
114 if (off > 8) {
115 count = 0;
116 } else {
117 if (off + count > 8)
118 count = 8 - off;
119
120 memcpy(buf, (u8 *)&sl->reg_num, count);
121 }
122 111
112 memcpy(buf, (u8 *)&sl->reg_num, count);
123 return count; 113 return count;
124} 114}
125 115
126static struct device_attribute w1_slave_attr_name = 116static struct device_attribute w1_slave_attr_name =
127 __ATTR(name, S_IRUGO, w1_slave_read_name, NULL); 117 __ATTR(name, S_IRUGO, w1_slave_read_name, NULL);
128 118static struct device_attribute w1_slave_attr_id =
129static struct bin_attribute w1_slave_attr_bin_id = { 119 __ATTR(id, S_IRUGO, w1_slave_read_id, NULL);
130 .attr = {
131 .name = "id",
132 .mode = S_IRUGO,
133 },
134 .size = 8,
135 .read = w1_slave_read_id,
136};
137 120
138/* Default family */ 121/* Default family */
139 122
@@ -250,11 +233,16 @@ static ssize_t w1_master_attribute_store_search(struct device * dev,
250 struct device_attribute *attr, 233 struct device_attribute *attr,
251 const char * buf, size_t count) 234 const char * buf, size_t count)
252{ 235{
236 long tmp;
253 struct w1_master *md = dev_to_w1_master(dev); 237 struct w1_master *md = dev_to_w1_master(dev);
254 238
239 if (strict_strtol(buf, 0, &tmp) == -EINVAL)
240 return -EINVAL;
241
255 mutex_lock(&md->mutex); 242 mutex_lock(&md->mutex);
256 md->search_count = simple_strtol(buf, NULL, 0); 243 md->search_count = tmp;
257 mutex_unlock(&md->mutex); 244 mutex_unlock(&md->mutex);
245 wake_up_process(md->thread);
258 246
259 return count; 247 return count;
260} 248}
@@ -273,6 +261,38 @@ static ssize_t w1_master_attribute_show_search(struct device *dev,
273 return count; 261 return count;
274} 262}
275 263
264static ssize_t w1_master_attribute_store_pullup(struct device *dev,
265 struct device_attribute *attr,
266 const char *buf, size_t count)
267{
268 long tmp;
269 struct w1_master *md = dev_to_w1_master(dev);
270
271 if (strict_strtol(buf, 0, &tmp) == -EINVAL)
272 return -EINVAL;
273
274 mutex_lock(&md->mutex);
275 md->enable_pullup = tmp;
276 mutex_unlock(&md->mutex);
277 wake_up_process(md->thread);
278
279 return count;
280}
281
282static ssize_t w1_master_attribute_show_pullup(struct device *dev,
283 struct device_attribute *attr,
284 char *buf)
285{
286 struct w1_master *md = dev_to_w1_master(dev);
287 ssize_t count;
288
289 mutex_lock(&md->mutex);
290 count = sprintf(buf, "%d\n", md->enable_pullup);
291 mutex_unlock(&md->mutex);
292
293 return count;
294}
295
276static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf) 296static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf)
277{ 297{
278 struct w1_master *md = dev_to_w1_master(dev); 298 struct w1_master *md = dev_to_w1_master(dev);
@@ -324,7 +344,8 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct d
324 return count; 344 return count;
325} 345}
326 346
327static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf) 347static ssize_t w1_master_attribute_show_slaves(struct device *dev,
348 struct device_attribute *attr, char *buf)
328{ 349{
329 struct w1_master *md = dev_to_w1_master(dev); 350 struct w1_master *md = dev_to_w1_master(dev);
330 int c = PAGE_SIZE; 351 int c = PAGE_SIZE;
@@ -349,6 +370,135 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device
349 return PAGE_SIZE - c; 370 return PAGE_SIZE - c;
350} 371}
351 372
373static ssize_t w1_master_attribute_show_add(struct device *dev,
374 struct device_attribute *attr, char *buf)
375{
376 int c = PAGE_SIZE;
377 c -= snprintf(buf+PAGE_SIZE - c, c,
378 "write device id xx-xxxxxxxxxxxx to add slave\n");
379 return PAGE_SIZE - c;
380}
381
382static int w1_atoreg_num(struct device *dev, const char *buf, size_t count,
383 struct w1_reg_num *rn)
384{
385 unsigned int family;
386 unsigned long long id;
387 int i;
388 u64 rn64_le;
389
390 /* The CRC value isn't read from the user because the sysfs directory
391 * doesn't include it and most messages from the bus search don't
392 * print it either. It would be unreasonable for the user to then
393 * provide it.
394 */
395 const char *error_msg = "bad slave string format, expecting "
396 "ff-dddddddddddd\n";
397
398 if (buf[2] != '-') {
399 dev_err(dev, "%s", error_msg);
400 return -EINVAL;
401 }
402 i = sscanf(buf, "%02x-%012llx", &family, &id);
403 if (i != 2) {
404 dev_err(dev, "%s", error_msg);
405 return -EINVAL;
406 }
407 rn->family = family;
408 rn->id = id;
409
410 rn64_le = cpu_to_le64(*(u64 *)rn);
411 rn->crc = w1_calc_crc8((u8 *)&rn64_le, 7);
412
413#if 0
414 dev_info(dev, "With CRC device is %02x.%012llx.%02x.\n",
415 rn->family, (unsigned long long)rn->id, rn->crc);
416#endif
417
418 return 0;
419}
420
421/* Searches the slaves in the w1_master and returns a pointer or NULL.
422 * Note: must hold the mutex
423 */
424static struct w1_slave *w1_slave_search_device(struct w1_master *dev,
425 struct w1_reg_num *rn)
426{
427 struct w1_slave *sl;
428 list_for_each_entry(sl, &dev->slist, w1_slave_entry) {
429 if (sl->reg_num.family == rn->family &&
430 sl->reg_num.id == rn->id &&
431 sl->reg_num.crc == rn->crc) {
432 return sl;
433 }
434 }
435 return NULL;
436}
437
438static ssize_t w1_master_attribute_store_add(struct device *dev,
439 struct device_attribute *attr,
440 const char *buf, size_t count)
441{
442 struct w1_master *md = dev_to_w1_master(dev);
443 struct w1_reg_num rn;
444 struct w1_slave *sl;
445 ssize_t result = count;
446
447 if (w1_atoreg_num(dev, buf, count, &rn))
448 return -EINVAL;
449
450 mutex_lock(&md->mutex);
451 sl = w1_slave_search_device(md, &rn);
452 /* It would be nice to do a targeted search one the one-wire bus
453 * for the new device to see if it is out there or not. But the
454 * current search doesn't support that.
455 */
456 if (sl) {
457 dev_info(dev, "Device %s already exists\n", sl->name);
458 result = -EINVAL;
459 } else {
460 w1_attach_slave_device(md, &rn);
461 }
462 mutex_unlock(&md->mutex);
463
464 return result;
465}
466
467static ssize_t w1_master_attribute_show_remove(struct device *dev,
468 struct device_attribute *attr, char *buf)
469{
470 int c = PAGE_SIZE;
471 c -= snprintf(buf+PAGE_SIZE - c, c,
472 "write device id xx-xxxxxxxxxxxx to remove slave\n");
473 return PAGE_SIZE - c;
474}
475
476static ssize_t w1_master_attribute_store_remove(struct device *dev,
477 struct device_attribute *attr,
478 const char *buf, size_t count)
479{
480 struct w1_master *md = dev_to_w1_master(dev);
481 struct w1_reg_num rn;
482 struct w1_slave *sl;
483 ssize_t result = count;
484
485 if (w1_atoreg_num(dev, buf, count, &rn))
486 return -EINVAL;
487
488 mutex_lock(&md->mutex);
489 sl = w1_slave_search_device(md, &rn);
490 if (sl) {
491 w1_slave_detach(sl);
492 } else {
493 dev_info(dev, "Device %02x-%012llx doesn't exists\n", rn.family,
494 (unsigned long long)rn.id);
495 result = -EINVAL;
496 }
497 mutex_unlock(&md->mutex);
498
499 return result;
500}
501
352#define W1_MASTER_ATTR_RO(_name, _mode) \ 502#define W1_MASTER_ATTR_RO(_name, _mode) \
353 struct device_attribute w1_master_attribute_##_name = \ 503 struct device_attribute w1_master_attribute_##_name = \
354 __ATTR(w1_master_##_name, _mode, \ 504 __ATTR(w1_master_##_name, _mode, \
@@ -368,6 +518,9 @@ static W1_MASTER_ATTR_RO(attempts, S_IRUGO);
368static W1_MASTER_ATTR_RO(timeout, S_IRUGO); 518static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
369static W1_MASTER_ATTR_RO(pointer, S_IRUGO); 519static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
370static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUGO); 520static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUGO);
521static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUGO);
522static W1_MASTER_ATTR_RW(add, S_IRUGO | S_IWUGO);
523static W1_MASTER_ATTR_RW(remove, S_IRUGO | S_IWUGO);
371 524
372static struct attribute *w1_master_default_attrs[] = { 525static struct attribute *w1_master_default_attrs[] = {
373 &w1_master_attribute_name.attr, 526 &w1_master_attribute_name.attr,
@@ -378,6 +531,9 @@ static struct attribute *w1_master_default_attrs[] = {
378 &w1_master_attribute_timeout.attr, 531 &w1_master_attribute_timeout.attr,
379 &w1_master_attribute_pointer.attr, 532 &w1_master_attribute_pointer.attr,
380 &w1_master_attribute_search.attr, 533 &w1_master_attribute_search.attr,
534 &w1_master_attribute_pullup.attr,
535 &w1_master_attribute_add.attr,
536 &w1_master_attribute_remove.attr,
381 NULL 537 NULL
382}; 538};
383 539
@@ -390,7 +546,7 @@ int w1_create_master_attributes(struct w1_master *master)
390 return sysfs_create_group(&master->dev.kobj, &w1_master_defattr_group); 546 return sysfs_create_group(&master->dev.kobj, &w1_master_defattr_group);
391} 547}
392 548
393static void w1_destroy_master_attributes(struct w1_master *master) 549void w1_destroy_master_attributes(struct w1_master *master)
394{ 550{
395 sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group); 551 sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group);
396} 552}
@@ -479,7 +635,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
479 } 635 }
480 636
481 /* Create "id" entry */ 637 /* Create "id" entry */
482 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); 638 err = device_create_file(&sl->dev, &w1_slave_attr_id);
483 if (err < 0) { 639 if (err < 0) {
484 dev_err(&sl->dev, 640 dev_err(&sl->dev,
485 "sysfs file creation for [%s] failed. err=%d\n", 641 "sysfs file creation for [%s] failed. err=%d\n",
@@ -501,7 +657,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
501 return 0; 657 return 0;
502 658
503out_rem2: 659out_rem2:
504 sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); 660 device_remove_file(&sl->dev, &w1_slave_attr_id);
505out_rem1: 661out_rem1:
506 device_remove_file(&sl->dev, &w1_slave_attr_name); 662 device_remove_file(&sl->dev, &w1_slave_attr_name);
507out_unreg: 663out_unreg:
@@ -567,7 +723,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
567 return 0; 723 return 0;
568} 724}
569 725
570static void w1_slave_detach(struct w1_slave *sl) 726void w1_slave_detach(struct w1_slave *sl)
571{ 727{
572 struct w1_netlink_msg msg; 728 struct w1_netlink_msg msg;
573 729
@@ -583,7 +739,7 @@ static void w1_slave_detach(struct w1_slave *sl)
583 msg.type = W1_SLAVE_REMOVE; 739 msg.type = W1_SLAVE_REMOVE;
584 w1_netlink_send(sl->master, &msg); 740 w1_netlink_send(sl->master, &msg);
585 741
586 sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); 742 device_remove_file(&sl->dev, &w1_slave_attr_id);
587 device_remove_file(&sl->dev, &w1_slave_attr_name); 743 device_remove_file(&sl->dev, &w1_slave_attr_name);
588 device_unregister(&sl->dev); 744 device_unregister(&sl->dev);
589 745
@@ -591,24 +747,6 @@ static void w1_slave_detach(struct w1_slave *sl)
591 kfree(sl); 747 kfree(sl);
592} 748}
593 749
594static struct w1_master *w1_search_master(void *data)
595{
596 struct w1_master *dev;
597 int found = 0;
598
599 mutex_lock(&w1_mlock);
600 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
601 if (dev->bus_master->data == data) {
602 found = 1;
603 atomic_inc(&dev->refcnt);
604 break;
605 }
606 }
607 mutex_unlock(&w1_mlock);
608
609 return (found)?dev:NULL;
610}
611
612struct w1_master *w1_search_master_id(u32 id) 750struct w1_master *w1_search_master_id(u32 id)
613{ 751{
614 struct w1_master *dev; 752 struct w1_master *dev;
@@ -656,55 +794,56 @@ struct w1_slave *w1_search_slave(struct w1_reg_num *id)
656 return (found)?sl:NULL; 794 return (found)?sl:NULL;
657} 795}
658 796
659void w1_reconnect_slaves(struct w1_family *f) 797void w1_reconnect_slaves(struct w1_family *f, int attach)
660{ 798{
799 struct w1_slave *sl, *sln;
661 struct w1_master *dev; 800 struct w1_master *dev;
662 801
663 mutex_lock(&w1_mlock); 802 mutex_lock(&w1_mlock);
664 list_for_each_entry(dev, &w1_masters, w1_master_entry) { 803 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
665 dev_dbg(&dev->dev, "Reconnecting slaves in %s into new family %02x.\n", 804 dev_dbg(&dev->dev, "Reconnecting slaves in device %s "
666 dev->name, f->fid); 805 "for family %02x.\n", dev->name, f->fid);
667 set_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); 806 mutex_lock(&dev->mutex);
807 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
808 /* If it is a new family, slaves with the default
809 * family driver and are that family will be
810 * connected. If the family is going away, devices
811 * matching that family are reconneced.
812 */
813 if ((attach && sl->family->fid == W1_FAMILY_DEFAULT
814 && sl->reg_num.family == f->fid) ||
815 (!attach && sl->family->fid == f->fid)) {
816 struct w1_reg_num rn;
817
818 memcpy(&rn, &sl->reg_num, sizeof(rn));
819 w1_slave_detach(sl);
820
821 w1_attach_slave_device(dev, &rn);
822 }
823 }
824 dev_dbg(&dev->dev, "Reconnecting slaves in device %s "
825 "has been finished.\n", dev->name);
826 mutex_unlock(&dev->mutex);
668 } 827 }
669 mutex_unlock(&w1_mlock); 828 mutex_unlock(&w1_mlock);
670} 829}
671 830
672static void w1_slave_found(void *data, u64 rn) 831static void w1_slave_found(struct w1_master *dev, u64 rn)
673{ 832{
674 int slave_count;
675 struct w1_slave *sl; 833 struct w1_slave *sl;
676 struct list_head *ent;
677 struct w1_reg_num *tmp; 834 struct w1_reg_num *tmp;
678 struct w1_master *dev;
679 u64 rn_le = cpu_to_le64(rn); 835 u64 rn_le = cpu_to_le64(rn);
680 836
681 dev = w1_search_master(data); 837 atomic_inc(&dev->refcnt);
682 if (!dev) {
683 printk(KERN_ERR "Failed to find w1 master device for data %p, "
684 "it is impossible.\n", data);
685 return;
686 }
687 838
688 tmp = (struct w1_reg_num *) &rn; 839 tmp = (struct w1_reg_num *) &rn;
689 840
690 slave_count = 0; 841 sl = w1_slave_search_device(dev, tmp);
691 list_for_each(ent, &dev->slist) { 842 if (sl) {
692 843 set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
693 sl = list_entry(ent, struct w1_slave, w1_slave_entry); 844 } else {
694 845 if (rn && tmp->crc == w1_calc_crc8((u8 *)&rn_le, 7))
695 if (sl->reg_num.family == tmp->family && 846 w1_attach_slave_device(dev, tmp);
696 sl->reg_num.id == tmp->id &&
697 sl->reg_num.crc == tmp->crc) {
698 set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
699 break;
700 }
701
702 slave_count++;
703 }
704
705 if (slave_count == dev->slave_count &&
706 rn && ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn_le, 7)) {
707 w1_attach_slave_device(dev, tmp);
708 } 847 }
709 848
710 atomic_dec(&dev->refcnt); 849 atomic_dec(&dev->refcnt);
@@ -779,80 +918,20 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
779 /* extract the direction taken & update the device number */ 918 /* extract the direction taken & update the device number */
780 tmp64 = (triplet_ret >> 2); 919 tmp64 = (triplet_ret >> 2);
781 rn |= (tmp64 << i); 920 rn |= (tmp64 << i);
921
922 if (kthread_should_stop()) {
923 dev_dbg(&dev->dev, "Abort w1_search\n");
924 return;
925 }
782 } 926 }
783 927
784 if ( (triplet_ret & 0x03) != 0x03 ) { 928 if ( (triplet_ret & 0x03) != 0x03 ) {
785 if ( (desc_bit == last_zero) || (last_zero < 0)) 929 if ( (desc_bit == last_zero) || (last_zero < 0))
786 last_device = 1; 930 last_device = 1;
787 desc_bit = last_zero; 931 desc_bit = last_zero;
788 cb(dev->bus_master->data, rn); 932 cb(dev, rn);
789 }
790 }
791}
792
793static int w1_control(void *data)
794{
795 struct w1_slave *sl, *sln;
796 struct w1_master *dev, *n;
797 int have_to_wait = 0;
798
799 set_freezable();
800 while (!kthread_should_stop() || have_to_wait) {
801 have_to_wait = 0;
802
803 try_to_freeze();
804 msleep_interruptible(w1_control_timeout * 1000);
805
806 list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) {
807 if (!kthread_should_stop() && !dev->flags)
808 continue;
809 /*
810 * Little race: we can create thread but not set the flag.
811 * Get a chance for external process to set flag up.
812 */
813 if (!dev->initialized) {
814 have_to_wait = 1;
815 continue;
816 }
817
818 if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
819 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
820
821 mutex_lock(&w1_mlock);
822 list_del(&dev->w1_master_entry);
823 mutex_unlock(&w1_mlock);
824
825 mutex_lock(&dev->mutex);
826 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
827 w1_slave_detach(sl);
828 }
829 w1_destroy_master_attributes(dev);
830 mutex_unlock(&dev->mutex);
831 atomic_dec(&dev->refcnt);
832 continue;
833 }
834
835 if (test_bit(W1_MASTER_NEED_RECONNECT, &dev->flags)) {
836 dev_dbg(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name);
837 mutex_lock(&dev->mutex);
838 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
839 if (sl->family->fid == W1_FAMILY_DEFAULT) {
840 struct w1_reg_num rn;
841
842 memcpy(&rn, &sl->reg_num, sizeof(rn));
843 w1_slave_detach(sl);
844
845 w1_attach_slave_device(dev, &rn);
846 }
847 }
848 dev_dbg(&dev->dev, "Reconnecting slaves in device %s has been finished.\n", dev->name);
849 clear_bit(W1_MASTER_NEED_RECONNECT, &dev->flags);
850 mutex_unlock(&dev->mutex);
851 }
852 } 933 }
853 } 934 }
854
855 return 0;
856} 935}
857 936
858void w1_search_process(struct w1_master *dev, u8 search_type) 937void w1_search_process(struct w1_master *dev, u8 search_type)
@@ -878,23 +957,29 @@ void w1_search_process(struct w1_master *dev, u8 search_type)
878int w1_process(void *data) 957int w1_process(void *data)
879{ 958{
880 struct w1_master *dev = (struct w1_master *) data; 959 struct w1_master *dev = (struct w1_master *) data;
960 /* As long as w1_timeout is only set by a module parameter the sleep
961 * time can be calculated in jiffies once.
962 */
963 const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
964
965 while (!kthread_should_stop()) {
966 if (dev->search_count) {
967 mutex_lock(&dev->mutex);
968 w1_search_process(dev, W1_SEARCH);
969 mutex_unlock(&dev->mutex);
970 }
881 971
882 while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
883 try_to_freeze(); 972 try_to_freeze();
884 msleep_interruptible(w1_timeout * 1000); 973 __set_current_state(TASK_INTERRUPTIBLE);
885 974
886 if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) 975 if (kthread_should_stop())
887 break; 976 break;
888 977
889 if (!dev->initialized) 978 /* Only sleep when the search is active. */
890 continue; 979 if (dev->search_count)
891 980 schedule_timeout(jtime);
892 if (dev->search_count == 0) 981 else
893 continue; 982 schedule();
894
895 mutex_lock(&dev->mutex);
896 w1_search_process(dev, W1_SEARCH);
897 mutex_unlock(&dev->mutex);
898 } 983 }
899 984
900 atomic_dec(&dev->refcnt); 985 atomic_dec(&dev->refcnt);
@@ -932,18 +1017,13 @@ static int w1_init(void)
932 goto err_out_master_unregister; 1017 goto err_out_master_unregister;
933 } 1018 }
934 1019
935 w1_control_thread = kthread_run(w1_control, NULL, "w1_control");
936 if (IS_ERR(w1_control_thread)) {
937 retval = PTR_ERR(w1_control_thread);
938 printk(KERN_ERR "Failed to create control thread. err=%d\n",
939 retval);
940 goto err_out_slave_unregister;
941 }
942
943 return 0; 1020 return 0;
944 1021
1022#if 0
1023/* For undoing the slave register if there was a step after it. */
945err_out_slave_unregister: 1024err_out_slave_unregister:
946 driver_unregister(&w1_slave_driver); 1025 driver_unregister(&w1_slave_driver);
1026#endif
947 1027
948err_out_master_unregister: 1028err_out_master_unregister:
949 driver_unregister(&w1_master_driver); 1029 driver_unregister(&w1_master_driver);
@@ -959,13 +1039,12 @@ static void w1_fini(void)
959{ 1039{
960 struct w1_master *dev; 1040 struct w1_master *dev;
961 1041
1042 /* Set netlink removal messages and some cleanup */
962 list_for_each_entry(dev, &w1_masters, w1_master_entry) 1043 list_for_each_entry(dev, &w1_masters, w1_master_entry)
963 __w1_remove_master_device(dev); 1044 __w1_remove_master_device(dev);
964 1045
965 w1_fini_netlink(); 1046 w1_fini_netlink();
966 1047
967 kthread_stop(w1_control_thread);
968
969 driver_unregister(&w1_slave_driver); 1048 driver_unregister(&w1_slave_driver);
970 driver_unregister(&w1_master_driver); 1049 driver_unregister(&w1_master_driver);
971 bus_unregister(&w1_bus_type); 1050 bus_unregister(&w1_bus_type);
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index f1df5343f4ad..cdaa6fffbfc7 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -46,7 +46,6 @@ struct w1_reg_num
46#include "w1_family.h" 46#include "w1_family.h"
47 47
48#define W1_MAXNAMELEN 32 48#define W1_MAXNAMELEN 32
49#define W1_SLAVE_DATA_SIZE 128
50 49
51#define W1_SEARCH 0xF0 50#define W1_SEARCH 0xF0
52#define W1_ALARM_SEARCH 0xEC 51#define W1_ALARM_SEARCH 0xEC
@@ -77,7 +76,7 @@ struct w1_slave
77 struct completion released; 76 struct completion released;
78}; 77};
79 78
80typedef void (* w1_slave_found_callback)(void *, u64); 79typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
81 80
82 81
83/** 82/**
@@ -142,12 +141,18 @@ struct w1_bus_master
142 */ 141 */
143 u8 (*reset_bus)(void *); 142 u8 (*reset_bus)(void *);
144 143
145 /** Really nice hardware can handles the different types of ROM search */ 144 /**
146 void (*search)(void *, u8, w1_slave_found_callback); 145 * Put out a strong pull-up pulse of the specified duration.
147}; 146 * @return -1=Error, 0=completed
147 */
148 u8 (*set_pullup)(void *, int);
148 149
149#define W1_MASTER_NEED_EXIT 0 150 /** Really nice hardware can handles the different types of ROM search
150#define W1_MASTER_NEED_RECONNECT 1 151 * w1_master* is passed to the slave found callback.
152 */
153 void (*search)(void *, struct w1_master *,
154 u8, w1_slave_found_callback);
155};
151 156
152struct w1_master 157struct w1_master
153{ 158{
@@ -167,7 +172,10 @@ struct w1_master
167 void *priv; 172 void *priv;
168 int priv_size; 173 int priv_size;
169 174
170 long flags; 175 /** 5V strong pullup enabled flag, 1 enabled, zero disabled. */
176 int enable_pullup;
177 /** 5V strong pullup duration in milliseconds, zero disabled. */
178 int pullup_duration;
171 179
172 struct task_struct *thread; 180 struct task_struct *thread;
173 struct mutex mutex; 181 struct mutex mutex;
@@ -181,12 +189,21 @@ struct w1_master
181}; 189};
182 190
183int w1_create_master_attributes(struct w1_master *); 191int w1_create_master_attributes(struct w1_master *);
192void w1_destroy_master_attributes(struct w1_master *master);
184void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 193void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
185void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 194void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
186struct w1_slave *w1_search_slave(struct w1_reg_num *id); 195struct w1_slave *w1_search_slave(struct w1_reg_num *id);
187void w1_search_process(struct w1_master *dev, u8 search_type); 196void w1_search_process(struct w1_master *dev, u8 search_type);
188struct w1_master *w1_search_master_id(u32 id); 197struct w1_master *w1_search_master_id(u32 id);
189 198
199/* Disconnect and reconnect devices in the given family. Used for finding
200 * unclaimed devices after a family has been registered or releasing devices
201 * after a family has been unregistered. Set attach to 1 when a new family
202 * has just been registered, to 0 when it has been unregistered.
203 */
204void w1_reconnect_slaves(struct w1_family *f, int attach);
205void w1_slave_detach(struct w1_slave *sl);
206
190u8 w1_triplet(struct w1_master *dev, int bdir); 207u8 w1_triplet(struct w1_master *dev, int bdir);
191void w1_write_8(struct w1_master *, u8); 208void w1_write_8(struct w1_master *, u8);
192int w1_reset_bus(struct w1_master *); 209int w1_reset_bus(struct w1_master *);
@@ -194,6 +211,7 @@ u8 w1_calc_crc8(u8 *, int);
194void w1_write_block(struct w1_master *, const u8 *, int); 211void w1_write_block(struct w1_master *, const u8 *, int);
195u8 w1_read_block(struct w1_master *, u8 *, int); 212u8 w1_read_block(struct w1_master *, u8 *, int);
196int w1_reset_select_slave(struct w1_slave *sl); 213int w1_reset_select_slave(struct w1_slave *sl);
214void w1_next_pullup(struct w1_master *, int);
197 215
198static inline struct w1_slave* dev_to_w1_slave(struct device *dev) 216static inline struct w1_slave* dev_to_w1_slave(struct device *dev)
199{ 217{
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index a3c95bd6890a..4a099041f28a 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -48,12 +48,12 @@ int w1_register_family(struct w1_family *newf)
48 48
49 if (!ret) { 49 if (!ret) {
50 atomic_set(&newf->refcnt, 0); 50 atomic_set(&newf->refcnt, 0);
51 newf->need_exit = 0;
52 list_add_tail(&newf->family_entry, &w1_families); 51 list_add_tail(&newf->family_entry, &w1_families);
53 } 52 }
54 spin_unlock(&w1_flock); 53 spin_unlock(&w1_flock);
55 54
56 w1_reconnect_slaves(newf); 55 /* check default devices against the new set of drivers */
56 w1_reconnect_slaves(newf, 1);
57 57
58 return ret; 58 return ret;
59} 59}
@@ -72,11 +72,11 @@ void w1_unregister_family(struct w1_family *fent)
72 break; 72 break;
73 } 73 }
74 } 74 }
75
76 fent->need_exit = 1;
77
78 spin_unlock(&w1_flock); 75 spin_unlock(&w1_flock);
79 76
77 /* deatch devices using this family code */
78 w1_reconnect_slaves(fent, 0);
79
80 while (atomic_read(&fent->refcnt)) { 80 while (atomic_read(&fent->refcnt)) {
81 printk(KERN_INFO "Waiting for family %u to become free: refcnt=%d.\n", 81 printk(KERN_INFO "Waiting for family %u to become free: refcnt=%d.\n",
82 fent->fid, atomic_read(&fent->refcnt)); 82 fent->fid, atomic_read(&fent->refcnt));
@@ -109,8 +109,7 @@ struct w1_family * w1_family_registered(u8 fid)
109 109
110static void __w1_family_put(struct w1_family *f) 110static void __w1_family_put(struct w1_family *f)
111{ 111{
112 if (atomic_dec_and_test(&f->refcnt)) 112 atomic_dec(&f->refcnt);
113 f->need_exit = 1;
114} 113}
115 114
116void w1_family_put(struct w1_family *f) 115void w1_family_put(struct w1_family *f)
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index ef1e1dafa19a..3ca1b9298f21 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -33,6 +33,7 @@
33#define W1_THERM_DS1822 0x22 33#define W1_THERM_DS1822 0x22
34#define W1_EEPROM_DS2433 0x23 34#define W1_EEPROM_DS2433 0x23
35#define W1_THERM_DS18B20 0x28 35#define W1_THERM_DS18B20 0x28
36#define W1_EEPROM_DS2431 0x2D
36#define W1_FAMILY_DS2760 0x30 37#define W1_FAMILY_DS2760 0x30
37 38
38#define MAXNAMELEN 32 39#define MAXNAMELEN 32
@@ -53,7 +54,6 @@ struct w1_family
53 struct w1_family_ops *fops; 54 struct w1_family_ops *fops;
54 55
55 atomic_t refcnt; 56 atomic_t refcnt;
56 u8 need_exit;
57}; 57};
58 58
59extern spinlock_t w1_flock; 59extern spinlock_t w1_flock;
@@ -63,6 +63,5 @@ void __w1_family_get(struct w1_family *);
63struct w1_family * w1_family_registered(u8); 63struct w1_family * w1_family_registered(u8);
64void w1_unregister_family(struct w1_family *); 64void w1_unregister_family(struct w1_family *);
65int w1_register_family(struct w1_family *); 65int w1_register_family(struct w1_family *);
66void w1_reconnect_slaves(struct w1_family *f);
67 66
68#endif /* __W1_FAMILY_H */ 67#endif /* __W1_FAMILY_H */
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 6840dfebe4d4..a3a54567bfba 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -29,7 +29,11 @@
29#include "w1_netlink.h" 29#include "w1_netlink.h"
30#include "w1_int.h" 30#include "w1_int.h"
31 31
32static u32 w1_ids = 1; 32static int w1_search_count = -1; /* Default is continual scan */
33module_param_named(search_count, w1_search_count, int, 0);
34
35static int w1_enable_pullup = 1;
36module_param_named(enable_pullup, w1_enable_pullup, int, 0);
33 37
34static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, 38static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
35 struct device_driver *driver, 39 struct device_driver *driver,
@@ -59,8 +63,12 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
59 dev->initialized = 0; 63 dev->initialized = 0;
60 dev->id = id; 64 dev->id = id;
61 dev->slave_ttl = slave_ttl; 65 dev->slave_ttl = slave_ttl;
62 dev->search_count = -1; /* continual scan */ 66 dev->search_count = w1_search_count;
67 dev->enable_pullup = w1_enable_pullup;
63 68
69 /* 1 for w1_process to decrement
70 * 1 for __w1_remove_master_device to decrement
71 */
64 atomic_set(&dev->refcnt, 2); 72 atomic_set(&dev->refcnt, 2);
65 73
66 INIT_LIST_HEAD(&dev->slist); 74 INIT_LIST_HEAD(&dev->slist);
@@ -93,9 +101,10 @@ static void w1_free_dev(struct w1_master *dev)
93 101
94int w1_add_master_device(struct w1_bus_master *master) 102int w1_add_master_device(struct w1_bus_master *master)
95{ 103{
96 struct w1_master *dev; 104 struct w1_master *dev, *entry;
97 int retval = 0; 105 int retval = 0;
98 struct w1_netlink_msg msg; 106 struct w1_netlink_msg msg;
107 int id, found;
99 108
100 /* validate minimum functionality */ 109 /* validate minimum functionality */
101 if (!(master->touch_bit && master->reset_bus) && 110 if (!(master->touch_bit && master->reset_bus) &&
@@ -104,10 +113,50 @@ int w1_add_master_device(struct w1_bus_master *master)
104 printk(KERN_ERR "w1_add_master_device: invalid function set\n"); 113 printk(KERN_ERR "w1_add_master_device: invalid function set\n");
105 return(-EINVAL); 114 return(-EINVAL);
106 } 115 }
116 /* While it would be electrically possible to make a device that
117 * generated a strong pullup in bit bang mode, only hardare that
118 * controls 1-wire time frames are even expected to support a strong
119 * pullup. w1_io.c would need to support calling set_pullup before
120 * the last write_bit operation of a w1_write_8 which it currently
121 * doesn't.
122 */
123 if (!master->write_byte && !master->touch_bit && master->set_pullup) {
124 printk(KERN_ERR "w1_add_master_device: set_pullup requires "
125 "write_byte or touch_bit, disabling\n");
126 master->set_pullup = NULL;
127 }
128
129 /* Lock until the device is added (or not) to w1_masters. */
130 mutex_lock(&w1_mlock);
131 /* Search for the first available id (starting at 1). */
132 id = 0;
133 do {
134 ++id;
135 found = 0;
136 list_for_each_entry(entry, &w1_masters, w1_master_entry) {
137 if (entry->id == id) {
138 found = 1;
139 break;
140 }
141 }
142 } while (found);
107 143
108 dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_master_driver, &w1_master_device); 144 dev = w1_alloc_dev(id, w1_max_slave_count, w1_max_slave_ttl,
109 if (!dev) 145 &w1_master_driver, &w1_master_device);
146 if (!dev) {
147 mutex_unlock(&w1_mlock);
110 return -ENOMEM; 148 return -ENOMEM;
149 }
150
151 retval = w1_create_master_attributes(dev);
152 if (retval) {
153 mutex_unlock(&w1_mlock);
154 goto err_out_free_dev;
155 }
156
157 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));
158
159 dev->initialized = 1;
111 160
112 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); 161 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name);
113 if (IS_ERR(dev->thread)) { 162 if (IS_ERR(dev->thread)) {
@@ -115,18 +164,10 @@ int w1_add_master_device(struct w1_bus_master *master)
115 dev_err(&dev->dev, 164 dev_err(&dev->dev,
116 "Failed to create new kernel thread. err=%d\n", 165 "Failed to create new kernel thread. err=%d\n",
117 retval); 166 retval);
118 goto err_out_free_dev; 167 mutex_unlock(&w1_mlock);
168 goto err_out_rm_attr;
119 } 169 }
120 170
121 retval = w1_create_master_attributes(dev);
122 if (retval)
123 goto err_out_kill_thread;
124
125 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));
126
127 dev->initialized = 1;
128
129 mutex_lock(&w1_mlock);
130 list_add(&dev->w1_master_entry, &w1_masters); 171 list_add(&dev->w1_master_entry, &w1_masters);
131 mutex_unlock(&w1_mlock); 172 mutex_unlock(&w1_mlock);
132 173
@@ -137,8 +178,12 @@ int w1_add_master_device(struct w1_bus_master *master)
137 178
138 return 0; 179 return 0;
139 180
181#if 0 /* Thread cleanup code, not required currently. */
140err_out_kill_thread: 182err_out_kill_thread:
141 kthread_stop(dev->thread); 183 kthread_stop(dev->thread);
184#endif
185err_out_rm_attr:
186 w1_destroy_master_attributes(dev);
142err_out_free_dev: 187err_out_free_dev:
143 w1_free_dev(dev); 188 w1_free_dev(dev);
144 189
@@ -148,10 +193,21 @@ err_out_free_dev:
148void __w1_remove_master_device(struct w1_master *dev) 193void __w1_remove_master_device(struct w1_master *dev)
149{ 194{
150 struct w1_netlink_msg msg; 195 struct w1_netlink_msg msg;
196 struct w1_slave *sl, *sln;
151 197
152 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
153 kthread_stop(dev->thread); 198 kthread_stop(dev->thread);
154 199
200 mutex_lock(&w1_mlock);
201 list_del(&dev->w1_master_entry);
202 mutex_unlock(&w1_mlock);
203
204 mutex_lock(&dev->mutex);
205 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry)
206 w1_slave_detach(sl);
207 w1_destroy_master_attributes(dev);
208 mutex_unlock(&dev->mutex);
209 atomic_dec(&dev->refcnt);
210
155 while (atomic_read(&dev->refcnt)) { 211 while (atomic_read(&dev->refcnt)) {
156 dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n", 212 dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n",
157 dev->name, atomic_read(&dev->refcnt)); 213 dev->name, atomic_read(&dev->refcnt));
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 30b6fbf83bd4..f4f82f1f486e 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -93,6 +93,40 @@ static void w1_write_bit(struct w1_master *dev, int bit)
93} 93}
94 94
95/** 95/**
96 * Pre-write operation, currently only supporting strong pullups.
97 * Program the hardware for a strong pullup, if one has been requested and
98 * the hardware supports it.
99 *
100 * @param dev the master device
101 */
102static void w1_pre_write(struct w1_master *dev)
103{
104 if (dev->pullup_duration &&
105 dev->enable_pullup && dev->bus_master->set_pullup) {
106 dev->bus_master->set_pullup(dev->bus_master->data,
107 dev->pullup_duration);
108 }
109}
110
111/**
112 * Post-write operation, currently only supporting strong pullups.
113 * If a strong pullup was requested, clear it if the hardware supports
114 * them, or execute the delay otherwise, in either case clear the request.
115 *
116 * @param dev the master device
117 */
118static void w1_post_write(struct w1_master *dev)
119{
120 if (dev->pullup_duration) {
121 if (dev->enable_pullup && dev->bus_master->set_pullup)
122 dev->bus_master->set_pullup(dev->bus_master->data, 0);
123 else
124 msleep(dev->pullup_duration);
125 dev->pullup_duration = 0;
126 }
127}
128
129/**
96 * Writes 8 bits. 130 * Writes 8 bits.
97 * 131 *
98 * @param dev the master device 132 * @param dev the master device
@@ -102,11 +136,17 @@ void w1_write_8(struct w1_master *dev, u8 byte)
102{ 136{
103 int i; 137 int i;
104 138
105 if (dev->bus_master->write_byte) 139 if (dev->bus_master->write_byte) {
140 w1_pre_write(dev);
106 dev->bus_master->write_byte(dev->bus_master->data, byte); 141 dev->bus_master->write_byte(dev->bus_master->data, byte);
142 }
107 else 143 else
108 for (i = 0; i < 8; ++i) 144 for (i = 0; i < 8; ++i) {
145 if (i == 7)
146 w1_pre_write(dev);
109 w1_touch_bit(dev, (byte >> i) & 0x1); 147 w1_touch_bit(dev, (byte >> i) & 0x1);
148 }
149 w1_post_write(dev);
110} 150}
111EXPORT_SYMBOL_GPL(w1_write_8); 151EXPORT_SYMBOL_GPL(w1_write_8);
112 152
@@ -203,11 +243,14 @@ void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
203{ 243{
204 int i; 244 int i;
205 245
206 if (dev->bus_master->write_block) 246 if (dev->bus_master->write_block) {
247 w1_pre_write(dev);
207 dev->bus_master->write_block(dev->bus_master->data, buf, len); 248 dev->bus_master->write_block(dev->bus_master->data, buf, len);
249 }
208 else 250 else
209 for (i = 0; i < len; ++i) 251 for (i = 0; i < len; ++i)
210 w1_write_8(dev, buf[i]); 252 w1_write_8(dev, buf[i]); /* calls w1_pre_write */
253 w1_post_write(dev);
211} 254}
212EXPORT_SYMBOL_GPL(w1_write_block); 255EXPORT_SYMBOL_GPL(w1_write_block);
213 256
@@ -250,12 +293,24 @@ int w1_reset_bus(struct w1_master *dev)
250 result = dev->bus_master->reset_bus(dev->bus_master->data) & 0x1; 293 result = dev->bus_master->reset_bus(dev->bus_master->data) & 0x1;
251 else { 294 else {
252 dev->bus_master->write_bit(dev->bus_master->data, 0); 295 dev->bus_master->write_bit(dev->bus_master->data, 0);
296 /* minimum 480, max ? us
297 * be nice and sleep, except 18b20 spec lists 960us maximum,
298 * so until we can sleep with microsecond accuracy, spin.
299 * Feel free to come up with some other way to give up the
300 * cpu for such a short amount of time AND get it back in
301 * the maximum amount of time.
302 */
253 w1_delay(480); 303 w1_delay(480);
254 dev->bus_master->write_bit(dev->bus_master->data, 1); 304 dev->bus_master->write_bit(dev->bus_master->data, 1);
255 w1_delay(70); 305 w1_delay(70);
256 306
257 result = dev->bus_master->read_bit(dev->bus_master->data) & 0x1; 307 result = dev->bus_master->read_bit(dev->bus_master->data) & 0x1;
258 w1_delay(410); 308 /* minmum 70 (above) + 410 = 480 us
309 * There aren't any timing requirements between a reset and
310 * the following transactions. Sleeping is safe here.
311 */
312 /* w1_delay(410); min required time */
313 msleep(1);
259 } 314 }
260 315
261 return result; 316 return result;
@@ -277,7 +332,8 @@ void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_cal
277{ 332{
278 dev->attempts++; 333 dev->attempts++;
279 if (dev->bus_master->search) 334 if (dev->bus_master->search)
280 dev->bus_master->search(dev->bus_master->data, search_type, cb); 335 dev->bus_master->search(dev->bus_master->data, dev,
336 search_type, cb);
281 else 337 else
282 w1_search(dev, search_type, cb); 338 w1_search(dev, search_type, cb);
283} 339}
@@ -305,3 +361,20 @@ int w1_reset_select_slave(struct w1_slave *sl)
305 return 0; 361 return 0;
306} 362}
307EXPORT_SYMBOL_GPL(w1_reset_select_slave); 363EXPORT_SYMBOL_GPL(w1_reset_select_slave);
364
365/**
366 * Put out a strong pull-up of the specified duration after the next write
367 * operation. Not all hardware supports strong pullups. Hardware that
368 * doesn't support strong pullups will sleep for the given time after the
369 * write operation without a strong pullup. This is a one shot request for
370 * the next write, specifying zero will clear a previous request.
371 * The w1 master lock must be held.
372 *
373 * @param delay time in milliseconds
374 * @return 0=success, anything else=error
375 */
376void w1_next_pullup(struct w1_master *dev, int delay)
377{
378 dev->pullup_duration = delay;
379}
380EXPORT_SYMBOL_GPL(w1_next_pullup);
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 17c9c5ec14c5..801db1341811 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -25,7 +25,7 @@ config BINFMT_ELF
25 25
26config COMPAT_BINFMT_ELF 26config COMPAT_BINFMT_ELF
27 bool 27 bool
28 depends on COMPAT && MMU 28 depends on COMPAT && BINFMT_ELF
29 29
30config BINFMT_ELF_FDPIC 30config BINFMT_ELF_FDPIC
31 bool "Kernel support for FDPIC ELF binaries" 31 bool "Kernel support for FDPIC ELF binaries"
diff --git a/fs/Makefile b/fs/Makefile
index b6f27dc26b72..d0c69f57e5bf 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -8,7 +8,7 @@
8obj-y := open.o read_write.o file_table.o super.o \ 8obj-y := open.o read_write.o file_table.o super.o \
9 char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ 9 char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
10 ioctl.o readdir.o select.o fifo.o dcache.o inode.o \ 10 ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
11 attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ 11 attr.o bad_inode.o file.o filesystems.o namespace.o \
12 seq_file.o xattr.o libfs.o fs-writeback.o \ 12 seq_file.o xattr.o libfs.o fs-writeback.o \
13 pnode.o drop_caches.o splice.o sync.o utimes.o \ 13 pnode.o drop_caches.o splice.o sync.o utimes.o \
14 stack.o 14 stack.o
@@ -27,6 +27,7 @@ obj-$(CONFIG_ANON_INODES) += anon_inodes.o
27obj-$(CONFIG_SIGNALFD) += signalfd.o 27obj-$(CONFIG_SIGNALFD) += signalfd.o
28obj-$(CONFIG_TIMERFD) += timerfd.o 28obj-$(CONFIG_TIMERFD) += timerfd.o
29obj-$(CONFIG_EVENTFD) += eventfd.o 29obj-$(CONFIG_EVENTFD) += eventfd.o
30obj-$(CONFIG_AIO) += aio.o
30obj-$(CONFIG_FILE_LOCKING) += locks.o 31obj-$(CONFIG_FILE_LOCKING) += locks.o
31obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o 32obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o
32 33
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 525f7c56e068..a3901769a96c 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -50,8 +50,8 @@ const struct address_space_operations afs_fs_aops = {
50 .launder_page = afs_launder_page, 50 .launder_page = afs_launder_page,
51 .releasepage = afs_releasepage, 51 .releasepage = afs_releasepage,
52 .invalidatepage = afs_invalidatepage, 52 .invalidatepage = afs_invalidatepage,
53 .prepare_write = afs_prepare_write, 53 .write_begin = afs_write_begin,
54 .commit_write = afs_commit_write, 54 .write_end = afs_write_end,
55 .writepage = afs_writepage, 55 .writepage = afs_writepage,
56 .writepages = afs_writepages, 56 .writepages = afs_writepages,
57}; 57};
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 3cb6920ff30b..67f259d99cd6 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -728,8 +728,12 @@ extern int afs_volume_release_fileserver(struct afs_vnode *,
728 */ 728 */
729extern int afs_set_page_dirty(struct page *); 729extern int afs_set_page_dirty(struct page *);
730extern void afs_put_writeback(struct afs_writeback *); 730extern void afs_put_writeback(struct afs_writeback *);
731extern int afs_prepare_write(struct file *, struct page *, unsigned, unsigned); 731extern int afs_write_begin(struct file *file, struct address_space *mapping,
732extern int afs_commit_write(struct file *, struct page *, unsigned, unsigned); 732 loff_t pos, unsigned len, unsigned flags,
733 struct page **pagep, void **fsdata);
734extern int afs_write_end(struct file *file, struct address_space *mapping,
735 loff_t pos, unsigned len, unsigned copied,
736 struct page *page, void *fsdata);
733extern int afs_writepage(struct page *, struct writeback_control *); 737extern int afs_writepage(struct page *, struct writeback_control *);
734extern int afs_writepages(struct address_space *, struct writeback_control *); 738extern int afs_writepages(struct address_space *, struct writeback_control *);
735extern int afs_write_inode(struct inode *, int); 739extern int afs_write_inode(struct inode *, int);
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 065b4e10681a..d6b85dab35fc 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -84,15 +84,23 @@ void afs_put_writeback(struct afs_writeback *wb)
84 * partly or wholly fill a page that's under preparation for writing 84 * partly or wholly fill a page that's under preparation for writing
85 */ 85 */
86static int afs_fill_page(struct afs_vnode *vnode, struct key *key, 86static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
87 unsigned start, unsigned len, struct page *page) 87 loff_t pos, unsigned len, struct page *page)
88{ 88{
89 loff_t i_size;
90 unsigned eof;
89 int ret; 91 int ret;
90 92
91 _enter(",,%u,%u", start, len); 93 _enter(",,%llu,%u", (unsigned long long)pos, len);
92 94
93 ASSERTCMP(start + len, <=, PAGE_SIZE); 95 ASSERTCMP(len, <=, PAGE_CACHE_SIZE);
94 96
95 ret = afs_vnode_fetch_data(vnode, key, start, len, page); 97 i_size = i_size_read(&vnode->vfs_inode);
98 if (pos + len > i_size)
99 eof = i_size;
100 else
101 eof = PAGE_CACHE_SIZE;
102
103 ret = afs_vnode_fetch_data(vnode, key, 0, eof, page);
96 if (ret < 0) { 104 if (ret < 0) {
97 if (ret == -ENOENT) { 105 if (ret == -ENOENT) {
98 _debug("got NOENT from server" 106 _debug("got NOENT from server"
@@ -107,109 +115,55 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
107} 115}
108 116
109/* 117/*
110 * prepare a page for being written to
111 */
112static int afs_prepare_page(struct afs_vnode *vnode, struct page *page,
113 struct key *key, unsigned offset, unsigned to)
114{
115 unsigned eof, tail, start, stop, len;
116 loff_t i_size, pos;
117 void *p;
118 int ret;
119
120 _enter("");
121
122 if (offset == 0 && to == PAGE_SIZE)
123 return 0;
124
125 p = kmap_atomic(page, KM_USER0);
126
127 i_size = i_size_read(&vnode->vfs_inode);
128 pos = (loff_t) page->index << PAGE_SHIFT;
129 if (pos >= i_size) {
130 /* partial write, page beyond EOF */
131 _debug("beyond");
132 if (offset > 0)
133 memset(p, 0, offset);
134 if (to < PAGE_SIZE)
135 memset(p + to, 0, PAGE_SIZE - to);
136 kunmap_atomic(p, KM_USER0);
137 return 0;
138 }
139
140 if (i_size - pos >= PAGE_SIZE) {
141 /* partial write, page entirely before EOF */
142 _debug("before");
143 tail = eof = PAGE_SIZE;
144 } else {
145 /* partial write, page overlaps EOF */
146 eof = i_size - pos;
147 _debug("overlap %u", eof);
148 tail = max(eof, to);
149 if (tail < PAGE_SIZE)
150 memset(p + tail, 0, PAGE_SIZE - tail);
151 if (offset > eof)
152 memset(p + eof, 0, PAGE_SIZE - eof);
153 }
154
155 kunmap_atomic(p, KM_USER0);
156
157 ret = 0;
158 if (offset > 0 || eof > to) {
159 /* need to fill one or two bits that aren't going to be written
160 * (cover both fillers in one read if there are two) */
161 start = (offset > 0) ? 0 : to;
162 stop = (eof > to) ? eof : offset;
163 len = stop - start;
164 _debug("wr=%u-%u av=0-%u rd=%u@%u",
165 offset, to, eof, start, len);
166 ret = afs_fill_page(vnode, key, start, len, page);
167 }
168
169 _leave(" = %d", ret);
170 return ret;
171}
172
173/*
174 * prepare to perform part of a write to a page 118 * prepare to perform part of a write to a page
175 * - the caller holds the page locked, preventing it from being written out or
176 * modified by anyone else
177 */ 119 */
178int afs_prepare_write(struct file *file, struct page *page, 120int afs_write_begin(struct file *file, struct address_space *mapping,
179 unsigned offset, unsigned to) 121 loff_t pos, unsigned len, unsigned flags,
122 struct page **pagep, void **fsdata)
180{ 123{
181 struct afs_writeback *candidate, *wb; 124 struct afs_writeback *candidate, *wb;
182 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode); 125 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode);
126 struct page *page;
183 struct key *key = file->private_data; 127 struct key *key = file->private_data;
184 pgoff_t index; 128 unsigned from = pos & (PAGE_CACHE_SIZE - 1);
129 unsigned to = from + len;
130 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
185 int ret; 131 int ret;
186 132
187 _enter("{%x:%u},{%lx},%u,%u", 133 _enter("{%x:%u},{%lx},%u,%u",
188 vnode->fid.vid, vnode->fid.vnode, page->index, offset, to); 134 vnode->fid.vid, vnode->fid.vnode, index, from, to);
189 135
190 candidate = kzalloc(sizeof(*candidate), GFP_KERNEL); 136 candidate = kzalloc(sizeof(*candidate), GFP_KERNEL);
191 if (!candidate) 137 if (!candidate)
192 return -ENOMEM; 138 return -ENOMEM;
193 candidate->vnode = vnode; 139 candidate->vnode = vnode;
194 candidate->first = candidate->last = page->index; 140 candidate->first = candidate->last = index;
195 candidate->offset_first = offset; 141 candidate->offset_first = from;
196 candidate->to_last = to; 142 candidate->to_last = to;
197 candidate->usage = 1; 143 candidate->usage = 1;
198 candidate->state = AFS_WBACK_PENDING; 144 candidate->state = AFS_WBACK_PENDING;
199 init_waitqueue_head(&candidate->waitq); 145 init_waitqueue_head(&candidate->waitq);
200 146
147 page = __grab_cache_page(mapping, index);
148 if (!page) {
149 kfree(candidate);
150 return -ENOMEM;
151 }
152 *pagep = page;
153 /* page won't leak in error case: it eventually gets cleaned off LRU */
154
201 if (!PageUptodate(page)) { 155 if (!PageUptodate(page)) {
202 _debug("not up to date"); 156 _debug("not up to date");
203 ret = afs_prepare_page(vnode, page, key, offset, to); 157 ret = afs_fill_page(vnode, key, pos, len, page);
204 if (ret < 0) { 158 if (ret < 0) {
205 kfree(candidate); 159 kfree(candidate);
206 _leave(" = %d [prep]", ret); 160 _leave(" = %d [prep]", ret);
207 return ret; 161 return ret;
208 } 162 }
163 SetPageUptodate(page);
209 } 164 }
210 165
211try_again: 166try_again:
212 index = page->index;
213 spin_lock(&vnode->writeback_lock); 167 spin_lock(&vnode->writeback_lock);
214 168
215 /* see if this page is already pending a writeback under a suitable key 169 /* see if this page is already pending a writeback under a suitable key
@@ -242,8 +196,8 @@ try_again:
242subsume_in_current_wb: 196subsume_in_current_wb:
243 _debug("subsume"); 197 _debug("subsume");
244 ASSERTRANGE(wb->first, <=, index, <=, wb->last); 198 ASSERTRANGE(wb->first, <=, index, <=, wb->last);
245 if (index == wb->first && offset < wb->offset_first) 199 if (index == wb->first && from < wb->offset_first)
246 wb->offset_first = offset; 200 wb->offset_first = from;
247 if (index == wb->last && to > wb->to_last) 201 if (index == wb->last && to > wb->to_last)
248 wb->to_last = to; 202 wb->to_last = to;
249 spin_unlock(&vnode->writeback_lock); 203 spin_unlock(&vnode->writeback_lock);
@@ -289,17 +243,17 @@ flush_conflicting_wb:
289/* 243/*
290 * finalise part of a write to a page 244 * finalise part of a write to a page
291 */ 245 */
292int afs_commit_write(struct file *file, struct page *page, 246int afs_write_end(struct file *file, struct address_space *mapping,
293 unsigned offset, unsigned to) 247 loff_t pos, unsigned len, unsigned copied,
248 struct page *page, void *fsdata)
294{ 249{
295 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode); 250 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode);
296 loff_t i_size, maybe_i_size; 251 loff_t i_size, maybe_i_size;
297 252
298 _enter("{%x:%u},{%lx},%u,%u", 253 _enter("{%x:%u},{%lx}",
299 vnode->fid.vid, vnode->fid.vnode, page->index, offset, to); 254 vnode->fid.vid, vnode->fid.vnode, page->index);
300 255
301 maybe_i_size = (loff_t) page->index << PAGE_SHIFT; 256 maybe_i_size = pos + copied;
302 maybe_i_size += to;
303 257
304 i_size = i_size_read(&vnode->vfs_inode); 258 i_size = i_size_read(&vnode->vfs_inode);
305 if (maybe_i_size > i_size) { 259 if (maybe_i_size > i_size) {
@@ -310,12 +264,13 @@ int afs_commit_write(struct file *file, struct page *page,
310 spin_unlock(&vnode->writeback_lock); 264 spin_unlock(&vnode->writeback_lock);
311 } 265 }
312 266
313 SetPageUptodate(page);
314 set_page_dirty(page); 267 set_page_dirty(page);
315 if (PageDirty(page)) 268 if (PageDirty(page))
316 _debug("dirtied"); 269 _debug("dirtied");
270 unlock_page(page);
271 page_cache_release(page);
317 272
318 return 0; 273 return copied;
319} 274}
320 275
321/* 276/*
diff --git a/fs/autofs4/Makefile b/fs/autofs4/Makefile
index f2c3b79e94d2..a811c1f7d9ab 100644
--- a/fs/autofs4/Makefile
+++ b/fs/autofs4/Makefile
@@ -4,4 +4,4 @@
4 4
5obj-$(CONFIG_AUTOFS4_FS) += autofs4.o 5obj-$(CONFIG_AUTOFS4_FS) += autofs4.o
6 6
7autofs4-objs := init.o inode.o root.o symlink.o waitq.o expire.o 7autofs4-objs := init.o inode.o root.o symlink.o waitq.o expire.o dev-ioctl.o
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 69a2f5c92319..e0f16da00e54 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -14,6 +14,7 @@
14/* Internal header file for autofs */ 14/* Internal header file for autofs */
15 15
16#include <linux/auto_fs4.h> 16#include <linux/auto_fs4.h>
17#include <linux/auto_dev-ioctl.h>
17#include <linux/mutex.h> 18#include <linux/mutex.h>
18#include <linux/list.h> 19#include <linux/list.h>
19 20
@@ -21,6 +22,11 @@
21#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY 22#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
22#define AUTOFS_IOC_COUNT 32 23#define AUTOFS_IOC_COUNT 32
23 24
25#define AUTOFS_DEV_IOCTL_IOC_FIRST (AUTOFS_DEV_IOCTL_VERSION)
26#define AUTOFS_DEV_IOCTL_IOC_COUNT (AUTOFS_IOC_COUNT - 11)
27
28#define AUTOFS_TYPE_TRIGGER (AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET)
29
24#include <linux/kernel.h> 30#include <linux/kernel.h>
25#include <linux/slab.h> 31#include <linux/slab.h>
26#include <linux/time.h> 32#include <linux/time.h>
@@ -35,11 +41,27 @@
35/* #define DEBUG */ 41/* #define DEBUG */
36 42
37#ifdef DEBUG 43#ifdef DEBUG
38#define DPRINTK(fmt,args...) do { printk(KERN_DEBUG "pid %d: %s: " fmt "\n" , current->pid , __func__ , ##args); } while(0) 44#define DPRINTK(fmt, args...) \
45do { \
46 printk(KERN_DEBUG "pid %d: %s: " fmt "\n", \
47 current->pid, __func__, ##args); \
48} while (0)
39#else 49#else
40#define DPRINTK(fmt,args...) do {} while(0) 50#define DPRINTK(fmt, args...) do {} while (0)
41#endif 51#endif
42 52
53#define AUTOFS_WARN(fmt, args...) \
54do { \
55 printk(KERN_WARNING "pid %d: %s: " fmt "\n", \
56 current->pid, __func__, ##args); \
57} while (0)
58
59#define AUTOFS_ERROR(fmt, args...) \
60do { \
61 printk(KERN_ERR "pid %d: %s: " fmt "\n", \
62 current->pid, __func__, ##args); \
63} while (0)
64
43/* Unified info structure. This is pointed to by both the dentry and 65/* Unified info structure. This is pointed to by both the dentry and
44 inode structures. Each file in the filesystem has an instance of this 66 inode structures. Each file in the filesystem has an instance of this
45 structure. It holds a reference to the dentry, so dentries are never 67 structure. It holds a reference to the dentry, so dentries are never
@@ -61,6 +83,9 @@ struct autofs_info {
61 unsigned long last_used; 83 unsigned long last_used;
62 atomic_t count; 84 atomic_t count;
63 85
86 uid_t uid;
87 gid_t gid;
88
64 mode_t mode; 89 mode_t mode;
65 size_t size; 90 size_t size;
66 91
@@ -92,10 +117,6 @@ struct autofs_wait_queue {
92 117
93#define AUTOFS_SBI_MAGIC 0x6d4a556d 118#define AUTOFS_SBI_MAGIC 0x6d4a556d
94 119
95#define AUTOFS_TYPE_INDIRECT 0x0001
96#define AUTOFS_TYPE_DIRECT 0x0002
97#define AUTOFS_TYPE_OFFSET 0x0004
98
99struct autofs_sb_info { 120struct autofs_sb_info {
100 u32 magic; 121 u32 magic;
101 int pipefd; 122 int pipefd;
@@ -169,6 +190,17 @@ int autofs4_expire_run(struct super_block *, struct vfsmount *,
169 struct autofs_packet_expire __user *); 190 struct autofs_packet_expire __user *);
170int autofs4_expire_multi(struct super_block *, struct vfsmount *, 191int autofs4_expire_multi(struct super_block *, struct vfsmount *,
171 struct autofs_sb_info *, int __user *); 192 struct autofs_sb_info *, int __user *);
193struct dentry *autofs4_expire_direct(struct super_block *sb,
194 struct vfsmount *mnt,
195 struct autofs_sb_info *sbi, int how);
196struct dentry *autofs4_expire_indirect(struct super_block *sb,
197 struct vfsmount *mnt,
198 struct autofs_sb_info *sbi, int how);
199
200/* Device node initialization */
201
202int autofs_dev_ioctl_init(void);
203void autofs_dev_ioctl_exit(void);
172 204
173/* Operations structures */ 205/* Operations structures */
174 206
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
new file mode 100644
index 000000000000..625abf5422e2
--- /dev/null
+++ b/fs/autofs4/dev-ioctl.c
@@ -0,0 +1,863 @@
1/*
2 * Copyright 2008 Red Hat, Inc. All rights reserved.
3 * Copyright 2008 Ian Kent <raven@themaw.net>
4 *
5 * This file is part of the Linux kernel and is made available under
6 * the terms of the GNU General Public License, version 2, or at your
7 * option, any later version, incorporated herein by reference.
8 */
9
10#include <linux/module.h>
11#include <linux/vmalloc.h>
12#include <linux/miscdevice.h>
13#include <linux/init.h>
14#include <linux/wait.h>
15#include <linux/namei.h>
16#include <linux/fcntl.h>
17#include <linux/file.h>
18#include <linux/fdtable.h>
19#include <linux/sched.h>
20#include <linux/compat.h>
21#include <linux/syscalls.h>
22#include <linux/smp_lock.h>
23#include <linux/magic.h>
24#include <linux/dcache.h>
25#include <linux/uaccess.h>
26
27#include "autofs_i.h"
28
29/*
30 * This module implements an interface for routing autofs ioctl control
31 * commands via a miscellaneous device file.
32 *
33 * The alternate interface is needed because we need to be able open
34 * an ioctl file descriptor on an autofs mount that may be covered by
35 * another mount. This situation arises when starting automount(8)
36 * or other user space daemon which uses direct mounts or offset
37 * mounts (used for autofs lazy mount/umount of nested mount trees),
38 * which have been left busy at at service shutdown.
39 */
40
41#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl)
42
43typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *,
44 struct autofs_dev_ioctl *);
45
46static int check_name(const char *name)
47{
48 if (!strchr(name, '/'))
49 return -EINVAL;
50 return 0;
51}
52
53/*
54 * Check a string doesn't overrun the chunk of
55 * memory we copied from user land.
56 */
57static int invalid_str(char *str, void *end)
58{
59 while ((void *) str <= end)
60 if (!*str++)
61 return 0;
62 return -EINVAL;
63}
64
65/*
66 * Check that the user compiled against correct version of autofs
67 * misc device code.
68 *
69 * As well as checking the version compatibility this always copies
70 * the kernel interface version out.
71 */
72static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
73{
74 int err = 0;
75
76 if ((AUTOFS_DEV_IOCTL_VERSION_MAJOR != param->ver_major) ||
77 (AUTOFS_DEV_IOCTL_VERSION_MINOR < param->ver_minor)) {
78 AUTOFS_WARN("ioctl control interface version mismatch: "
79 "kernel(%u.%u), user(%u.%u), cmd(%d)",
80 AUTOFS_DEV_IOCTL_VERSION_MAJOR,
81 AUTOFS_DEV_IOCTL_VERSION_MINOR,
82 param->ver_major, param->ver_minor, cmd);
83 err = -EINVAL;
84 }
85
86 /* Fill in the kernel version. */
87 param->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
88 param->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
89
90 return err;
91}
92
93/*
94 * Copy parameter control struct, including a possible path allocated
95 * at the end of the struct.
96 */
97static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
98{
99 struct autofs_dev_ioctl tmp, *ads;
100
101 if (copy_from_user(&tmp, in, sizeof(tmp)))
102 return ERR_PTR(-EFAULT);
103
104 if (tmp.size < sizeof(tmp))
105 return ERR_PTR(-EINVAL);
106
107 ads = kmalloc(tmp.size, GFP_KERNEL);
108 if (!ads)
109 return ERR_PTR(-ENOMEM);
110
111 if (copy_from_user(ads, in, tmp.size)) {
112 kfree(ads);
113 return ERR_PTR(-EFAULT);
114 }
115
116 return ads;
117}
118
119static inline void free_dev_ioctl(struct autofs_dev_ioctl *param)
120{
121 kfree(param);
122 return;
123}
124
125/*
126 * Check sanity of parameter control fields and if a path is present
127 * check that it has a "/" and is terminated.
128 */
129static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
130{
131 int err = -EINVAL;
132
133 if (check_dev_ioctl_version(cmd, param)) {
134 AUTOFS_WARN("invalid device control module version "
135 "supplied for cmd(0x%08x)", cmd);
136 goto out;
137 }
138
139 if (param->size > sizeof(*param)) {
140 err = check_name(param->path);
141 if (err) {
142 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
143 cmd);
144 goto out;
145 }
146
147 err = invalid_str(param->path,
148 (void *) ((size_t) param + param->size));
149 if (err) {
150 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
151 cmd);
152 goto out;
153 }
154 }
155
156 err = 0;
157out:
158 return err;
159}
160
161/*
162 * Get the autofs super block info struct from the file opened on
163 * the autofs mount point.
164 */
165static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct file *f)
166{
167 struct autofs_sb_info *sbi = NULL;
168 struct inode *inode;
169
170 if (f) {
171 inode = f->f_path.dentry->d_inode;
172 sbi = autofs4_sbi(inode->i_sb);
173 }
174 return sbi;
175}
176
177/* Return autofs module protocol version */
178static int autofs_dev_ioctl_protover(struct file *fp,
179 struct autofs_sb_info *sbi,
180 struct autofs_dev_ioctl *param)
181{
182 param->arg1 = sbi->version;
183 return 0;
184}
185
186/* Return autofs module protocol sub version */
187static int autofs_dev_ioctl_protosubver(struct file *fp,
188 struct autofs_sb_info *sbi,
189 struct autofs_dev_ioctl *param)
190{
191 param->arg1 = sbi->sub_version;
192 return 0;
193}
194
195/*
196 * Walk down the mount stack looking for an autofs mount that
197 * has the requested device number (aka. new_encode_dev(sb->s_dev).
198 */
199static int autofs_dev_ioctl_find_super(struct nameidata *nd, dev_t devno)
200{
201 struct dentry *dentry;
202 struct inode *inode;
203 struct super_block *sb;
204 dev_t s_dev;
205 unsigned int err;
206
207 err = -ENOENT;
208
209 /* Lookup the dentry name at the base of our mount point */
210 dentry = d_lookup(nd->path.dentry, &nd->last);
211 if (!dentry)
212 goto out;
213
214 dput(nd->path.dentry);
215 nd->path.dentry = dentry;
216
217 /* And follow the mount stack looking for our autofs mount */
218 while (follow_down(&nd->path.mnt, &nd->path.dentry)) {
219 inode = nd->path.dentry->d_inode;
220 if (!inode)
221 break;
222
223 sb = inode->i_sb;
224 s_dev = new_encode_dev(sb->s_dev);
225 if (devno == s_dev) {
226 if (sb->s_magic == AUTOFS_SUPER_MAGIC) {
227 err = 0;
228 break;
229 }
230 }
231 }
232out:
233 return err;
234}
235
236/*
237 * Walk down the mount stack looking for an autofs mount that
238 * has the requested mount type (ie. indirect, direct or offset).
239 */
240static int autofs_dev_ioctl_find_sbi_type(struct nameidata *nd, unsigned int type)
241{
242 struct dentry *dentry;
243 struct autofs_info *ino;
244 unsigned int err;
245
246 err = -ENOENT;
247
248 /* Lookup the dentry name at the base of our mount point */
249 dentry = d_lookup(nd->path.dentry, &nd->last);
250 if (!dentry)
251 goto out;
252
253 dput(nd->path.dentry);
254 nd->path.dentry = dentry;
255
256 /* And follow the mount stack looking for our autofs mount */
257 while (follow_down(&nd->path.mnt, &nd->path.dentry)) {
258 ino = autofs4_dentry_ino(nd->path.dentry);
259 if (ino && ino->sbi->type & type) {
260 err = 0;
261 break;
262 }
263 }
264out:
265 return err;
266}
267
268static void autofs_dev_ioctl_fd_install(unsigned int fd, struct file *file)
269{
270 struct files_struct *files = current->files;
271 struct fdtable *fdt;
272
273 spin_lock(&files->file_lock);
274 fdt = files_fdtable(files);
275 BUG_ON(fdt->fd[fd] != NULL);
276 rcu_assign_pointer(fdt->fd[fd], file);
277 FD_SET(fd, fdt->close_on_exec);
278 spin_unlock(&files->file_lock);
279}
280
281
282/*
283 * Open a file descriptor on the autofs mount point corresponding
284 * to the given path and device number (aka. new_encode_dev(sb->s_dev)).
285 */
286static int autofs_dev_ioctl_open_mountpoint(const char *path, dev_t devid)
287{
288 struct file *filp;
289 struct nameidata nd;
290 int err, fd;
291
292 fd = get_unused_fd();
293 if (likely(fd >= 0)) {
294 /* Get nameidata of the parent directory */
295 err = path_lookup(path, LOOKUP_PARENT, &nd);
296 if (err)
297 goto out;
298
299 /*
300 * Search down, within the parent, looking for an
301 * autofs super block that has the device number
302 * corresponding to the autofs fs we want to open.
303 */
304 err = autofs_dev_ioctl_find_super(&nd, devid);
305 if (err) {
306 path_put(&nd.path);
307 goto out;
308 }
309
310 filp = dentry_open(nd.path.dentry, nd.path.mnt, O_RDONLY);
311 if (IS_ERR(filp)) {
312 err = PTR_ERR(filp);
313 goto out;
314 }
315
316 autofs_dev_ioctl_fd_install(fd, filp);
317 }
318
319 return fd;
320
321out:
322 put_unused_fd(fd);
323 return err;
324}
325
326/* Open a file descriptor on an autofs mount point */
327static int autofs_dev_ioctl_openmount(struct file *fp,
328 struct autofs_sb_info *sbi,
329 struct autofs_dev_ioctl *param)
330{
331 const char *path;
332 dev_t devid;
333 int err, fd;
334
335 /* param->path has already been checked */
336 if (!param->arg1)
337 return -EINVAL;
338
339 param->ioctlfd = -1;
340
341 path = param->path;
342 devid = param->arg1;
343
344 err = 0;
345 fd = autofs_dev_ioctl_open_mountpoint(path, devid);
346 if (unlikely(fd < 0)) {
347 err = fd;
348 goto out;
349 }
350
351 param->ioctlfd = fd;
352out:
353 return err;
354}
355
356/* Close file descriptor allocated above (user can also use close(2)). */
357static int autofs_dev_ioctl_closemount(struct file *fp,
358 struct autofs_sb_info *sbi,
359 struct autofs_dev_ioctl *param)
360{
361 return sys_close(param->ioctlfd);
362}
363
364/*
365 * Send "ready" status for an existing wait (either a mount or an expire
366 * request).
367 */
368static int autofs_dev_ioctl_ready(struct file *fp,
369 struct autofs_sb_info *sbi,
370 struct autofs_dev_ioctl *param)
371{
372 autofs_wqt_t token;
373
374 token = (autofs_wqt_t) param->arg1;
375 return autofs4_wait_release(sbi, token, 0);
376}
377
378/*
379 * Send "fail" status for an existing wait (either a mount or an expire
380 * request).
381 */
382static int autofs_dev_ioctl_fail(struct file *fp,
383 struct autofs_sb_info *sbi,
384 struct autofs_dev_ioctl *param)
385{
386 autofs_wqt_t token;
387 int status;
388
389 token = (autofs_wqt_t) param->arg1;
390 status = param->arg2 ? param->arg2 : -ENOENT;
391 return autofs4_wait_release(sbi, token, status);
392}
393
394/*
395 * Set the pipe fd for kernel communication to the daemon.
396 *
397 * Normally this is set at mount using an option but if we
398 * are reconnecting to a busy mount then we need to use this
399 * to tell the autofs mount about the new kernel pipe fd. In
400 * order to protect mounts against incorrectly setting the
401 * pipefd we also require that the autofs mount be catatonic.
402 *
403 * This also sets the process group id used to identify the
404 * controlling process (eg. the owning automount(8) daemon).
405 */
406static int autofs_dev_ioctl_setpipefd(struct file *fp,
407 struct autofs_sb_info *sbi,
408 struct autofs_dev_ioctl *param)
409{
410 int pipefd;
411 int err = 0;
412
413 if (param->arg1 == -1)
414 return -EINVAL;
415
416 pipefd = param->arg1;
417
418 mutex_lock(&sbi->wq_mutex);
419 if (!sbi->catatonic) {
420 mutex_unlock(&sbi->wq_mutex);
421 return -EBUSY;
422 } else {
423 struct file *pipe = fget(pipefd);
424 if (!pipe->f_op || !pipe->f_op->write) {
425 err = -EPIPE;
426 fput(pipe);
427 goto out;
428 }
429 sbi->oz_pgrp = task_pgrp_nr(current);
430 sbi->pipefd = pipefd;
431 sbi->pipe = pipe;
432 sbi->catatonic = 0;
433 }
434out:
435 mutex_unlock(&sbi->wq_mutex);
436 return err;
437}
438
439/*
440 * Make the autofs mount point catatonic, no longer responsive to
441 * mount requests. Also closes the kernel pipe file descriptor.
442 */
443static int autofs_dev_ioctl_catatonic(struct file *fp,
444 struct autofs_sb_info *sbi,
445 struct autofs_dev_ioctl *param)
446{
447 autofs4_catatonic_mode(sbi);
448 return 0;
449}
450
451/* Set the autofs mount timeout */
452static int autofs_dev_ioctl_timeout(struct file *fp,
453 struct autofs_sb_info *sbi,
454 struct autofs_dev_ioctl *param)
455{
456 unsigned long timeout;
457
458 timeout = param->arg1;
459 param->arg1 = sbi->exp_timeout / HZ;
460 sbi->exp_timeout = timeout * HZ;
461 return 0;
462}
463
464/*
465 * Return the uid and gid of the last request for the mount
466 *
467 * When reconstructing an autofs mount tree with active mounts
468 * we need to re-connect to mounts that may have used the original
469 * process uid and gid (or string variations of them) for mount
470 * lookups within the map entry.
471 */
472static int autofs_dev_ioctl_requester(struct file *fp,
473 struct autofs_sb_info *sbi,
474 struct autofs_dev_ioctl *param)
475{
476 struct autofs_info *ino;
477 struct nameidata nd;
478 const char *path;
479 dev_t devid;
480 int err = -ENOENT;
481
482 if (param->size <= sizeof(*param)) {
483 err = -EINVAL;
484 goto out;
485 }
486
487 path = param->path;
488 devid = sbi->sb->s_dev;
489
490 param->arg1 = param->arg2 = -1;
491
492 /* Get nameidata of the parent directory */
493 err = path_lookup(path, LOOKUP_PARENT, &nd);
494 if (err)
495 goto out;
496
497 err = autofs_dev_ioctl_find_super(&nd, devid);
498 if (err)
499 goto out_release;
500
501 ino = autofs4_dentry_ino(nd.path.dentry);
502 if (ino) {
503 err = 0;
504 autofs4_expire_wait(nd.path.dentry);
505 spin_lock(&sbi->fs_lock);
506 param->arg1 = ino->uid;
507 param->arg2 = ino->gid;
508 spin_unlock(&sbi->fs_lock);
509 }
510
511out_release:
512 path_put(&nd.path);
513out:
514 return err;
515}
516
517/*
518 * Call repeatedly until it returns -EAGAIN, meaning there's nothing
519 * more that can be done.
520 */
521static int autofs_dev_ioctl_expire(struct file *fp,
522 struct autofs_sb_info *sbi,
523 struct autofs_dev_ioctl *param)
524{
525 struct dentry *dentry;
526 struct vfsmount *mnt;
527 int err = -EAGAIN;
528 int how;
529
530 how = param->arg1;
531 mnt = fp->f_path.mnt;
532
533 if (sbi->type & AUTOFS_TYPE_TRIGGER)
534 dentry = autofs4_expire_direct(sbi->sb, mnt, sbi, how);
535 else
536 dentry = autofs4_expire_indirect(sbi->sb, mnt, sbi, how);
537
538 if (dentry) {
539 struct autofs_info *ino = autofs4_dentry_ino(dentry);
540
541 /*
542 * This is synchronous because it makes the daemon a
543 * little easier
544 */
545 err = autofs4_wait(sbi, dentry, NFY_EXPIRE);
546
547 spin_lock(&sbi->fs_lock);
548 if (ino->flags & AUTOFS_INF_MOUNTPOINT) {
549 ino->flags &= ~AUTOFS_INF_MOUNTPOINT;
550 sbi->sb->s_root->d_mounted++;
551 }
552 ino->flags &= ~AUTOFS_INF_EXPIRING;
553 complete_all(&ino->expire_complete);
554 spin_unlock(&sbi->fs_lock);
555 dput(dentry);
556 }
557
558 return err;
559}
560
561/* Check if autofs mount point is in use */
562static int autofs_dev_ioctl_askumount(struct file *fp,
563 struct autofs_sb_info *sbi,
564 struct autofs_dev_ioctl *param)
565{
566 param->arg1 = 0;
567 if (may_umount(fp->f_path.mnt))
568 param->arg1 = 1;
569 return 0;
570}
571
572/*
573 * Check if the given path is a mountpoint.
574 *
575 * If we are supplied with the file descriptor of an autofs
576 * mount we're looking for a specific mount. In this case
577 * the path is considered a mountpoint if it is itself a
578 * mountpoint or contains a mount, such as a multi-mount
579 * without a root mount. In this case we return 1 if the
580 * path is a mount point and the super magic of the covering
581 * mount if there is one or 0 if it isn't a mountpoint.
582 *
583 * If we aren't supplied with a file descriptor then we
584 * lookup the nameidata of the path and check if it is the
585 * root of a mount. If a type is given we are looking for
586 * a particular autofs mount and if we don't find a match
587 * we return fail. If the located nameidata path is the
588 * root of a mount we return 1 along with the super magic
589 * of the mount or 0 otherwise.
590 *
591 * In both cases the the device number (as returned by
592 * new_encode_dev()) is also returned.
593 */
594static int autofs_dev_ioctl_ismountpoint(struct file *fp,
595 struct autofs_sb_info *sbi,
596 struct autofs_dev_ioctl *param)
597{
598 struct nameidata nd;
599 const char *path;
600 unsigned int type;
601 int err = -ENOENT;
602
603 if (param->size <= sizeof(*param)) {
604 err = -EINVAL;
605 goto out;
606 }
607
608 path = param->path;
609 type = param->arg1;
610
611 param->arg1 = 0;
612 param->arg2 = 0;
613
614 if (!fp || param->ioctlfd == -1) {
615 if (type == AUTOFS_TYPE_ANY) {
616 struct super_block *sb;
617
618 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
619 if (err)
620 goto out;
621
622 sb = nd.path.dentry->d_sb;
623 param->arg1 = new_encode_dev(sb->s_dev);
624 } else {
625 struct autofs_info *ino;
626
627 err = path_lookup(path, LOOKUP_PARENT, &nd);
628 if (err)
629 goto out;
630
631 err = autofs_dev_ioctl_find_sbi_type(&nd, type);
632 if (err)
633 goto out_release;
634
635 ino = autofs4_dentry_ino(nd.path.dentry);
636 param->arg1 = autofs4_get_dev(ino->sbi);
637 }
638
639 err = 0;
640 if (nd.path.dentry->d_inode &&
641 nd.path.mnt->mnt_root == nd.path.dentry) {
642 err = 1;
643 param->arg2 = nd.path.dentry->d_inode->i_sb->s_magic;
644 }
645 } else {
646 dev_t devid = new_encode_dev(sbi->sb->s_dev);
647
648 err = path_lookup(path, LOOKUP_PARENT, &nd);
649 if (err)
650 goto out;
651
652 err = autofs_dev_ioctl_find_super(&nd, devid);
653 if (err)
654 goto out_release;
655
656 param->arg1 = autofs4_get_dev(sbi);
657
658 err = have_submounts(nd.path.dentry);
659
660 if (nd.path.mnt->mnt_mountpoint != nd.path.mnt->mnt_root) {
661 if (follow_down(&nd.path.mnt, &nd.path.dentry)) {
662 struct inode *inode = nd.path.dentry->d_inode;
663 param->arg2 = inode->i_sb->s_magic;
664 }
665 }
666 }
667
668out_release:
669 path_put(&nd.path);
670out:
671 return err;
672}
673
674/*
675 * Our range of ioctl numbers isn't 0 based so we need to shift
676 * the array index by _IOC_NR(AUTOFS_CTL_IOC_FIRST) for the table
677 * lookup.
678 */
679#define cmd_idx(cmd) (cmd - _IOC_NR(AUTOFS_DEV_IOCTL_IOC_FIRST))
680
681static ioctl_fn lookup_dev_ioctl(unsigned int cmd)
682{
683 static struct {
684 int cmd;
685 ioctl_fn fn;
686 } _ioctls[] = {
687 {cmd_idx(AUTOFS_DEV_IOCTL_VERSION_CMD), NULL},
688 {cmd_idx(AUTOFS_DEV_IOCTL_PROTOVER_CMD),
689 autofs_dev_ioctl_protover},
690 {cmd_idx(AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD),
691 autofs_dev_ioctl_protosubver},
692 {cmd_idx(AUTOFS_DEV_IOCTL_OPENMOUNT_CMD),
693 autofs_dev_ioctl_openmount},
694 {cmd_idx(AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD),
695 autofs_dev_ioctl_closemount},
696 {cmd_idx(AUTOFS_DEV_IOCTL_READY_CMD),
697 autofs_dev_ioctl_ready},
698 {cmd_idx(AUTOFS_DEV_IOCTL_FAIL_CMD),
699 autofs_dev_ioctl_fail},
700 {cmd_idx(AUTOFS_DEV_IOCTL_SETPIPEFD_CMD),
701 autofs_dev_ioctl_setpipefd},
702 {cmd_idx(AUTOFS_DEV_IOCTL_CATATONIC_CMD),
703 autofs_dev_ioctl_catatonic},
704 {cmd_idx(AUTOFS_DEV_IOCTL_TIMEOUT_CMD),
705 autofs_dev_ioctl_timeout},
706 {cmd_idx(AUTOFS_DEV_IOCTL_REQUESTER_CMD),
707 autofs_dev_ioctl_requester},
708 {cmd_idx(AUTOFS_DEV_IOCTL_EXPIRE_CMD),
709 autofs_dev_ioctl_expire},
710 {cmd_idx(AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD),
711 autofs_dev_ioctl_askumount},
712 {cmd_idx(AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD),
713 autofs_dev_ioctl_ismountpoint}
714 };
715 unsigned int idx = cmd_idx(cmd);
716
717 return (idx >= ARRAY_SIZE(_ioctls)) ? NULL : _ioctls[idx].fn;
718}
719
720/* ioctl dispatcher */
721static int _autofs_dev_ioctl(unsigned int command, struct autofs_dev_ioctl __user *user)
722{
723 struct autofs_dev_ioctl *param;
724 struct file *fp;
725 struct autofs_sb_info *sbi;
726 unsigned int cmd_first, cmd;
727 ioctl_fn fn = NULL;
728 int err = 0;
729
730 /* only root can play with this */
731 if (!capable(CAP_SYS_ADMIN))
732 return -EPERM;
733
734 cmd_first = _IOC_NR(AUTOFS_DEV_IOCTL_IOC_FIRST);
735 cmd = _IOC_NR(command);
736
737 if (_IOC_TYPE(command) != _IOC_TYPE(AUTOFS_DEV_IOCTL_IOC_FIRST) ||
738 cmd - cmd_first >= AUTOFS_DEV_IOCTL_IOC_COUNT) {
739 return -ENOTTY;
740 }
741
742 /* Copy the parameters into kernel space. */
743 param = copy_dev_ioctl(user);
744 if (IS_ERR(param))
745 return PTR_ERR(param);
746
747 err = validate_dev_ioctl(command, param);
748 if (err)
749 goto out;
750
751 /* The validate routine above always sets the version */
752 if (cmd == AUTOFS_DEV_IOCTL_VERSION_CMD)
753 goto done;
754
755 fn = lookup_dev_ioctl(cmd);
756 if (!fn) {
757 AUTOFS_WARN("unknown command 0x%08x", command);
758 return -ENOTTY;
759 }
760
761 fp = NULL;
762 sbi = NULL;
763
764 /*
765 * For obvious reasons the openmount can't have a file
766 * descriptor yet. We don't take a reference to the
767 * file during close to allow for immediate release.
768 */
769 if (cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD &&
770 cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) {
771 fp = fget(param->ioctlfd);
772 if (!fp) {
773 if (cmd == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD)
774 goto cont;
775 err = -EBADF;
776 goto out;
777 }
778
779 if (!fp->f_op) {
780 err = -ENOTTY;
781 fput(fp);
782 goto out;
783 }
784
785 sbi = autofs_dev_ioctl_sbi(fp);
786 if (!sbi || sbi->magic != AUTOFS_SBI_MAGIC) {
787 err = -EINVAL;
788 fput(fp);
789 goto out;
790 }
791
792 /*
793 * Admin needs to be able to set the mount catatonic in
794 * order to be able to perform the re-open.
795 */
796 if (!autofs4_oz_mode(sbi) &&
797 cmd != AUTOFS_DEV_IOCTL_CATATONIC_CMD) {
798 err = -EACCES;
799 fput(fp);
800 goto out;
801 }
802 }
803cont:
804 err = fn(fp, sbi, param);
805
806 if (fp)
807 fput(fp);
808done:
809 if (err >= 0 && copy_to_user(user, param, AUTOFS_DEV_IOCTL_SIZE))
810 err = -EFAULT;
811out:
812 free_dev_ioctl(param);
813 return err;
814}
815
816static long autofs_dev_ioctl(struct file *file, uint command, ulong u)
817{
818 int err;
819 err = _autofs_dev_ioctl(command, (struct autofs_dev_ioctl __user *) u);
820 return (long) err;
821}
822
823#ifdef CONFIG_COMPAT
824static long autofs_dev_ioctl_compat(struct file *file, uint command, ulong u)
825{
826 return (long) autofs_dev_ioctl(file, command, (ulong) compat_ptr(u));
827}
828#else
829#define autofs_dev_ioctl_compat NULL
830#endif
831
832static const struct file_operations _dev_ioctl_fops = {
833 .unlocked_ioctl = autofs_dev_ioctl,
834 .compat_ioctl = autofs_dev_ioctl_compat,
835 .owner = THIS_MODULE,
836};
837
838static struct miscdevice _autofs_dev_ioctl_misc = {
839 .minor = MISC_DYNAMIC_MINOR,
840 .name = AUTOFS_DEVICE_NAME,
841 .fops = &_dev_ioctl_fops
842};
843
844/* Register/deregister misc character device */
845int autofs_dev_ioctl_init(void)
846{
847 int r;
848
849 r = misc_register(&_autofs_dev_ioctl_misc);
850 if (r) {
851 AUTOFS_ERROR("misc_register failed for control device");
852 return r;
853 }
854
855 return 0;
856}
857
858void autofs_dev_ioctl_exit(void)
859{
860 misc_deregister(&_autofs_dev_ioctl_misc);
861 return;
862}
863
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index cdabb796ff01..cde2f8e8935a 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -244,10 +244,10 @@ cont:
244} 244}
245 245
246/* Check if we can expire a direct mount (possibly a tree) */ 246/* Check if we can expire a direct mount (possibly a tree) */
247static struct dentry *autofs4_expire_direct(struct super_block *sb, 247struct dentry *autofs4_expire_direct(struct super_block *sb,
248 struct vfsmount *mnt, 248 struct vfsmount *mnt,
249 struct autofs_sb_info *sbi, 249 struct autofs_sb_info *sbi,
250 int how) 250 int how)
251{ 251{
252 unsigned long timeout; 252 unsigned long timeout;
253 struct dentry *root = dget(sb->s_root); 253 struct dentry *root = dget(sb->s_root);
@@ -283,10 +283,10 @@ static struct dentry *autofs4_expire_direct(struct super_block *sb,
283 * - it is unused by any user process 283 * - it is unused by any user process
284 * - it has been unused for exp_timeout time 284 * - it has been unused for exp_timeout time
285 */ 285 */
286static struct dentry *autofs4_expire_indirect(struct super_block *sb, 286struct dentry *autofs4_expire_indirect(struct super_block *sb,
287 struct vfsmount *mnt, 287 struct vfsmount *mnt,
288 struct autofs_sb_info *sbi, 288 struct autofs_sb_info *sbi,
289 int how) 289 int how)
290{ 290{
291 unsigned long timeout; 291 unsigned long timeout;
292 struct dentry *root = sb->s_root; 292 struct dentry *root = sb->s_root;
@@ -479,7 +479,7 @@ int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
479 if (arg && get_user(do_now, arg)) 479 if (arg && get_user(do_now, arg))
480 return -EFAULT; 480 return -EFAULT;
481 481
482 if (sbi->type & AUTOFS_TYPE_DIRECT) 482 if (sbi->type & AUTOFS_TYPE_TRIGGER)
483 dentry = autofs4_expire_direct(sb, mnt, sbi, do_now); 483 dentry = autofs4_expire_direct(sb, mnt, sbi, do_now);
484 else 484 else
485 dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now); 485 dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now);
diff --git a/fs/autofs4/init.c b/fs/autofs4/init.c
index 723a1c5e361b..9722e4bd8957 100644
--- a/fs/autofs4/init.c
+++ b/fs/autofs4/init.c
@@ -29,11 +29,20 @@ static struct file_system_type autofs_fs_type = {
29 29
30static int __init init_autofs4_fs(void) 30static int __init init_autofs4_fs(void)
31{ 31{
32 return register_filesystem(&autofs_fs_type); 32 int err;
33
34 err = register_filesystem(&autofs_fs_type);
35 if (err)
36 return err;
37
38 autofs_dev_ioctl_init();
39
40 return err;
33} 41}
34 42
35static void __exit exit_autofs4_fs(void) 43static void __exit exit_autofs4_fs(void)
36{ 44{
45 autofs_dev_ioctl_exit();
37 unregister_filesystem(&autofs_fs_type); 46 unregister_filesystem(&autofs_fs_type);
38} 47}
39 48
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 45d55819203d..c7e65bb30ba0 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -53,6 +53,8 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
53 atomic_set(&ino->count, 0); 53 atomic_set(&ino->count, 0);
54 } 54 }
55 55
56 ino->uid = 0;
57 ino->gid = 0;
56 ino->mode = mode; 58 ino->mode = mode;
57 ino->last_used = jiffies; 59 ino->last_used = jiffies;
58 60
@@ -288,7 +290,7 @@ static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
288 *type = AUTOFS_TYPE_DIRECT; 290 *type = AUTOFS_TYPE_DIRECT;
289 break; 291 break;
290 case Opt_offset: 292 case Opt_offset:
291 *type = AUTOFS_TYPE_DIRECT | AUTOFS_TYPE_OFFSET; 293 *type = AUTOFS_TYPE_OFFSET;
292 break; 294 break;
293 default: 295 default:
294 return 1; 296 return 1;
@@ -336,7 +338,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
336 sbi->sb = s; 338 sbi->sb = s;
337 sbi->version = 0; 339 sbi->version = 0;
338 sbi->sub_version = 0; 340 sbi->sub_version = 0;
339 sbi->type = 0; 341 sbi->type = AUTOFS_TYPE_INDIRECT;
340 sbi->min_proto = 0; 342 sbi->min_proto = 0;
341 sbi->max_proto = 0; 343 sbi->max_proto = 0;
342 mutex_init(&sbi->wq_mutex); 344 mutex_init(&sbi->wq_mutex);
@@ -378,7 +380,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
378 } 380 }
379 381
380 root_inode->i_fop = &autofs4_root_operations; 382 root_inode->i_fop = &autofs4_root_operations;
381 root_inode->i_op = sbi->type & AUTOFS_TYPE_DIRECT ? 383 root_inode->i_op = sbi->type & AUTOFS_TYPE_TRIGGER ?
382 &autofs4_direct_root_inode_operations : 384 &autofs4_direct_root_inode_operations :
383 &autofs4_indirect_root_inode_operations; 385 &autofs4_indirect_root_inode_operations;
384 386
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 35216d18d8b5..4b67c2a2d77c 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -337,7 +337,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
337 * is very similar for indirect mounts except only dentrys 337 * is very similar for indirect mounts except only dentrys
338 * in the root of the autofs file system may be negative. 338 * in the root of the autofs file system may be negative.
339 */ 339 */
340 if (sbi->type & (AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET)) 340 if (sbi->type & AUTOFS_TYPE_TRIGGER)
341 return -ENOENT; 341 return -ENOENT;
342 else if (!IS_ROOT(dentry->d_parent)) 342 else if (!IS_ROOT(dentry->d_parent))
343 return -ENOENT; 343 return -ENOENT;
@@ -348,7 +348,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
348 return -ENOMEM; 348 return -ENOMEM;
349 349
350 /* If this is a direct mount request create a dummy name */ 350 /* If this is a direct mount request create a dummy name */
351 if (IS_ROOT(dentry) && (sbi->type & AUTOFS_TYPE_DIRECT)) 351 if (IS_ROOT(dentry) && sbi->type & AUTOFS_TYPE_TRIGGER)
352 qstr.len = sprintf(name, "%p", dentry); 352 qstr.len = sprintf(name, "%p", dentry);
353 else { 353 else {
354 qstr.len = autofs4_getpath(sbi, dentry, &name); 354 qstr.len = autofs4_getpath(sbi, dentry, &name);
@@ -406,11 +406,11 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
406 type = autofs_ptype_expire_multi; 406 type = autofs_ptype_expire_multi;
407 } else { 407 } else {
408 if (notify == NFY_MOUNT) 408 if (notify == NFY_MOUNT)
409 type = (sbi->type & AUTOFS_TYPE_DIRECT) ? 409 type = (sbi->type & AUTOFS_TYPE_TRIGGER) ?
410 autofs_ptype_missing_direct : 410 autofs_ptype_missing_direct :
411 autofs_ptype_missing_indirect; 411 autofs_ptype_missing_indirect;
412 else 412 else
413 type = (sbi->type & AUTOFS_TYPE_DIRECT) ? 413 type = (sbi->type & AUTOFS_TYPE_TRIGGER) ?
414 autofs_ptype_expire_direct : 414 autofs_ptype_expire_direct :
415 autofs_ptype_expire_indirect; 415 autofs_ptype_expire_indirect;
416 } 416 }
@@ -457,6 +457,40 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
457 457
458 status = wq->status; 458 status = wq->status;
459 459
460 /*
461 * For direct and offset mounts we need to track the requester's
462 * uid and gid in the dentry info struct. This is so it can be
463 * supplied, on request, by the misc device ioctl interface.
464 * This is needed during daemon resatart when reconnecting
465 * to existing, active, autofs mounts. The uid and gid (and
466 * related string values) may be used for macro substitution
467 * in autofs mount maps.
468 */
469 if (!status) {
470 struct autofs_info *ino;
471 struct dentry *de = NULL;
472
473 /* direct mount or browsable map */
474 ino = autofs4_dentry_ino(dentry);
475 if (!ino) {
476 /* If not lookup actual dentry used */
477 de = d_lookup(dentry->d_parent, &dentry->d_name);
478 if (de)
479 ino = autofs4_dentry_ino(de);
480 }
481
482 /* Set mount requester */
483 if (ino) {
484 spin_lock(&sbi->fs_lock);
485 ino->uid = wq->uid;
486 ino->gid = wq->gid;
487 spin_unlock(&sbi->fs_lock);
488 }
489
490 if (de)
491 dput(de);
492 }
493
460 /* Are we the last process to need status? */ 494 /* Are we the last process to need status? */
461 mutex_lock(&sbi->wq_mutex); 495 mutex_lock(&sbi->wq_mutex);
462 if (!--wq->wait_ctr) 496 if (!--wq->wait_ctr)
diff --git a/fs/befs/befs_fs_types.h b/fs/befs/befs_fs_types.h
index e2595c2c403a..7893eaa1e58c 100644
--- a/fs/befs/befs_fs_types.h
+++ b/fs/befs/befs_fs_types.h
@@ -55,8 +55,12 @@ enum super_flags {
55}; 55};
56 56
57#define BEFS_BYTEORDER_NATIVE 0x42494745 57#define BEFS_BYTEORDER_NATIVE 0x42494745
58#define BEFS_BYTEORDER_NATIVE_LE (__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE)
59#define BEFS_BYTEORDER_NATIVE_BE (__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE)
58 60
59#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1 61#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
62#define BEFS_SUPER_MAGIC1_LE (__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1)
63#define BEFS_SUPER_MAGIC1_BE (__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1)
60 64
61/* 65/*
62 * Flags of inode 66 * Flags of inode
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 9286b2af893a..b6dfee37c7b7 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -809,8 +809,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
809 809
810 /* account for offset of super block on x86 */ 810 /* account for offset of super block on x86 */
811 disk_sb = (befs_super_block *) bh->b_data; 811 disk_sb = (befs_super_block *) bh->b_data;
812 if ((le32_to_cpu(disk_sb->magic1) == BEFS_SUPER_MAGIC1) || 812 if ((disk_sb->magic1 == BEFS_SUPER_MAGIC1_LE) ||
813 (be32_to_cpu(disk_sb->magic1) == BEFS_SUPER_MAGIC1)) { 813 (disk_sb->magic1 == BEFS_SUPER_MAGIC1_BE)) {
814 befs_debug(sb, "Using PPC superblock location"); 814 befs_debug(sb, "Using PPC superblock location");
815 } else { 815 } else {
816 befs_debug(sb, "Using x86 superblock location"); 816 befs_debug(sb, "Using x86 superblock location");
diff --git a/fs/befs/super.c b/fs/befs/super.c
index 8c3401ff6d6a..41f2b4d0093e 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -26,10 +26,10 @@ befs_load_sb(struct super_block *sb, befs_super_block * disk_sb)
26 befs_sb_info *befs_sb = BEFS_SB(sb); 26 befs_sb_info *befs_sb = BEFS_SB(sb);
27 27
28 /* Check the byte order of the filesystem */ 28 /* Check the byte order of the filesystem */
29 if (le32_to_cpu(disk_sb->fs_byte_order) == BEFS_BYTEORDER_NATIVE) 29 if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE)
30 befs_sb->byte_order = BEFS_BYTESEX_LE; 30 befs_sb->byte_order = BEFS_BYTESEX_LE;
31 else if (be32_to_cpu(disk_sb->fs_byte_order) == BEFS_BYTEORDER_NATIVE) 31 else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE)
32 befs_sb->byte_order = BEFS_BYTESEX_BE; 32 befs_sb->byte_order = BEFS_BYTESEX_BE;
33 33
34 befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1); 34 befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1);
35 befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2); 35 befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2);
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 655ed8d30a86..c76afa26edf7 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -683,7 +683,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
683 * switch really is going to happen - do this in 683 * switch really is going to happen - do this in
684 * flush_thread(). - akpm 684 * flush_thread(). - akpm
685 */ 685 */
686 SET_PERSONALITY(loc->elf_ex, 0); 686 SET_PERSONALITY(loc->elf_ex);
687 687
688 interpreter = open_exec(elf_interpreter); 688 interpreter = open_exec(elf_interpreter);
689 retval = PTR_ERR(interpreter); 689 retval = PTR_ERR(interpreter);
@@ -734,7 +734,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
734 goto out_free_dentry; 734 goto out_free_dentry;
735 } else { 735 } else {
736 /* Executables without an interpreter also need a personality */ 736 /* Executables without an interpreter also need a personality */
737 SET_PERSONALITY(loc->elf_ex, 0); 737 SET_PERSONALITY(loc->elf_ex);
738 } 738 }
739 739
740 /* Flush all traces of the currently running executable */ 740 /* Flush all traces of the currently running executable */
@@ -748,7 +748,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
748 748
749 /* Do this immediately, since STACK_TOP as used in setup_arg_pages 749 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
750 may depend on the personality. */ 750 may depend on the personality. */
751 SET_PERSONALITY(loc->elf_ex, 0); 751 SET_PERSONALITY(loc->elf_ex);
752 if (elf_read_implies_exec(loc->elf_ex, executable_stack)) 752 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
753 current->personality |= READ_IMPLIES_EXEC; 753 current->personality |= READ_IMPLIES_EXEC;
754 754
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 80c1f952ef78..0e8367c54624 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -25,6 +25,7 @@
25#include <linux/fcntl.h> 25#include <linux/fcntl.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/pagemap.h> 27#include <linux/pagemap.h>
28#include <linux/security.h>
28#include <linux/highmem.h> 29#include <linux/highmem.h>
29#include <linux/highuid.h> 30#include <linux/highuid.h>
30#include <linux/personality.h> 31#include <linux/personality.h>
@@ -455,8 +456,19 @@ error_kill:
455} 456}
456 457
457/*****************************************************************************/ 458/*****************************************************************************/
459
460#ifndef ELF_BASE_PLATFORM
458/* 461/*
459 * present useful information to the program 462 * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.
463 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value
464 * will be copied to the user stack in the same manner as AT_PLATFORM.
465 */
466#define ELF_BASE_PLATFORM NULL
467#endif
468
469/*
470 * present useful information to the program by shovelling it onto the new
471 * process's stack
460 */ 472 */
461static int create_elf_fdpic_tables(struct linux_binprm *bprm, 473static int create_elf_fdpic_tables(struct linux_binprm *bprm,
462 struct mm_struct *mm, 474 struct mm_struct *mm,
@@ -466,15 +478,19 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
466 unsigned long sp, csp, nitems; 478 unsigned long sp, csp, nitems;
467 elf_caddr_t __user *argv, *envp; 479 elf_caddr_t __user *argv, *envp;
468 size_t platform_len = 0, len; 480 size_t platform_len = 0, len;
469 char *k_platform; 481 char *k_platform, *k_base_platform;
470 char __user *u_platform, *p; 482 char __user *u_platform, *u_base_platform, *p;
471 long hwcap; 483 long hwcap;
472 int loop; 484 int loop;
473 int nr; /* reset for each csp adjustment */ 485 int nr; /* reset for each csp adjustment */
474 486
475 /* we're going to shovel a whole load of stuff onto the stack */
476#ifdef CONFIG_MMU 487#ifdef CONFIG_MMU
477 sp = bprm->p; 488 /* In some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
489 * by the processes running on the same package. One thing we can do is
490 * to shuffle the initial stack for them, so we give the architecture
491 * an opportunity to do so here.
492 */
493 sp = arch_align_stack(bprm->p);
478#else 494#else
479 sp = mm->start_stack; 495 sp = mm->start_stack;
480 496
@@ -483,11 +499,14 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
483 return -EFAULT; 499 return -EFAULT;
484#endif 500#endif
485 501
486 /* get hold of platform and hardware capabilities masks for the machine
487 * we are running on. In some cases (Sparc), this info is impossible
488 * to get, in others (i386) it is merely difficult.
489 */
490 hwcap = ELF_HWCAP; 502 hwcap = ELF_HWCAP;
503
504 /*
505 * If this architecture has a platform capability string, copy it
506 * to userspace. In some cases (Sparc), this info is impossible
507 * for userspace to get any other way, in others (i386) it is
508 * merely difficult.
509 */
491 k_platform = ELF_PLATFORM; 510 k_platform = ELF_PLATFORM;
492 u_platform = NULL; 511 u_platform = NULL;
493 512
@@ -499,19 +518,20 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
499 return -EFAULT; 518 return -EFAULT;
500 } 519 }
501 520
502#if defined(__i386__) && defined(CONFIG_SMP) 521 /*
503 /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions 522 * If this architecture has a "base" platform capability
504 * by the processes running on the same package. One thing we can do is 523 * string, copy it to userspace.
505 * to shuffle the initial stack for them.
506 *
507 * the conditionals here are unneeded, but kept in to make the code
508 * behaviour the same as pre change unless we have hyperthreaded
509 * processors. This keeps Mr Marcelo Person happier but should be
510 * removed for 2.5
511 */ 524 */
512 if (smp_num_siblings > 1) 525 k_base_platform = ELF_BASE_PLATFORM;
513 sp = sp - ((current->pid % 64) << 7); 526 u_base_platform = NULL;
514#endif 527
528 if (k_base_platform) {
529 platform_len = strlen(k_base_platform) + 1;
530 sp -= platform_len;
531 u_base_platform = (char __user *) sp;
532 if (__copy_to_user(u_base_platform, k_base_platform, platform_len) != 0)
533 return -EFAULT;
534 }
515 535
516 sp &= ~7UL; 536 sp &= ~7UL;
517 537
@@ -541,9 +561,13 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
541 } 561 }
542 562
543 /* force 16 byte _final_ alignment here for generality */ 563 /* force 16 byte _final_ alignment here for generality */
544#define DLINFO_ITEMS 13 564#define DLINFO_ITEMS 15
565
566 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) +
567 (k_base_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;
545 568
546 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH; 569 if (bprm->interp_flags & BINPRM_FLAGS_EXECFD)
570 nitems++;
547 571
548 csp = sp; 572 csp = sp;
549 sp -= nitems * 2 * sizeof(unsigned long); 573 sp -= nitems * 2 * sizeof(unsigned long);
@@ -575,6 +599,19 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
575 (elf_addr_t) (unsigned long) u_platform); 599 (elf_addr_t) (unsigned long) u_platform);
576 } 600 }
577 601
602 if (k_base_platform) {
603 nr = 0;
604 csp -= 2 * sizeof(unsigned long);
605 NEW_AUX_ENT(AT_BASE_PLATFORM,
606 (elf_addr_t) (unsigned long) u_base_platform);
607 }
608
609 if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) {
610 nr = 0;
611 csp -= 2 * sizeof(unsigned long);
612 NEW_AUX_ENT(AT_EXECFD, bprm->interp_data);
613 }
614
578 nr = 0; 615 nr = 0;
579 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long); 616 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long);
580 NEW_AUX_ENT(AT_HWCAP, hwcap); 617 NEW_AUX_ENT(AT_HWCAP, hwcap);
@@ -590,6 +627,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
590 NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->euid); 627 NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->euid);
591 NEW_AUX_ENT(AT_GID, (elf_addr_t) current->gid); 628 NEW_AUX_ENT(AT_GID, (elf_addr_t) current->gid);
592 NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->egid); 629 NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->egid);
630 NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm));
631 NEW_AUX_ENT(AT_EXECFN, bprm->exec);
593 632
594#ifdef ARCH_DLINFO 633#ifdef ARCH_DLINFO
595 nr = 0; 634 nr = 0;
diff --git a/fs/binfmt_em86.c b/fs/binfmt_em86.c
index f9c88d0c8ced..32fb00b52cd0 100644
--- a/fs/binfmt_em86.c
+++ b/fs/binfmt_em86.c
@@ -43,7 +43,7 @@ static int load_em86(struct linux_binprm *bprm,struct pt_regs *regs)
43 return -ENOEXEC; 43 return -ENOEXEC;
44 } 44 }
45 45
46 bprm->sh_bang = 1; /* Well, the bang-shell is implicit... */ 46 bprm->recursion_depth++; /* Well, the bang-shell is implicit... */
47 allow_write_access(bprm->file); 47 allow_write_access(bprm->file);
48 fput(bprm->file); 48 fput(bprm->file);
49 bprm->file = NULL; 49 bprm->file = NULL;
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index dfc0197905ca..ccb781a6a804 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -229,13 +229,13 @@ static int decompress_exec(
229 ret = 10; 229 ret = 10;
230 if (buf[3] & EXTRA_FIELD) { 230 if (buf[3] & EXTRA_FIELD) {
231 ret += 2 + buf[10] + (buf[11] << 8); 231 ret += 2 + buf[10] + (buf[11] << 8);
232 if (unlikely(LBUFSIZE == ret)) { 232 if (unlikely(LBUFSIZE <= ret)) {
233 DBG_FLT("binfmt_flat: buffer overflow (EXTRA)?\n"); 233 DBG_FLT("binfmt_flat: buffer overflow (EXTRA)?\n");
234 goto out_free_buf; 234 goto out_free_buf;
235 } 235 }
236 } 236 }
237 if (buf[3] & ORIG_NAME) { 237 if (buf[3] & ORIG_NAME) {
238 for (; ret < LBUFSIZE && (buf[ret] != 0); ret++) 238 while (ret < LBUFSIZE && buf[ret++] != 0)
239 ; 239 ;
240 if (unlikely(LBUFSIZE == ret)) { 240 if (unlikely(LBUFSIZE == ret)) {
241 DBG_FLT("binfmt_flat: buffer overflow (ORIG_NAME)?\n"); 241 DBG_FLT("binfmt_flat: buffer overflow (ORIG_NAME)?\n");
@@ -243,7 +243,7 @@ static int decompress_exec(
243 } 243 }
244 } 244 }
245 if (buf[3] & COMMENT) { 245 if (buf[3] & COMMENT) {
246 for (; ret < LBUFSIZE && (buf[ret] != 0); ret++) 246 while (ret < LBUFSIZE && buf[ret++] != 0)
247 ; 247 ;
248 if (unlikely(LBUFSIZE == ret)) { 248 if (unlikely(LBUFSIZE == ret)) {
249 DBG_FLT("binfmt_flat: buffer overflow (COMMENT)?\n"); 249 DBG_FLT("binfmt_flat: buffer overflow (COMMENT)?\n");
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 8d7e88e02e0f..f2744ab4e5b3 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -117,7 +117,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
117 goto _ret; 117 goto _ret;
118 118
119 retval = -ENOEXEC; 119 retval = -ENOEXEC;
120 if (bprm->misc_bang) 120 if (bprm->recursion_depth > BINPRM_MAX_RECURSION)
121 goto _ret; 121 goto _ret;
122 122
123 /* to keep locking time low, we copy the interpreter string */ 123 /* to keep locking time low, we copy the interpreter string */
@@ -197,7 +197,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
197 if (retval < 0) 197 if (retval < 0)
198 goto _error; 198 goto _error;
199 199
200 bprm->misc_bang = 1; 200 bprm->recursion_depth++;
201 201
202 retval = search_binary_handler (bprm, regs); 202 retval = search_binary_handler (bprm, regs);
203 if (retval < 0) 203 if (retval < 0)
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index 9e3963f7ebf1..08343505e184 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -22,14 +22,15 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
22 char interp[BINPRM_BUF_SIZE]; 22 char interp[BINPRM_BUF_SIZE];
23 int retval; 23 int retval;
24 24
25 if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') || (bprm->sh_bang)) 25 if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') ||
26 (bprm->recursion_depth > BINPRM_MAX_RECURSION))
26 return -ENOEXEC; 27 return -ENOEXEC;
27 /* 28 /*
28 * This section does the #! interpretation. 29 * This section does the #! interpretation.
29 * Sorta complicated, but hopefully it will work. -TYT 30 * Sorta complicated, but hopefully it will work. -TYT
30 */ 31 */
31 32
32 bprm->sh_bang = 1; 33 bprm->recursion_depth++;
33 allow_write_access(bprm->file); 34 allow_write_access(bprm->file);
34 fput(bprm->file); 35 fput(bprm->file);
35 bprm->file = NULL; 36 bprm->file = NULL;
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c
index 68be580ba289..74e587a52796 100644
--- a/fs/binfmt_som.c
+++ b/fs/binfmt_som.c
@@ -306,3 +306,5 @@ static void __exit exit_som_binfmt(void)
306 306
307core_initcall(init_som_binfmt); 307core_initcall(init_som_binfmt);
308module_exit(exit_som_binfmt); 308module_exit(exit_som_binfmt);
309
310MODULE_LICENSE("GPL");
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 3cb7cda3d780..262fa10e213d 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -22,9 +22,6 @@
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/backing-dev.h> 23#include <linux/backing-dev.h>
24 24
25#ifdef CONFIG_KMOD
26#include <linux/kmod.h>
27#endif
28#include "internal.h" 25#include "internal.h"
29 26
30/* 27/*
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 0d9b80ec689c..cfd29da714d1 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -362,9 +362,8 @@ static int init_coda_psdev(void)
362 goto out_chrdev; 362 goto out_chrdev;
363 } 363 }
364 for (i = 0; i < MAX_CODADEVS; i++) 364 for (i = 0; i < MAX_CODADEVS; i++)
365 device_create_drvdata(coda_psdev_class, NULL, 365 device_create(coda_psdev_class, NULL,
366 MKDEV(CODA_PSDEV_MAJOR, i), 366 MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i);
367 NULL, "cfs%d", i);
368 coda_sysctl_init(); 367 coda_sysctl_init();
369 goto out; 368 goto out;
370 369
diff --git a/fs/compat.c b/fs/compat.c
index 075d0509970d..5f9ec449c799 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -137,6 +137,45 @@ asmlinkage long compat_sys_utimes(char __user *filename, struct compat_timeval _
137 return compat_sys_futimesat(AT_FDCWD, filename, t); 137 return compat_sys_futimesat(AT_FDCWD, filename, t);
138} 138}
139 139
140static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
141{
142 compat_ino_t ino = stat->ino;
143 typeof(ubuf->st_uid) uid = 0;
144 typeof(ubuf->st_gid) gid = 0;
145 int err;
146
147 SET_UID(uid, stat->uid);
148 SET_GID(gid, stat->gid);
149
150 if ((u64) stat->size > MAX_NON_LFS ||
151 !old_valid_dev(stat->dev) ||
152 !old_valid_dev(stat->rdev))
153 return -EOVERFLOW;
154 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
155 return -EOVERFLOW;
156
157 if (clear_user(ubuf, sizeof(*ubuf)))
158 return -EFAULT;
159
160 err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
161 err |= __put_user(ino, &ubuf->st_ino);
162 err |= __put_user(stat->mode, &ubuf->st_mode);
163 err |= __put_user(stat->nlink, &ubuf->st_nlink);
164 err |= __put_user(uid, &ubuf->st_uid);
165 err |= __put_user(gid, &ubuf->st_gid);
166 err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
167 err |= __put_user(stat->size, &ubuf->st_size);
168 err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
169 err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
170 err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
171 err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
172 err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
173 err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
174 err |= __put_user(stat->blksize, &ubuf->st_blksize);
175 err |= __put_user(stat->blocks, &ubuf->st_blocks);
176 return err;
177}
178
140asmlinkage long compat_sys_newstat(char __user * filename, 179asmlinkage long compat_sys_newstat(char __user * filename,
141 struct compat_stat __user *statbuf) 180 struct compat_stat __user *statbuf)
142{ 181{
@@ -1239,7 +1278,7 @@ static int compat_count(compat_uptr_t __user *argv, int max)
1239 if (!p) 1278 if (!p)
1240 break; 1279 break;
1241 argv++; 1280 argv++;
1242 if(++i > max) 1281 if (i++ >= max)
1243 return -E2BIG; 1282 return -E2BIG;
1244 } 1283 }
1245 } 1284 }
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 9606ee848fd8..af0558dbe8b7 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -5,11 +5,11 @@
5 * 5 *
6 * O_DIRECT 6 * O_DIRECT
7 * 7 *
8 * 04Jul2002 akpm@zip.com.au 8 * 04Jul2002 Andrew Morton
9 * Initial version 9 * Initial version
10 * 11Sep2002 janetinc@us.ibm.com 10 * 11Sep2002 janetinc@us.ibm.com
11 * added readv/writev support. 11 * added readv/writev support.
12 * 29Oct2002 akpm@zip.com.au 12 * 29Oct2002 Andrew Morton
13 * rewrote bio_add_page() support. 13 * rewrote bio_add_page() support.
14 * 30Oct2002 pbadari@us.ibm.com 14 * 30Oct2002 pbadari@us.ibm.com
15 * added support for non-aligned IO. 15 * added support for non-aligned IO.
diff --git a/fs/dquot.c b/fs/dquot.c
index ad7e59003e04..da30a27f2242 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -9,8 +9,6 @@
9 * implementation is based on one of the several variants of the LINUX 9 * implementation is based on one of the several variants of the LINUX
10 * inode-subsystem with added complexity of the diskquota system. 10 * inode-subsystem with added complexity of the diskquota system.
11 * 11 *
12 * Version: $Id: dquot.c,v 6.3 1996/11/17 18:35:34 mvw Exp mvw $
13 *
14 * Author: Marco van Wieringen <mvw@planets.elm.net> 12 * Author: Marco van Wieringen <mvw@planets.elm.net>
15 * 13 *
16 * Fixes: Dmitry Gorodchanin <pgmdsg@ibi.com>, 11 Feb 96 14 * Fixes: Dmitry Gorodchanin <pgmdsg@ibi.com>, 11 Feb 96
diff --git a/fs/ecryptfs/Makefile b/fs/ecryptfs/Makefile
index b4755a85996e..2cc9ee4ad2eb 100644
--- a/fs/ecryptfs/Makefile
+++ b/fs/ecryptfs/Makefile
@@ -4,4 +4,4 @@
4 4
5obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o 5obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o
6 6
7ecryptfs-objs := dentry.o file.o inode.o main.o super.o mmap.o read_write.o crypto.o keystore.o messaging.o netlink.o miscdev.o kthread.o debug.o 7ecryptfs-objs := dentry.o file.o inode.o main.o super.o mmap.o read_write.o crypto.o keystore.o messaging.o miscdev.o kthread.o debug.o
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index b73fb752c5f8..3504cf9df358 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -79,11 +79,6 @@
79#define ECRYPTFS_MAX_PKI_NAME_BYTES 16 79#define ECRYPTFS_MAX_PKI_NAME_BYTES 16
80#define ECRYPTFS_DEFAULT_NUM_USERS 4 80#define ECRYPTFS_DEFAULT_NUM_USERS 4
81#define ECRYPTFS_MAX_NUM_USERS 32768 81#define ECRYPTFS_MAX_NUM_USERS 32768
82#define ECRYPTFS_TRANSPORT_NETLINK 0
83#define ECRYPTFS_TRANSPORT_CONNECTOR 1
84#define ECRYPTFS_TRANSPORT_RELAYFS 2
85#define ECRYPTFS_TRANSPORT_MISCDEV 3
86#define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_MISCDEV
87#define ECRYPTFS_XATTR_NAME "user.ecryptfs" 82#define ECRYPTFS_XATTR_NAME "user.ecryptfs"
88 83
89#define RFC2440_CIPHER_DES3_EDE 0x02 84#define RFC2440_CIPHER_DES3_EDE 0x02
@@ -400,8 +395,6 @@ struct ecryptfs_msg_ctx {
400 struct mutex mux; 395 struct mutex mux;
401}; 396};
402 397
403extern unsigned int ecryptfs_transport;
404
405struct ecryptfs_daemon; 398struct ecryptfs_daemon;
406 399
407struct ecryptfs_daemon { 400struct ecryptfs_daemon {
@@ -627,31 +620,20 @@ int
627ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, 620ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
628 size_t size, int flags); 621 size_t size, int flags);
629int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); 622int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode);
630int ecryptfs_process_helo(unsigned int transport, uid_t euid, 623int ecryptfs_process_helo(uid_t euid, struct user_namespace *user_ns,
631 struct user_namespace *user_ns, struct pid *pid); 624 struct pid *pid);
632int ecryptfs_process_quit(uid_t euid, struct user_namespace *user_ns, 625int ecryptfs_process_quit(uid_t euid, struct user_namespace *user_ns,
633 struct pid *pid); 626 struct pid *pid);
634int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t euid, 627int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t euid,
635 struct user_namespace *user_ns, struct pid *pid, 628 struct user_namespace *user_ns, struct pid *pid,
636 u32 seq); 629 u32 seq);
637int ecryptfs_send_message(unsigned int transport, char *data, int data_len, 630int ecryptfs_send_message(char *data, int data_len,
638 struct ecryptfs_msg_ctx **msg_ctx); 631 struct ecryptfs_msg_ctx **msg_ctx);
639int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx, 632int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx,
640 struct ecryptfs_message **emsg); 633 struct ecryptfs_message **emsg);
641int ecryptfs_init_messaging(unsigned int transport); 634int ecryptfs_init_messaging(void);
642void ecryptfs_release_messaging(unsigned int transport); 635void ecryptfs_release_messaging(void);
643 636
644int ecryptfs_send_netlink(char *data, int data_len,
645 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
646 u16 msg_flags, struct pid *daemon_pid);
647int ecryptfs_init_netlink(void);
648void ecryptfs_release_netlink(void);
649
650int ecryptfs_send_connector(char *data, int data_len,
651 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
652 u16 msg_flags, struct pid *daemon_pid);
653int ecryptfs_init_connector(void);
654void ecryptfs_release_connector(void);
655void 637void
656ecryptfs_write_header_metadata(char *virt, 638ecryptfs_write_header_metadata(char *virt,
657 struct ecryptfs_crypt_stat *crypt_stat, 639 struct ecryptfs_crypt_stat *crypt_stat,
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 9244d653743e..eb3dc4c7ac06 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -71,12 +71,11 @@ struct ecryptfs_getdents_callback {
71 void *dirent; 71 void *dirent;
72 struct dentry *dentry; 72 struct dentry *dentry;
73 filldir_t filldir; 73 filldir_t filldir;
74 int err;
75 int filldir_called; 74 int filldir_called;
76 int entries_written; 75 int entries_written;
77}; 76};
78 77
79/* Inspired by generic filldir in fs/readir.c */ 78/* Inspired by generic filldir in fs/readdir.c */
80static int 79static int
81ecryptfs_filldir(void *dirent, const char *name, int namelen, loff_t offset, 80ecryptfs_filldir(void *dirent, const char *name, int namelen, loff_t offset,
82 u64 ino, unsigned int d_type) 81 u64 ino, unsigned int d_type)
@@ -125,18 +124,18 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
125 buf.dirent = dirent; 124 buf.dirent = dirent;
126 buf.dentry = file->f_path.dentry; 125 buf.dentry = file->f_path.dentry;
127 buf.filldir = filldir; 126 buf.filldir = filldir;
128retry:
129 buf.filldir_called = 0; 127 buf.filldir_called = 0;
130 buf.entries_written = 0; 128 buf.entries_written = 0;
131 buf.err = 0;
132 rc = vfs_readdir(lower_file, ecryptfs_filldir, (void *)&buf); 129 rc = vfs_readdir(lower_file, ecryptfs_filldir, (void *)&buf);
133 if (buf.err)
134 rc = buf.err;
135 if (buf.filldir_called && !buf.entries_written)
136 goto retry;
137 file->f_pos = lower_file->f_pos; 130 file->f_pos = lower_file->f_pos;
131 if (rc < 0)
132 goto out;
133 if (buf.filldir_called && !buf.entries_written)
134 goto out;
138 if (rc >= 0) 135 if (rc >= 0)
139 fsstack_copy_attr_atime(inode, lower_file->f_path.dentry->d_inode); 136 fsstack_copy_attr_atime(inode,
137 lower_file->f_path.dentry->d_inode);
138out:
140 return rc; 139 return rc;
141} 140}
142 141
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index f5b76a331b9c..e22bc3961345 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -234,8 +234,8 @@ parse_tag_65_packet(struct ecryptfs_session_key *session_key, u8 *cipher_code,
234 } 234 }
235 i += data_len; 235 i += data_len;
236 if (message_len < (i + m_size)) { 236 if (message_len < (i + m_size)) {
237 ecryptfs_printk(KERN_ERR, "The received netlink message is " 237 ecryptfs_printk(KERN_ERR, "The message received from ecryptfsd "
238 "shorter than expected\n"); 238 "is shorter than expected\n");
239 rc = -EIO; 239 rc = -EIO;
240 goto out; 240 goto out;
241 } 241 }
@@ -438,8 +438,8 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
438 struct ecryptfs_msg_ctx *msg_ctx; 438 struct ecryptfs_msg_ctx *msg_ctx;
439 struct ecryptfs_message *msg = NULL; 439 struct ecryptfs_message *msg = NULL;
440 char *auth_tok_sig; 440 char *auth_tok_sig;
441 char *netlink_message; 441 char *payload;
442 size_t netlink_message_length; 442 size_t payload_len;
443 int rc; 443 int rc;
444 444
445 rc = ecryptfs_get_auth_tok_sig(&auth_tok_sig, auth_tok); 445 rc = ecryptfs_get_auth_tok_sig(&auth_tok_sig, auth_tok);
@@ -449,15 +449,15 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
449 goto out; 449 goto out;
450 } 450 }
451 rc = write_tag_64_packet(auth_tok_sig, &(auth_tok->session_key), 451 rc = write_tag_64_packet(auth_tok_sig, &(auth_tok->session_key),
452 &netlink_message, &netlink_message_length); 452 &payload, &payload_len);
453 if (rc) { 453 if (rc) {
454 ecryptfs_printk(KERN_ERR, "Failed to write tag 64 packet\n"); 454 ecryptfs_printk(KERN_ERR, "Failed to write tag 64 packet\n");
455 goto out; 455 goto out;
456 } 456 }
457 rc = ecryptfs_send_message(ecryptfs_transport, netlink_message, 457 rc = ecryptfs_send_message(payload, payload_len, &msg_ctx);
458 netlink_message_length, &msg_ctx);
459 if (rc) { 458 if (rc) {
460 ecryptfs_printk(KERN_ERR, "Error sending netlink message\n"); 459 ecryptfs_printk(KERN_ERR, "Error sending message to "
460 "ecryptfsd\n");
461 goto out; 461 goto out;
462 } 462 }
463 rc = ecryptfs_wait_for_response(msg_ctx, &msg); 463 rc = ecryptfs_wait_for_response(msg_ctx, &msg);
@@ -1333,23 +1333,22 @@ pki_encrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
1333 struct ecryptfs_key_record *key_rec) 1333 struct ecryptfs_key_record *key_rec)
1334{ 1334{
1335 struct ecryptfs_msg_ctx *msg_ctx = NULL; 1335 struct ecryptfs_msg_ctx *msg_ctx = NULL;
1336 char *netlink_payload; 1336 char *payload = NULL;
1337 size_t netlink_payload_length; 1337 size_t payload_len;
1338 struct ecryptfs_message *msg; 1338 struct ecryptfs_message *msg;
1339 int rc; 1339 int rc;
1340 1340
1341 rc = write_tag_66_packet(auth_tok->token.private_key.signature, 1341 rc = write_tag_66_packet(auth_tok->token.private_key.signature,
1342 ecryptfs_code_for_cipher_string(crypt_stat), 1342 ecryptfs_code_for_cipher_string(crypt_stat),
1343 crypt_stat, &netlink_payload, 1343 crypt_stat, &payload, &payload_len);
1344 &netlink_payload_length);
1345 if (rc) { 1344 if (rc) {
1346 ecryptfs_printk(KERN_ERR, "Error generating tag 66 packet\n"); 1345 ecryptfs_printk(KERN_ERR, "Error generating tag 66 packet\n");
1347 goto out; 1346 goto out;
1348 } 1347 }
1349 rc = ecryptfs_send_message(ecryptfs_transport, netlink_payload, 1348 rc = ecryptfs_send_message(payload, payload_len, &msg_ctx);
1350 netlink_payload_length, &msg_ctx);
1351 if (rc) { 1349 if (rc) {
1352 ecryptfs_printk(KERN_ERR, "Error sending netlink message\n"); 1350 ecryptfs_printk(KERN_ERR, "Error sending message to "
1351 "ecryptfsd\n");
1353 goto out; 1352 goto out;
1354 } 1353 }
1355 rc = ecryptfs_wait_for_response(msg_ctx, &msg); 1354 rc = ecryptfs_wait_for_response(msg_ctx, &msg);
@@ -1364,8 +1363,7 @@ pki_encrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
1364 ecryptfs_printk(KERN_ERR, "Error parsing tag 67 packet\n"); 1363 ecryptfs_printk(KERN_ERR, "Error parsing tag 67 packet\n");
1365 kfree(msg); 1364 kfree(msg);
1366out: 1365out:
1367 if (netlink_payload) 1366 kfree(payload);
1368 kfree(netlink_payload);
1369 return rc; 1367 return rc;
1370} 1368}
1371/** 1369/**
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 8ebe9a5d1d99..046e027a4cb1 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -30,7 +30,6 @@
30#include <linux/namei.h> 30#include <linux/namei.h>
31#include <linux/skbuff.h> 31#include <linux/skbuff.h>
32#include <linux/crypto.h> 32#include <linux/crypto.h>
33#include <linux/netlink.h>
34#include <linux/mount.h> 33#include <linux/mount.h>
35#include <linux/pagemap.h> 34#include <linux/pagemap.h>
36#include <linux/key.h> 35#include <linux/key.h>
@@ -49,8 +48,7 @@ MODULE_PARM_DESC(ecryptfs_verbosity,
49 "0, which is Quiet)"); 48 "0, which is Quiet)");
50 49
51/** 50/**
52 * Module parameter that defines the number of netlink message buffer 51 * Module parameter that defines the number of message buffer elements
53 * elements
54 */ 52 */
55unsigned int ecryptfs_message_buf_len = ECRYPTFS_DEFAULT_MSG_CTX_ELEMS; 53unsigned int ecryptfs_message_buf_len = ECRYPTFS_DEFAULT_MSG_CTX_ELEMS;
56 54
@@ -60,9 +58,9 @@ MODULE_PARM_DESC(ecryptfs_message_buf_len,
60 58
61/** 59/**
62 * Module parameter that defines the maximum guaranteed amount of time to wait 60 * Module parameter that defines the maximum guaranteed amount of time to wait
63 * for a response through netlink. The actual sleep time will be, more than 61 * for a response from ecryptfsd. The actual sleep time will be, more than
64 * likely, a small amount greater than this specified value, but only less if 62 * likely, a small amount greater than this specified value, but only less if
65 * the netlink message successfully arrives. 63 * the message successfully arrives.
66 */ 64 */
67signed long ecryptfs_message_wait_timeout = ECRYPTFS_MAX_MSG_CTX_TTL / HZ; 65signed long ecryptfs_message_wait_timeout = ECRYPTFS_MAX_MSG_CTX_TTL / HZ;
68 66
@@ -83,8 +81,6 @@ module_param(ecryptfs_number_of_users, uint, 0);
83MODULE_PARM_DESC(ecryptfs_number_of_users, "An estimate of the number of " 81MODULE_PARM_DESC(ecryptfs_number_of_users, "An estimate of the number of "
84 "concurrent users of eCryptfs"); 82 "concurrent users of eCryptfs");
85 83
86unsigned int ecryptfs_transport = ECRYPTFS_DEFAULT_TRANSPORT;
87
88void __ecryptfs_printk(const char *fmt, ...) 84void __ecryptfs_printk(const char *fmt, ...)
89{ 85{
90 va_list args; 86 va_list args;
@@ -779,10 +775,11 @@ static int __init ecryptfs_init(void)
779 "rc = [%d]\n", __func__, rc); 775 "rc = [%d]\n", __func__, rc);
780 goto out_do_sysfs_unregistration; 776 goto out_do_sysfs_unregistration;
781 } 777 }
782 rc = ecryptfs_init_messaging(ecryptfs_transport); 778 rc = ecryptfs_init_messaging();
783 if (rc) { 779 if (rc) {
784 printk(KERN_ERR "Failure occured while attempting to " 780 printk(KERN_ERR "Failure occured while attempting to "
785 "initialize the eCryptfs netlink socket\n"); 781 "initialize the communications channel to "
782 "ecryptfsd\n");
786 goto out_destroy_kthread; 783 goto out_destroy_kthread;
787 } 784 }
788 rc = ecryptfs_init_crypto(); 785 rc = ecryptfs_init_crypto();
@@ -797,7 +794,7 @@ static int __init ecryptfs_init(void)
797 794
798 goto out; 795 goto out;
799out_release_messaging: 796out_release_messaging:
800 ecryptfs_release_messaging(ecryptfs_transport); 797 ecryptfs_release_messaging();
801out_destroy_kthread: 798out_destroy_kthread:
802 ecryptfs_destroy_kthread(); 799 ecryptfs_destroy_kthread();
803out_do_sysfs_unregistration: 800out_do_sysfs_unregistration:
@@ -818,7 +815,7 @@ static void __exit ecryptfs_exit(void)
818 if (rc) 815 if (rc)
819 printk(KERN_ERR "Failure whilst attempting to destroy crypto; " 816 printk(KERN_ERR "Failure whilst attempting to destroy crypto; "
820 "rc = [%d]\n", rc); 817 "rc = [%d]\n", rc);
821 ecryptfs_release_messaging(ecryptfs_transport); 818 ecryptfs_release_messaging();
822 ecryptfs_destroy_kthread(); 819 ecryptfs_destroy_kthread();
823 do_sysfs_unregistration(); 820 do_sysfs_unregistration();
824 unregister_filesystem(&ecryptfs_fs_type); 821 unregister_filesystem(&ecryptfs_fs_type);
diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
index 1b5c20058acb..c6983978a31e 100644
--- a/fs/ecryptfs/messaging.c
+++ b/fs/ecryptfs/messaging.c
@@ -134,12 +134,11 @@ out:
134} 134}
135 135
136static int 136static int
137ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len, 137ecryptfs_send_message_locked(char *data, int data_len, u8 msg_type,
138 u8 msg_type, struct ecryptfs_msg_ctx **msg_ctx); 138 struct ecryptfs_msg_ctx **msg_ctx);
139 139
140/** 140/**
141 * ecryptfs_send_raw_message 141 * ecryptfs_send_raw_message
142 * @transport: Transport type
143 * @msg_type: Message type 142 * @msg_type: Message type
144 * @daemon: Daemon struct for recipient of message 143 * @daemon: Daemon struct for recipient of message
145 * 144 *
@@ -150,38 +149,25 @@ ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len,
150 * 149 *
151 * Returns zero on success; non-zero otherwise 150 * Returns zero on success; non-zero otherwise
152 */ 151 */
153static int ecryptfs_send_raw_message(unsigned int transport, u8 msg_type, 152static int ecryptfs_send_raw_message(u8 msg_type,
154 struct ecryptfs_daemon *daemon) 153 struct ecryptfs_daemon *daemon)
155{ 154{
156 struct ecryptfs_msg_ctx *msg_ctx; 155 struct ecryptfs_msg_ctx *msg_ctx;
157 int rc; 156 int rc;
158 157
159 switch(transport) { 158 rc = ecryptfs_send_message_locked(NULL, 0, msg_type, &msg_ctx);
160 case ECRYPTFS_TRANSPORT_NETLINK: 159 if (rc) {
161 rc = ecryptfs_send_netlink(NULL, 0, NULL, msg_type, 0, 160 printk(KERN_ERR "%s: Error whilst attempting to send "
162 daemon->pid); 161 "message to ecryptfsd; rc = [%d]\n", __func__, rc);
163 break; 162 goto out;
164 case ECRYPTFS_TRANSPORT_MISCDEV:
165 rc = ecryptfs_send_message_locked(transport, NULL, 0, msg_type,
166 &msg_ctx);
167 if (rc) {
168 printk(KERN_ERR "%s: Error whilst attempting to send "
169 "message via procfs; rc = [%d]\n", __func__, rc);
170 goto out;
171 }
172 /* Raw messages are logically context-free (e.g., no
173 * reply is expected), so we set the state of the
174 * ecryptfs_msg_ctx object to indicate that it should
175 * be freed as soon as the transport sends out the message. */
176 mutex_lock(&msg_ctx->mux);
177 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_NO_REPLY;
178 mutex_unlock(&msg_ctx->mux);
179 break;
180 case ECRYPTFS_TRANSPORT_CONNECTOR:
181 case ECRYPTFS_TRANSPORT_RELAYFS:
182 default:
183 rc = -ENOSYS;
184 } 163 }
164 /* Raw messages are logically context-free (e.g., no
165 * reply is expected), so we set the state of the
166 * ecryptfs_msg_ctx object to indicate that it should
167 * be freed as soon as the message is sent. */
168 mutex_lock(&msg_ctx->mux);
169 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_NO_REPLY;
170 mutex_unlock(&msg_ctx->mux);
185out: 171out:
186 return rc; 172 return rc;
187} 173}
@@ -227,7 +213,6 @@ out:
227 213
228/** 214/**
229 * ecryptfs_process_helo 215 * ecryptfs_process_helo
230 * @transport: The underlying transport (netlink, etc.)
231 * @euid: The user ID owner of the message 216 * @euid: The user ID owner of the message
232 * @user_ns: The namespace in which @euid applies 217 * @user_ns: The namespace in which @euid applies
233 * @pid: The process ID for the userspace program that sent the 218 * @pid: The process ID for the userspace program that sent the
@@ -239,8 +224,8 @@ out:
239 * Returns zero after adding a new daemon to the hash list; 224 * Returns zero after adding a new daemon to the hash list;
240 * non-zero otherwise. 225 * non-zero otherwise.
241 */ 226 */
242int ecryptfs_process_helo(unsigned int transport, uid_t euid, 227int ecryptfs_process_helo(uid_t euid, struct user_namespace *user_ns,
243 struct user_namespace *user_ns, struct pid *pid) 228 struct pid *pid)
244{ 229{
245 struct ecryptfs_daemon *new_daemon; 230 struct ecryptfs_daemon *new_daemon;
246 struct ecryptfs_daemon *old_daemon; 231 struct ecryptfs_daemon *old_daemon;
@@ -252,8 +237,7 @@ int ecryptfs_process_helo(unsigned int transport, uid_t euid,
252 printk(KERN_WARNING "Received request from user [%d] " 237 printk(KERN_WARNING "Received request from user [%d] "
253 "to register daemon [0x%p]; unregistering daemon " 238 "to register daemon [0x%p]; unregistering daemon "
254 "[0x%p]\n", euid, pid, old_daemon->pid); 239 "[0x%p]\n", euid, pid, old_daemon->pid);
255 rc = ecryptfs_send_raw_message(transport, ECRYPTFS_MSG_QUIT, 240 rc = ecryptfs_send_raw_message(ECRYPTFS_MSG_QUIT, old_daemon);
256 old_daemon);
257 if (rc) 241 if (rc)
258 printk(KERN_WARNING "Failed to send QUIT " 242 printk(KERN_WARNING "Failed to send QUIT "
259 "message to daemon [0x%p]; rc = [%d]\n", 243 "message to daemon [0x%p]; rc = [%d]\n",
@@ -467,8 +451,6 @@ out:
467 451
468/** 452/**
469 * ecryptfs_send_message_locked 453 * ecryptfs_send_message_locked
470 * @transport: The transport over which to send the message (i.e.,
471 * netlink)
472 * @data: The data to send 454 * @data: The data to send
473 * @data_len: The length of data 455 * @data_len: The length of data
474 * @msg_ctx: The message context allocated for the send 456 * @msg_ctx: The message context allocated for the send
@@ -478,8 +460,8 @@ out:
478 * Returns zero on success; non-zero otherwise 460 * Returns zero on success; non-zero otherwise
479 */ 461 */
480static int 462static int
481ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len, 463ecryptfs_send_message_locked(char *data, int data_len, u8 msg_type,
482 u8 msg_type, struct ecryptfs_msg_ctx **msg_ctx) 464 struct ecryptfs_msg_ctx **msg_ctx)
483{ 465{
484 struct ecryptfs_daemon *daemon; 466 struct ecryptfs_daemon *daemon;
485 int rc; 467 int rc;
@@ -503,20 +485,8 @@ ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len,
503 ecryptfs_msg_ctx_free_to_alloc(*msg_ctx); 485 ecryptfs_msg_ctx_free_to_alloc(*msg_ctx);
504 mutex_unlock(&(*msg_ctx)->mux); 486 mutex_unlock(&(*msg_ctx)->mux);
505 mutex_unlock(&ecryptfs_msg_ctx_lists_mux); 487 mutex_unlock(&ecryptfs_msg_ctx_lists_mux);
506 switch (transport) { 488 rc = ecryptfs_send_miscdev(data, data_len, *msg_ctx, msg_type, 0,
507 case ECRYPTFS_TRANSPORT_NETLINK: 489 daemon);
508 rc = ecryptfs_send_netlink(data, data_len, *msg_ctx, msg_type,
509 0, daemon->pid);
510 break;
511 case ECRYPTFS_TRANSPORT_MISCDEV:
512 rc = ecryptfs_send_miscdev(data, data_len, *msg_ctx, msg_type,
513 0, daemon);
514 break;
515 case ECRYPTFS_TRANSPORT_CONNECTOR:
516 case ECRYPTFS_TRANSPORT_RELAYFS:
517 default:
518 rc = -ENOSYS;
519 }
520 if (rc) 490 if (rc)
521 printk(KERN_ERR "%s: Error attempting to send message to " 491 printk(KERN_ERR "%s: Error attempting to send message to "
522 "userspace daemon; rc = [%d]\n", __func__, rc); 492 "userspace daemon; rc = [%d]\n", __func__, rc);
@@ -526,8 +496,6 @@ out:
526 496
527/** 497/**
528 * ecryptfs_send_message 498 * ecryptfs_send_message
529 * @transport: The transport over which to send the message (i.e.,
530 * netlink)
531 * @data: The data to send 499 * @data: The data to send
532 * @data_len: The length of data 500 * @data_len: The length of data
533 * @msg_ctx: The message context allocated for the send 501 * @msg_ctx: The message context allocated for the send
@@ -536,14 +504,14 @@ out:
536 * 504 *
537 * Returns zero on success; non-zero otherwise 505 * Returns zero on success; non-zero otherwise
538 */ 506 */
539int ecryptfs_send_message(unsigned int transport, char *data, int data_len, 507int ecryptfs_send_message(char *data, int data_len,
540 struct ecryptfs_msg_ctx **msg_ctx) 508 struct ecryptfs_msg_ctx **msg_ctx)
541{ 509{
542 int rc; 510 int rc;
543 511
544 mutex_lock(&ecryptfs_daemon_hash_mux); 512 mutex_lock(&ecryptfs_daemon_hash_mux);
545 rc = ecryptfs_send_message_locked(transport, data, data_len, 513 rc = ecryptfs_send_message_locked(data, data_len, ECRYPTFS_MSG_REQUEST,
546 ECRYPTFS_MSG_REQUEST, msg_ctx); 514 msg_ctx);
547 mutex_unlock(&ecryptfs_daemon_hash_mux); 515 mutex_unlock(&ecryptfs_daemon_hash_mux);
548 return rc; 516 return rc;
549} 517}
@@ -586,7 +554,7 @@ sleep:
586 return rc; 554 return rc;
587} 555}
588 556
589int ecryptfs_init_messaging(unsigned int transport) 557int ecryptfs_init_messaging(void)
590{ 558{
591 int i; 559 int i;
592 int rc = 0; 560 int rc = 0;
@@ -639,27 +607,14 @@ int ecryptfs_init_messaging(unsigned int transport)
639 mutex_unlock(&ecryptfs_msg_ctx_arr[i].mux); 607 mutex_unlock(&ecryptfs_msg_ctx_arr[i].mux);
640 } 608 }
641 mutex_unlock(&ecryptfs_msg_ctx_lists_mux); 609 mutex_unlock(&ecryptfs_msg_ctx_lists_mux);
642 switch(transport) { 610 rc = ecryptfs_init_ecryptfs_miscdev();
643 case ECRYPTFS_TRANSPORT_NETLINK: 611 if (rc)
644 rc = ecryptfs_init_netlink(); 612 ecryptfs_release_messaging();
645 if (rc)
646 ecryptfs_release_messaging(transport);
647 break;
648 case ECRYPTFS_TRANSPORT_MISCDEV:
649 rc = ecryptfs_init_ecryptfs_miscdev();
650 if (rc)
651 ecryptfs_release_messaging(transport);
652 break;
653 case ECRYPTFS_TRANSPORT_CONNECTOR:
654 case ECRYPTFS_TRANSPORT_RELAYFS:
655 default:
656 rc = -ENOSYS;
657 }
658out: 613out:
659 return rc; 614 return rc;
660} 615}
661 616
662void ecryptfs_release_messaging(unsigned int transport) 617void ecryptfs_release_messaging(void)
663{ 618{
664 if (ecryptfs_msg_ctx_arr) { 619 if (ecryptfs_msg_ctx_arr) {
665 int i; 620 int i;
@@ -698,17 +653,6 @@ void ecryptfs_release_messaging(unsigned int transport)
698 kfree(ecryptfs_daemon_hash); 653 kfree(ecryptfs_daemon_hash);
699 mutex_unlock(&ecryptfs_daemon_hash_mux); 654 mutex_unlock(&ecryptfs_daemon_hash_mux);
700 } 655 }
701 switch(transport) { 656 ecryptfs_destroy_ecryptfs_miscdev();
702 case ECRYPTFS_TRANSPORT_NETLINK:
703 ecryptfs_release_netlink();
704 break;
705 case ECRYPTFS_TRANSPORT_MISCDEV:
706 ecryptfs_destroy_ecryptfs_miscdev();
707 break;
708 case ECRYPTFS_TRANSPORT_CONNECTOR:
709 case ECRYPTFS_TRANSPORT_RELAYFS:
710 default:
711 break;
712 }
713 return; 657 return;
714} 658}
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 245c2dc02d5c..04d7b3fa1ac6 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -265,22 +265,34 @@ out:
265} 265}
266 266
267/** 267/**
268 * ecryptfs_prepare_write 268 * ecryptfs_write_begin
269 * @file: The eCryptfs file 269 * @file: The eCryptfs file
270 * @page: The eCryptfs page 270 * @mapping: The eCryptfs object
271 * @from: The start byte from which we will write 271 * @pos: The file offset at which to start writing
272 * @to: The end byte to which we will write 272 * @len: Length of the write
273 * @flags: Various flags
274 * @pagep: Pointer to return the page
275 * @fsdata: Pointer to return fs data (unused)
273 * 276 *
274 * This function must zero any hole we create 277 * This function must zero any hole we create
275 * 278 *
276 * Returns zero on success; non-zero otherwise 279 * Returns zero on success; non-zero otherwise
277 */ 280 */
278static int ecryptfs_prepare_write(struct file *file, struct page *page, 281static int ecryptfs_write_begin(struct file *file,
279 unsigned from, unsigned to) 282 struct address_space *mapping,
283 loff_t pos, unsigned len, unsigned flags,
284 struct page **pagep, void **fsdata)
280{ 285{
286 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
287 struct page *page;
281 loff_t prev_page_end_size; 288 loff_t prev_page_end_size;
282 int rc = 0; 289 int rc = 0;
283 290
291 page = __grab_cache_page(mapping, index);
292 if (!page)
293 return -ENOMEM;
294 *pagep = page;
295
284 if (!PageUptodate(page)) { 296 if (!PageUptodate(page)) {
285 struct ecryptfs_crypt_stat *crypt_stat = 297 struct ecryptfs_crypt_stat *crypt_stat =
286 &ecryptfs_inode_to_private( 298 &ecryptfs_inode_to_private(
@@ -289,8 +301,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
289 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED) 301 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)
290 || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) { 302 || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) {
291 rc = ecryptfs_read_lower_page_segment( 303 rc = ecryptfs_read_lower_page_segment(
292 page, page->index, 0, PAGE_CACHE_SIZE, 304 page, index, 0, PAGE_CACHE_SIZE, mapping->host);
293 page->mapping->host);
294 if (rc) { 305 if (rc) {
295 printk(KERN_ERR "%s: Error attemping to read " 306 printk(KERN_ERR "%s: Error attemping to read "
296 "lower page segment; rc = [%d]\n", 307 "lower page segment; rc = [%d]\n",
@@ -316,8 +327,8 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
316 SetPageUptodate(page); 327 SetPageUptodate(page);
317 } else { 328 } else {
318 rc = ecryptfs_read_lower_page_segment( 329 rc = ecryptfs_read_lower_page_segment(
319 page, page->index, 0, PAGE_CACHE_SIZE, 330 page, index, 0, PAGE_CACHE_SIZE,
320 page->mapping->host); 331 mapping->host);
321 if (rc) { 332 if (rc) {
322 printk(KERN_ERR "%s: Error reading " 333 printk(KERN_ERR "%s: Error reading "
323 "page; rc = [%d]\n", 334 "page; rc = [%d]\n",
@@ -339,10 +350,10 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
339 SetPageUptodate(page); 350 SetPageUptodate(page);
340 } 351 }
341 } 352 }
342 prev_page_end_size = ((loff_t)page->index << PAGE_CACHE_SHIFT); 353 prev_page_end_size = ((loff_t)index << PAGE_CACHE_SHIFT);
343 /* If creating a page or more of holes, zero them out via truncate. 354 /* If creating a page or more of holes, zero them out via truncate.
344 * Note, this will increase i_size. */ 355 * Note, this will increase i_size. */
345 if (page->index != 0) { 356 if (index != 0) {
346 if (prev_page_end_size > i_size_read(page->mapping->host)) { 357 if (prev_page_end_size > i_size_read(page->mapping->host)) {
347 rc = ecryptfs_truncate(file->f_path.dentry, 358 rc = ecryptfs_truncate(file->f_path.dentry,
348 prev_page_end_size); 359 prev_page_end_size);
@@ -357,8 +368,8 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
357 } 368 }
358 /* Writing to a new page, and creating a small hole from start 369 /* Writing to a new page, and creating a small hole from start
359 * of page? Zero it out. */ 370 * of page? Zero it out. */
360 if ((i_size_read(page->mapping->host) == prev_page_end_size) 371 if ((i_size_read(mapping->host) == prev_page_end_size)
361 && (from != 0)) 372 && (pos != 0))
362 zero_user(page, 0, PAGE_CACHE_SIZE); 373 zero_user(page, 0, PAGE_CACHE_SIZE);
363out: 374out:
364 return rc; 375 return rc;
@@ -445,21 +456,28 @@ int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode)
445} 456}
446 457
447/** 458/**
448 * ecryptfs_commit_write 459 * ecryptfs_write_end
449 * @file: The eCryptfs file object 460 * @file: The eCryptfs file object
461 * @mapping: The eCryptfs object
462 * @pos: The file position
463 * @len: The length of the data (unused)
464 * @copied: The amount of data copied
450 * @page: The eCryptfs page 465 * @page: The eCryptfs page
451 * @from: Ignored (we rotate the page IV on each write) 466 * @fsdata: The fsdata (unused)
452 * @to: Ignored
453 * 467 *
454 * This is where we encrypt the data and pass the encrypted data to 468 * This is where we encrypt the data and pass the encrypted data to
455 * the lower filesystem. In OpenPGP-compatible mode, we operate on 469 * the lower filesystem. In OpenPGP-compatible mode, we operate on
456 * entire underlying packets. 470 * entire underlying packets.
457 */ 471 */
458static int ecryptfs_commit_write(struct file *file, struct page *page, 472static int ecryptfs_write_end(struct file *file,
459 unsigned from, unsigned to) 473 struct address_space *mapping,
474 loff_t pos, unsigned len, unsigned copied,
475 struct page *page, void *fsdata)
460{ 476{
461 loff_t pos; 477 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
462 struct inode *ecryptfs_inode = page->mapping->host; 478 unsigned from = pos & (PAGE_CACHE_SIZE - 1);
479 unsigned to = from + copied;
480 struct inode *ecryptfs_inode = mapping->host;
463 struct ecryptfs_crypt_stat *crypt_stat = 481 struct ecryptfs_crypt_stat *crypt_stat =
464 &ecryptfs_inode_to_private(file->f_path.dentry->d_inode)->crypt_stat; 482 &ecryptfs_inode_to_private(file->f_path.dentry->d_inode)->crypt_stat;
465 int rc; 483 int rc;
@@ -471,25 +489,22 @@ static int ecryptfs_commit_write(struct file *file, struct page *page,
471 } else 489 } else
472 ecryptfs_printk(KERN_DEBUG, "Not a new file\n"); 490 ecryptfs_printk(KERN_DEBUG, "Not a new file\n");
473 ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" 491 ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
474 "(page w/ index = [0x%.16x], to = [%d])\n", page->index, 492 "(page w/ index = [0x%.16x], to = [%d])\n", index, to);
475 to);
476 /* Fills in zeros if 'to' goes beyond inode size */ 493 /* Fills in zeros if 'to' goes beyond inode size */
477 rc = fill_zeros_to_end_of_page(page, to); 494 rc = fill_zeros_to_end_of_page(page, to);
478 if (rc) { 495 if (rc) {
479 ecryptfs_printk(KERN_WARNING, "Error attempting to fill " 496 ecryptfs_printk(KERN_WARNING, "Error attempting to fill "
480 "zeros in page with index = [0x%.16x]\n", 497 "zeros in page with index = [0x%.16x]\n", index);
481 page->index);
482 goto out; 498 goto out;
483 } 499 }
484 rc = ecryptfs_encrypt_page(page); 500 rc = ecryptfs_encrypt_page(page);
485 if (rc) { 501 if (rc) {
486 ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper " 502 ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper "
487 "index [0x%.16x])\n", page->index); 503 "index [0x%.16x])\n", index);
488 goto out; 504 goto out;
489 } 505 }
490 pos = (((loff_t)page->index) << PAGE_CACHE_SHIFT) + to; 506 if (pos + copied > i_size_read(ecryptfs_inode)) {
491 if (pos > i_size_read(ecryptfs_inode)) { 507 i_size_write(ecryptfs_inode, pos + copied);
492 i_size_write(ecryptfs_inode, pos);
493 ecryptfs_printk(KERN_DEBUG, "Expanded file size to " 508 ecryptfs_printk(KERN_DEBUG, "Expanded file size to "
494 "[0x%.16x]\n", i_size_read(ecryptfs_inode)); 509 "[0x%.16x]\n", i_size_read(ecryptfs_inode));
495 } 510 }
@@ -497,7 +512,11 @@ static int ecryptfs_commit_write(struct file *file, struct page *page,
497 if (rc) 512 if (rc)
498 printk(KERN_ERR "Error writing inode size to metadata; " 513 printk(KERN_ERR "Error writing inode size to metadata; "
499 "rc = [%d]\n", rc); 514 "rc = [%d]\n", rc);
515 else
516 rc = copied;
500out: 517out:
518 unlock_page(page);
519 page_cache_release(page);
501 return rc; 520 return rc;
502} 521}
503 522
@@ -518,7 +537,7 @@ static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block)
518struct address_space_operations ecryptfs_aops = { 537struct address_space_operations ecryptfs_aops = {
519 .writepage = ecryptfs_writepage, 538 .writepage = ecryptfs_writepage,
520 .readpage = ecryptfs_readpage, 539 .readpage = ecryptfs_readpage,
521 .prepare_write = ecryptfs_prepare_write, 540 .write_begin = ecryptfs_write_begin,
522 .commit_write = ecryptfs_commit_write, 541 .write_end = ecryptfs_write_end,
523 .bmap = ecryptfs_bmap, 542 .bmap = ecryptfs_bmap,
524}; 543};
diff --git a/fs/ecryptfs/netlink.c b/fs/ecryptfs/netlink.c
deleted file mode 100644
index e0abad62b395..000000000000
--- a/fs/ecryptfs/netlink.c
+++ /dev/null
@@ -1,249 +0,0 @@
1/**
2 * eCryptfs: Linux filesystem encryption layer
3 *
4 * Copyright (C) 2004-2006 International Business Machines Corp.
5 * Author(s): Michael A. Halcrow <mhalcrow@us.ibm.com>
6 * Tyler Hicks <tyhicks@ou.edu>
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 version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <net/sock.h>
24#include <linux/hash.h>
25#include <linux/random.h>
26#include "ecryptfs_kernel.h"
27
28static struct sock *ecryptfs_nl_sock;
29
30/**
31 * ecryptfs_send_netlink
32 * @data: The data to include as the payload
33 * @data_len: The byte count of the data
34 * @msg_ctx: The netlink context that will be used to handle the
35 * response message
36 * @msg_type: The type of netlink message to send
37 * @msg_flags: The flags to include in the netlink header
38 * @daemon_pid: The process id of the daemon to send the message to
39 *
40 * Sends the data to the specified daemon pid and uses the netlink
41 * context element to store the data needed for validation upon
42 * receiving the response. The data and the netlink context can be
43 * null if just sending a netlink header is sufficient. Returns zero
44 * upon sending the message; non-zero upon error.
45 */
46int ecryptfs_send_netlink(char *data, int data_len,
47 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
48 u16 msg_flags, struct pid *daemon_pid)
49{
50 struct sk_buff *skb;
51 struct nlmsghdr *nlh;
52 struct ecryptfs_message *msg;
53 size_t payload_len;
54 int rc;
55
56 payload_len = ((data && data_len) ? (sizeof(*msg) + data_len) : 0);
57 skb = alloc_skb(NLMSG_SPACE(payload_len), GFP_KERNEL);
58 if (!skb) {
59 rc = -ENOMEM;
60 ecryptfs_printk(KERN_ERR, "Failed to allocate socket buffer\n");
61 goto out;
62 }
63 nlh = NLMSG_PUT(skb, pid_nr(daemon_pid), msg_ctx ? msg_ctx->counter : 0,
64 msg_type, payload_len);
65 nlh->nlmsg_flags = msg_flags;
66 if (msg_ctx && payload_len) {
67 msg = (struct ecryptfs_message *)NLMSG_DATA(nlh);
68 msg->index = msg_ctx->index;
69 msg->data_len = data_len;
70 memcpy(msg->data, data, data_len);
71 }
72 rc = netlink_unicast(ecryptfs_nl_sock, skb, pid_nr(daemon_pid), 0);
73 if (rc < 0) {
74 ecryptfs_printk(KERN_ERR, "Failed to send eCryptfs netlink "
75 "message; rc = [%d]\n", rc);
76 goto out;
77 }
78 rc = 0;
79 goto out;
80nlmsg_failure:
81 rc = -EMSGSIZE;
82 kfree_skb(skb);
83out:
84 return rc;
85}
86
87/**
88 * ecryptfs_process_nl_reponse
89 * @skb: The socket buffer containing the netlink message of state
90 * RESPONSE
91 *
92 * Processes a response message after sending a operation request to
93 * userspace. Attempts to assign the msg to a netlink context element
94 * at the index specified in the msg. The sk_buff and nlmsghdr must
95 * be validated before this function. Returns zero upon delivery to
96 * desired context element; non-zero upon delivery failure or error.
97 */
98static int ecryptfs_process_nl_response(struct sk_buff *skb)
99{
100 struct nlmsghdr *nlh = nlmsg_hdr(skb);
101 struct ecryptfs_message *msg = NLMSG_DATA(nlh);
102 struct pid *pid;
103 int rc;
104
105 if (skb->len - NLMSG_HDRLEN - sizeof(*msg) != msg->data_len) {
106 rc = -EINVAL;
107 ecryptfs_printk(KERN_ERR, "Received netlink message with "
108 "incorrectly specified data length\n");
109 goto out;
110 }
111 pid = find_get_pid(NETLINK_CREDS(skb)->pid);
112 rc = ecryptfs_process_response(msg, NETLINK_CREDS(skb)->uid, NULL,
113 pid, nlh->nlmsg_seq);
114 put_pid(pid);
115 if (rc)
116 printk(KERN_ERR
117 "Error processing response message; rc = [%d]\n", rc);
118out:
119 return rc;
120}
121
122/**
123 * ecryptfs_process_nl_helo
124 * @skb: The socket buffer containing the nlmsghdr in HELO state
125 *
126 * Gets uid and pid of the skb and adds the values to the daemon id
127 * hash. Returns zero after adding a new daemon id to the hash list;
128 * non-zero otherwise.
129 */
130static int ecryptfs_process_nl_helo(struct sk_buff *skb)
131{
132 struct pid *pid;
133 int rc;
134
135 pid = find_get_pid(NETLINK_CREDS(skb)->pid);
136 rc = ecryptfs_process_helo(ECRYPTFS_TRANSPORT_NETLINK,
137 NETLINK_CREDS(skb)->uid, NULL, pid);
138 put_pid(pid);
139 if (rc)
140 printk(KERN_WARNING "Error processing HELO; rc = [%d]\n", rc);
141 return rc;
142}
143
144/**
145 * ecryptfs_process_nl_quit
146 * @skb: The socket buffer containing the nlmsghdr in QUIT state
147 *
148 * Gets uid and pid of the skb and deletes the corresponding daemon
149 * id, if it is the registered that is requesting the
150 * deletion. Returns zero after deleting the desired daemon id;
151 * non-zero otherwise.
152 */
153static int ecryptfs_process_nl_quit(struct sk_buff *skb)
154{
155 struct pid *pid;
156 int rc;
157
158 pid = find_get_pid(NETLINK_CREDS(skb)->pid);
159 rc = ecryptfs_process_quit(NETLINK_CREDS(skb)->uid, NULL, pid);
160 put_pid(pid);
161 if (rc)
162 printk(KERN_WARNING
163 "Error processing QUIT message; rc = [%d]\n", rc);
164 return rc;
165}
166
167/**
168 * ecryptfs_receive_nl_message
169 *
170 * Callback function called by netlink system when a message arrives.
171 * If the message looks to be valid, then an attempt is made to assign
172 * it to its desired netlink context element and wake up the process
173 * that is waiting for a response.
174 */
175static void ecryptfs_receive_nl_message(struct sk_buff *skb)
176{
177 struct nlmsghdr *nlh;
178
179 nlh = nlmsg_hdr(skb);
180 if (!NLMSG_OK(nlh, skb->len)) {
181 ecryptfs_printk(KERN_ERR, "Received corrupt netlink "
182 "message\n");
183 goto free;
184 }
185 switch (nlh->nlmsg_type) {
186 case ECRYPTFS_MSG_RESPONSE:
187 if (ecryptfs_process_nl_response(skb)) {
188 ecryptfs_printk(KERN_WARNING, "Failed to "
189 "deliver netlink response to "
190 "requesting operation\n");
191 }
192 break;
193 case ECRYPTFS_MSG_HELO:
194 if (ecryptfs_process_nl_helo(skb)) {
195 ecryptfs_printk(KERN_WARNING, "Failed to "
196 "fulfill HELO request\n");
197 }
198 break;
199 case ECRYPTFS_MSG_QUIT:
200 if (ecryptfs_process_nl_quit(skb)) {
201 ecryptfs_printk(KERN_WARNING, "Failed to "
202 "fulfill QUIT request\n");
203 }
204 break;
205 default:
206 ecryptfs_printk(KERN_WARNING, "Dropping netlink "
207 "message of unrecognized type [%d]\n",
208 nlh->nlmsg_type);
209 break;
210 }
211free:
212 kfree_skb(skb);
213}
214
215/**
216 * ecryptfs_init_netlink
217 *
218 * Initializes the daemon id hash list, netlink context array, and
219 * necessary locks. Returns zero upon success; non-zero upon error.
220 */
221int ecryptfs_init_netlink(void)
222{
223 int rc;
224
225 ecryptfs_nl_sock = netlink_kernel_create(&init_net, NETLINK_ECRYPTFS, 0,
226 ecryptfs_receive_nl_message,
227 NULL, THIS_MODULE);
228 if (!ecryptfs_nl_sock) {
229 rc = -EIO;
230 ecryptfs_printk(KERN_ERR, "Failed to create netlink socket\n");
231 goto out;
232 }
233 ecryptfs_nl_sock->sk_sndtimeo = ECRYPTFS_DEFAULT_SEND_TIMEOUT;
234 rc = 0;
235out:
236 return rc;
237}
238
239/**
240 * ecryptfs_release_netlink
241 *
242 * Frees all memory used by the netlink context array and releases the
243 * netlink socket.
244 */
245void ecryptfs_release_netlink(void)
246{
247 netlink_kernel_release(ecryptfs_nl_sock);
248 ecryptfs_nl_sock = NULL;
249}
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7cc0eb756b55..99368bda0261 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -927,14 +927,11 @@ errxit:
927 /* 927 /*
928 * During the time we spent in the loop above, some other events 928 * During the time we spent in the loop above, some other events
929 * might have been queued by the poll callback. We re-insert them 929 * might have been queued by the poll callback. We re-insert them
930 * here (in case they are not already queued, or they're one-shot). 930 * inside the main ready-list here.
931 */ 931 */
932 for (nepi = ep->ovflist; (epi = nepi) != NULL; 932 for (nepi = ep->ovflist; (epi = nepi) != NULL;
933 nepi = epi->next, epi->next = EP_UNACTIVE_PTR) { 933 nepi = epi->next, epi->next = EP_UNACTIVE_PTR)
934 if (!ep_is_linked(&epi->rdllink) && 934 list_add_tail(&epi->rdllink, &ep->rdllist);
935 (epi->event.events & ~EP_PRIVATE_BITS))
936 list_add_tail(&epi->rdllink, &ep->rdllist);
937 }
938 /* 935 /*
939 * We need to set back ep->ovflist to EP_UNACTIVE_PTR, so that after 936 * We need to set back ep->ovflist to EP_UNACTIVE_PTR, so that after
940 * releasing the lock, events will be queued in the normal way inside 937 * releasing the lock, events will be queued in the normal way inside
diff --git a/fs/exec.c b/fs/exec.c
index cecee501ce78..a41e7902ed0b 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -50,15 +50,12 @@
50#include <linux/cn_proc.h> 50#include <linux/cn_proc.h>
51#include <linux/audit.h> 51#include <linux/audit.h>
52#include <linux/tracehook.h> 52#include <linux/tracehook.h>
53#include <linux/kmod.h>
53 54
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
55#include <asm/mmu_context.h> 56#include <asm/mmu_context.h>
56#include <asm/tlb.h> 57#include <asm/tlb.h>
57 58
58#ifdef CONFIG_KMOD
59#include <linux/kmod.h>
60#endif
61
62#ifdef __alpha__ 59#ifdef __alpha__
63/* for /sbin/loader handling in search_binary_handler() */ 60/* for /sbin/loader handling in search_binary_handler() */
64#include <linux/a.out.h> 61#include <linux/a.out.h>
@@ -391,7 +388,7 @@ static int count(char __user * __user * argv, int max)
391 if (!p) 388 if (!p)
392 break; 389 break;
393 argv++; 390 argv++;
394 if(++i > max) 391 if (i++ >= max)
395 return -E2BIG; 392 return -E2BIG;
396 cond_resched(); 393 cond_resched();
397 } 394 }
@@ -825,8 +822,6 @@ static int de_thread(struct task_struct *tsk)
825 schedule(); 822 schedule();
826 } 823 }
827 824
828 if (unlikely(task_child_reaper(tsk) == leader))
829 task_active_pid_ns(tsk)->child_reaper = tsk;
830 /* 825 /*
831 * The only record we have of the real-time age of a 826 * The only record we have of the real-time age of a
832 * process, regardless of execs it's done, is start_time. 827 * process, regardless of execs it's done, is start_time.
@@ -1189,7 +1184,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1189 return retval; 1184 return retval;
1190 1185
1191 /* Remember if the application is TASO. */ 1186 /* Remember if the application is TASO. */
1192 bprm->sh_bang = eh->ah.entry < 0x100000000UL; 1187 bprm->taso = eh->ah.entry < 0x100000000UL;
1193 1188
1194 bprm->file = file; 1189 bprm->file = file;
1195 bprm->loader = loader; 1190 bprm->loader = loader;
@@ -1247,8 +1242,8 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1247 read_unlock(&binfmt_lock); 1242 read_unlock(&binfmt_lock);
1248 if (retval != -ENOEXEC || bprm->mm == NULL) { 1243 if (retval != -ENOEXEC || bprm->mm == NULL) {
1249 break; 1244 break;
1250#ifdef CONFIG_KMOD 1245#ifdef CONFIG_MODULES
1251 }else{ 1246 } else {
1252#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e)) 1247#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
1253 if (printable(bprm->buf[0]) && 1248 if (printable(bprm->buf[0]) &&
1254 printable(bprm->buf[1]) && 1249 printable(bprm->buf[1]) &&
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 10bb02c3f25c..6dac7ba2d22d 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -1295,6 +1295,7 @@ retry_alloc:
1295 * turn off reservation for this allocation 1295 * turn off reservation for this allocation
1296 */ 1296 */
1297 if (my_rsv && (free_blocks < windowsz) 1297 if (my_rsv && (free_blocks < windowsz)
1298 && (free_blocks > 0)
1298 && (rsv_is_empty(&my_rsv->rsv_window))) 1299 && (rsv_is_empty(&my_rsv->rsv_window)))
1299 my_rsv = NULL; 1300 my_rsv = NULL;
1300 1301
@@ -1332,7 +1333,7 @@ retry_alloc:
1332 * free blocks is less than half of the reservation 1333 * free blocks is less than half of the reservation
1333 * window size. 1334 * window size.
1334 */ 1335 */
1335 if (free_blocks <= (windowsz/2)) 1336 if (my_rsv && (free_blocks <= (windowsz/2)))
1336 continue; 1337 continue;
1337 1338
1338 brelse(bitmap_bh); 1339 brelse(bitmap_bh);
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index a78c6b4af060..11a49ce84392 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -103,7 +103,7 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
103 return err; 103 return err;
104} 104}
105 105
106static void ext2_check_page(struct page *page) 106static void ext2_check_page(struct page *page, int quiet)
107{ 107{
108 struct inode *dir = page->mapping->host; 108 struct inode *dir = page->mapping->host;
109 struct super_block *sb = dir->i_sb; 109 struct super_block *sb = dir->i_sb;
@@ -146,10 +146,10 @@ out:
146 /* Too bad, we had an error */ 146 /* Too bad, we had an error */
147 147
148Ebadsize: 148Ebadsize:
149 ext2_error(sb, "ext2_check_page", 149 if (!quiet)
150 "size of directory #%lu is not a multiple of chunk size", 150 ext2_error(sb, __func__,
151 dir->i_ino 151 "size of directory #%lu is not a multiple "
152 ); 152 "of chunk size", dir->i_ino);
153 goto fail; 153 goto fail;
154Eshort: 154Eshort:
155 error = "rec_len is smaller than minimal"; 155 error = "rec_len is smaller than minimal";
@@ -166,32 +166,36 @@ Espan:
166Einumber: 166Einumber:
167 error = "inode out of bounds"; 167 error = "inode out of bounds";
168bad_entry: 168bad_entry:
169 ext2_error (sb, "ext2_check_page", "bad entry in directory #%lu: %s - " 169 if (!quiet)
170 "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", 170 ext2_error(sb, __func__, "bad entry in directory #%lu: : %s - "
171 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs, 171 "offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
172 (unsigned long) le32_to_cpu(p->inode), 172 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs,
173 rec_len, p->name_len); 173 (unsigned long) le32_to_cpu(p->inode),
174 rec_len, p->name_len);
174 goto fail; 175 goto fail;
175Eend: 176Eend:
176 p = (ext2_dirent *)(kaddr + offs); 177 if (!quiet) {
177 ext2_error (sb, "ext2_check_page", 178 p = (ext2_dirent *)(kaddr + offs);
178 "entry in directory #%lu spans the page boundary" 179 ext2_error(sb, "ext2_check_page",
179 "offset=%lu, inode=%lu", 180 "entry in directory #%lu spans the page boundary"
180 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs, 181 "offset=%lu, inode=%lu",
181 (unsigned long) le32_to_cpu(p->inode)); 182 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
183 (unsigned long) le32_to_cpu(p->inode));
184 }
182fail: 185fail:
183 SetPageChecked(page); 186 SetPageChecked(page);
184 SetPageError(page); 187 SetPageError(page);
185} 188}
186 189
187static struct page * ext2_get_page(struct inode *dir, unsigned long n) 190static struct page * ext2_get_page(struct inode *dir, unsigned long n,
191 int quiet)
188{ 192{
189 struct address_space *mapping = dir->i_mapping; 193 struct address_space *mapping = dir->i_mapping;
190 struct page *page = read_mapping_page(mapping, n, NULL); 194 struct page *page = read_mapping_page(mapping, n, NULL);
191 if (!IS_ERR(page)) { 195 if (!IS_ERR(page)) {
192 kmap(page); 196 kmap(page);
193 if (!PageChecked(page)) 197 if (!PageChecked(page))
194 ext2_check_page(page); 198 ext2_check_page(page, quiet);
195 if (PageError(page)) 199 if (PageError(page))
196 goto fail; 200 goto fail;
197 } 201 }
@@ -292,7 +296,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
292 for ( ; n < npages; n++, offset = 0) { 296 for ( ; n < npages; n++, offset = 0) {
293 char *kaddr, *limit; 297 char *kaddr, *limit;
294 ext2_dirent *de; 298 ext2_dirent *de;
295 struct page *page = ext2_get_page(inode, n); 299 struct page *page = ext2_get_page(inode, n, 0);
296 300
297 if (IS_ERR(page)) { 301 if (IS_ERR(page)) {
298 ext2_error(sb, __func__, 302 ext2_error(sb, __func__,
@@ -361,6 +365,7 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
361 struct page *page = NULL; 365 struct page *page = NULL;
362 struct ext2_inode_info *ei = EXT2_I(dir); 366 struct ext2_inode_info *ei = EXT2_I(dir);
363 ext2_dirent * de; 367 ext2_dirent * de;
368 int dir_has_error = 0;
364 369
365 if (npages == 0) 370 if (npages == 0)
366 goto out; 371 goto out;
@@ -374,7 +379,7 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
374 n = start; 379 n = start;
375 do { 380 do {
376 char *kaddr; 381 char *kaddr;
377 page = ext2_get_page(dir, n); 382 page = ext2_get_page(dir, n, dir_has_error);
378 if (!IS_ERR(page)) { 383 if (!IS_ERR(page)) {
379 kaddr = page_address(page); 384 kaddr = page_address(page);
380 de = (ext2_dirent *) kaddr; 385 de = (ext2_dirent *) kaddr;
@@ -391,7 +396,9 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
391 de = ext2_next_entry(de); 396 de = ext2_next_entry(de);
392 } 397 }
393 ext2_put_page(page); 398 ext2_put_page(page);
394 } 399 } else
400 dir_has_error = 1;
401
395 if (++n >= npages) 402 if (++n >= npages)
396 n = 0; 403 n = 0;
397 /* next page is past the blocks we've got */ 404 /* next page is past the blocks we've got */
@@ -414,7 +421,7 @@ found:
414 421
415struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p) 422struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
416{ 423{
417 struct page *page = ext2_get_page(dir, 0); 424 struct page *page = ext2_get_page(dir, 0, 0);
418 ext2_dirent *de = NULL; 425 ext2_dirent *de = NULL;
419 426
420 if (!IS_ERR(page)) { 427 if (!IS_ERR(page)) {
@@ -487,7 +494,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
487 for (n = 0; n <= npages; n++) { 494 for (n = 0; n <= npages; n++) {
488 char *dir_end; 495 char *dir_end;
489 496
490 page = ext2_get_page(dir, n); 497 page = ext2_get_page(dir, n, 0);
491 err = PTR_ERR(page); 498 err = PTR_ERR(page);
492 if (IS_ERR(page)) 499 if (IS_ERR(page))
493 goto out; 500 goto out;
@@ -655,14 +662,17 @@ int ext2_empty_dir (struct inode * inode)
655{ 662{
656 struct page *page = NULL; 663 struct page *page = NULL;
657 unsigned long i, npages = dir_pages(inode); 664 unsigned long i, npages = dir_pages(inode);
665 int dir_has_error = 0;
658 666
659 for (i = 0; i < npages; i++) { 667 for (i = 0; i < npages; i++) {
660 char *kaddr; 668 char *kaddr;
661 ext2_dirent * de; 669 ext2_dirent * de;
662 page = ext2_get_page(inode, i); 670 page = ext2_get_page(inode, i, dir_has_error);
663 671
664 if (IS_ERR(page)) 672 if (IS_ERR(page)) {
673 dir_has_error = 1;
665 continue; 674 continue;
675 }
666 676
667 kaddr = page_address(page); 677 kaddr = page_address(page);
668 de = (ext2_dirent *)kaddr; 678 de = (ext2_dirent *)kaddr;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 25adfc3c693a..d0ff0b8cf309 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -8,7 +8,7 @@
8 * pages against inodes. ie: data writeback. Writeout of the 8 * pages against inodes. ie: data writeback. Writeout of the
9 * inode itself is not handled here. 9 * inode itself is not handled here.
10 * 10 *
11 * 10Apr2002 akpm@zip.com.au 11 * 10Apr2002 Andrew Morton
12 * Split out of fs/inode.c 12 * Split out of fs/inode.c
13 * Additions for address_space-based writeback 13 * Additions for address_space-based writeback
14 */ 14 */
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index ba851576ebb1..6d98f116ca03 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -190,6 +190,10 @@ int hfs_cat_find_brec(struct super_block *sb, u32 cnid,
190 190
191 fd->search_key->cat.ParID = rec.thread.ParID; 191 fd->search_key->cat.ParID = rec.thread.ParID;
192 len = fd->search_key->cat.CName.len = rec.thread.CName.len; 192 len = fd->search_key->cat.CName.len = rec.thread.CName.len;
193 if (len > HFS_NAMELEN) {
194 printk(KERN_ERR "hfs: bad catalog namelength\n");
195 return -EIO;
196 }
193 memcpy(fd->search_key->cat.CName.name, rec.thread.CName.name, len); 197 memcpy(fd->search_key->cat.CName.name, rec.thread.CName.name, len);
194 return hfs_brec_find(fd); 198 return hfs_brec_find(fd);
195} 199}
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index d128a25b74d2..ea30afc2a03c 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -32,6 +32,10 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
32 mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); 32 mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
33 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; 33 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
34 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); 34 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
35 if (IS_ERR(page)) {
36 start = size;
37 goto out;
38 }
35 pptr = kmap(page); 39 pptr = kmap(page);
36 curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; 40 curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
37 i = offset % 32; 41 i = offset % 32;
@@ -73,6 +77,10 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
73 break; 77 break;
74 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, 78 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS,
75 NULL); 79 NULL);
80 if (IS_ERR(page)) {
81 start = size;
82 goto out;
83 }
76 curr = pptr = kmap(page); 84 curr = pptr = kmap(page);
77 if ((size ^ offset) / PAGE_CACHE_BITS) 85 if ((size ^ offset) / PAGE_CACHE_BITS)
78 end = pptr + PAGE_CACHE_BITS / 32; 86 end = pptr + PAGE_CACHE_BITS / 32;
@@ -120,6 +128,10 @@ found:
120 offset += PAGE_CACHE_BITS; 128 offset += PAGE_CACHE_BITS;
121 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, 129 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS,
122 NULL); 130 NULL);
131 if (IS_ERR(page)) {
132 start = size;
133 goto out;
134 }
123 pptr = kmap(page); 135 pptr = kmap(page);
124 curr = pptr; 136 curr = pptr;
125 end = pptr + PAGE_CACHE_BITS / 32; 137 end = pptr + PAGE_CACHE_BITS / 32;
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index ba117c445e78..f6874acb2cf2 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -168,6 +168,11 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
168 return -EIO; 168 return -EIO;
169 } 169 }
170 170
171 if (be16_to_cpu(tmp.thread.nodeName.length) > 255) {
172 printk(KERN_ERR "hfs: catalog name length corrupted\n");
173 return -EIO;
174 }
175
171 hfsplus_cat_build_key_uni(fd->search_key, be32_to_cpu(tmp.thread.parentID), 176 hfsplus_cat_build_key_uni(fd->search_key, be32_to_cpu(tmp.thread.parentID),
172 &tmp.thread.nodeName); 177 &tmp.thread.nodeName);
173 return hfs_brec_find(fd); 178 return hfs_brec_find(fd);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index e834e578c93f..eb74531a0a8e 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -356,7 +356,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
356 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { 356 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
357 printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n"); 357 printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
358 sb->s_flags |= MS_RDONLY; 358 sb->s_flags |= MS_RDONLY;
359 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { 359 } else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) && !(sb->s_flags & MS_RDONLY)) {
360 printk(KERN_WARNING "hfs: write access to a journaled filesystem is not supported, " 360 printk(KERN_WARNING "hfs: write access to a journaled filesystem is not supported, "
361 "use the force option at your own risk, mounting read-only.\n"); 361 "use the force option at your own risk, mounting read-only.\n");
362 sb->s_flags |= MS_RDONLY; 362 sb->s_flags |= MS_RDONLY;
diff --git a/fs/mpage.c b/fs/mpage.c
index dbcc7af76a15..552b80b3facc 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -6,7 +6,7 @@
6 * Contains functions related to preparing and submitting BIOs which contain 6 * Contains functions related to preparing and submitting BIOs which contain
7 * multiple pagecache pages. 7 * multiple pagecache pages.
8 * 8 *
9 * 15May2002 akpm@zip.com.au 9 * 15May2002 Andrew Morton
10 * Initial version 10 * Initial version
11 * 27Jun2002 axboe@suse.de 11 * 27Jun2002 axboe@suse.de
12 * use bio_add_page() to build bio's just the right size 12 * use bio_add_page() to build bio's just the right size
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5ee23e7058b3..7547600b6174 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -675,7 +675,7 @@ static int nfs_init_server(struct nfs_server *server,
675 server->nfs_client = clp; 675 server->nfs_client = clp;
676 676
677 /* Initialise the client representation from the mount data */ 677 /* Initialise the client representation from the mount data */
678 server->flags = data->flags & NFS_MOUNT_FLAGMASK; 678 server->flags = data->flags;
679 679
680 if (data->rsize) 680 if (data->rsize)
681 server->rsize = nfs_block_size(data->rsize, NULL); 681 server->rsize = nfs_block_size(data->rsize, NULL);
@@ -850,7 +850,6 @@ static struct nfs_server *nfs_alloc_server(void)
850 INIT_LIST_HEAD(&server->client_link); 850 INIT_LIST_HEAD(&server->client_link);
851 INIT_LIST_HEAD(&server->master_link); 851 INIT_LIST_HEAD(&server->master_link);
852 852
853 init_waitqueue_head(&server->active_wq);
854 atomic_set(&server->active, 0); 853 atomic_set(&server->active, 0);
855 854
856 server->io_stats = nfs_alloc_iostats(); 855 server->io_stats = nfs_alloc_iostats();
@@ -1073,7 +1072,7 @@ static int nfs4_init_server(struct nfs_server *server,
1073 goto error; 1072 goto error;
1074 1073
1075 /* Initialise the client representation from the mount data */ 1074 /* Initialise the client representation from the mount data */
1076 server->flags = data->flags & NFS_MOUNT_FLAGMASK; 1075 server->flags = data->flags;
1077 server->caps |= NFS_CAP_ATOMIC_OPEN; 1076 server->caps |= NFS_CAP_ATOMIC_OPEN;
1078 1077
1079 if (data->rsize) 1078 if (data->rsize)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 74f92b717f78..2ab70d46ecbc 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -156,6 +156,7 @@ typedef struct {
156 decode_dirent_t decode; 156 decode_dirent_t decode;
157 int plus; 157 int plus;
158 unsigned long timestamp; 158 unsigned long timestamp;
159 unsigned long gencount;
159 int timestamp_valid; 160 int timestamp_valid;
160} nfs_readdir_descriptor_t; 161} nfs_readdir_descriptor_t;
161 162
@@ -177,7 +178,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
177 struct file *file = desc->file; 178 struct file *file = desc->file;
178 struct inode *inode = file->f_path.dentry->d_inode; 179 struct inode *inode = file->f_path.dentry->d_inode;
179 struct rpc_cred *cred = nfs_file_cred(file); 180 struct rpc_cred *cred = nfs_file_cred(file);
180 unsigned long timestamp; 181 unsigned long timestamp, gencount;
181 int error; 182 int error;
182 183
183 dfprintk(DIRCACHE, "NFS: %s: reading cookie %Lu into page %lu\n", 184 dfprintk(DIRCACHE, "NFS: %s: reading cookie %Lu into page %lu\n",
@@ -186,6 +187,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
186 187
187 again: 188 again:
188 timestamp = jiffies; 189 timestamp = jiffies;
190 gencount = nfs_inc_attr_generation_counter();
189 error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, desc->entry->cookie, page, 191 error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, desc->entry->cookie, page,
190 NFS_SERVER(inode)->dtsize, desc->plus); 192 NFS_SERVER(inode)->dtsize, desc->plus);
191 if (error < 0) { 193 if (error < 0) {
@@ -199,6 +201,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
199 goto error; 201 goto error;
200 } 202 }
201 desc->timestamp = timestamp; 203 desc->timestamp = timestamp;
204 desc->gencount = gencount;
202 desc->timestamp_valid = 1; 205 desc->timestamp_valid = 1;
203 SetPageUptodate(page); 206 SetPageUptodate(page);
204 /* Ensure consistent page alignment of the data. 207 /* Ensure consistent page alignment of the data.
@@ -224,9 +227,10 @@ int dir_decode(nfs_readdir_descriptor_t *desc)
224 if (IS_ERR(p)) 227 if (IS_ERR(p))
225 return PTR_ERR(p); 228 return PTR_ERR(p);
226 desc->ptr = p; 229 desc->ptr = p;
227 if (desc->timestamp_valid) 230 if (desc->timestamp_valid) {
228 desc->entry->fattr->time_start = desc->timestamp; 231 desc->entry->fattr->time_start = desc->timestamp;
229 else 232 desc->entry->fattr->gencount = desc->gencount;
233 } else
230 desc->entry->fattr->valid &= ~NFS_ATTR_FATTR; 234 desc->entry->fattr->valid &= ~NFS_ATTR_FATTR;
231 return 0; 235 return 0;
232} 236}
@@ -471,7 +475,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
471 struct rpc_cred *cred = nfs_file_cred(file); 475 struct rpc_cred *cred = nfs_file_cred(file);
472 struct page *page = NULL; 476 struct page *page = NULL;
473 int status; 477 int status;
474 unsigned long timestamp; 478 unsigned long timestamp, gencount;
475 479
476 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n", 480 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n",
477 (unsigned long long)*desc->dir_cookie); 481 (unsigned long long)*desc->dir_cookie);
@@ -482,6 +486,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
482 goto out; 486 goto out;
483 } 487 }
484 timestamp = jiffies; 488 timestamp = jiffies;
489 gencount = nfs_inc_attr_generation_counter();
485 status = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, 490 status = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred,
486 *desc->dir_cookie, page, 491 *desc->dir_cookie, page,
487 NFS_SERVER(inode)->dtsize, 492 NFS_SERVER(inode)->dtsize,
@@ -490,6 +495,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
490 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ 495 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */
491 if (status >= 0) { 496 if (status >= 0) {
492 desc->timestamp = timestamp; 497 desc->timestamp = timestamp;
498 desc->gencount = gencount;
493 desc->timestamp_valid = 1; 499 desc->timestamp_valid = 1;
494 if ((status = dir_decode(desc)) == 0) 500 if ((status = dir_decode(desc)) == 0)
495 desc->entry->prev_cookie = *desc->dir_cookie; 501 desc->entry->prev_cookie = *desc->dir_cookie;
@@ -655,7 +661,7 @@ static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync)
655 */ 661 */
656void nfs_force_lookup_revalidate(struct inode *dir) 662void nfs_force_lookup_revalidate(struct inode *dir)
657{ 663{
658 NFS_I(dir)->cache_change_attribute = jiffies; 664 NFS_I(dir)->cache_change_attribute++;
659} 665}
660 666
661/* 667/*
@@ -667,6 +673,8 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
667{ 673{
668 if (IS_ROOT(dentry)) 674 if (IS_ROOT(dentry))
669 return 1; 675 return 1;
676 if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONE)
677 return 0;
670 if (!nfs_verify_change_attribute(dir, dentry->d_time)) 678 if (!nfs_verify_change_attribute(dir, dentry->d_time))
671 return 0; 679 return 0;
672 /* Revalidate nfsi->cache_change_attribute before we declare a match */ 680 /* Revalidate nfsi->cache_change_attribute before we declare a match */
@@ -750,6 +758,8 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,
750 /* Don't revalidate a negative dentry if we're creating a new file */ 758 /* Don't revalidate a negative dentry if we're creating a new file */
751 if (nd != NULL && nfs_lookup_check_intent(nd, LOOKUP_CREATE) != 0) 759 if (nd != NULL && nfs_lookup_check_intent(nd, LOOKUP_CREATE) != 0)
752 return 0; 760 return 0;
761 if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG)
762 return 1;
753 return !nfs_check_verifier(dir, dentry); 763 return !nfs_check_verifier(dir, dentry);
754} 764}
755 765
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 78460657f5cb..d319b49f8f06 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -188,13 +188,16 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
188 /* origin == SEEK_END => we must revalidate the cached file length */ 188 /* origin == SEEK_END => we must revalidate the cached file length */
189 if (origin == SEEK_END) { 189 if (origin == SEEK_END) {
190 struct inode *inode = filp->f_mapping->host; 190 struct inode *inode = filp->f_mapping->host;
191
191 int retval = nfs_revalidate_file_size(inode, filp); 192 int retval = nfs_revalidate_file_size(inode, filp);
192 if (retval < 0) 193 if (retval < 0)
193 return (loff_t)retval; 194 return (loff_t)retval;
194 } 195
195 lock_kernel(); /* BKL needed? */ 196 spin_lock(&inode->i_lock);
196 loff = generic_file_llseek_unlocked(filp, offset, origin); 197 loff = generic_file_llseek_unlocked(filp, offset, origin);
197 unlock_kernel(); 198 spin_unlock(&inode->i_lock);
199 } else
200 loff = generic_file_llseek_unlocked(filp, offset, origin);
198 return loff; 201 return loff;
199} 202}
200 203
@@ -699,13 +702,6 @@ static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
699 filp->f_path.dentry->d_name.name, 702 filp->f_path.dentry->d_name.name,
700 fl->fl_type, fl->fl_flags); 703 fl->fl_type, fl->fl_flags);
701 704
702 /*
703 * No BSD flocks over NFS allowed.
704 * Note: we could try to fake a POSIX lock request here by
705 * using ((u32) filp | 0x80000000) or some such as the pid.
706 * Not sure whether that would be unique, though, or whether
707 * that would break in other places.
708 */
709 if (!(fl->fl_flags & FL_FLOCK)) 705 if (!(fl->fl_flags & FL_FLOCK))
710 return -ENOLCK; 706 return -ENOLCK;
711 707
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 52daefa2f521..b9195c02a863 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -305,8 +305,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
305 init_special_inode(inode, inode->i_mode, fattr->rdev); 305 init_special_inode(inode, inode->i_mode, fattr->rdev);
306 306
307 nfsi->read_cache_jiffies = fattr->time_start; 307 nfsi->read_cache_jiffies = fattr->time_start;
308 nfsi->last_updated = now; 308 nfsi->attr_gencount = fattr->gencount;
309 nfsi->cache_change_attribute = now;
310 inode->i_atime = fattr->atime; 309 inode->i_atime = fattr->atime;
311 inode->i_mtime = fattr->mtime; 310 inode->i_mtime = fattr->mtime;
312 inode->i_ctime = fattr->ctime; 311 inode->i_ctime = fattr->ctime;
@@ -453,6 +452,7 @@ out_big:
453void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) 452void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
454{ 453{
455 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) { 454 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) {
455 spin_lock(&inode->i_lock);
456 if ((attr->ia_valid & ATTR_MODE) != 0) { 456 if ((attr->ia_valid & ATTR_MODE) != 0) {
457 int mode = attr->ia_mode & S_IALLUGO; 457 int mode = attr->ia_mode & S_IALLUGO;
458 mode |= inode->i_mode & ~S_IALLUGO; 458 mode |= inode->i_mode & ~S_IALLUGO;
@@ -462,7 +462,6 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
462 inode->i_uid = attr->ia_uid; 462 inode->i_uid = attr->ia_uid;
463 if ((attr->ia_valid & ATTR_GID) != 0) 463 if ((attr->ia_valid & ATTR_GID) != 0)
464 inode->i_gid = attr->ia_gid; 464 inode->i_gid = attr->ia_gid;
465 spin_lock(&inode->i_lock);
466 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; 465 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
467 spin_unlock(&inode->i_lock); 466 spin_unlock(&inode->i_lock);
468 } 467 }
@@ -472,37 +471,6 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
472 } 471 }
473} 472}
474 473
475static int nfs_wait_schedule(void *word)
476{
477 if (signal_pending(current))
478 return -ERESTARTSYS;
479 schedule();
480 return 0;
481}
482
483/*
484 * Wait for the inode to get unlocked.
485 */
486static int nfs_wait_on_inode(struct inode *inode)
487{
488 struct nfs_inode *nfsi = NFS_I(inode);
489 int error;
490
491 error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING,
492 nfs_wait_schedule, TASK_KILLABLE);
493
494 return error;
495}
496
497static void nfs_wake_up_inode(struct inode *inode)
498{
499 struct nfs_inode *nfsi = NFS_I(inode);
500
501 clear_bit(NFS_INO_REVALIDATING, &nfsi->flags);
502 smp_mb__after_clear_bit();
503 wake_up_bit(&nfsi->flags, NFS_INO_REVALIDATING);
504}
505
506int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) 474int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
507{ 475{
508 struct inode *inode = dentry->d_inode; 476 struct inode *inode = dentry->d_inode;
@@ -697,20 +665,15 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
697 dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", 665 dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n",
698 inode->i_sb->s_id, (long long)NFS_FILEID(inode)); 666 inode->i_sb->s_id, (long long)NFS_FILEID(inode));
699 667
700 nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE);
701 if (is_bad_inode(inode)) 668 if (is_bad_inode(inode))
702 goto out_nowait; 669 goto out;
703 if (NFS_STALE(inode)) 670 if (NFS_STALE(inode))
704 goto out_nowait;
705
706 status = nfs_wait_on_inode(inode);
707 if (status < 0)
708 goto out; 671 goto out;
709 672
710 status = -ESTALE;
711 if (NFS_STALE(inode)) 673 if (NFS_STALE(inode))
712 goto out; 674 goto out;
713 675
676 nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE);
714 status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), &fattr); 677 status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), &fattr);
715 if (status != 0) { 678 if (status != 0) {
716 dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) getattr failed, error=%d\n", 679 dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) getattr failed, error=%d\n",
@@ -724,16 +687,13 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
724 goto out; 687 goto out;
725 } 688 }
726 689
727 spin_lock(&inode->i_lock); 690 status = nfs_refresh_inode(inode, &fattr);
728 status = nfs_update_inode(inode, &fattr);
729 if (status) { 691 if (status) {
730 spin_unlock(&inode->i_lock);
731 dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n", 692 dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n",
732 inode->i_sb->s_id, 693 inode->i_sb->s_id,
733 (long long)NFS_FILEID(inode), status); 694 (long long)NFS_FILEID(inode), status);
734 goto out; 695 goto out;
735 } 696 }
736 spin_unlock(&inode->i_lock);
737 697
738 if (nfsi->cache_validity & NFS_INO_INVALID_ACL) 698 if (nfsi->cache_validity & NFS_INO_INVALID_ACL)
739 nfs_zap_acl_cache(inode); 699 nfs_zap_acl_cache(inode);
@@ -743,9 +703,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
743 (long long)NFS_FILEID(inode)); 703 (long long)NFS_FILEID(inode));
744 704
745 out: 705 out:
746 nfs_wake_up_inode(inode);
747
748 out_nowait:
749 return status; 706 return status;
750} 707}
751 708
@@ -908,9 +865,6 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
908 return -EIO; 865 return -EIO;
909 } 866 }
910 867
911 /* Do atomic weak cache consistency updates */
912 nfs_wcc_update_inode(inode, fattr);
913
914 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && 868 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 &&
915 nfsi->change_attr != fattr->change_attr) 869 nfsi->change_attr != fattr->change_attr)
916 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 870 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
@@ -939,15 +893,81 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
939 893
940 if (invalid != 0) 894 if (invalid != 0)
941 nfsi->cache_validity |= invalid; 895 nfsi->cache_validity |= invalid;
942 else
943 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR
944 | NFS_INO_INVALID_ATIME
945 | NFS_INO_REVAL_PAGECACHE);
946 896
947 nfsi->read_cache_jiffies = fattr->time_start; 897 nfsi->read_cache_jiffies = fattr->time_start;
948 return 0; 898 return 0;
949} 899}
950 900
901static int nfs_ctime_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
902{
903 return timespec_compare(&fattr->ctime, &inode->i_ctime) > 0;
904}
905
906static int nfs_size_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
907{
908 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
909}
910
911static unsigned long nfs_attr_generation_counter;
912
913static unsigned long nfs_read_attr_generation_counter(void)
914{
915 smp_rmb();
916 return nfs_attr_generation_counter;
917}
918
919unsigned long nfs_inc_attr_generation_counter(void)
920{
921 unsigned long ret;
922 smp_rmb();
923 ret = ++nfs_attr_generation_counter;
924 smp_wmb();
925 return ret;
926}
927
928void nfs_fattr_init(struct nfs_fattr *fattr)
929{
930 fattr->valid = 0;
931 fattr->time_start = jiffies;
932 fattr->gencount = nfs_inc_attr_generation_counter();
933}
934
935/**
936 * nfs_inode_attrs_need_update - check if the inode attributes need updating
937 * @inode - pointer to inode
938 * @fattr - attributes
939 *
940 * Attempt to divine whether or not an RPC call reply carrying stale
941 * attributes got scheduled after another call carrying updated ones.
942 *
943 * To do so, the function first assumes that a more recent ctime means
944 * that the attributes in fattr are newer, however it also attempt to
945 * catch the case where ctime either didn't change, or went backwards
946 * (if someone reset the clock on the server) by looking at whether
947 * or not this RPC call was started after the inode was last updated.
948 * Note also the check for wraparound of 'attr_gencount'
949 *
950 * The function returns 'true' if it thinks the attributes in 'fattr' are
951 * more recent than the ones cached in the inode.
952 *
953 */
954static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
955{
956 const struct nfs_inode *nfsi = NFS_I(inode);
957
958 return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 ||
959 nfs_ctime_need_update(inode, fattr) ||
960 nfs_size_need_update(inode, fattr) ||
961 ((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0);
962}
963
964static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
965{
966 if (nfs_inode_attrs_need_update(inode, fattr))
967 return nfs_update_inode(inode, fattr);
968 return nfs_check_inode_attributes(inode, fattr);
969}
970
951/** 971/**
952 * nfs_refresh_inode - try to update the inode attribute cache 972 * nfs_refresh_inode - try to update the inode attribute cache
953 * @inode - pointer to inode 973 * @inode - pointer to inode
@@ -960,21 +980,28 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
960 */ 980 */
961int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) 981int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
962{ 982{
963 struct nfs_inode *nfsi = NFS_I(inode);
964 int status; 983 int status;
965 984
966 if ((fattr->valid & NFS_ATTR_FATTR) == 0) 985 if ((fattr->valid & NFS_ATTR_FATTR) == 0)
967 return 0; 986 return 0;
968 spin_lock(&inode->i_lock); 987 spin_lock(&inode->i_lock);
969 if (time_after(fattr->time_start, nfsi->last_updated)) 988 status = nfs_refresh_inode_locked(inode, fattr);
970 status = nfs_update_inode(inode, fattr);
971 else
972 status = nfs_check_inode_attributes(inode, fattr);
973
974 spin_unlock(&inode->i_lock); 989 spin_unlock(&inode->i_lock);
975 return status; 990 return status;
976} 991}
977 992
993static int nfs_post_op_update_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
994{
995 struct nfs_inode *nfsi = NFS_I(inode);
996
997 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
998 if (S_ISDIR(inode->i_mode))
999 nfsi->cache_validity |= NFS_INO_INVALID_DATA;
1000 if ((fattr->valid & NFS_ATTR_FATTR) == 0)
1001 return 0;
1002 return nfs_refresh_inode_locked(inode, fattr);
1003}
1004
978/** 1005/**
979 * nfs_post_op_update_inode - try to update the inode attribute cache 1006 * nfs_post_op_update_inode - try to update the inode attribute cache
980 * @inode - pointer to inode 1007 * @inode - pointer to inode
@@ -991,14 +1018,12 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
991 */ 1018 */
992int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) 1019int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
993{ 1020{
994 struct nfs_inode *nfsi = NFS_I(inode); 1021 int status;
995 1022
996 spin_lock(&inode->i_lock); 1023 spin_lock(&inode->i_lock);
997 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 1024 status = nfs_post_op_update_inode_locked(inode, fattr);
998 if (S_ISDIR(inode->i_mode))
999 nfsi->cache_validity |= NFS_INO_INVALID_DATA;
1000 spin_unlock(&inode->i_lock); 1025 spin_unlock(&inode->i_lock);
1001 return nfs_refresh_inode(inode, fattr); 1026 return status;
1002} 1027}
1003 1028
1004/** 1029/**
@@ -1014,6 +1039,15 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1014 */ 1039 */
1015int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr) 1040int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr)
1016{ 1041{
1042 int status;
1043
1044 spin_lock(&inode->i_lock);
1045 /* Don't do a WCC update if these attributes are already stale */
1046 if ((fattr->valid & NFS_ATTR_FATTR) == 0 ||
1047 !nfs_inode_attrs_need_update(inode, fattr)) {
1048 fattr->valid &= ~(NFS_ATTR_WCC_V4|NFS_ATTR_WCC);
1049 goto out_noforce;
1050 }
1017 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && 1051 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 &&
1018 (fattr->valid & NFS_ATTR_WCC_V4) == 0) { 1052 (fattr->valid & NFS_ATTR_WCC_V4) == 0) {
1019 fattr->pre_change_attr = NFS_I(inode)->change_attr; 1053 fattr->pre_change_attr = NFS_I(inode)->change_attr;
@@ -1026,7 +1060,10 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa
1026 fattr->pre_size = i_size_read(inode); 1060 fattr->pre_size = i_size_read(inode);
1027 fattr->valid |= NFS_ATTR_WCC; 1061 fattr->valid |= NFS_ATTR_WCC;
1028 } 1062 }
1029 return nfs_post_op_update_inode(inode, fattr); 1063out_noforce:
1064 status = nfs_post_op_update_inode_locked(inode, fattr);
1065 spin_unlock(&inode->i_lock);
1066 return status;
1030} 1067}
1031 1068
1032/* 1069/*
@@ -1092,7 +1129,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1092 } 1129 }
1093 /* If ctime has changed we should definitely clear access+acl caches */ 1130 /* If ctime has changed we should definitely clear access+acl caches */
1094 if (!timespec_equal(&inode->i_ctime, &fattr->ctime)) 1131 if (!timespec_equal(&inode->i_ctime, &fattr->ctime))
1095 invalid |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; 1132 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
1096 } else if (nfsi->change_attr != fattr->change_attr) { 1133 } else if (nfsi->change_attr != fattr->change_attr) {
1097 dprintk("NFS: change_attr change on server for file %s/%ld\n", 1134 dprintk("NFS: change_attr change on server for file %s/%ld\n",
1098 inode->i_sb->s_id, inode->i_ino); 1135 inode->i_sb->s_id, inode->i_ino);
@@ -1126,6 +1163,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1126 inode->i_gid != fattr->gid) 1163 inode->i_gid != fattr->gid)
1127 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; 1164 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
1128 1165
1166 if (inode->i_nlink != fattr->nlink)
1167 invalid |= NFS_INO_INVALID_ATTR;
1168
1129 inode->i_mode = fattr->mode; 1169 inode->i_mode = fattr->mode;
1130 inode->i_nlink = fattr->nlink; 1170 inode->i_nlink = fattr->nlink;
1131 inode->i_uid = fattr->uid; 1171 inode->i_uid = fattr->uid;
@@ -1145,18 +1185,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1145 nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); 1185 nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);
1146 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); 1186 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
1147 nfsi->attrtimeo_timestamp = now; 1187 nfsi->attrtimeo_timestamp = now;
1148 nfsi->last_updated = now; 1188 nfsi->attr_gencount = nfs_inc_attr_generation_counter();
1149 } else { 1189 } else {
1150 if (!time_in_range(now, nfsi->attrtimeo_timestamp, nfsi->attrtimeo_timestamp + nfsi->attrtimeo)) { 1190 if (!time_in_range(now, nfsi->attrtimeo_timestamp, nfsi->attrtimeo_timestamp + nfsi->attrtimeo)) {
1151 if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode)) 1191 if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode))
1152 nfsi->attrtimeo = NFS_MAXATTRTIMEO(inode); 1192 nfsi->attrtimeo = NFS_MAXATTRTIMEO(inode);
1153 nfsi->attrtimeo_timestamp = now; 1193 nfsi->attrtimeo_timestamp = now;
1154 } 1194 }
1155 /*
1156 * Avoid jiffy wraparound issues with nfsi->last_updated
1157 */
1158 if (!time_in_range(nfsi->last_updated, nfsi->read_cache_jiffies, now))
1159 nfsi->last_updated = nfsi->read_cache_jiffies;
1160 } 1195 }
1161 invalid &= ~NFS_INO_INVALID_ATTR; 1196 invalid &= ~NFS_INO_INVALID_ATTR;
1162 /* Don't invalidate the data if we were to blame */ 1197 /* Don't invalidate the data if we were to blame */
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 24241fcbb98d..d212ee41caf2 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -153,6 +153,7 @@ extern void nfs4_clear_inode(struct inode *);
153void nfs_zap_acl_cache(struct inode *inode); 153void nfs_zap_acl_cache(struct inode *inode);
154 154
155/* super.c */ 155/* super.c */
156void nfs_parse_ip_address(char *, size_t, struct sockaddr *, size_t *);
156extern struct file_system_type nfs_xdev_fs_type; 157extern struct file_system_type nfs_xdev_fs_type;
157#ifdef CONFIG_NFS_V4 158#ifdef CONFIG_NFS_V4
158extern struct file_system_type nfs4_xdev_fs_type; 159extern struct file_system_type nfs4_xdev_fs_type;
@@ -163,8 +164,8 @@ extern struct rpc_stat nfs_rpcstat;
163 164
164extern int __init register_nfs_fs(void); 165extern int __init register_nfs_fs(void);
165extern void __exit unregister_nfs_fs(void); 166extern void __exit unregister_nfs_fs(void);
166extern void nfs_sb_active(struct nfs_server *server); 167extern void nfs_sb_active(struct super_block *sb);
167extern void nfs_sb_deactive(struct nfs_server *server); 168extern void nfs_sb_deactive(struct super_block *sb);
168 169
169/* namespace.c */ 170/* namespace.c */
170extern char *nfs_path(const char *base, 171extern char *nfs_path(const char *base,
@@ -276,3 +277,23 @@ unsigned int nfs_page_array_len(unsigned int base, size_t len)
276 PAGE_SIZE - 1) >> PAGE_SHIFT; 277 PAGE_SIZE - 1) >> PAGE_SHIFT;
277} 278}
278 279
280#define IPV6_SCOPE_DELIMITER '%'
281
282/*
283 * Set the port number in an address. Be agnostic about the address
284 * family.
285 */
286static inline void nfs_set_port(struct sockaddr *sap, unsigned short port)
287{
288 struct sockaddr_in *ap = (struct sockaddr_in *)sap;
289 struct sockaddr_in6 *ap6 = (struct sockaddr_in6 *)sap;
290
291 switch (sap->sa_family) {
292 case AF_INET:
293 ap->sin_port = htons(port);
294 break;
295 case AF_INET6:
296 ap6->sin6_port = htons(port);
297 break;
298 }
299}
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index 779d2eb649c5..086a6830d785 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -14,6 +14,7 @@
14#include <linux/sunrpc/clnt.h> 14#include <linux/sunrpc/clnt.h>
15#include <linux/sunrpc/sched.h> 15#include <linux/sunrpc/sched.h>
16#include <linux/nfs_fs.h> 16#include <linux/nfs_fs.h>
17#include "internal.h"
17 18
18#ifdef RPC_DEBUG 19#ifdef RPC_DEBUG
19# define NFSDBG_FACILITY NFSDBG_MOUNT 20# define NFSDBG_FACILITY NFSDBG_MOUNT
@@ -98,7 +99,7 @@ out_call_err:
98 99
99out_mnt_err: 100out_mnt_err:
100 dprintk("NFS: MNT server returned result %d\n", result.status); 101 dprintk("NFS: MNT server returned result %d\n", result.status);
101 status = -EACCES; 102 status = nfs_stat_to_errno(result.status);
102 goto out; 103 goto out;
103} 104}
104 105
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 66df08dd1caf..64a288ee046d 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -105,7 +105,10 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
105 105
106 dprintk("--> nfs_follow_mountpoint()\n"); 106 dprintk("--> nfs_follow_mountpoint()\n");
107 107
108 BUG_ON(IS_ROOT(dentry)); 108 err = -ESTALE;
109 if (IS_ROOT(dentry))
110 goto out_err;
111
109 dprintk("%s: enter\n", __func__); 112 dprintk("%s: enter\n", __func__);
110 dput(nd->path.dentry); 113 dput(nd->path.dentry);
111 nd->path.dentry = dget(dentry); 114 nd->path.dentry = dget(dentry);
@@ -189,7 +192,7 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
189 struct nfs_clone_mount *mountdata) 192 struct nfs_clone_mount *mountdata)
190{ 193{
191#ifdef CONFIG_NFS_V4 194#ifdef CONFIG_NFS_V4
192 struct vfsmount *mnt = NULL; 195 struct vfsmount *mnt = ERR_PTR(-EINVAL);
193 switch (server->nfs_client->rpc_ops->version) { 196 switch (server->nfs_client->rpc_ops->version) {
194 case 2: 197 case 2:
195 case 3: 198 case 3:
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 423842f51ac9..cef62557c87d 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -229,6 +229,7 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
229 229
230 dprintk("NFS call getacl\n"); 230 dprintk("NFS call getacl\n");
231 msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_GETACL]; 231 msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_GETACL];
232 nfs_fattr_init(&fattr);
232 status = rpc_call_sync(server->client_acl, &msg, 0); 233 status = rpc_call_sync(server->client_acl, &msg, 0);
233 dprintk("NFS reply getacl: %d\n", status); 234 dprintk("NFS reply getacl: %d\n", status);
234 235
@@ -322,6 +323,7 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
322 323
323 dprintk("NFS call setacl\n"); 324 dprintk("NFS call setacl\n");
324 msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; 325 msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL];
326 nfs_fattr_init(&fattr);
325 status = rpc_call_sync(server->client_acl, &msg, 0); 327 status = rpc_call_sync(server->client_acl, &msg, 0);
326 nfs_access_zap_cache(inode); 328 nfs_access_zap_cache(inode);
327 nfs_zap_acl_cache(inode); 329 nfs_zap_acl_cache(inode);
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 1e750e4574a9..c55be7a7679e 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -699,7 +699,7 @@ nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
699} 699}
700 700
701static int 701static int
702nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, 702do_proc_fsinfo(struct rpc_clnt *client, struct nfs_fh *fhandle,
703 struct nfs_fsinfo *info) 703 struct nfs_fsinfo *info)
704{ 704{
705 struct rpc_message msg = { 705 struct rpc_message msg = {
@@ -711,11 +711,27 @@ nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
711 711
712 dprintk("NFS call fsinfo\n"); 712 dprintk("NFS call fsinfo\n");
713 nfs_fattr_init(info->fattr); 713 nfs_fattr_init(info->fattr);
714 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 714 status = rpc_call_sync(client, &msg, 0);
715 dprintk("NFS reply fsinfo: %d\n", status); 715 dprintk("NFS reply fsinfo: %d\n", status);
716 return status; 716 return status;
717} 717}
718 718
719/*
720 * Bare-bones access to fsinfo: this is for nfs_get_root/nfs_get_sb via
721 * nfs_create_server
722 */
723static int
724nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
725 struct nfs_fsinfo *info)
726{
727 int status;
728
729 status = do_proc_fsinfo(server->client, fhandle, info);
730 if (status && server->nfs_client->cl_rpcclient != server->client)
731 status = do_proc_fsinfo(server->nfs_client->cl_rpcclient, fhandle, info);
732 return status;
733}
734
719static int 735static int
720nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, 736nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
721 struct nfs_pathconf *info) 737 struct nfs_pathconf *info)
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index b112857301f7..30befc39b3c6 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -93,21 +93,52 @@ static int nfs4_validate_fspath(const struct vfsmount *mnt_parent,
93 return 0; 93 return 0;
94} 94}
95 95
96/* 96static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
97 * Check if the string represents a "valid" IPv4 address 97 char *page, char *page2,
98 */ 98 const struct nfs4_fs_location *location)
99static inline int valid_ipaddr4(const char *buf)
100{ 99{
101 int rc, count, in[4]; 100 struct vfsmount *mnt = ERR_PTR(-ENOENT);
102 101 char *mnt_path;
103 rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]); 102 int page2len;
104 if (rc != 4) 103 unsigned int s;
105 return -EINVAL; 104
106 for (count = 0; count < 4; count++) { 105 mnt_path = nfs4_pathname_string(&location->rootpath, page2, PAGE_SIZE);
107 if (in[count] > 255) 106 if (IS_ERR(mnt_path))
108 return -EINVAL; 107 return mnt;
108 mountdata->mnt_path = mnt_path;
109 page2 += strlen(mnt_path) + 1;
110 page2len = PAGE_SIZE - strlen(mnt_path) - 1;
111
112 for (s = 0; s < location->nservers; s++) {
113 const struct nfs4_string *buf = &location->servers[s];
114 struct sockaddr_storage addr;
115
116 if (buf->len <= 0 || buf->len >= PAGE_SIZE)
117 continue;
118
119 mountdata->addr = (struct sockaddr *)&addr;
120
121 if (memchr(buf->data, IPV6_SCOPE_DELIMITER, buf->len))
122 continue;
123 nfs_parse_ip_address(buf->data, buf->len,
124 mountdata->addr, &mountdata->addrlen);
125 if (mountdata->addr->sa_family == AF_UNSPEC)
126 continue;
127 nfs_set_port(mountdata->addr, NFS_PORT);
128
129 strncpy(page2, buf->data, page2len);
130 page2[page2len] = '\0';
131 mountdata->hostname = page2;
132
133 snprintf(page, PAGE_SIZE, "%s:%s",
134 mountdata->hostname,
135 mountdata->mnt_path);
136
137 mnt = vfs_kern_mount(&nfs4_referral_fs_type, 0, page, mountdata);
138 if (!IS_ERR(mnt))
139 break;
109 } 140 }
110 return 0; 141 return mnt;
111} 142}
112 143
113/** 144/**
@@ -128,7 +159,6 @@ static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
128 .authflavor = NFS_SB(mnt_parent->mnt_sb)->client->cl_auth->au_flavor, 159 .authflavor = NFS_SB(mnt_parent->mnt_sb)->client->cl_auth->au_flavor,
129 }; 160 };
130 char *page = NULL, *page2 = NULL; 161 char *page = NULL, *page2 = NULL;
131 unsigned int s;
132 int loc, error; 162 int loc, error;
133 163
134 if (locations == NULL || locations->nlocations <= 0) 164 if (locations == NULL || locations->nlocations <= 0)
@@ -152,53 +182,16 @@ static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
152 goto out; 182 goto out;
153 } 183 }
154 184
155 loc = 0; 185 for (loc = 0; loc < locations->nlocations; loc++) {
156 while (loc < locations->nlocations && IS_ERR(mnt)) {
157 const struct nfs4_fs_location *location = &locations->locations[loc]; 186 const struct nfs4_fs_location *location = &locations->locations[loc];
158 char *mnt_path;
159 187
160 if (location == NULL || location->nservers <= 0 || 188 if (location == NULL || location->nservers <= 0 ||
161 location->rootpath.ncomponents == 0) { 189 location->rootpath.ncomponents == 0)
162 loc++;
163 continue; 190 continue;
164 }
165 191
166 mnt_path = nfs4_pathname_string(&location->rootpath, page2, PAGE_SIZE); 192 mnt = try_location(&mountdata, page, page2, location);
167 if (IS_ERR(mnt_path)) { 193 if (!IS_ERR(mnt))
168 loc++; 194 break;
169 continue;
170 }
171 mountdata.mnt_path = mnt_path;
172
173 s = 0;
174 while (s < location->nservers) {
175 struct sockaddr_in addr = {
176 .sin_family = AF_INET,
177 .sin_port = htons(NFS_PORT),
178 };
179
180 if (location->servers[s].len <= 0 ||
181 valid_ipaddr4(location->servers[s].data) < 0) {
182 s++;
183 continue;
184 }
185
186 mountdata.hostname = location->servers[s].data;
187 addr.sin_addr.s_addr = in_aton(mountdata.hostname),
188 mountdata.addr = (struct sockaddr *)&addr;
189 mountdata.addrlen = sizeof(addr);
190
191 snprintf(page, PAGE_SIZE, "%s:%s",
192 mountdata.hostname,
193 mountdata.mnt_path);
194
195 mnt = vfs_kern_mount(&nfs4_referral_fs_type, 0, page, &mountdata);
196 if (!IS_ERR(mnt)) {
197 break;
198 }
199 s++;
200 }
201 loc++;
202 } 195 }
203 196
204out: 197out:
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 4dbb84df1b68..193465210d7c 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -65,14 +65,20 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
65 65
66 dprintk("%s: call getattr\n", __func__); 66 dprintk("%s: call getattr\n", __func__);
67 nfs_fattr_init(fattr); 67 nfs_fattr_init(fattr);
68 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 68 status = rpc_call_sync(server->client, &msg, 0);
69 /* Retry with default authentication if different */
70 if (status && server->nfs_client->cl_rpcclient != server->client)
71 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
69 dprintk("%s: reply getattr: %d\n", __func__, status); 72 dprintk("%s: reply getattr: %d\n", __func__, status);
70 if (status) 73 if (status)
71 return status; 74 return status;
72 dprintk("%s: call statfs\n", __func__); 75 dprintk("%s: call statfs\n", __func__);
73 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS]; 76 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
74 msg.rpc_resp = &fsinfo; 77 msg.rpc_resp = &fsinfo;
75 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 78 status = rpc_call_sync(server->client, &msg, 0);
79 /* Retry with default authentication if different */
80 if (status && server->nfs_client->cl_rpcclient != server->client)
81 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
76 dprintk("%s: reply statfs: %d\n", __func__, status); 82 dprintk("%s: reply statfs: %d\n", __func__, status);
77 if (status) 83 if (status)
78 return status; 84 return status;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ffb697416cb1..8b28b95c9e44 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -91,6 +91,7 @@ enum {
91 /* Mount options that take string arguments */ 91 /* Mount options that take string arguments */
92 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, 92 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
93 Opt_addr, Opt_mountaddr, Opt_clientaddr, 93 Opt_addr, Opt_mountaddr, Opt_clientaddr,
94 Opt_lookupcache,
94 95
95 /* Special mount options */ 96 /* Special mount options */
96 Opt_userspace, Opt_deprecated, Opt_sloppy, 97 Opt_userspace, Opt_deprecated, Opt_sloppy,
@@ -154,6 +155,8 @@ static const match_table_t nfs_mount_option_tokens = {
154 { Opt_mounthost, "mounthost=%s" }, 155 { Opt_mounthost, "mounthost=%s" },
155 { Opt_mountaddr, "mountaddr=%s" }, 156 { Opt_mountaddr, "mountaddr=%s" },
156 157
158 { Opt_lookupcache, "lookupcache=%s" },
159
157 { Opt_err, NULL } 160 { Opt_err, NULL }
158}; 161};
159 162
@@ -200,6 +203,22 @@ static const match_table_t nfs_secflavor_tokens = {
200 { Opt_sec_err, NULL } 203 { Opt_sec_err, NULL }
201}; 204};
202 205
206enum {
207 Opt_lookupcache_all, Opt_lookupcache_positive,
208 Opt_lookupcache_none,
209
210 Opt_lookupcache_err
211};
212
213static match_table_t nfs_lookupcache_tokens = {
214 { Opt_lookupcache_all, "all" },
215 { Opt_lookupcache_positive, "pos" },
216 { Opt_lookupcache_positive, "positive" },
217 { Opt_lookupcache_none, "none" },
218
219 { Opt_lookupcache_err, NULL }
220};
221
203 222
204static void nfs_umount_begin(struct super_block *); 223static void nfs_umount_begin(struct super_block *);
205static int nfs_statfs(struct dentry *, struct kstatfs *); 224static int nfs_statfs(struct dentry *, struct kstatfs *);
@@ -209,7 +228,6 @@ static int nfs_get_sb(struct file_system_type *, int, const char *, void *, stru
209static int nfs_xdev_get_sb(struct file_system_type *fs_type, 228static int nfs_xdev_get_sb(struct file_system_type *fs_type,
210 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); 229 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
211static void nfs_kill_super(struct super_block *); 230static void nfs_kill_super(struct super_block *);
212static void nfs_put_super(struct super_block *);
213static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); 231static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
214 232
215static struct file_system_type nfs_fs_type = { 233static struct file_system_type nfs_fs_type = {
@@ -232,7 +250,6 @@ static const struct super_operations nfs_sops = {
232 .alloc_inode = nfs_alloc_inode, 250 .alloc_inode = nfs_alloc_inode,
233 .destroy_inode = nfs_destroy_inode, 251 .destroy_inode = nfs_destroy_inode,
234 .write_inode = nfs_write_inode, 252 .write_inode = nfs_write_inode,
235 .put_super = nfs_put_super,
236 .statfs = nfs_statfs, 253 .statfs = nfs_statfs,
237 .clear_inode = nfs_clear_inode, 254 .clear_inode = nfs_clear_inode,
238 .umount_begin = nfs_umount_begin, 255 .umount_begin = nfs_umount_begin,
@@ -337,26 +354,20 @@ void __exit unregister_nfs_fs(void)
337 unregister_filesystem(&nfs_fs_type); 354 unregister_filesystem(&nfs_fs_type);
338} 355}
339 356
340void nfs_sb_active(struct nfs_server *server) 357void nfs_sb_active(struct super_block *sb)
341{ 358{
342 atomic_inc(&server->active); 359 struct nfs_server *server = NFS_SB(sb);
343}
344 360
345void nfs_sb_deactive(struct nfs_server *server) 361 if (atomic_inc_return(&server->active) == 1)
346{ 362 atomic_inc(&sb->s_active);
347 if (atomic_dec_and_test(&server->active))
348 wake_up(&server->active_wq);
349} 363}
350 364
351static void nfs_put_super(struct super_block *sb) 365void nfs_sb_deactive(struct super_block *sb)
352{ 366{
353 struct nfs_server *server = NFS_SB(sb); 367 struct nfs_server *server = NFS_SB(sb);
354 /* 368
355 * Make sure there are no outstanding ops to this server. 369 if (atomic_dec_and_test(&server->active))
356 * If so, wait for them to finish before allowing the 370 deactivate_super(sb);
357 * unmount to continue.
358 */
359 wait_event(server->active_wq, atomic_read(&server->active) == 0);
360} 371}
361 372
362/* 373/*
@@ -664,25 +675,6 @@ static void nfs_umount_begin(struct super_block *sb)
664} 675}
665 676
666/* 677/*
667 * Set the port number in an address. Be agnostic about the address family.
668 */
669static void nfs_set_port(struct sockaddr *sap, unsigned short port)
670{
671 switch (sap->sa_family) {
672 case AF_INET: {
673 struct sockaddr_in *ap = (struct sockaddr_in *)sap;
674 ap->sin_port = htons(port);
675 break;
676 }
677 case AF_INET6: {
678 struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
679 ap->sin6_port = htons(port);
680 break;
681 }
682 }
683}
684
685/*
686 * Sanity-check a server address provided by the mount command. 678 * Sanity-check a server address provided by the mount command.
687 * 679 *
688 * Address family must be initialized, and address must not be 680 * Address family must be initialized, and address must not be
@@ -724,20 +716,22 @@ static void nfs_parse_ipv4_address(char *string, size_t str_len,
724 *addr_len = 0; 716 *addr_len = 0;
725} 717}
726 718
727#define IPV6_SCOPE_DELIMITER '%'
728
729#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 719#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
730static void nfs_parse_ipv6_scope_id(const char *string, const size_t str_len, 720static int nfs_parse_ipv6_scope_id(const char *string, const size_t str_len,
731 const char *delim, 721 const char *delim,
732 struct sockaddr_in6 *sin6) 722 struct sockaddr_in6 *sin6)
733{ 723{
734 char *p; 724 char *p;
735 size_t len; 725 size_t len;
736 726
737 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)) 727 if ((string + str_len) == delim)
738 return ; 728 return 1;
729
739 if (*delim != IPV6_SCOPE_DELIMITER) 730 if (*delim != IPV6_SCOPE_DELIMITER)
740 return; 731 return 0;
732
733 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL))
734 return 0;
741 735
742 len = (string + str_len) - delim - 1; 736 len = (string + str_len) - delim - 1;
743 p = kstrndup(delim + 1, len, GFP_KERNEL); 737 p = kstrndup(delim + 1, len, GFP_KERNEL);
@@ -750,14 +744,20 @@ static void nfs_parse_ipv6_scope_id(const char *string, const size_t str_len,
750 scope_id = dev->ifindex; 744 scope_id = dev->ifindex;
751 dev_put(dev); 745 dev_put(dev);
752 } else { 746 } else {
753 /* scope_id is set to zero on error */ 747 if (strict_strtoul(p, 10, &scope_id) == 0) {
754 strict_strtoul(p, 10, &scope_id); 748 kfree(p);
749 return 0;
750 }
755 } 751 }
756 752
757 kfree(p); 753 kfree(p);
754
758 sin6->sin6_scope_id = scope_id; 755 sin6->sin6_scope_id = scope_id;
759 dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id); 756 dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id);
757 return 1;
760 } 758 }
759
760 return 0;
761} 761}
762 762
763static void nfs_parse_ipv6_address(char *string, size_t str_len, 763static void nfs_parse_ipv6_address(char *string, size_t str_len,
@@ -773,9 +773,11 @@ static void nfs_parse_ipv6_address(char *string, size_t str_len,
773 773
774 sin6->sin6_family = AF_INET6; 774 sin6->sin6_family = AF_INET6;
775 *addr_len = sizeof(*sin6); 775 *addr_len = sizeof(*sin6);
776 if (in6_pton(string, str_len, addr, IPV6_SCOPE_DELIMITER, &delim)) { 776 if (in6_pton(string, str_len, addr,
777 nfs_parse_ipv6_scope_id(string, str_len, delim, sin6); 777 IPV6_SCOPE_DELIMITER, &delim) != 0) {
778 return; 778 if (nfs_parse_ipv6_scope_id(string, str_len,
779 delim, sin6) != 0)
780 return;
779 } 781 }
780 } 782 }
781 783
@@ -798,7 +800,7 @@ static void nfs_parse_ipv6_address(char *string, size_t str_len,
798 * If there is a problem constructing the new sockaddr, set the address 800 * If there is a problem constructing the new sockaddr, set the address
799 * family to AF_UNSPEC. 801 * family to AF_UNSPEC.
800 */ 802 */
801static void nfs_parse_ip_address(char *string, size_t str_len, 803void nfs_parse_ip_address(char *string, size_t str_len,
802 struct sockaddr *sap, size_t *addr_len) 804 struct sockaddr *sap, size_t *addr_len)
803{ 805{
804 unsigned int i, colons; 806 unsigned int i, colons;
@@ -1258,6 +1260,30 @@ static int nfs_parse_mount_options(char *raw,
1258 &mnt->mount_server.addrlen); 1260 &mnt->mount_server.addrlen);
1259 kfree(string); 1261 kfree(string);
1260 break; 1262 break;
1263 case Opt_lookupcache:
1264 string = match_strdup(args);
1265 if (string == NULL)
1266 goto out_nomem;
1267 token = match_token(string,
1268 nfs_lookupcache_tokens, args);
1269 kfree(string);
1270 switch (token) {
1271 case Opt_lookupcache_all:
1272 mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE);
1273 break;
1274 case Opt_lookupcache_positive:
1275 mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE;
1276 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG;
1277 break;
1278 case Opt_lookupcache_none:
1279 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE;
1280 break;
1281 default:
1282 errors++;
1283 dfprintk(MOUNT, "NFS: invalid "
1284 "lookupcache argument\n");
1285 };
1286 break;
1261 1287
1262 /* 1288 /*
1263 * Special options 1289 * Special options
@@ -1558,7 +1584,7 @@ static int nfs_validate_mount_data(void *options,
1558 * Translate to nfs_parsed_mount_data, which nfs_fill_super 1584 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1559 * can deal with. 1585 * can deal with.
1560 */ 1586 */
1561 args->flags = data->flags; 1587 args->flags = data->flags & NFS_MOUNT_FLAGMASK;
1562 args->rsize = data->rsize; 1588 args->rsize = data->rsize;
1563 args->wsize = data->wsize; 1589 args->wsize = data->wsize;
1564 args->timeo = data->timeo; 1590 args->timeo = data->timeo;
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index f089e5839d7d..ecc295347775 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -99,7 +99,7 @@ static void nfs_async_unlink_release(void *calldata)
99 99
100 nfs_dec_sillycount(data->dir); 100 nfs_dec_sillycount(data->dir);
101 nfs_free_unlinkdata(data); 101 nfs_free_unlinkdata(data);
102 nfs_sb_deactive(NFS_SB(sb)); 102 nfs_sb_deactive(sb);
103} 103}
104 104
105static const struct rpc_call_ops nfs_unlink_ops = { 105static const struct rpc_call_ops nfs_unlink_ops = {
@@ -118,6 +118,7 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n
118 .rpc_message = &msg, 118 .rpc_message = &msg,
119 .callback_ops = &nfs_unlink_ops, 119 .callback_ops = &nfs_unlink_ops,
120 .callback_data = data, 120 .callback_data = data,
121 .workqueue = nfsiod_workqueue,
121 .flags = RPC_TASK_ASYNC, 122 .flags = RPC_TASK_ASYNC,
122 }; 123 };
123 struct rpc_task *task; 124 struct rpc_task *task;
@@ -149,7 +150,7 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n
149 nfs_dec_sillycount(dir); 150 nfs_dec_sillycount(dir);
150 return 0; 151 return 0;
151 } 152 }
152 nfs_sb_active(NFS_SERVER(dir)); 153 nfs_sb_active(dir->i_sb);
153 data->args.fh = NFS_FH(dir); 154 data->args.fh = NFS_FH(dir);
154 nfs_fattr_init(&data->res.dir_attr); 155 nfs_fattr_init(&data->res.dir_attr);
155 156
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 3229e217c773..9f9845859fc1 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1427,8 +1427,9 @@ static int nfs_write_mapping(struct address_space *mapping, int how)
1427 .bdi = mapping->backing_dev_info, 1427 .bdi = mapping->backing_dev_info,
1428 .sync_mode = WB_SYNC_NONE, 1428 .sync_mode = WB_SYNC_NONE,
1429 .nr_to_write = LONG_MAX, 1429 .nr_to_write = LONG_MAX,
1430 .range_start = 0,
1431 .range_end = LLONG_MAX,
1430 .for_writepages = 1, 1432 .for_writepages = 1,
1431 .range_cyclic = 1,
1432 }; 1433 };
1433 int ret; 1434 int ret;
1434 1435
diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
index 64965e1c21c4..9b0efdad8910 100644
--- a/fs/nls/nls_base.c
+++ b/fs/nls/nls_base.c
@@ -13,9 +13,7 @@
13#include <linux/nls.h> 13#include <linux/nls.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#ifdef CONFIG_KMOD
17#include <linux/kmod.h> 16#include <linux/kmod.h>
18#endif
19#include <linux/spinlock.h> 17#include <linux/spinlock.h>
20 18
21static struct nls_table default_table; 19static struct nls_table default_table;
@@ -215,24 +213,7 @@ static struct nls_table *find_nls(char *charset)
215 213
216struct nls_table *load_nls(char *charset) 214struct nls_table *load_nls(char *charset)
217{ 215{
218 struct nls_table *nls; 216 return try_then_request_module(find_nls(charset), "nls_%s", charset);
219#ifdef CONFIG_KMOD
220 int ret;
221#endif
222
223 nls = find_nls(charset);
224 if (nls)
225 return nls;
226
227#ifdef CONFIG_KMOD
228 ret = request_module("nls_%s", charset);
229 if (ret != 0) {
230 printk("Unable to load NLS charset %s\n", charset);
231 return NULL;
232 }
233 nls = find_nls(charset);
234#endif
235 return nls;
236} 217}
237 218
238void unload_nls(struct nls_table *nls) 219void unload_nls(struct nls_table *nls)
diff --git a/fs/partitions/acorn.c b/fs/partitions/acorn.c
index 3d3e16631472..a97b477ac0fc 100644
--- a/fs/partitions/acorn.c
+++ b/fs/partitions/acorn.c
@@ -275,16 +275,6 @@ adfspart_check_ADFS(struct parsed_partitions *state, struct block_device *bdev)
275 id = data[0x1fc] & 15; 275 id = data[0x1fc] & 15;
276 put_dev_sector(sect); 276 put_dev_sector(sect);
277 277
278#ifdef CONFIG_BLK_DEV_MFM
279 if (MAJOR(bdev->bd_dev) == MFM_ACORN_MAJOR) {
280 extern void xd_set_geometry(struct block_device *,
281 unsigned char, unsigned char, unsigned int);
282 xd_set_geometry(bdev, dr->secspertrack, heads, 1);
283 invalidate_bh_lrus();
284 truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
285 }
286#endif
287
288 /* 278 /*
289 * Work out start of non-adfs partition. 279 * Work out start of non-adfs partition.
290 */ 280 */
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 7408227c49c9..fbeb2f372a93 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -538,10 +538,23 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
538 sector_t from = state->parts[p].from; 538 sector_t from = state->parts[p].from;
539 if (!size) 539 if (!size)
540 continue; 540 continue;
541 if (from >= get_capacity(disk)) {
542 printk(KERN_WARNING
543 "%s: p%d ignored, start %llu is behind the end of the disk\n",
544 disk->disk_name, p, (unsigned long long) from);
545 continue;
546 }
541 if (from + size > get_capacity(disk)) { 547 if (from + size > get_capacity(disk)) {
548 /*
549 * we can not ignore partitions of broken tables
550 * created by for example camera firmware, but we
551 * limit them to the end of the disk to avoid
552 * creating invalid block devices
553 */
542 printk(KERN_WARNING 554 printk(KERN_WARNING
543 "%s: p%d exceeds device capacity\n", 555 "%s: p%d size %llu limited to end of disk\n",
544 disk->disk_name, p); 556 disk->disk_name, p, (unsigned long long) size);
557 size = get_capacity(disk) - from;
545 } 558 }
546 res = add_partition(disk, p, from, size, state->parts[p].flags); 559 res = add_partition(disk, p, from, size, state->parts[p].flags);
547 if (res) { 560 if (res) {
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index b675a49c1823..59ea42e1ef03 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -45,7 +45,6 @@
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/hugetlb.h> 46#include <linux/hugetlb.h>
47#include <linux/jiffies.h> 47#include <linux/jiffies.h>
48#include <linux/sysrq.h>
49#include <linux/vmalloc.h> 48#include <linux/vmalloc.h>
50#include <linux/crash_dump.h> 49#include <linux/crash_dump.h>
51#include <linux/pid_namespace.h> 50#include <linux/pid_namespace.h>
@@ -704,28 +703,6 @@ static int execdomains_read_proc(char *page, char **start, off_t off,
704 return proc_calc_metrics(page, start, off, count, eof, len); 703 return proc_calc_metrics(page, start, off, count, eof, len);
705} 704}
706 705
707#ifdef CONFIG_MAGIC_SYSRQ
708/*
709 * writing 'C' to /proc/sysrq-trigger is like sysrq-C
710 */
711static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
712 size_t count, loff_t *ppos)
713{
714 if (count) {
715 char c;
716
717 if (get_user(c, buf))
718 return -EFAULT;
719 __handle_sysrq(c, NULL, 0);
720 }
721 return count;
722}
723
724static const struct file_operations proc_sysrq_trigger_operations = {
725 .write = write_sysrq_trigger,
726};
727#endif
728
729#ifdef CONFIG_PROC_PAGE_MONITOR 706#ifdef CONFIG_PROC_PAGE_MONITOR
730#define KPMSIZE sizeof(u64) 707#define KPMSIZE sizeof(u64)
731#define KPMMASK (KPMSIZE - 1) 708#define KPMMASK (KPMSIZE - 1)
@@ -934,7 +911,4 @@ void __init proc_misc_init(void)
934#ifdef CONFIG_PROC_VMCORE 911#ifdef CONFIG_PROC_VMCORE
935 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); 912 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations);
936#endif 913#endif
937#ifdef CONFIG_MAGIC_SYSRQ
938 proc_create("sysrq-trigger", S_IWUSR, NULL, &proc_sysrq_trigger_operations);
939#endif
940} 914}
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index b9dbeeca7049..37173fa07d15 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -8,8 +8,6 @@
8 8
9/* proc info support a la one created by Sizif@Botik.RU for PGC */ 9/* proc info support a la one created by Sizif@Botik.RU for PGC */
10 10
11/* $Id: procfs.c,v 1.1.8.2 2001/07/15 17:08:42 god Exp $ */
12
13#include <linux/module.h> 11#include <linux/module.h>
14#include <linux/time.h> 12#include <linux/time.h>
15#include <linux/seq_file.h> 13#include <linux/seq_file.h>
@@ -621,7 +619,6 @@ int reiserfs_global_version_in_proc(char *buffer, char **start,
621#endif 619#endif
622 620
623/* 621/*
624 * $Log: procfs.c,v $
625 * Revision 1.1.8.2 2001/07/15 17:08:42 god 622 * Revision 1.1.8.2 2001/07/15 17:08:42 god
626 * . use get_super() in procfs.c 623 * . use get_super() in procfs.c
627 * . remove remove_save_link() from reiserfs_do_truncate() 624 * . remove remove_save_link() from reiserfs_do_truncate()
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index bb3cb5b7cdb2..ad92461cbfc3 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -155,7 +155,7 @@ static struct dentry *get_xa_file_dentry(const struct inode *inode,
155 xadir = open_xa_dir(inode, flags); 155 xadir = open_xa_dir(inode, flags);
156 if (IS_ERR(xadir)) { 156 if (IS_ERR(xadir)) {
157 return ERR_CAST(xadir); 157 return ERR_CAST(xadir);
158 } else if (xadir && !xadir->d_inode) { 158 } else if (!xadir->d_inode) {
159 dput(xadir); 159 dput(xadir);
160 return ERR_PTR(-ENODATA); 160 return ERR_PTR(-ENODATA);
161 } 161 }
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 006fc64227dd..66f6e58a7e4b 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -61,6 +61,7 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off)
61 int size = dentry->d_inode->i_size; 61 int size = dentry->d_inode->i_size;
62 loff_t offs = *off; 62 loff_t offs = *off;
63 int count = min_t(size_t, bytes, PAGE_SIZE); 63 int count = min_t(size_t, bytes, PAGE_SIZE);
64 char *temp;
64 65
65 if (size) { 66 if (size) {
66 if (offs > size) 67 if (offs > size)
@@ -69,23 +70,33 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off)
69 count = size - offs; 70 count = size - offs;
70 } 71 }
71 72
73 temp = kmalloc(count, GFP_KERNEL);
74 if (!temp)
75 return -ENOMEM;
76
72 mutex_lock(&bb->mutex); 77 mutex_lock(&bb->mutex);
73 78
74 count = fill_read(dentry, bb->buffer, offs, count); 79 count = fill_read(dentry, bb->buffer, offs, count);
75 if (count < 0) 80 if (count < 0) {
76 goto out_unlock; 81 mutex_unlock(&bb->mutex);
82 goto out_free;
83 }
77 84
78 if (copy_to_user(userbuf, bb->buffer, count)) { 85 memcpy(temp, bb->buffer, count);
86
87 mutex_unlock(&bb->mutex);
88
89 if (copy_to_user(userbuf, temp, count)) {
79 count = -EFAULT; 90 count = -EFAULT;
80 goto out_unlock; 91 goto out_free;
81 } 92 }
82 93
83 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count); 94 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count);
84 95
85 *off = offs + count; 96 *off = offs + count;
86 97
87 out_unlock: 98 out_free:
88 mutex_unlock(&bb->mutex); 99 kfree(temp);
89 return count; 100 return count;
90} 101}
91 102
@@ -118,6 +129,7 @@ static ssize_t write(struct file *file, const char __user *userbuf,
118 int size = dentry->d_inode->i_size; 129 int size = dentry->d_inode->i_size;
119 loff_t offs = *off; 130 loff_t offs = *off;
120 int count = min_t(size_t, bytes, PAGE_SIZE); 131 int count = min_t(size_t, bytes, PAGE_SIZE);
132 char *temp;
121 133
122 if (size) { 134 if (size) {
123 if (offs > size) 135 if (offs > size)
@@ -126,19 +138,27 @@ static ssize_t write(struct file *file, const char __user *userbuf,
126 count = size - offs; 138 count = size - offs;
127 } 139 }
128 140
129 mutex_lock(&bb->mutex); 141 temp = kmalloc(count, GFP_KERNEL);
142 if (!temp)
143 return -ENOMEM;
130 144
131 if (copy_from_user(bb->buffer, userbuf, count)) { 145 if (copy_from_user(temp, userbuf, count)) {
132 count = -EFAULT; 146 count = -EFAULT;
133 goto out_unlock; 147 goto out_free;
134 } 148 }
135 149
150 mutex_lock(&bb->mutex);
151
152 memcpy(bb->buffer, temp, count);
153
136 count = flush_write(dentry, bb->buffer, offs, count); 154 count = flush_write(dentry, bb->buffer, offs, count);
155 mutex_unlock(&bb->mutex);
156
137 if (count > 0) 157 if (count > 0)
138 *off = offs + count; 158 *off = offs + count;
139 159
140 out_unlock: 160out_free:
141 mutex_unlock(&bb->mutex); 161 kfree(temp);
142 return count; 162 return count;
143} 163}
144 164
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index aedaeba82ae5..3a05a596e3b4 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
370 memset(acxt, 0, sizeof(*acxt)); 370 memset(acxt, 0, sizeof(*acxt));
371 acxt->parent_sd = parent_sd; 371 acxt->parent_sd = parent_sd;
372 372
373 /* Lookup parent inode. inode initialization and I_NEW 373 /* Lookup parent inode. inode initialization is protected by
374 * clearing are protected by sysfs_mutex. By grabbing it and 374 * sysfs_mutex, so inode existence can be determined by
375 * looking up with _nowait variant, inode state can be 375 * looking up inode while holding sysfs_mutex.
376 * determined reliably.
377 */ 376 */
378 mutex_lock(&sysfs_mutex); 377 mutex_lock(&sysfs_mutex);
379 378
380 inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, 379 inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
381 parent_sd); 380 parent_sd);
381 if (inode) {
382 WARN_ON(inode->i_state & I_NEW);
382 383
383 if (inode && !(inode->i_state & I_NEW)) {
384 /* parent inode available */ 384 /* parent inode available */
385 acxt->parent_inode = inode; 385 acxt->parent_inode = inode;
386 386
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
393 mutex_lock(&inode->i_mutex); 393 mutex_lock(&inode->i_mutex);
394 mutex_lock(&sysfs_mutex); 394 mutex_lock(&sysfs_mutex);
395 } 395 }
396 } else 396 }
397 iput(inode);
398} 397}
399 398
400/** 399/**
@@ -636,6 +635,7 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
636 635
637 return sd; 636 return sd;
638} 637}
638EXPORT_SYMBOL_GPL(sysfs_get_dirent);
639 639
640static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, 640static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
641 const char *name, struct sysfs_dirent **p_sd) 641 const char *name, struct sysfs_dirent **p_sd)
@@ -829,16 +829,12 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
829 if (!new_dentry) 829 if (!new_dentry)
830 goto out_unlock; 830 goto out_unlock;
831 831
832 /* rename kobject and sysfs_dirent */ 832 /* rename sysfs_dirent */
833 error = -ENOMEM; 833 error = -ENOMEM;
834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL); 834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
835 if (!new_name) 835 if (!new_name)
836 goto out_unlock; 836 goto out_unlock;
837 837
838 error = kobject_set_name(kobj, "%s", new_name);
839 if (error)
840 goto out_unlock;
841
842 dup_name = sd->s_name; 838 dup_name = sd->s_name;
843 sd->s_name = new_name; 839 sd->s_name = new_name;
844 840
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index c9e4e5091da1..1f4a3f877262 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -19,10 +19,18 @@
19#include <linux/poll.h> 19#include <linux/poll.h>
20#include <linux/list.h> 20#include <linux/list.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/limits.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23 24
24#include "sysfs.h" 25#include "sysfs.h"
25 26
27/* used in crash dumps to help with debugging */
28static char last_sysfs_file[PATH_MAX];
29void sysfs_printk_last_file(void)
30{
31 printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
32}
33
26/* 34/*
27 * There's one sysfs_buffer for each open file and one 35 * There's one sysfs_buffer for each open file and one
28 * sysfs_open_dirent for each sysfs_dirent with one or more open 36 * sysfs_open_dirent for each sysfs_dirent with one or more open
@@ -328,6 +336,11 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
328 struct sysfs_buffer *buffer; 336 struct sysfs_buffer *buffer;
329 struct sysfs_ops *ops; 337 struct sysfs_ops *ops;
330 int error = -EACCES; 338 int error = -EACCES;
339 char *p;
340
341 p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
342 if (p)
343 memmove(last_sysfs_file, p, strlen(p) + 1);
331 344
332 /* need attr_sd for attr and ops, its parent for kobj */ 345 /* need attr_sd for attr and ops, its parent for kobj */
333 if (!sysfs_get_active_two(attr_sd)) 346 if (!sysfs_get_active_two(attr_sd))
@@ -440,7 +453,23 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
440 return POLLERR|POLLPRI; 453 return POLLERR|POLLPRI;
441} 454}
442 455
443void sysfs_notify(struct kobject *k, char *dir, char *attr) 456void sysfs_notify_dirent(struct sysfs_dirent *sd)
457{
458 struct sysfs_open_dirent *od;
459
460 spin_lock(&sysfs_open_dirent_lock);
461
462 od = sd->s_attr.open;
463 if (od) {
464 atomic_inc(&od->event);
465 wake_up_interruptible(&od->poll);
466 }
467
468 spin_unlock(&sysfs_open_dirent_lock);
469}
470EXPORT_SYMBOL_GPL(sysfs_notify_dirent);
471
472void sysfs_notify(struct kobject *k, const char *dir, const char *attr)
444{ 473{
445 struct sysfs_dirent *sd = k->sd; 474 struct sysfs_dirent *sd = k->sd;
446 475
@@ -450,19 +479,8 @@ void sysfs_notify(struct kobject *k, char *dir, char *attr)
450 sd = sysfs_find_dirent(sd, dir); 479 sd = sysfs_find_dirent(sd, dir);
451 if (sd && attr) 480 if (sd && attr)
452 sd = sysfs_find_dirent(sd, attr); 481 sd = sysfs_find_dirent(sd, attr);
453 if (sd) { 482 if (sd)
454 struct sysfs_open_dirent *od; 483 sysfs_notify_dirent(sd);
455
456 spin_lock(&sysfs_open_dirent_lock);
457
458 od = sd->s_attr.open;
459 if (od) {
460 atomic_inc(&od->event);
461 wake_up_interruptible(&od->poll);
462 }
463
464 spin_unlock(&sysfs_open_dirent_lock);
465 }
466 484
467 mutex_unlock(&sysfs_mutex); 485 mutex_unlock(&sysfs_mutex);
468} 486}
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 14f0023984d7..ab343e371d64 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -16,6 +16,7 @@
16#include <linux/mount.h> 16#include <linux/mount.h>
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h>
19 20
20#include "sysfs.h" 21#include "sysfs.h"
21 22
@@ -115,3 +116,17 @@ out_err:
115 sysfs_dir_cachep = NULL; 116 sysfs_dir_cachep = NULL;
116 goto out; 117 goto out;
117} 118}
119
120#undef sysfs_get
121struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
122{
123 return __sysfs_get(sd);
124}
125EXPORT_SYMBOL_GPL(sysfs_get);
126
127#undef sysfs_put
128void sysfs_put(struct sysfs_dirent *sd)
129{
130 __sysfs_put(sd);
131}
132EXPORT_SYMBOL_GPL(sysfs_put);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index a5db496f71c7..93c6d6b27c4d 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -124,7 +124,7 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name,
124 struct sysfs_dirent **p_sd); 124 struct sysfs_dirent **p_sd);
125void sysfs_remove_subdir(struct sysfs_dirent *sd); 125void sysfs_remove_subdir(struct sysfs_dirent *sd);
126 126
127static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) 127static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd)
128{ 128{
129 if (sd) { 129 if (sd) {
130 WARN_ON(!atomic_read(&sd->s_count)); 130 WARN_ON(!atomic_read(&sd->s_count));
@@ -132,12 +132,14 @@ static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
132 } 132 }
133 return sd; 133 return sd;
134} 134}
135#define sysfs_get(sd) __sysfs_get(sd)
135 136
136static inline void sysfs_put(struct sysfs_dirent *sd) 137static inline void __sysfs_put(struct sysfs_dirent *sd)
137{ 138{
138 if (sd && atomic_dec_and_test(&sd->s_count)) 139 if (sd && atomic_dec_and_test(&sd->s_count))
139 release_sysfs_dirent(sd); 140 release_sysfs_dirent(sd);
140} 141}
142#define sysfs_put(sd) __sysfs_put(sd)
141 143
142/* 144/*
143 * inode.c 145 * inode.c
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 57ab9e9d7593..74a9617776a8 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -467,7 +467,7 @@ struct acpi_integer_overlay {
467/* 467/*
468 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, 468 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
469 * define it now. This is the case where there the compiler does not support 469 * define it now. This is the case where there the compiler does not support
470 * a __FUNCTION__ macro or equivalent. 470 * a __func__ macro or equivalent.
471 */ 471 */
472#ifndef ACPI_GET_FUNCTION_NAME 472#ifndef ACPI_GET_FUNCTION_NAME
473#define ACPI_GET_FUNCTION_NAME _acpi_function_name 473#define ACPI_GET_FUNCTION_NAME _acpi_function_name
@@ -475,12 +475,12 @@ struct acpi_integer_overlay {
475 * The Name parameter should be the procedure name as a quoted string. 475 * The Name parameter should be the procedure name as a quoted string.
476 * The function name is also used by the function exit macros below. 476 * The function name is also used by the function exit macros below.
477 * Note: (const char) is used to be compatible with the debug interfaces 477 * Note: (const char) is used to be compatible with the debug interfaces
478 * and macros such as __FUNCTION__. 478 * and macros such as __func__.
479 */ 479 */
480#define ACPI_FUNCTION_NAME(name) static const char _acpi_function_name[] = #name; 480#define ACPI_FUNCTION_NAME(name) static const char _acpi_function_name[] = #name;
481 481
482#else 482#else
483/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ 483/* Compiler supports __func__ (or equivalent) -- Ignore this macro */
484 484
485#define ACPI_FUNCTION_NAME(name) 485#define ACPI_FUNCTION_NAME(name)
486#endif 486#endif
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 8996dba90cd9..8e2cdc57b197 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -46,7 +46,7 @@
46 46
47/* Function name is used for debug output. Non-ANSI, compiler-dependent */ 47/* Function name is used for debug output. Non-ANSI, compiler-dependent */
48 48
49#define ACPI_GET_FUNCTION_NAME __FUNCTION__ 49#define ACPI_GET_FUNCTION_NAME __func__
50 50
51/* 51/*
52 * This macro is used to tag functions as "printf-like" because 52 * This macro is used to tag functions as "printf-like" because
diff --git a/include/asm-cris/elf.h b/include/asm-cris/elf.h
index 001f64ad11e8..f0d17fbc81ba 100644
--- a/include/asm-cris/elf.h
+++ b/include/asm-cris/elf.h
@@ -88,6 +88,6 @@ typedef unsigned long elf_fpregset_t;
88 88
89#define ELF_PLATFORM (NULL) 89#define ELF_PLATFORM (NULL)
90 90
91#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 91#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
92 92
93#endif 93#endif
diff --git a/include/asm-frv/elf.h b/include/asm-frv/elf.h
index 9fb946bb7dc9..7279ec07d62e 100644
--- a/include/asm-frv/elf.h
+++ b/include/asm-frv/elf.h
@@ -137,6 +137,6 @@ do { \
137 137
138#define ELF_PLATFORM (NULL) 138#define ELF_PLATFORM (NULL)
139 139
140#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 140#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
141 141
142#endif 142#endif
diff --git a/include/asm-frv/unaligned.h b/include/asm-frv/unaligned.h
index 839a2fbffa0f..6c61c05b2e0c 100644
--- a/include/asm-frv/unaligned.h
+++ b/include/asm-frv/unaligned.h
@@ -13,7 +13,7 @@
13#define _ASM_UNALIGNED_H 13#define _ASM_UNALIGNED_H
14 14
15#include <linux/unaligned/le_byteshift.h> 15#include <linux/unaligned/le_byteshift.h>
16#include <linux/unaligned/be_byteshift.h> 16#include <linux/unaligned/be_struct.h>
17#include <linux/unaligned/generic.h> 17#include <linux/unaligned/generic.h>
18 18
19#define get_unaligned __get_unaligned_be 19#define get_unaligned __get_unaligned_be
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index edc6ba82e090..0f6dabd4b517 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -22,7 +22,7 @@ struct bug_entry {
22 22
23#ifndef HAVE_ARCH_BUG 23#ifndef HAVE_ARCH_BUG
24#define BUG() do { \ 24#define BUG() do { \
25 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ 25 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
26 panic("BUG!"); \ 26 panic("BUG!"); \
27} while (0) 27} while (0)
28#endif 28#endif
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 0f99ad38b012..81797ec9ab29 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -35,11 +35,17 @@ struct module;
35 * @label: for diagnostics 35 * @label: for diagnostics
36 * @dev: optional device providing the GPIOs 36 * @dev: optional device providing the GPIOs
37 * @owner: helps prevent removal of modules exporting active GPIOs 37 * @owner: helps prevent removal of modules exporting active GPIOs
38 * @request: optional hook for chip-specific activation, such as
39 * enabling module power and clock; may sleep
40 * @free: optional hook for chip-specific deactivation, such as
41 * disabling module power and clock; may sleep
38 * @direction_input: configures signal "offset" as input, or returns error 42 * @direction_input: configures signal "offset" as input, or returns error
39 * @get: returns value for signal "offset"; for output signals this 43 * @get: returns value for signal "offset"; for output signals this
40 * returns either the value actually sensed, or zero 44 * returns either the value actually sensed, or zero
41 * @direction_output: configures signal "offset" as output, or returns error 45 * @direction_output: configures signal "offset" as output, or returns error
42 * @set: assigns output value for signal "offset" 46 * @set: assigns output value for signal "offset"
47 * @to_irq: optional hook supporting non-static gpio_to_irq() mappings;
48 * implementation may not sleep
43 * @dbg_show: optional routine to show contents in debugfs; default code 49 * @dbg_show: optional routine to show contents in debugfs; default code
44 * will be used when this is omitted, but custom code can show extra 50 * will be used when this is omitted, but custom code can show extra
45 * state (such as pullup/pulldown configuration). 51 * state (such as pullup/pulldown configuration).
@@ -61,10 +67,15 @@ struct module;
61 * is calculated by subtracting @base from the gpio number. 67 * is calculated by subtracting @base from the gpio number.
62 */ 68 */
63struct gpio_chip { 69struct gpio_chip {
64 char *label; 70 const char *label;
65 struct device *dev; 71 struct device *dev;
66 struct module *owner; 72 struct module *owner;
67 73
74 int (*request)(struct gpio_chip *chip,
75 unsigned offset);
76 void (*free)(struct gpio_chip *chip,
77 unsigned offset);
78
68 int (*direction_input)(struct gpio_chip *chip, 79 int (*direction_input)(struct gpio_chip *chip,
69 unsigned offset); 80 unsigned offset);
70 int (*get)(struct gpio_chip *chip, 81 int (*get)(struct gpio_chip *chip,
@@ -73,6 +84,10 @@ struct gpio_chip {
73 unsigned offset, int value); 84 unsigned offset, int value);
74 void (*set)(struct gpio_chip *chip, 85 void (*set)(struct gpio_chip *chip,
75 unsigned offset, int value); 86 unsigned offset, int value);
87
88 int (*to_irq)(struct gpio_chip *chip,
89 unsigned offset);
90
76 void (*dbg_show)(struct seq_file *s, 91 void (*dbg_show)(struct seq_file *s,
77 struct gpio_chip *chip); 92 struct gpio_chip *chip);
78 int base; 93 int base;
@@ -112,6 +127,7 @@ extern void __gpio_set_value(unsigned gpio, int value);
112 127
113extern int __gpio_cansleep(unsigned gpio); 128extern int __gpio_cansleep(unsigned gpio);
114 129
130extern int __gpio_to_irq(unsigned gpio);
115 131
116#ifdef CONFIG_GPIO_SYSFS 132#ifdef CONFIG_GPIO_SYSFS
117 133
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 7440a0dceddb..74c5faf26c05 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -268,7 +268,15 @@
268 CPU_DISCARD(init.data) \ 268 CPU_DISCARD(init.data) \
269 CPU_DISCARD(init.rodata) \ 269 CPU_DISCARD(init.rodata) \
270 MEM_DISCARD(init.data) \ 270 MEM_DISCARD(init.data) \
271 MEM_DISCARD(init.rodata) 271 MEM_DISCARD(init.rodata) \
272 /* implement dynamic printk debug */ \
273 VMLINUX_SYMBOL(__start___verbose_strings) = .; \
274 *(__verbose_strings) \
275 VMLINUX_SYMBOL(__stop___verbose_strings) = .; \
276 . = ALIGN(8); \
277 VMLINUX_SYMBOL(__start___verbose) = .; \
278 *(__verbose) \
279 VMLINUX_SYMBOL(__stop___verbose) = .;
272 280
273#define INIT_TEXT \ 281#define INIT_TEXT \
274 *(.init.text) \ 282 *(.init.text) \
diff --git a/include/asm-h8300/timer.h b/include/asm-h8300/timer.h
new file mode 100644
index 000000000000..def80464d38f
--- /dev/null
+++ b/include/asm-h8300/timer.h
@@ -0,0 +1,25 @@
1#ifndef __H8300_TIMER_H
2#define __H8300_TIMER_H
3
4void h8300_timer_tick(void);
5void h8300_timer_setup(void);
6void h8300_gettod(unsigned int *year, unsigned int *mon, unsigned int *day,
7 unsigned int *hour, unsigned int *min, unsigned int *sec);
8
9#define TIMER_FREQ (CONFIG_CPU_CLOCK*10000) /* Timer input freq. */
10
11#define calc_param(cnt, div, rate, limit) \
12do { \
13 cnt = TIMER_FREQ / HZ; \
14 for (div = 0; div < ARRAY_SIZE(divide_rate); div++) { \
15 if (rate[div] == 0) \
16 continue; \
17 if ((cnt / rate[div]) > limit) \
18 break; \
19 } \
20 if (div == ARRAY_SIZE(divide_rate)) \
21 panic("Timer counter overflow"); \
22 cnt /= divide_rate[div]; \
23} while(0)
24
25#endif
diff --git a/include/asm-m32r/elf.h b/include/asm-m32r/elf.h
index 67bcd77494a5..0cc34c94bf2b 100644
--- a/include/asm-m32r/elf.h
+++ b/include/asm-m32r/elf.h
@@ -129,6 +129,6 @@ typedef elf_fpreg_t elf_fpregset_t;
129 intent than poking at uname or /proc/cpuinfo. */ 129 intent than poking at uname or /proc/cpuinfo. */
130#define ELF_PLATFORM (NULL) 130#define ELF_PLATFORM (NULL)
131 131
132#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) 132#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
133 133
134#endif /* _ASM_M32R__ELF_H */ 134#endif /* _ASM_M32R__ELF_H */
diff --git a/include/asm-m68k/elf.h b/include/asm-m68k/elf.h
index 14ea42152b97..0b0f49eb876b 100644
--- a/include/asm-m68k/elf.h
+++ b/include/asm-m68k/elf.h
@@ -114,6 +114,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t;
114 114
115#define ELF_PLATFORM (NULL) 115#define ELF_PLATFORM (NULL)
116 116
117#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 117#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
118 118
119#endif 119#endif
diff --git a/include/asm-mn10300/elf.h b/include/asm-mn10300/elf.h
index 256a70466ca4..bf09f8bb392e 100644
--- a/include/asm-mn10300/elf.h
+++ b/include/asm-mn10300/elf.h
@@ -141,7 +141,7 @@ do { \
141#define ELF_PLATFORM (NULL) 141#define ELF_PLATFORM (NULL)
142 142
143#ifdef __KERNEL__ 143#ifdef __KERNEL__
144#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) 144#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
145#endif 145#endif
146 146
147#endif /* _ASM_ELF_H */ 147#endif /* _ASM_ELF_H */
diff --git a/include/asm-parisc/elf.h b/include/asm-parisc/elf.h
index d0a4a8262818..7fa675799e6d 100644
--- a/include/asm-parisc/elf.h
+++ b/include/asm-parisc/elf.h
@@ -236,7 +236,7 @@ typedef unsigned long elf_greg_t;
236 236
237#define ELF_PLATFORM ("PARISC\0") 237#define ELF_PLATFORM ("PARISC\0")
238 238
239#define SET_PERSONALITY(ex, ibcs2) \ 239#define SET_PERSONALITY(ex) \
240 current->personality = PER_LINUX; \ 240 current->personality = PER_LINUX; \
241 current->thread.map_base = DEFAULT_MAP_BASE; \ 241 current->thread.map_base = DEFAULT_MAP_BASE; \
242 current->thread.task_size = DEFAULT_TASK_SIZE \ 242 current->thread.task_size = DEFAULT_TASK_SIZE \
diff --git a/include/asm-um/elf-i386.h b/include/asm-um/elf-i386.h
index 23d6893e8617..d0da9d7c5371 100644
--- a/include/asm-um/elf-i386.h
+++ b/include/asm-um/elf-i386.h
@@ -86,7 +86,7 @@ extern long elf_aux_hwcap;
86extern char * elf_aux_platform; 86extern char * elf_aux_platform;
87#define ELF_PLATFORM (elf_aux_platform) 87#define ELF_PLATFORM (elf_aux_platform)
88 88
89#define SET_PERSONALITY(ex, ibcs2) do { } while (0) 89#define SET_PERSONALITY(ex) do { } while (0)
90 90
91extern unsigned long vsyscall_ehdr; 91extern unsigned long vsyscall_ehdr;
92extern unsigned long vsyscall_end; 92extern unsigned long vsyscall_end;
diff --git a/include/asm-um/elf-ppc.h b/include/asm-um/elf-ppc.h
index d3b90b7ac3e9..af9463cd8ce5 100644
--- a/include/asm-um/elf-ppc.h
+++ b/include/asm-um/elf-ppc.h
@@ -5,7 +5,7 @@
5extern long elf_aux_hwcap; 5extern long elf_aux_hwcap;
6#define ELF_HWCAP (elf_aux_hwcap) 6#define ELF_HWCAP (elf_aux_hwcap)
7 7
8#define SET_PERSONALITY(ex, ibcs2) do ; while(0) 8#define SET_PERSONALITY(ex) do ; while(0)
9 9
10#define ELF_EXEC_PAGESIZE 4096 10#define ELF_EXEC_PAGESIZE 4096
11 11
diff --git a/include/asm-um/elf-x86_64.h b/include/asm-um/elf-x86_64.h
index 3b2d5224a7e1..6e8a9195e952 100644
--- a/include/asm-um/elf-x86_64.h
+++ b/include/asm-um/elf-x86_64.h
@@ -114,6 +114,6 @@ extern long elf_aux_hwcap;
114 114
115#define ELF_PLATFORM "x86_64" 115#define ELF_PLATFORM "x86_64"
116 116
117#define SET_PERSONALITY(ex, ibcs2) do ; while(0) 117#define SET_PERSONALITY(ex) do ; while(0)
118 118
119#endif 119#endif
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index 5c4745bec906..26bc15f01e78 100644
--- a/include/asm-x86/elf.h
+++ b/include/asm-x86/elf.h
@@ -186,7 +186,7 @@ do { \
186 set_fs(USER_DS); \ 186 set_fs(USER_DS); \
187} while (0) 187} while (0)
188 188
189#define COMPAT_SET_PERSONALITY(ex, ibcs2) \ 189#define COMPAT_SET_PERSONALITY(ex) \
190do { \ 190do { \
191 if (test_thread_flag(TIF_IA32)) \ 191 if (test_thread_flag(TIF_IA32)) \
192 clear_thread_flag(TIF_ABI_PENDING); \ 192 clear_thread_flag(TIF_ABI_PENDING); \
@@ -267,7 +267,7 @@ extern int force_personality32;
267 For the moment, we have only optimizations for the Intel generations, 267 For the moment, we have only optimizations for the Intel generations,
268 but that could change... */ 268 but that could change... */
269 269
270#define SET_PERSONALITY(ex, ibcs2) set_personality_64bit() 270#define SET_PERSONALITY(ex) set_personality_64bit()
271 271
272/* 272/*
273 * An executable for which elf_read_implies_exec() returns TRUE will 273 * An executable for which elf_read_implies_exec() returns TRUE will
diff --git a/include/asm-x86/es7000/apic.h b/include/asm-x86/es7000/apic.h
index bd2c44d1f7ac..aae50c2fb303 100644
--- a/include/asm-x86/es7000/apic.h
+++ b/include/asm-x86/es7000/apic.h
@@ -171,7 +171,7 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
171 int new_apicid = cpu_to_logical_apicid(cpu); 171 int new_apicid = cpu_to_logical_apicid(cpu);
172 if (apicid_cluster(apicid) != 172 if (apicid_cluster(apicid) !=
173 apicid_cluster(new_apicid)){ 173 apicid_cluster(new_apicid)){
174 printk ("%s: Not a valid mask!\n",__FUNCTION__); 174 printk ("%s: Not a valid mask!\n", __func__);
175#if defined CONFIG_ES7000_CLUSTERED_APIC 175#if defined CONFIG_ES7000_CLUSTERED_APIC
176 return 0xFF; 176 return 0xFF;
177#else 177#else
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h
index 546ad3110fea..961e746da977 100644
--- a/include/asm-x86/iommu.h
+++ b/include/asm-x86/iommu.h
@@ -8,7 +8,7 @@ extern int force_iommu, no_iommu;
8extern int iommu_detected; 8extern int iommu_detected;
9extern int dmar_disabled; 9extern int dmar_disabled;
10 10
11extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len); 11extern unsigned long iommu_nr_pages(unsigned long addr, unsigned long len);
12 12
13#ifdef CONFIG_GART_IOMMU 13#ifdef CONFIG_GART_IOMMU
14extern int gart_iommu_aperture; 14extern int gart_iommu_aperture;
diff --git a/include/asm-x86/kvm.h b/include/asm-x86/kvm.h
index 78e954db1e7f..ba0dd791fadf 100644
--- a/include/asm-x86/kvm.h
+++ b/include/asm-x86/kvm.h
@@ -208,26 +208,4 @@ struct kvm_pit_channel_state {
208struct kvm_pit_state { 208struct kvm_pit_state {
209 struct kvm_pit_channel_state channels[3]; 209 struct kvm_pit_channel_state channels[3];
210}; 210};
211
212#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
213#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
214#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
215#define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
216#define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
217#define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
218#define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
219#define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
220#define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
221#define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
222#define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
223#define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
224#define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
225#define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
226#define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
227#define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
228#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
229#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
230#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
231#define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
232
233#endif /* ASM_X86__KVM_H */ 211#endif /* ASM_X86__KVM_H */
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 69794547f514..411fb8cfb24e 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -57,6 +57,10 @@
57#define KVM_PAGES_PER_HPAGE (KVM_HPAGE_SIZE / PAGE_SIZE) 57#define KVM_PAGES_PER_HPAGE (KVM_HPAGE_SIZE / PAGE_SIZE)
58 58
59#define DE_VECTOR 0 59#define DE_VECTOR 0
60#define DB_VECTOR 1
61#define BP_VECTOR 3
62#define OF_VECTOR 4
63#define BR_VECTOR 5
60#define UD_VECTOR 6 64#define UD_VECTOR 6
61#define NM_VECTOR 7 65#define NM_VECTOR 7
62#define DF_VECTOR 8 66#define DF_VECTOR 8
@@ -65,6 +69,7 @@
65#define SS_VECTOR 12 69#define SS_VECTOR 12
66#define GP_VECTOR 13 70#define GP_VECTOR 13
67#define PF_VECTOR 14 71#define PF_VECTOR 14
72#define MF_VECTOR 16
68#define MC_VECTOR 18 73#define MC_VECTOR 18
69 74
70#define SELECTOR_TI_MASK (1 << 2) 75#define SELECTOR_TI_MASK (1 << 2)
@@ -89,7 +94,7 @@ extern struct list_head vm_list;
89struct kvm_vcpu; 94struct kvm_vcpu;
90struct kvm; 95struct kvm;
91 96
92enum { 97enum kvm_reg {
93 VCPU_REGS_RAX = 0, 98 VCPU_REGS_RAX = 0,
94 VCPU_REGS_RCX = 1, 99 VCPU_REGS_RCX = 1,
95 VCPU_REGS_RDX = 2, 100 VCPU_REGS_RDX = 2,
@@ -108,6 +113,7 @@ enum {
108 VCPU_REGS_R14 = 14, 113 VCPU_REGS_R14 = 14,
109 VCPU_REGS_R15 = 15, 114 VCPU_REGS_R15 = 15,
110#endif 115#endif
116 VCPU_REGS_RIP,
111 NR_VCPU_REGS 117 NR_VCPU_REGS
112}; 118};
113 119
@@ -189,10 +195,20 @@ struct kvm_mmu_page {
189 */ 195 */
190 int multimapped; /* More than one parent_pte? */ 196 int multimapped; /* More than one parent_pte? */
191 int root_count; /* Currently serving as active root */ 197 int root_count; /* Currently serving as active root */
198 bool unsync;
199 bool unsync_children;
192 union { 200 union {
193 u64 *parent_pte; /* !multimapped */ 201 u64 *parent_pte; /* !multimapped */
194 struct hlist_head parent_ptes; /* multimapped, kvm_pte_chain */ 202 struct hlist_head parent_ptes; /* multimapped, kvm_pte_chain */
195 }; 203 };
204 DECLARE_BITMAP(unsync_child_bitmap, 512);
205};
206
207struct kvm_pv_mmu_op_buffer {
208 void *ptr;
209 unsigned len;
210 unsigned processed;
211 char buf[512] __aligned(sizeof(long));
196}; 212};
197 213
198/* 214/*
@@ -207,6 +223,9 @@ struct kvm_mmu {
207 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva); 223 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva);
208 void (*prefetch_page)(struct kvm_vcpu *vcpu, 224 void (*prefetch_page)(struct kvm_vcpu *vcpu,
209 struct kvm_mmu_page *page); 225 struct kvm_mmu_page *page);
226 int (*sync_page)(struct kvm_vcpu *vcpu,
227 struct kvm_mmu_page *sp);
228 void (*invlpg)(struct kvm_vcpu *vcpu, gva_t gva);
210 hpa_t root_hpa; 229 hpa_t root_hpa;
211 int root_level; 230 int root_level;
212 int shadow_root_level; 231 int shadow_root_level;
@@ -219,8 +238,13 @@ struct kvm_vcpu_arch {
219 int interrupt_window_open; 238 int interrupt_window_open;
220 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */ 239 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
221 DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS); 240 DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
222 unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */ 241 /*
223 unsigned long rip; /* needs vcpu_load_rsp_rip() */ 242 * rip and regs accesses must go through
243 * kvm_{register,rip}_{read,write} functions.
244 */
245 unsigned long regs[NR_VCPU_REGS];
246 u32 regs_avail;
247 u32 regs_dirty;
224 248
225 unsigned long cr0; 249 unsigned long cr0;
226 unsigned long cr2; 250 unsigned long cr2;
@@ -237,6 +261,9 @@ struct kvm_vcpu_arch {
237 bool tpr_access_reporting; 261 bool tpr_access_reporting;
238 262
239 struct kvm_mmu mmu; 263 struct kvm_mmu mmu;
264 /* only needed in kvm_pv_mmu_op() path, but it's hot so
265 * put it here to avoid allocation */
266 struct kvm_pv_mmu_op_buffer mmu_op_buffer;
240 267
241 struct kvm_mmu_memory_cache mmu_pte_chain_cache; 268 struct kvm_mmu_memory_cache mmu_pte_chain_cache;
242 struct kvm_mmu_memory_cache mmu_rmap_desc_cache; 269 struct kvm_mmu_memory_cache mmu_rmap_desc_cache;
@@ -269,6 +296,11 @@ struct kvm_vcpu_arch {
269 u32 error_code; 296 u32 error_code;
270 } exception; 297 } exception;
271 298
299 struct kvm_queued_interrupt {
300 bool pending;
301 u8 nr;
302 } interrupt;
303
272 struct { 304 struct {
273 int active; 305 int active;
274 u8 save_iopl; 306 u8 save_iopl;
@@ -294,6 +326,7 @@ struct kvm_vcpu_arch {
294 struct page *time_page; 326 struct page *time_page;
295 327
296 bool nmi_pending; 328 bool nmi_pending;
329 bool nmi_injected;
297 330
298 u64 mtrr[0x100]; 331 u64 mtrr[0x100];
299}; 332};
@@ -316,9 +349,12 @@ struct kvm_arch{
316 * Hash table of struct kvm_mmu_page. 349 * Hash table of struct kvm_mmu_page.
317 */ 350 */
318 struct list_head active_mmu_pages; 351 struct list_head active_mmu_pages;
352 struct list_head assigned_dev_head;
353 struct dmar_domain *intel_iommu_domain;
319 struct kvm_pic *vpic; 354 struct kvm_pic *vpic;
320 struct kvm_ioapic *vioapic; 355 struct kvm_ioapic *vioapic;
321 struct kvm_pit *vpit; 356 struct kvm_pit *vpit;
357 struct hlist_head irq_ack_notifier_list;
322 358
323 int round_robin_prev_vcpu; 359 int round_robin_prev_vcpu;
324 unsigned int tss_addr; 360 unsigned int tss_addr;
@@ -338,6 +374,7 @@ struct kvm_vm_stat {
338 u32 mmu_flooded; 374 u32 mmu_flooded;
339 u32 mmu_recycled; 375 u32 mmu_recycled;
340 u32 mmu_cache_miss; 376 u32 mmu_cache_miss;
377 u32 mmu_unsync;
341 u32 remote_tlb_flush; 378 u32 remote_tlb_flush;
342 u32 lpages; 379 u32 lpages;
343}; 380};
@@ -364,6 +401,7 @@ struct kvm_vcpu_stat {
364 u32 insn_emulation; 401 u32 insn_emulation;
365 u32 insn_emulation_fail; 402 u32 insn_emulation_fail;
366 u32 hypercalls; 403 u32 hypercalls;
404 u32 irq_injections;
367}; 405};
368 406
369struct descriptor_table { 407struct descriptor_table {
@@ -414,8 +452,7 @@ struct kvm_x86_ops {
414 unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr); 452 unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr);
415 void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value, 453 void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value,
416 int *exception); 454 int *exception);
417 void (*cache_regs)(struct kvm_vcpu *vcpu); 455 void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
418 void (*decache_regs)(struct kvm_vcpu *vcpu);
419 unsigned long (*get_rflags)(struct kvm_vcpu *vcpu); 456 unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
420 void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); 457 void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
421 458
@@ -528,6 +565,8 @@ void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
528void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, 565void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2,
529 u32 error_code); 566 u32 error_code);
530 567
568void kvm_pic_set_irq(void *opaque, int irq, int level);
569
531void kvm_inject_nmi(struct kvm_vcpu *vcpu); 570void kvm_inject_nmi(struct kvm_vcpu *vcpu);
532 571
533void fx_init(struct kvm_vcpu *vcpu); 572void fx_init(struct kvm_vcpu *vcpu);
@@ -550,12 +589,14 @@ int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
550void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu); 589void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
551int kvm_mmu_load(struct kvm_vcpu *vcpu); 590int kvm_mmu_load(struct kvm_vcpu *vcpu);
552void kvm_mmu_unload(struct kvm_vcpu *vcpu); 591void kvm_mmu_unload(struct kvm_vcpu *vcpu);
592void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu);
553 593
554int kvm_emulate_hypercall(struct kvm_vcpu *vcpu); 594int kvm_emulate_hypercall(struct kvm_vcpu *vcpu);
555 595
556int kvm_fix_hypercall(struct kvm_vcpu *vcpu); 596int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
557 597
558int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); 598int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);
599void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva);
559 600
560void kvm_enable_tdp(void); 601void kvm_enable_tdp(void);
561void kvm_disable_tdp(void); 602void kvm_disable_tdp(void);
@@ -686,33 +727,6 @@ enum {
686 TASK_SWITCH_GATE = 3, 727 TASK_SWITCH_GATE = 3,
687}; 728};
688 729
689#define KVMTRACE_5D(evt, vcpu, d1, d2, d3, d4, d5, name) \
690 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
691 vcpu, 5, d1, d2, d3, d4, d5)
692#define KVMTRACE_4D(evt, vcpu, d1, d2, d3, d4, name) \
693 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
694 vcpu, 4, d1, d2, d3, d4, 0)
695#define KVMTRACE_3D(evt, vcpu, d1, d2, d3, name) \
696 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
697 vcpu, 3, d1, d2, d3, 0, 0)
698#define KVMTRACE_2D(evt, vcpu, d1, d2, name) \
699 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
700 vcpu, 2, d1, d2, 0, 0, 0)
701#define KVMTRACE_1D(evt, vcpu, d1, name) \
702 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
703 vcpu, 1, d1, 0, 0, 0, 0)
704#define KVMTRACE_0D(evt, vcpu, name) \
705 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
706 vcpu, 0, 0, 0, 0, 0, 0)
707
708#ifdef CONFIG_64BIT
709# define KVM_EX_ENTRY ".quad"
710# define KVM_EX_PUSH "pushq"
711#else
712# define KVM_EX_ENTRY ".long"
713# define KVM_EX_PUSH "pushl"
714#endif
715
716/* 730/*
717 * Hardware virtualization extension instructions may fault if a 731 * Hardware virtualization extension instructions may fault if a
718 * reboot turns off virtualization while processes are running. 732 * reboot turns off virtualization while processes are running.
@@ -724,11 +738,11 @@ asmlinkage void kvm_handle_fault_on_reboot(void);
724 "666: " insn "\n\t" \ 738 "666: " insn "\n\t" \
725 ".pushsection .fixup, \"ax\" \n" \ 739 ".pushsection .fixup, \"ax\" \n" \
726 "667: \n\t" \ 740 "667: \n\t" \
727 KVM_EX_PUSH " $666b \n\t" \ 741 __ASM_SIZE(push) " $666b \n\t" \
728 "jmp kvm_handle_fault_on_reboot \n\t" \ 742 "jmp kvm_handle_fault_on_reboot \n\t" \
729 ".popsection \n\t" \ 743 ".popsection \n\t" \
730 ".pushsection __ex_table, \"a\" \n\t" \ 744 ".pushsection __ex_table, \"a\" \n\t" \
731 KVM_EX_ENTRY " 666b, 667b \n\t" \ 745 _ASM_PTR " 666b, 667b \n\t" \
732 ".popsection" 746 ".popsection"
733 747
734#define KVM_ARCH_WANT_MMU_NOTIFIER 748#define KVM_ARCH_WANT_MMU_NOTIFIER
diff --git a/include/asm-x86/msr-index.h b/include/asm-x86/msr-index.h
index 0bb43301a202..dabd10f0bbee 100644
--- a/include/asm-x86/msr-index.h
+++ b/include/asm-x86/msr-index.h
@@ -178,6 +178,9 @@
178#define MSR_IA32_EBL_CR_POWERON 0x0000002a 178#define MSR_IA32_EBL_CR_POWERON 0x0000002a
179#define MSR_IA32_FEATURE_CONTROL 0x0000003a 179#define MSR_IA32_FEATURE_CONTROL 0x0000003a
180 180
181#define FEATURE_CONTROL_LOCKED (1<<0)
182#define FEATURE_CONTROL_VMXON_ENABLED (1<<2)
183
181#define MSR_IA32_APICBASE 0x0000001b 184#define MSR_IA32_APICBASE 0x0000001b
182#define MSR_IA32_APICBASE_BSP (1<<8) 185#define MSR_IA32_APICBASE_BSP (1<<8)
183#define MSR_IA32_APICBASE_ENABLE (1<<11) 186#define MSR_IA32_APICBASE_ENABLE (1<<11)
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
index e8d80d1de237..bdf5dba4cfb0 100644
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -39,7 +39,6 @@ typedef u64 pmdval_t;
39typedef u64 pudval_t; 39typedef u64 pudval_t;
40typedef u64 pgdval_t; 40typedef u64 pgdval_t;
41typedef u64 pgprotval_t; 41typedef u64 pgprotval_t;
42typedef u64 phys_addr_t;
43 42
44typedef union { 43typedef union {
45 struct { 44 struct {
@@ -60,7 +59,6 @@ typedef unsigned long pmdval_t;
60typedef unsigned long pudval_t; 59typedef unsigned long pudval_t;
61typedef unsigned long pgdval_t; 60typedef unsigned long pgdval_t;
62typedef unsigned long pgprotval_t; 61typedef unsigned long pgprotval_t;
63typedef unsigned long phys_addr_t;
64 62
65typedef union { 63typedef union {
66 pteval_t pte; 64 pteval_t pte;
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index 5e64acfed0a4..49380b8c7e25 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -79,7 +79,6 @@ typedef unsigned long pmdval_t;
79typedef unsigned long pudval_t; 79typedef unsigned long pudval_t;
80typedef unsigned long pgdval_t; 80typedef unsigned long pgdval_t;
81typedef unsigned long pgprotval_t; 81typedef unsigned long pgprotval_t;
82typedef unsigned long phys_addr_t;
83 82
84typedef struct page *pgtable_t; 83typedef struct page *pgtable_t;
85 84
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 182f9d4c570f..88a53b1a17f0 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -148,8 +148,13 @@
148#ifdef CONFIG_X86_64 148#ifdef CONFIG_X86_64
149#define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC 149#define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
150#else 150#else
151/*
152 * For PDE_IDENT_ATTR include USER bit. As the PDE and PTE protection
153 * bits are combined, this will alow user to access the high address mapped
154 * VDSO in the presence of CONFIG_COMPAT_VDSO
155 */
151#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */ 156#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
152#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */ 157#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
153#define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */ 158#define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
154#endif 159#endif
155 160
diff --git a/include/asm-x86/pvclock.h b/include/asm-x86/pvclock.h
index 1a38f6834800..ad29e277fd6d 100644
--- a/include/asm-x86/pvclock.h
+++ b/include/asm-x86/pvclock.h
@@ -6,6 +6,7 @@
6 6
7/* some helper functions for xen and kvm pv clock sources */ 7/* some helper functions for xen and kvm pv clock sources */
8cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src); 8cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
9unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
9void pvclock_read_wallclock(struct pvclock_wall_clock *wall, 10void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
10 struct pvclock_vcpu_time_info *vcpu, 11 struct pvclock_vcpu_time_info *vcpu,
11 struct timespec *ts); 12 struct timespec *ts);
diff --git a/include/asm-x86/summit/apic.h b/include/asm-x86/summit/apic.h
index c5b2e4b10358..394b00bb5e72 100644
--- a/include/asm-x86/summit/apic.h
+++ b/include/asm-x86/summit/apic.h
@@ -160,7 +160,7 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
160 int new_apicid = cpu_to_logical_apicid(cpu); 160 int new_apicid = cpu_to_logical_apicid(cpu);
161 if (apicid_cluster(apicid) != 161 if (apicid_cluster(apicid) !=
162 apicid_cluster(new_apicid)){ 162 apicid_cluster(new_apicid)){
163 printk ("%s: Not a valid mask!\n",__FUNCTION__); 163 printk ("%s: Not a valid mask!\n", __func__);
164 return 0xFF; 164 return 0xFF;
165 } 165 }
166 apicid = apicid | new_apicid; 166 apicid = apicid | new_apicid;
diff --git a/include/asm-x86/xen/page.h b/include/asm-x86/xen/page.h
index c50185dccec1..d5eada0a48d9 100644
--- a/include/asm-x86/xen/page.h
+++ b/include/asm-x86/xen/page.h
@@ -76,13 +76,13 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
76static inline xmaddr_t phys_to_machine(xpaddr_t phys) 76static inline xmaddr_t phys_to_machine(xpaddr_t phys)
77{ 77{
78 unsigned offset = phys.paddr & ~PAGE_MASK; 78 unsigned offset = phys.paddr & ~PAGE_MASK;
79 return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset); 79 return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
80} 80}
81 81
82static inline xpaddr_t machine_to_phys(xmaddr_t machine) 82static inline xpaddr_t machine_to_phys(xmaddr_t machine)
83{ 83{
84 unsigned offset = machine.maddr & ~PAGE_MASK; 84 unsigned offset = machine.maddr & ~PAGE_MASK;
85 return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); 85 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
86} 86}
87 87
88/* 88/*
diff --git a/include/asm-xtensa/elf.h b/include/asm-xtensa/elf.h
index ca6e5101a2cb..c3f53e755ca5 100644
--- a/include/asm-xtensa/elf.h
+++ b/include/asm-xtensa/elf.h
@@ -189,7 +189,7 @@ typedef struct {
189#endif 189#endif
190} elf_xtregs_t; 190} elf_xtregs_t;
191 191
192#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) 192#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
193 193
194struct task_struct; 194struct task_struct;
195 195
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 282a504bd1db..bf9aca548f14 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -107,6 +107,7 @@ header-y += keyctl.h
107header-y += limits.h 107header-y += limits.h
108header-y += magic.h 108header-y += magic.h
109header-y += major.h 109header-y += major.h
110header-y += map_to_7segment.h
110header-y += matroxfb.h 111header-y += matroxfb.h
111header-y += meye.h 112header-y += meye.h
112header-y += minix_fs.h 113header-y += minix_fs.h
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 09b276c35227..f6b8cf99b596 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -204,12 +204,21 @@ struct kioctx {
204/* prototypes */ 204/* prototypes */
205extern unsigned aio_max_size; 205extern unsigned aio_max_size;
206 206
207#ifdef CONFIG_AIO
207extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb); 208extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb);
208extern int aio_put_req(struct kiocb *iocb); 209extern int aio_put_req(struct kiocb *iocb);
209extern void kick_iocb(struct kiocb *iocb); 210extern void kick_iocb(struct kiocb *iocb);
210extern int aio_complete(struct kiocb *iocb, long res, long res2); 211extern int aio_complete(struct kiocb *iocb, long res, long res2);
211struct mm_struct; 212struct mm_struct;
212extern void exit_aio(struct mm_struct *mm); 213extern void exit_aio(struct mm_struct *mm);
214#else
215static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; }
216static inline int aio_put_req(struct kiocb *iocb) { return 0; }
217static inline void kick_iocb(struct kiocb *iocb) { }
218static inline int aio_complete(struct kiocb *iocb, long res, long res2) { return 0; }
219struct mm_struct;
220static inline void exit_aio(struct mm_struct *mm) { }
221#endif /* CONFIG_AIO */
213 222
214#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) 223#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
215 224
diff --git a/include/linux/auto_dev-ioctl.h b/include/linux/auto_dev-ioctl.h
new file mode 100644
index 000000000000..f4d05ccd731f
--- /dev/null
+++ b/include/linux/auto_dev-ioctl.h
@@ -0,0 +1,157 @@
1/*
2 * Copyright 2008 Red Hat, Inc. All rights reserved.
3 * Copyright 2008 Ian Kent <raven@themaw.net>
4 *
5 * This file is part of the Linux kernel and is made available under
6 * the terms of the GNU General Public License, version 2, or at your
7 * option, any later version, incorporated herein by reference.
8 */
9
10#ifndef _LINUX_AUTO_DEV_IOCTL_H
11#define _LINUX_AUTO_DEV_IOCTL_H
12
13#include <linux/types.h>
14
15#define AUTOFS_DEVICE_NAME "autofs"
16
17#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1
18#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0
19
20#define AUTOFS_DEVID_LEN 16
21
22#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl)
23
24/*
25 * An ioctl interface for autofs mount point control.
26 */
27
28/*
29 * All the ioctls use this structure.
30 * When sending a path size must account for the total length
31 * of the chunk of memory otherwise is is the size of the
32 * structure.
33 */
34
35struct autofs_dev_ioctl {
36 __u32 ver_major;
37 __u32 ver_minor;
38 __u32 size; /* total size of data passed in
39 * including this struct */
40 __s32 ioctlfd; /* automount command fd */
41
42 __u32 arg1; /* Command parameters */
43 __u32 arg2;
44
45 char path[0];
46};
47
48static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in)
49{
50 in->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
51 in->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
52 in->size = sizeof(struct autofs_dev_ioctl);
53 in->ioctlfd = -1;
54 in->arg1 = 0;
55 in->arg2 = 0;
56 return;
57}
58
59/*
60 * If you change this make sure you make the corresponding change
61 * to autofs-dev-ioctl.c:lookup_ioctl()
62 */
63enum {
64 /* Get various version info */
65 AUTOFS_DEV_IOCTL_VERSION_CMD = 0x71,
66 AUTOFS_DEV_IOCTL_PROTOVER_CMD,
67 AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD,
68
69 /* Open mount ioctl fd */
70 AUTOFS_DEV_IOCTL_OPENMOUNT_CMD,
71
72 /* Close mount ioctl fd */
73 AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD,
74
75 /* Mount/expire status returns */
76 AUTOFS_DEV_IOCTL_READY_CMD,
77 AUTOFS_DEV_IOCTL_FAIL_CMD,
78
79 /* Activate/deactivate autofs mount */
80 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD,
81 AUTOFS_DEV_IOCTL_CATATONIC_CMD,
82
83 /* Expiry timeout */
84 AUTOFS_DEV_IOCTL_TIMEOUT_CMD,
85
86 /* Get mount last requesting uid and gid */
87 AUTOFS_DEV_IOCTL_REQUESTER_CMD,
88
89 /* Check for eligible expire candidates */
90 AUTOFS_DEV_IOCTL_EXPIRE_CMD,
91
92 /* Request busy status */
93 AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD,
94
95 /* Check if path is a mountpoint */
96 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD,
97};
98
99#define AUTOFS_IOCTL 0x93
100
101#define AUTOFS_DEV_IOCTL_VERSION \
102 _IOWR(AUTOFS_IOCTL, \
103 AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl)
104
105#define AUTOFS_DEV_IOCTL_PROTOVER \
106 _IOWR(AUTOFS_IOCTL, \
107 AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl)
108
109#define AUTOFS_DEV_IOCTL_PROTOSUBVER \
110 _IOWR(AUTOFS_IOCTL, \
111 AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl)
112
113#define AUTOFS_DEV_IOCTL_OPENMOUNT \
114 _IOWR(AUTOFS_IOCTL, \
115 AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl)
116
117#define AUTOFS_DEV_IOCTL_CLOSEMOUNT \
118 _IOWR(AUTOFS_IOCTL, \
119 AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl)
120
121#define AUTOFS_DEV_IOCTL_READY \
122 _IOWR(AUTOFS_IOCTL, \
123 AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl)
124
125#define AUTOFS_DEV_IOCTL_FAIL \
126 _IOWR(AUTOFS_IOCTL, \
127 AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl)
128
129#define AUTOFS_DEV_IOCTL_SETPIPEFD \
130 _IOWR(AUTOFS_IOCTL, \
131 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl)
132
133#define AUTOFS_DEV_IOCTL_CATATONIC \
134 _IOWR(AUTOFS_IOCTL, \
135 AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl)
136
137#define AUTOFS_DEV_IOCTL_TIMEOUT \
138 _IOWR(AUTOFS_IOCTL, \
139 AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl)
140
141#define AUTOFS_DEV_IOCTL_REQUESTER \
142 _IOWR(AUTOFS_IOCTL, \
143 AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl)
144
145#define AUTOFS_DEV_IOCTL_EXPIRE \
146 _IOWR(AUTOFS_IOCTL, \
147 AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl)
148
149#define AUTOFS_DEV_IOCTL_ASKUMOUNT \
150 _IOWR(AUTOFS_IOCTL, \
151 AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl)
152
153#define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \
154 _IOWR(AUTOFS_IOCTL, \
155 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl)
156
157#endif /* _LINUX_AUTO_DEV_IOCTL_H */
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
index b785c6f8644d..2253716d4b92 100644
--- a/include/linux/auto_fs4.h
+++ b/include/linux/auto_fs4.h
@@ -23,12 +23,17 @@
23#define AUTOFS_MIN_PROTO_VERSION 3 23#define AUTOFS_MIN_PROTO_VERSION 3
24#define AUTOFS_MAX_PROTO_VERSION 5 24#define AUTOFS_MAX_PROTO_VERSION 5
25 25
26#define AUTOFS_PROTO_SUBVERSION 0 26#define AUTOFS_PROTO_SUBVERSION 1
27 27
28/* Mask for expire behaviour */ 28/* Mask for expire behaviour */
29#define AUTOFS_EXP_IMMEDIATE 1 29#define AUTOFS_EXP_IMMEDIATE 1
30#define AUTOFS_EXP_LEAVES 2 30#define AUTOFS_EXP_LEAVES 2
31 31
32#define AUTOFS_TYPE_ANY 0x0000
33#define AUTOFS_TYPE_INDIRECT 0x0001
34#define AUTOFS_TYPE_DIRECT 0x0002
35#define AUTOFS_TYPE_OFFSET 0x0004
36
32/* Daemon notification packet types */ 37/* Daemon notification packet types */
33enum autofs_notify { 38enum autofs_notify {
34 NFY_NONE, 39 NFY_NONE,
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index 826f62350805..7394b5b349ff 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -36,6 +36,10 @@ struct linux_binprm{
36 unsigned long p; /* current top of mem */ 36 unsigned long p; /* current top of mem */
37 unsigned int sh_bang:1, 37 unsigned int sh_bang:1,
38 misc_bang:1; 38 misc_bang:1;
39#ifdef __alpha__
40 unsigned int taso:1;
41#endif
42 unsigned int recursion_depth;
39 struct file * file; 43 struct file * file;
40 int e_uid, e_gid; 44 int e_uid, e_gid;
41 kernel_cap_t cap_post_exec_permitted; 45 kernel_cap_t cap_post_exec_permitted;
@@ -58,6 +62,7 @@ struct linux_binprm{
58#define BINPRM_FLAGS_EXECFD_BIT 1 62#define BINPRM_FLAGS_EXECFD_BIT 1
59#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT) 63#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
60 64
65#define BINPRM_MAX_RECURSION 4
61 66
62/* 67/*
63 * This structure defines the functions that are used to load the binary formats that 68 * This structure defines the functions that are used to load the binary formats that
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index c98dd7cb7076..30934e4bfaab 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -326,7 +326,8 @@ struct cgroup_subsys {
326 */ 326 */
327 void (*mm_owner_changed)(struct cgroup_subsys *ss, 327 void (*mm_owner_changed)(struct cgroup_subsys *ss,
328 struct cgroup *old, 328 struct cgroup *old,
329 struct cgroup *new); 329 struct cgroup *new,
330 struct task_struct *p);
330 int subsys_id; 331 int subsys_id;
331 int active; 332 int active;
332 int disabled; 333 int disabled;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 5ca8c6fddb56..778777316ea4 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -35,6 +35,8 @@ struct clk;
35 * clk_get may return different clock producers depending on @dev.) 35 * clk_get may return different clock producers depending on @dev.)
36 * 36 *
37 * Drivers must assume that the clock source is not enabled. 37 * Drivers must assume that the clock source is not enabled.
38 *
39 * clk_get should not be called from within interrupt context.
38 */ 40 */
39struct clk *clk_get(struct device *dev, const char *id); 41struct clk *clk_get(struct device *dev, const char *id);
40 42
@@ -76,6 +78,8 @@ unsigned long clk_get_rate(struct clk *clk);
76 * Note: drivers must ensure that all clk_enable calls made on this 78 * Note: drivers must ensure that all clk_enable calls made on this
77 * clock source are balanced by clk_disable calls prior to calling 79 * clock source are balanced by clk_disable calls prior to calling
78 * this function. 80 * this function.
81 *
82 * clk_put should not be called from within interrupt context.
79 */ 83 */
80void clk_put(struct clk *clk); 84void clk_put(struct clk *clk);
81 85
diff --git a/include/linux/compat.h b/include/linux/compat.h
index cf8d11cad5ae..f061a1ea1b74 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -78,7 +78,6 @@ typedef struct {
78 compat_sigset_word sig[_COMPAT_NSIG_WORDS]; 78 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
79} compat_sigset_t; 79} compat_sigset_t;
80 80
81extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
82extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); 81extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
83extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); 82extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
84 83
@@ -235,6 +234,11 @@ extern int get_compat_itimerspec(struct itimerspec *dst,
235extern int put_compat_itimerspec(struct compat_itimerspec __user *dst, 234extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
236 const struct itimerspec *src); 235 const struct itimerspec *src);
237 236
237asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
238 struct timezone __user *tz);
239asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
240 struct timezone __user *tz);
241
238asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 242asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
239 243
240extern int compat_printk(const char *fmt, ...); 244extern int compat_printk(const char *fmt, ...);
diff --git a/include/linux/device.h b/include/linux/device.h
index 246937c9cbc7..987f5912720a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -90,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus,
90 struct device_driver *start, void *data, 90 struct device_driver *start, void *data,
91 int (*fn)(struct device_driver *, void *)); 91 int (*fn)(struct device_driver *, void *));
92 92
93void bus_sort_breadthfirst(struct bus_type *bus,
94 int (*compare)(const struct device *a,
95 const struct device *b));
93/* 96/*
94 * Bus notifiers: Get notified of addition/removal of devices 97 * Bus notifiers: Get notified of addition/removal of devices
95 * and binding/unbinding of drivers to devices. 98 * and binding/unbinding of drivers to devices.
@@ -502,7 +505,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
502 dev_t devt, void *drvdata, 505 dev_t devt, void *drvdata,
503 const char *fmt, ...) 506 const char *fmt, ...)
504 __attribute__((format(printf, 5, 6))); 507 __attribute__((format(printf, 5, 6)));
505#define device_create_drvdata device_create
506extern void device_destroy(struct class *cls, dev_t devt); 508extern void device_destroy(struct class *cls, dev_t devt);
507 509
508/* 510/*
@@ -551,7 +553,11 @@ extern const char *dev_driver_string(const struct device *dev);
551#define dev_info(dev, format, arg...) \ 553#define dev_info(dev, format, arg...) \
552 dev_printk(KERN_INFO , dev , format , ## arg) 554 dev_printk(KERN_INFO , dev , format , ## arg)
553 555
554#ifdef DEBUG 556#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
557#define dev_dbg(dev, format, ...) do { \
558 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
559 } while (0)
560#elif defined(DEBUG)
555#define dev_dbg(dev, format, arg...) \ 561#define dev_dbg(dev, format, arg...) \
556 dev_printk(KERN_DEBUG , dev , format , ## arg) 562 dev_printk(KERN_DEBUG , dev , format , ## arg)
557#else 563#else
@@ -567,6 +573,14 @@ extern const char *dev_driver_string(const struct device *dev);
567 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 573 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
568#endif 574#endif
569 575
576/*
577 * dev_WARN() acts like dev_printk(), but with the key difference
578 * of using a WARN/WARN_ON to get the message out, including the
579 * file/line information and a backtrace.
580 */
581#define dev_WARN(dev, format, arg...) \
582 WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
583
570/* Create alias, so I can be autoloaded. */ 584/* Create alias, so I can be autoloaded. */
571#define MODULE_ALIAS_CHARDEV(major,minor) \ 585#define MODULE_ALIAS_CHARDEV(major,minor) \
572 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 586 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
diff --git a/drivers/pci/dma_remapping.h b/include/linux/dma_remapping.h
index bff5c65f81dc..bff5c65f81dc 100644
--- a/drivers/pci/dma_remapping.h
+++ b/include/linux/dma_remapping.h
diff --git a/include/linux/dynamic_printk.h b/include/linux/dynamic_printk.h
new file mode 100644
index 000000000000..2d528d009074
--- /dev/null
+++ b/include/linux/dynamic_printk.h
@@ -0,0 +1,93 @@
1#ifndef _DYNAMIC_PRINTK_H
2#define _DYNAMIC_PRINTK_H
3
4#define DYNAMIC_DEBUG_HASH_BITS 6
5#define DEBUG_HASH_TABLE_SIZE (1 << DYNAMIC_DEBUG_HASH_BITS)
6
7#define TYPE_BOOLEAN 1
8
9#define DYNAMIC_ENABLED_ALL 0
10#define DYNAMIC_ENABLED_NONE 1
11#define DYNAMIC_ENABLED_SOME 2
12
13extern int dynamic_enabled;
14
15/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
16 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
17 * use independent hash functions, to reduce the chance of false positives.
18 */
19extern long long dynamic_printk_enabled;
20extern long long dynamic_printk_enabled2;
21
22struct mod_debug {
23 char *modname;
24 char *logical_modname;
25 char *flag_names;
26 int type;
27 int hash;
28 int hash2;
29} __attribute__((aligned(8)));
30
31int register_dynamic_debug_module(char *mod_name, int type, char *share_name,
32 char *flags, int hash, int hash2);
33
34#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
35extern int unregister_dynamic_debug_module(char *mod_name);
36extern int __dynamic_dbg_enabled_helper(char *modname, int type,
37 int value, int hash);
38
39#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ \
40 int __ret = 0; \
41 if (unlikely((dynamic_printk_enabled & (1LL << DEBUG_HASH)) && \
42 (dynamic_printk_enabled2 & (1LL << DEBUG_HASH2)))) \
43 __ret = __dynamic_dbg_enabled_helper(module, type, \
44 value, hash);\
45 __ret; })
46
47#define dynamic_pr_debug(fmt, ...) do { \
48 static char mod_name[] \
49 __attribute__((section("__verbose_strings"))) \
50 = KBUILD_MODNAME; \
51 static struct mod_debug descriptor \
52 __used \
53 __attribute__((section("__verbose"), aligned(8))) = \
54 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
55 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
56 0, 0, DEBUG_HASH)) \
57 printk(KERN_DEBUG KBUILD_MODNAME ":" fmt, \
58 ##__VA_ARGS__); \
59 } while (0)
60
61#define dynamic_dev_dbg(dev, format, ...) do { \
62 static char mod_name[] \
63 __attribute__((section("__verbose_strings"))) \
64 = KBUILD_MODNAME; \
65 static struct mod_debug descriptor \
66 __used \
67 __attribute__((section("__verbose"), aligned(8))) = \
68 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
69 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
70 0, 0, DEBUG_HASH)) \
71 dev_printk(KERN_DEBUG, dev, \
72 KBUILD_MODNAME ": " format, \
73 ##__VA_ARGS__); \
74 } while (0)
75
76#else
77
78static inline int unregister_dynamic_debug_module(const char *mod_name)
79{
80 return 0;
81}
82static inline int __dynamic_dbg_enabled_helper(char *modname, int type,
83 int value, int hash)
84{
85 return 0;
86}
87
88#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ 0; })
89#define dynamic_pr_debug(fmt, ...) do { } while (0)
90#define dynamic_dev_dbg(dev, format, ...) do { } while (0)
91#endif
92
93#endif
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h
index 2efe7b863cff..78c775a83f7c 100644
--- a/include/linux/ext2_fs.h
+++ b/include/linux/ext2_fs.h
@@ -47,7 +47,7 @@
47#ifdef EXT2FS_DEBUG 47#ifdef EXT2FS_DEBUG
48# define ext2_debug(f, a...) { \ 48# define ext2_debug(f, a...) { \
49 printk ("EXT2-fs DEBUG (%s, %d): %s:", \ 49 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
50 __FILE__, __LINE__, __FUNCTION__); \ 50 __FILE__, __LINE__, __func__); \
51 printk (f, ## a); \ 51 printk (f, ## a); \
52 } 52 }
53#else 53#else
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 8120fa1bc235..159d9b476cd7 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -43,7 +43,7 @@
43#define ext3_debug(f, a...) \ 43#define ext3_debug(f, a...) \
44 do { \ 44 do { \
45 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \ 45 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \
46 __FILE__, __LINE__, __FUNCTION__); \ 46 __FILE__, __LINE__, __func__); \
47 printk (KERN_DEBUG f, ## a); \ 47 printk (KERN_DEBUG f, ## a); \
48 } while (0) 48 } while (0)
49#else 49#else
@@ -871,7 +871,7 @@ extern void ext3_update_dynamic_rev (struct super_block *sb);
871#define ext3_std_error(sb, errno) \ 871#define ext3_std_error(sb, errno) \
872do { \ 872do { \
873 if ((errno)) \ 873 if ((errno)) \
874 __ext3_std_error((sb), __FUNCTION__, (errno)); \ 874 __ext3_std_error((sb), __func__, (errno)); \
875} while (0) 875} while (0)
876 876
877/* 877/*
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
index 8c43b13a02fe..cf82d519be40 100644
--- a/include/linux/ext3_jbd.h
+++ b/include/linux/ext3_jbd.h
@@ -137,17 +137,17 @@ int __ext3_journal_dirty_metadata(const char *where,
137 handle_t *handle, struct buffer_head *bh); 137 handle_t *handle, struct buffer_head *bh);
138 138
139#define ext3_journal_get_undo_access(handle, bh) \ 139#define ext3_journal_get_undo_access(handle, bh) \
140 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 140 __ext3_journal_get_undo_access(__func__, (handle), (bh))
141#define ext3_journal_get_write_access(handle, bh) \ 141#define ext3_journal_get_write_access(handle, bh) \
142 __ext3_journal_get_write_access(__FUNCTION__, (handle), (bh)) 142 __ext3_journal_get_write_access(__func__, (handle), (bh))
143#define ext3_journal_revoke(handle, blocknr, bh) \ 143#define ext3_journal_revoke(handle, blocknr, bh) \
144 __ext3_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh)) 144 __ext3_journal_revoke(__func__, (handle), (blocknr), (bh))
145#define ext3_journal_get_create_access(handle, bh) \ 145#define ext3_journal_get_create_access(handle, bh) \
146 __ext3_journal_get_create_access(__FUNCTION__, (handle), (bh)) 146 __ext3_journal_get_create_access(__func__, (handle), (bh))
147#define ext3_journal_dirty_metadata(handle, bh) \ 147#define ext3_journal_dirty_metadata(handle, bh) \
148 __ext3_journal_dirty_metadata(__FUNCTION__, (handle), (bh)) 148 __ext3_journal_dirty_metadata(__func__, (handle), (bh))
149#define ext3_journal_forget(handle, bh) \ 149#define ext3_journal_forget(handle, bh) \
150 __ext3_journal_forget(__FUNCTION__, (handle), (bh)) 150 __ext3_journal_forget(__func__, (handle), (bh))
151 151
152int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh); 152int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
153 153
@@ -160,7 +160,7 @@ static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
160} 160}
161 161
162#define ext3_journal_stop(handle) \ 162#define ext3_journal_stop(handle) \
163 __ext3_journal_stop(__FUNCTION__, (handle)) 163 __ext3_journal_stop(__func__, (handle))
164 164
165static inline handle_t *ext3_journal_current_handle(void) 165static inline handle_t *ext3_journal_current_handle(void)
166{ 166{
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index 0f0e271f97fa..4d078e99c017 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -154,8 +154,13 @@ struct fw_cdev_event_iso_interrupt {
154 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST 154 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST
155 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT 155 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
156 * 156 *
157 * Convenience union for userspace use. Events could be read(2) into a char 157 * Convenience union for userspace use. Events could be read(2) into an
158 * buffer and then cast to this union for further processing. 158 * appropriately aligned char buffer and then cast to this union for further
159 * processing. Note that for a request, response or iso_interrupt event,
160 * the data[] or header[] may make the size of the full event larger than
161 * sizeof(union fw_cdev_event). Also note that if you attempt to read(2)
162 * an event into a buffer that is not large enough for it, the data that does
163 * not fit will be discarded so that the next read(2) will return a new event.
159 */ 164 */
160union fw_cdev_event { 165union fw_cdev_event {
161 struct fw_cdev_event_common common; 166 struct fw_cdev_event_common common;
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
index f64e29c0ef3f..0cd825f7363a 100644
--- a/include/linux/gameport.h
+++ b/include/linux/gameport.h
@@ -146,10 +146,11 @@ static inline void gameport_unpin_driver(struct gameport *gameport)
146 mutex_unlock(&gameport->drv_mutex); 146 mutex_unlock(&gameport->drv_mutex);
147} 147}
148 148
149void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); 149int __gameport_register_driver(struct gameport_driver *drv,
150static inline void gameport_register_driver(struct gameport_driver *drv) 150 struct module *owner, const char *mod_name);
151static inline int __must_check gameport_register_driver(struct gameport_driver *drv)
151{ 152{
152 __gameport_register_driver(drv, THIS_MODULE); 153 return __gameport_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
153} 154}
154 155
155void gameport_unregister_driver(struct gameport_driver *drv); 156void gameport_unregister_driver(struct gameport_driver *drv);
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 730a20b83576..e10c49a5b96e 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -8,6 +8,7 @@
8 8
9#else 9#else
10 10
11#include <linux/kernel.h>
11#include <linux/types.h> 12#include <linux/types.h>
12#include <linux/errno.h> 13#include <linux/errno.h>
13 14
@@ -32,6 +33,8 @@ static inline int gpio_request(unsigned gpio, const char *label)
32 33
33static inline void gpio_free(unsigned gpio) 34static inline void gpio_free(unsigned gpio)
34{ 35{
36 might_sleep();
37
35 /* GPIO can never have been requested */ 38 /* GPIO can never have been requested */
36 WARN_ON(1); 39 WARN_ON(1);
37} 40}
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 75ae6d8aba4f..4c4e57d1f19d 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -570,7 +570,6 @@ struct i2o_controller {
570#endif 570#endif
571 spinlock_t lock; /* lock for controller 571 spinlock_t lock; /* lock for controller
572 configuration */ 572 configuration */
573
574 void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */ 573 void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */
575}; 574};
576 575
@@ -691,289 +690,22 @@ static inline u32 i2o_dma_high(dma_addr_t dma_addr)
691}; 690};
692#endif 691#endif
693 692
694/** 693extern u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size);
695 * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL 694extern dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
696 * @c: I2O controller for which the calculation should be done
697 * @body_size: maximum body size used for message in 32-bit words.
698 *
699 * Return the maximum number of SG elements in a SG list.
700 */
701static inline u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size)
702{
703 i2o_status_block *sb = c->status_block.virt;
704 u16 sg_count =
705 (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) -
706 body_size;
707
708 if (c->pae_support) {
709 /*
710 * for 64-bit a SG attribute element must be added and each
711 * SG element needs 12 bytes instead of 8.
712 */
713 sg_count -= 2;
714 sg_count /= 3;
715 } else
716 sg_count /= 2;
717
718 if (c->short_req && (sg_count > 8))
719 sg_count = 8;
720
721 return sg_count;
722};
723
724/**
725 * i2o_dma_map_single - Map pointer to controller and fill in I2O message.
726 * @c: I2O controller
727 * @ptr: pointer to the data which should be mapped
728 * @size: size of data in bytes
729 * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
730 * @sg_ptr: pointer to the SG list inside the I2O message
731 *
732 * This function does all necessary DMA handling and also writes the I2O
733 * SGL elements into the I2O message. For details on DMA handling see also
734 * dma_map_single(). The pointer sg_ptr will only be set to the end of the
735 * SG list if the allocation was successful.
736 *
737 * Returns DMA address which must be checked for failures using
738 * dma_mapping_error().
739 */
740static inline dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
741 size_t size, 695 size_t size,
742 enum dma_data_direction direction, 696 enum dma_data_direction direction,
743 u32 ** sg_ptr) 697 u32 ** sg_ptr);
744{ 698extern int i2o_dma_map_sg(struct i2o_controller *c,
745 u32 sg_flags;
746 u32 *mptr = *sg_ptr;
747 dma_addr_t dma_addr;
748
749 switch (direction) {
750 case DMA_TO_DEVICE:
751 sg_flags = 0xd4000000;
752 break;
753 case DMA_FROM_DEVICE:
754 sg_flags = 0xd0000000;
755 break;
756 default:
757 return 0;
758 }
759
760 dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction);
761 if (!dma_mapping_error(&c->pdev->dev, dma_addr)) {
762#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
763 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
764 *mptr++ = cpu_to_le32(0x7C020002);
765 *mptr++ = cpu_to_le32(PAGE_SIZE);
766 }
767#endif
768
769 *mptr++ = cpu_to_le32(sg_flags | size);
770 *mptr++ = cpu_to_le32(i2o_dma_low(dma_addr));
771#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
772 if ((sizeof(dma_addr_t) > 4) && c->pae_support)
773 *mptr++ = cpu_to_le32(i2o_dma_high(dma_addr));
774#endif
775 *sg_ptr = mptr;
776 }
777 return dma_addr;
778};
779
780/**
781 * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message.
782 * @c: I2O controller
783 * @sg: SG list to be mapped
784 * @sg_count: number of elements in the SG list
785 * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
786 * @sg_ptr: pointer to the SG list inside the I2O message
787 *
788 * This function does all necessary DMA handling and also writes the I2O
789 * SGL elements into the I2O message. For details on DMA handling see also
790 * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG
791 * list if the allocation was successful.
792 *
793 * Returns 0 on failure or 1 on success.
794 */
795static inline int i2o_dma_map_sg(struct i2o_controller *c,
796 struct scatterlist *sg, int sg_count, 699 struct scatterlist *sg, int sg_count,
797 enum dma_data_direction direction, 700 enum dma_data_direction direction,
798 u32 ** sg_ptr) 701 u32 ** sg_ptr);
799{ 702extern int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len);
800 u32 sg_flags; 703extern void i2o_dma_free(struct device *dev, struct i2o_dma *addr);
801 u32 *mptr = *sg_ptr; 704extern int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
802 705 size_t len);
803 switch (direction) { 706extern int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
804 case DMA_TO_DEVICE: 707 size_t size, int min_nr);
805 sg_flags = 0x14000000; 708extern void i2o_pool_free(struct i2o_pool *pool);
806 break;
807 case DMA_FROM_DEVICE:
808 sg_flags = 0x10000000;
809 break;
810 default:
811 return 0;
812 }
813
814 sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction);
815 if (!sg_count)
816 return 0;
817
818#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
819 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
820 *mptr++ = cpu_to_le32(0x7C020002);
821 *mptr++ = cpu_to_le32(PAGE_SIZE);
822 }
823#endif
824
825 while (sg_count-- > 0) {
826 if (!sg_count)
827 sg_flags |= 0xC0000000;
828 *mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg));
829 *mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg)));
830#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
831 if ((sizeof(dma_addr_t) > 4) && c->pae_support)
832 *mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg)));
833#endif
834 sg = sg_next(sg);
835 }
836 *sg_ptr = mptr;
837
838 return 1;
839};
840
841/**
842 * i2o_dma_alloc - Allocate DMA memory
843 * @dev: struct device pointer to the PCI device of the I2O controller
844 * @addr: i2o_dma struct which should get the DMA buffer
845 * @len: length of the new DMA memory
846 * @gfp_mask: GFP mask
847 *
848 * Allocate a coherent DMA memory and write the pointers into addr.
849 *
850 * Returns 0 on success or -ENOMEM on failure.
851 */
852static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr,
853 size_t len, gfp_t gfp_mask)
854{
855 struct pci_dev *pdev = to_pci_dev(dev);
856 int dma_64 = 0;
857
858 if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_64BIT_MASK)) {
859 dma_64 = 1;
860 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))
861 return -ENOMEM;
862 }
863
864 addr->virt = dma_alloc_coherent(dev, len, &addr->phys, gfp_mask);
865
866 if ((sizeof(dma_addr_t) > 4) && dma_64)
867 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK))
868 printk(KERN_WARNING "i2o: unable to set 64-bit DMA");
869
870 if (!addr->virt)
871 return -ENOMEM;
872
873 memset(addr->virt, 0, len);
874 addr->len = len;
875
876 return 0;
877};
878
879/**
880 * i2o_dma_free - Free DMA memory
881 * @dev: struct device pointer to the PCI device of the I2O controller
882 * @addr: i2o_dma struct which contains the DMA buffer
883 *
884 * Free a coherent DMA memory and set virtual address of addr to NULL.
885 */
886static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
887{
888 if (addr->virt) {
889 if (addr->phys)
890 dma_free_coherent(dev, addr->len, addr->virt,
891 addr->phys);
892 else
893 kfree(addr->virt);
894 addr->virt = NULL;
895 }
896};
897
898/**
899 * i2o_dma_realloc - Realloc DMA memory
900 * @dev: struct device pointer to the PCI device of the I2O controller
901 * @addr: pointer to a i2o_dma struct DMA buffer
902 * @len: new length of memory
903 * @gfp_mask: GFP mask
904 *
905 * If there was something allocated in the addr, free it first. If len > 0
906 * than try to allocate it and write the addresses back to the addr
907 * structure. If len == 0 set the virtual address to NULL.
908 *
909 * Returns the 0 on success or negative error code on failure.
910 */
911static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
912 size_t len, gfp_t gfp_mask)
913{
914 i2o_dma_free(dev, addr);
915
916 if (len)
917 return i2o_dma_alloc(dev, addr, len, gfp_mask);
918
919 return 0;
920};
921
922/*
923 * i2o_pool_alloc - Allocate an slab cache and mempool
924 * @mempool: pointer to struct i2o_pool to write data into.
925 * @name: name which is used to identify cache
926 * @size: size of each object
927 * @min_nr: minimum number of objects
928 *
929 * First allocates a slab cache with name and size. Then allocates a
930 * mempool which uses the slab cache for allocation and freeing.
931 *
932 * Returns 0 on success or negative error code on failure.
933 */
934static inline int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
935 size_t size, int min_nr)
936{
937 pool->name = kmalloc(strlen(name) + 1, GFP_KERNEL);
938 if (!pool->name)
939 goto exit;
940 strcpy(pool->name, name);
941
942 pool->slab =
943 kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
944 if (!pool->slab)
945 goto free_name;
946
947 pool->mempool = mempool_create_slab_pool(min_nr, pool->slab);
948 if (!pool->mempool)
949 goto free_slab;
950
951 return 0;
952
953 free_slab:
954 kmem_cache_destroy(pool->slab);
955
956 free_name:
957 kfree(pool->name);
958
959 exit:
960 return -ENOMEM;
961};
962
963/*
964 * i2o_pool_free - Free slab cache and mempool again
965 * @mempool: pointer to struct i2o_pool which should be freed
966 *
967 * Note that you have to return all objects to the mempool again before
968 * calling i2o_pool_free().
969 */
970static inline void i2o_pool_free(struct i2o_pool *pool)
971{
972 mempool_destroy(pool->mempool);
973 kmem_cache_destroy(pool->slab);
974 kfree(pool->name);
975};
976
977/* I2O driver (OSM) functions */ 709/* I2O driver (OSM) functions */
978extern int i2o_driver_register(struct i2o_driver *); 710extern int i2o_driver_register(struct i2o_driver *);
979extern void i2o_driver_unregister(struct i2o_driver *); 711extern void i2o_driver_unregister(struct i2o_driver *);
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index 03067443198a..a93a8dd33118 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -40,16 +40,18 @@ struct icmp6hdr {
40 struct icmpv6_nd_ra { 40 struct icmpv6_nd_ra {
41 __u8 hop_limit; 41 __u8 hop_limit;
42#if defined(__LITTLE_ENDIAN_BITFIELD) 42#if defined(__LITTLE_ENDIAN_BITFIELD)
43 __u8 reserved:4, 43 __u8 reserved:3,
44 router_pref:2, 44 router_pref:2,
45 home_agent:1,
45 other:1, 46 other:1,
46 managed:1; 47 managed:1;
47 48
48#elif defined(__BIG_ENDIAN_BITFIELD) 49#elif defined(__BIG_ENDIAN_BITFIELD)
49 __u8 managed:1, 50 __u8 managed:1,
50 other:1, 51 other:1,
52 home_agent:1,
51 router_pref:2, 53 router_pref:2,
52 reserved:4; 54 reserved:3;
53#else 55#else
54#error "Please fix <asm/byteorder.h>" 56#error "Please fix <asm/byteorder.h>"
55#endif 57#endif
diff --git a/include/linux/init.h b/include/linux/init.h
index 93538b696e3d..ad63824460e3 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -233,9 +233,6 @@ struct obs_kernel_param {
233 __attribute__((aligned((sizeof(long))))) \ 233 __attribute__((aligned((sizeof(long))))) \
234 = { __setup_str_##unique_id, fn, early } 234 = { __setup_str_##unique_id, fn, early }
235 235
236#define __setup_null_param(str, unique_id) \
237 __setup_param(str, unique_id, NULL, 0)
238
239#define __setup(str, fn) \ 236#define __setup(str, fn) \
240 __setup_param(str, fn, fn, 0) 237 __setup_param(str, fn, fn, 0)
241 238
@@ -296,7 +293,6 @@ void __init parse_early_param(void);
296 void cleanup_module(void) __attribute__((alias(#exitfn))); 293 void cleanup_module(void) __attribute__((alias(#exitfn)));
297 294
298#define __setup_param(str, unique_id, fn) /* nothing */ 295#define __setup_param(str, unique_id, fn) /* nothing */
299#define __setup_null_param(str, unique_id) /* nothing */
300#define __setup(str, func) /* nothing */ 296#define __setup(str, func) /* nothing */
301#endif 297#endif
302 298
diff --git a/include/linux/input.h b/include/linux/input.h
index a5802c9c81a4..b86fb5581ce6 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -577,9 +577,22 @@ struct input_absinfo {
577#define KEY_BRL_DOT9 0x1f9 577#define KEY_BRL_DOT9 0x1f9
578#define KEY_BRL_DOT10 0x1fa 578#define KEY_BRL_DOT10 0x1fa
579 579
580#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */
581#define KEY_NUMERIC_1 0x201 /* and other keypads */
582#define KEY_NUMERIC_2 0x202
583#define KEY_NUMERIC_3 0x203
584#define KEY_NUMERIC_4 0x204
585#define KEY_NUMERIC_5 0x205
586#define KEY_NUMERIC_6 0x206
587#define KEY_NUMERIC_7 0x207
588#define KEY_NUMERIC_8 0x208
589#define KEY_NUMERIC_9 0x209
590#define KEY_NUMERIC_STAR 0x20a
591#define KEY_NUMERIC_POUND 0x20b
592
580/* We avoid low common keys in module aliases so they don't get huge. */ 593/* We avoid low common keys in module aliases so they don't get huge. */
581#define KEY_MIN_INTERESTING KEY_MUTE 594#define KEY_MIN_INTERESTING KEY_MUTE
582#define KEY_MAX 0x1ff 595#define KEY_MAX 0x2ff
583#define KEY_CNT (KEY_MAX+1) 596#define KEY_CNT (KEY_MAX+1)
584 597
585/* 598/*
diff --git a/drivers/pci/intel-iommu.h b/include/linux/intel-iommu.h
index 2142c01e0143..2e117f30a76c 100644
--- a/drivers/pci/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -25,10 +25,10 @@
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/msi.h> 26#include <linux/msi.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include "iova.h" 28#include <linux/iova.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/dma_remapping.h>
30#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
31#include "dma_remapping.h"
32 32
33/* 33/*
34 * Intel IOMMU register specification per version 1.0 public spec. 34 * Intel IOMMU register specification per version 1.0 public spec.
@@ -304,4 +304,24 @@ extern int dmar_enable_qi(struct intel_iommu *iommu);
304extern void qi_global_iec(struct intel_iommu *iommu); 304extern void qi_global_iec(struct intel_iommu *iommu);
305 305
306extern void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); 306extern void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
307
308void intel_iommu_domain_exit(struct dmar_domain *domain);
309struct dmar_domain *intel_iommu_domain_alloc(struct pci_dev *pdev);
310int intel_iommu_context_mapping(struct dmar_domain *domain,
311 struct pci_dev *pdev);
312int intel_iommu_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
313 u64 hpa, size_t size, int prot);
314void intel_iommu_detach_dev(struct dmar_domain *domain, u8 bus, u8 devfn);
315struct dmar_domain *intel_iommu_find_domain(struct pci_dev *pdev);
316u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova);
317
318#ifdef CONFIG_DMAR
319int intel_iommu_found(void);
320#else /* CONFIG_DMAR */
321static inline int intel_iommu_found(void)
322{
323 return 0;
324}
325#endif /* CONFIG_DMAR */
326
307#endif 327#endif
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 58ff4e74b2f3..54b3623434ec 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -252,6 +252,8 @@ enum
252 HRTIMER_SOFTIRQ, 252 HRTIMER_SOFTIRQ,
253#endif 253#endif
254 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */ 254 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
255
256 NR_SOFTIRQS
255}; 257};
256 258
257/* softirq mask and active fields moved to irq_cpustat_t in 259/* softirq mask and active fields moved to irq_cpustat_t in
diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h
index a6d0586e2bf7..3b068e5b5671 100644
--- a/include/linux/iommu-helper.h
+++ b/include/linux/iommu-helper.h
@@ -23,4 +23,7 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
23extern void iommu_area_free(unsigned long *map, unsigned long start, 23extern void iommu_area_free(unsigned long *map, unsigned long start,
24 unsigned int nr); 24 unsigned int nr);
25 25
26extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len,
27 unsigned long io_page_size);
28
26#endif 29#endif
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index ee9bcc6f32b6..041e95aac2bf 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -34,7 +34,8 @@ struct resource_list {
34 */ 34 */
35#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ 35#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
36 36
37#define IORESOURCE_IO 0x00000100 /* Resource type */ 37#define IORESOURCE_TYPE_BITS 0x00000f00 /* Resource type */
38#define IORESOURCE_IO 0x00000100
38#define IORESOURCE_MEM 0x00000200 39#define IORESOURCE_MEM 0x00000200
39#define IORESOURCE_IRQ 0x00000400 40#define IORESOURCE_IRQ 0x00000400
40#define IORESOURCE_DMA 0x00000800 41#define IORESOURCE_DMA 0x00000800
@@ -126,6 +127,10 @@ static inline resource_size_t resource_size(struct resource *res)
126{ 127{
127 return res->end - res->start + 1; 128 return res->end - res->start + 1;
128} 129}
130static inline unsigned long resource_type(struct resource *res)
131{
132 return res->flags & IORESOURCE_TYPE_BITS;
133}
129 134
130/* Convenience shorthand with allocation */ 135/* Convenience shorthand with allocation */
131#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name)) 136#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
@@ -169,6 +174,7 @@ extern struct resource * __devm_request_region(struct device *dev,
169 174
170extern void __devm_release_region(struct device *dev, struct resource *parent, 175extern void __devm_release_region(struct device *dev, struct resource *parent,
171 resource_size_t start, resource_size_t n); 176 resource_size_t start, resource_size_t n);
177extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size);
172 178
173#endif /* __ASSEMBLY__ */ 179#endif /* __ASSEMBLY__ */
174#endif /* _LINUX_IOPORT_H */ 180#endif /* _LINUX_IOPORT_H */
diff --git a/drivers/pci/iova.h b/include/linux/iova.h
index 228f6c94b69c..228f6c94b69c 100644
--- a/drivers/pci/iova.h
+++ b/include/linux/iova.h
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 07a9b52a2654..7ebbcb1c9ba4 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -61,7 +61,7 @@ extern u8 journal_enable_debug;
61 do { \ 61 do { \
62 if ((n) <= journal_enable_debug) { \ 62 if ((n) <= journal_enable_debug) { \
63 printk (KERN_DEBUG "(%s, %d): %s: ", \ 63 printk (KERN_DEBUG "(%s, %d): %s: ", \
64 __FILE__, __LINE__, __FUNCTION__); \ 64 __FILE__, __LINE__, __func__); \
65 printk (f, ## a); \ 65 printk (f, ## a); \
66 } \ 66 } \
67 } while (0) 67 } while (0)
@@ -984,7 +984,7 @@ extern int cleanup_journal_tail(journal_t *);
984 984
985#define jbd_ENOSYS() \ 985#define jbd_ENOSYS() \
986do { \ 986do { \
987 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \ 987 printk (KERN_ERR "JBD unimplemented function %s\n", __func__); \
988 current->state = TASK_UNINTERRUPTIBLE; \ 988 current->state = TASK_UNINTERRUPTIBLE; \
989 schedule(); \ 989 schedule(); \
990} while (1) 990} while (1)
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index d2e91ea998fd..463d6f10b64f 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -61,7 +61,7 @@ extern u8 jbd2_journal_enable_debug;
61 do { \ 61 do { \
62 if ((n) <= jbd2_journal_enable_debug) { \ 62 if ((n) <= jbd2_journal_enable_debug) { \
63 printk (KERN_DEBUG "(%s, %d): %s: ", \ 63 printk (KERN_DEBUG "(%s, %d): %s: ", \
64 __FILE__, __LINE__, __FUNCTION__); \ 64 __FILE__, __LINE__, __func__); \
65 printk (f, ## a); \ 65 printk (f, ## a); \
66 } \ 66 } \
67 } while (0) 67 } while (0)
@@ -1143,7 +1143,7 @@ extern int jbd2_cleanup_journal_tail(journal_t *);
1143 1143
1144#define jbd_ENOSYS() \ 1144#define jbd_ENOSYS() \
1145do { \ 1145do { \
1146 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \ 1146 printk (KERN_ERR "JBD unimplemented function %s\n", __func__); \
1147 current->state = TASK_UNINTERRUPTIBLE; \ 1147 current->state = TASK_UNINTERRUPTIBLE; \
1148 schedule(); \ 1148 schedule(); \
1149} while (1) 1149} while (1)
diff --git a/include/linux/journal-head.h b/include/linux/journal-head.h
index 8a62d1e84b9b..bb70ebb6a2d5 100644
--- a/include/linux/journal-head.h
+++ b/include/linux/journal-head.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * buffer_head fields for JBD 4 * buffer_head fields for JBD
5 * 5 *
6 * 27 May 2001 Andrew Morton <akpm@digeo.com> 6 * 27 May 2001 Andrew Morton
7 * Created - pulled out of fs.h 7 * Created - pulled out of fs.h
8 */ 8 */
9 9
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index b96144887444..f3fe34391d8e 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -93,12 +93,10 @@ static inline void print_symbol(const char *fmt, unsigned long addr)
93} 93}
94 94
95/* 95/*
96 * Pretty-print a function pointer. 96 * Pretty-print a function pointer. This function is deprecated.
97 * 97 * Please use the "%pF" vsprintf format instead.
98 * ia64 and ppc64 function pointers are really function descriptors,
99 * which contain a pointer the real address.
100 */ 98 */
101static inline void print_fn_descriptor_symbol(const char *fmt, void *addr) 99static inline void __deprecated print_fn_descriptor_symbol(const char *fmt, void *addr)
102{ 100{
103#if defined(CONFIG_IA64) || defined(CONFIG_PPC64) 101#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
104 addr = *(void **)addr; 102 addr = *(void **)addr;
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 75d81f157d2e..6803318fa2ea 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -16,6 +16,7 @@
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/typecheck.h> 17#include <linux/typecheck.h>
18#include <linux/ratelimit.h> 18#include <linux/ratelimit.h>
19#include <linux/dynamic_printk.h>
19#include <asm/byteorder.h> 20#include <asm/byteorder.h>
20#include <asm/bug.h> 21#include <asm/bug.h>
21 22
@@ -213,6 +214,9 @@ static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
213 { return false; } 214 { return false; }
214#endif 215#endif
215 216
217extern int printk_needs_cpu(int cpu);
218extern void printk_tick(void);
219
216extern void asmlinkage __attribute__((format(printf, 1, 2))) 220extern void asmlinkage __attribute__((format(printf, 1, 2)))
217 early_printk(const char *fmt, ...); 221 early_printk(const char *fmt, ...);
218 222
@@ -235,9 +239,10 @@ extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in
235extern int panic_timeout; 239extern int panic_timeout;
236extern int panic_on_oops; 240extern int panic_on_oops;
237extern int panic_on_unrecovered_nmi; 241extern int panic_on_unrecovered_nmi;
238extern int tainted;
239extern const char *print_tainted(void); 242extern const char *print_tainted(void);
240extern void add_taint(unsigned); 243extern void add_taint(unsigned flag);
244extern int test_taint(unsigned flag);
245extern unsigned long get_taint(void);
241extern int root_mountflags; 246extern int root_mountflags;
242 247
243/* Values used for system_state */ 248/* Values used for system_state */
@@ -250,16 +255,16 @@ extern enum system_states {
250 SYSTEM_SUSPEND_DISK, 255 SYSTEM_SUSPEND_DISK,
251} system_state; 256} system_state;
252 257
253#define TAINT_PROPRIETARY_MODULE (1<<0) 258#define TAINT_PROPRIETARY_MODULE 0
254#define TAINT_FORCED_MODULE (1<<1) 259#define TAINT_FORCED_MODULE 1
255#define TAINT_UNSAFE_SMP (1<<2) 260#define TAINT_UNSAFE_SMP 2
256#define TAINT_FORCED_RMMOD (1<<3) 261#define TAINT_FORCED_RMMOD 3
257#define TAINT_MACHINE_CHECK (1<<4) 262#define TAINT_MACHINE_CHECK 4
258#define TAINT_BAD_PAGE (1<<5) 263#define TAINT_BAD_PAGE 5
259#define TAINT_USER (1<<6) 264#define TAINT_USER 6
260#define TAINT_DIE (1<<7) 265#define TAINT_DIE 7
261#define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8) 266#define TAINT_OVERRIDDEN_ACPI_TABLE 8
262#define TAINT_WARN (1<<9) 267#define TAINT_WARN 9
263 268
264extern void dump_stack(void) __cold; 269extern void dump_stack(void) __cold;
265 270
@@ -303,8 +308,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
303#define pr_info(fmt, arg...) \ 308#define pr_info(fmt, arg...) \
304 printk(KERN_INFO fmt, ##arg) 309 printk(KERN_INFO fmt, ##arg)
305 310
306#ifdef DEBUG
307/* If you are writing a driver, please use dev_dbg instead */ 311/* If you are writing a driver, please use dev_dbg instead */
312#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
313#define pr_debug(fmt, ...) do { \
314 dynamic_pr_debug(fmt, ##__VA_ARGS__); \
315 } while (0)
316#elif defined(DEBUG)
308#define pr_debug(fmt, arg...) \ 317#define pr_debug(fmt, arg...) \
309 printk(KERN_DEBUG fmt, ##arg) 318 printk(KERN_DEBUG fmt, ##arg)
310#else 319#else
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index a1a91577813c..92213a9194e1 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -99,4 +99,7 @@ struct file;
99extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[], 99extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
100 struct file **filp); 100 struct file **filp);
101 101
102extern int usermodehelper_disable(void);
103extern void usermodehelper_enable(void);
104
102#endif /* __LINUX_KMOD_H__ */ 105#endif /* __LINUX_KMOD_H__ */
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 70a30651cd12..797fcd781242 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -311,22 +311,33 @@ struct kvm_s390_interrupt {
311 311
312/* This structure represents a single trace buffer record. */ 312/* This structure represents a single trace buffer record. */
313struct kvm_trace_rec { 313struct kvm_trace_rec {
314 __u32 event:28; 314 /* variable rec_val
315 __u32 extra_u32:3; 315 * is split into:
316 __u32 cycle_in:1; 316 * bits 0 - 27 -> event id
317 * bits 28 -30 -> number of extra data args of size u32
318 * bits 31 -> binary indicator for if tsc is in record
319 */
320 __u32 rec_val;
317 __u32 pid; 321 __u32 pid;
318 __u32 vcpu_id; 322 __u32 vcpu_id;
319 union { 323 union {
320 struct { 324 struct {
321 __u64 cycle_u64; 325 __u64 timestamp;
322 __u32 extra_u32[KVM_TRC_EXTRA_MAX]; 326 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
323 } __attribute__((packed)) cycle; 327 } __attribute__((packed)) timestamp;
324 struct { 328 struct {
325 __u32 extra_u32[KVM_TRC_EXTRA_MAX]; 329 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
326 } nocycle; 330 } notimestamp;
327 } u; 331 } u;
328}; 332};
329 333
334#define TRACE_REC_EVENT_ID(val) \
335 (0x0fffffff & (val))
336#define TRACE_REC_NUM_DATA_ARGS(val) \
337 (0x70000000 & ((val) << 28))
338#define TRACE_REC_TCS(val) \
339 (0x80000000 & ((val) << 31))
340
330#define KVMIO 0xAE 341#define KVMIO 0xAE
331 342
332/* 343/*
@@ -372,6 +383,10 @@ struct kvm_trace_rec {
372#define KVM_CAP_MP_STATE 14 383#define KVM_CAP_MP_STATE 14
373#define KVM_CAP_COALESCED_MMIO 15 384#define KVM_CAP_COALESCED_MMIO 15
374#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 385#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */
386#if defined(CONFIG_X86)||defined(CONFIG_IA64)
387#define KVM_CAP_DEVICE_ASSIGNMENT 17
388#endif
389#define KVM_CAP_IOMMU 18
375 390
376/* 391/*
377 * ioctls for VM fds 392 * ioctls for VM fds
@@ -401,6 +416,10 @@ struct kvm_trace_rec {
401 _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 416 _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
402#define KVM_UNREGISTER_COALESCED_MMIO \ 417#define KVM_UNREGISTER_COALESCED_MMIO \
403 _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 418 _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
419#define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \
420 struct kvm_assigned_pci_dev)
421#define KVM_ASSIGN_IRQ _IOR(KVMIO, 0x70, \
422 struct kvm_assigned_irq)
404 423
405/* 424/*
406 * ioctls for vcpu fds 425 * ioctls for vcpu fds
@@ -440,4 +459,45 @@ struct kvm_trace_rec {
440#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 459#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
441#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 460#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
442 461
462#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
463#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
464#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
465#define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
466#define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
467#define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
468#define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
469#define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
470#define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
471#define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
472#define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
473#define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
474#define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
475#define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
476#define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
477#define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
478#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
479#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
480#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
481#define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
482#define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16)
483#define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17)
484#define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18)
485#define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19)
486
487struct kvm_assigned_pci_dev {
488 __u32 assigned_dev_id;
489 __u32 busnr;
490 __u32 devfn;
491 __u32 flags;
492};
493
494struct kvm_assigned_irq {
495 __u32 assigned_dev_id;
496 __u32 host_irq;
497 __u32 guest_irq;
498 __u32 flags;
499};
500
501#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
502
443#endif 503#endif
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 8525afc53107..3833c48fae3a 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -34,6 +34,8 @@
34#define KVM_REQ_MMU_RELOAD 3 34#define KVM_REQ_MMU_RELOAD 3
35#define KVM_REQ_TRIPLE_FAULT 4 35#define KVM_REQ_TRIPLE_FAULT 4
36#define KVM_REQ_PENDING_TIMER 5 36#define KVM_REQ_PENDING_TIMER 5
37#define KVM_REQ_UNHALT 6
38#define KVM_REQ_MMU_SYNC 7
37 39
38struct kvm_vcpu; 40struct kvm_vcpu;
39extern struct kmem_cache *kvm_vcpu_cache; 41extern struct kmem_cache *kvm_vcpu_cache;
@@ -279,12 +281,68 @@ void kvm_free_physmem(struct kvm *kvm);
279 281
280struct kvm *kvm_arch_create_vm(void); 282struct kvm *kvm_arch_create_vm(void);
281void kvm_arch_destroy_vm(struct kvm *kvm); 283void kvm_arch_destroy_vm(struct kvm *kvm);
284void kvm_free_all_assigned_devices(struct kvm *kvm);
282 285
283int kvm_cpu_get_interrupt(struct kvm_vcpu *v); 286int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
284int kvm_cpu_has_interrupt(struct kvm_vcpu *v); 287int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
285int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); 288int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
286void kvm_vcpu_kick(struct kvm_vcpu *vcpu); 289void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
287 290
291int kvm_is_mmio_pfn(pfn_t pfn);
292
293struct kvm_irq_ack_notifier {
294 struct hlist_node link;
295 unsigned gsi;
296 void (*irq_acked)(struct kvm_irq_ack_notifier *kian);
297};
298
299struct kvm_assigned_dev_kernel {
300 struct kvm_irq_ack_notifier ack_notifier;
301 struct work_struct interrupt_work;
302 struct list_head list;
303 int assigned_dev_id;
304 int host_busnr;
305 int host_devfn;
306 int host_irq;
307 int guest_irq;
308 int irq_requested;
309 struct pci_dev *dev;
310 struct kvm *kvm;
311};
312void kvm_set_irq(struct kvm *kvm, int irq, int level);
313void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
314void kvm_register_irq_ack_notifier(struct kvm *kvm,
315 struct kvm_irq_ack_notifier *kian);
316void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
317 struct kvm_irq_ack_notifier *kian);
318
319#ifdef CONFIG_DMAR
320int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
321 unsigned long npages);
322int kvm_iommu_map_guest(struct kvm *kvm,
323 struct kvm_assigned_dev_kernel *assigned_dev);
324int kvm_iommu_unmap_guest(struct kvm *kvm);
325#else /* CONFIG_DMAR */
326static inline int kvm_iommu_map_pages(struct kvm *kvm,
327 gfn_t base_gfn,
328 unsigned long npages)
329{
330 return 0;
331}
332
333static inline int kvm_iommu_map_guest(struct kvm *kvm,
334 struct kvm_assigned_dev_kernel
335 *assigned_dev)
336{
337 return -ENODEV;
338}
339
340static inline int kvm_iommu_unmap_guest(struct kvm *kvm)
341{
342 return 0;
343}
344#endif /* CONFIG_DMAR */
345
288static inline void kvm_guest_enter(void) 346static inline void kvm_guest_enter(void)
289{ 347{
290 account_system_vtime(current); 348 account_system_vtime(current);
@@ -307,6 +365,11 @@ static inline gpa_t gfn_to_gpa(gfn_t gfn)
307 return (gpa_t)gfn << PAGE_SHIFT; 365 return (gpa_t)gfn << PAGE_SHIFT;
308} 366}
309 367
368static inline hpa_t pfn_to_hpa(pfn_t pfn)
369{
370 return (hpa_t)pfn << PAGE_SHIFT;
371}
372
310static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu) 373static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu)
311{ 374{
312 set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests); 375 set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests);
@@ -326,6 +389,25 @@ struct kvm_stats_debugfs_item {
326extern struct kvm_stats_debugfs_item debugfs_entries[]; 389extern struct kvm_stats_debugfs_item debugfs_entries[];
327extern struct dentry *kvm_debugfs_dir; 390extern struct dentry *kvm_debugfs_dir;
328 391
392#define KVMTRACE_5D(evt, vcpu, d1, d2, d3, d4, d5, name) \
393 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
394 vcpu, 5, d1, d2, d3, d4, d5)
395#define KVMTRACE_4D(evt, vcpu, d1, d2, d3, d4, name) \
396 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
397 vcpu, 4, d1, d2, d3, d4, 0)
398#define KVMTRACE_3D(evt, vcpu, d1, d2, d3, name) \
399 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
400 vcpu, 3, d1, d2, d3, 0, 0)
401#define KVMTRACE_2D(evt, vcpu, d1, d2, name) \
402 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
403 vcpu, 2, d1, d2, 0, 0, 0)
404#define KVMTRACE_1D(evt, vcpu, d1, name) \
405 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
406 vcpu, 1, d1, 0, 0, 0, 0)
407#define KVMTRACE_0D(evt, vcpu, name) \
408 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
409 vcpu, 0, 0, 0, 0, 0, 0)
410
329#ifdef CONFIG_KVM_TRACE 411#ifdef CONFIG_KVM_TRACE
330int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg); 412int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg);
331void kvm_trace_cleanup(void); 413void kvm_trace_cleanup(void);
diff --git a/drivers/input/misc/map_to_7segment.h b/include/linux/map_to_7segment.h
index a424094d9fe2..7df8432c4402 100644
--- a/drivers/input/misc/map_to_7segment.h
+++ b/include/linux/map_to_7segment.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/usb/input/map_to_7segment.h
3 *
4 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> 2 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com>
5 * 3 *
6 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
@@ -36,7 +34,7 @@
36 * Usage: 34 * Usage:
37 * 35 *
38 * Register a map variable, and fill it with a character set: 36 * Register a map variable, and fill it with a character set:
39 * static SEG7_DEFAULT_MAP(map_seg7); 37 * static SEG7_DEFAULT_MAP(map_seg7);
40 * 38 *
41 * 39 *
42 * Then use for conversion: 40 * Then use for conversion:
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index ec612e66391c..516d955ab8a1 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -1,6 +1,8 @@
1#ifndef MFD_TMIO_H 1#ifndef MFD_TMIO_H
2#define MFD_TMIO_H 2#define MFD_TMIO_H
3 3
4#include <linux/fb.h>
5
4#define tmio_ioread8(addr) readb(addr) 6#define tmio_ioread8(addr) readb(addr)
5#define tmio_ioread16(addr) readw(addr) 7#define tmio_ioread16(addr) readw(addr)
6#define tmio_ioread16_rep(r, b, l) readsw(r, b, l) 8#define tmio_ioread16_rep(r, b, l) readsw(r, b, l)
@@ -25,4 +27,21 @@ struct tmio_nand_data {
25 unsigned int num_partitions; 27 unsigned int num_partitions;
26}; 28};
27 29
30#define FBIO_TMIO_ACC_WRITE 0x7C639300
31#define FBIO_TMIO_ACC_SYNC 0x7C639301
32
33struct tmio_fb_data {
34 int (*lcd_set_power)(struct platform_device *fb_dev,
35 bool on);
36 int (*lcd_mode)(struct platform_device *fb_dev,
37 const struct fb_videomode *mode);
38 int num_modes;
39 struct fb_videomode *modes;
40
41 /* in mm: size of screen */
42 int height;
43 int width;
44};
45
46
28#endif 47#endif
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index d6a3f47e95cb..eb71b45fdf5a 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -284,7 +284,7 @@ struct pcmcia_device_id {
284/* Input */ 284/* Input */
285#define INPUT_DEVICE_ID_EV_MAX 0x1f 285#define INPUT_DEVICE_ID_EV_MAX 0x1f
286#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 286#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71
287#define INPUT_DEVICE_ID_KEY_MAX 0x1ff 287#define INPUT_DEVICE_ID_KEY_MAX 0x2ff
288#define INPUT_DEVICE_ID_REL_MAX 0x0f 288#define INPUT_DEVICE_ID_REL_MAX 0x0f
289#define INPUT_DEVICE_ID_ABS_MAX 0x3f 289#define INPUT_DEVICE_ID_ABS_MAX 0x3f
290#define INPUT_DEVICE_ID_MSC_MAX 0x07 290#define INPUT_DEVICE_ID_MSC_MAX 0x07
diff --git a/include/linux/module.h b/include/linux/module.h
index 68e09557c951..a41555cbe00a 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -345,7 +345,6 @@ struct module
345 /* Reference counts */ 345 /* Reference counts */
346 struct module_ref ref[NR_CPUS]; 346 struct module_ref ref[NR_CPUS];
347#endif 347#endif
348
349}; 348};
350#ifndef MODULE_ARCH_INIT 349#ifndef MODULE_ARCH_INIT
351#define MODULE_ARCH_INIT {} 350#define MODULE_ARCH_INIT {}
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 30a1d63b6fb5..cab2a85e2ee8 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -5,8 +5,6 @@
5 * 5 *
6 * Author: Marco van Wieringen <mvw@planets.elm.net> 6 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 * 7 *
8 * Version: $Id: mount.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
9 *
10 */ 8 */
11#ifndef _LINUX_MOUNT_H 9#ifndef _LINUX_MOUNT_H
12#define _LINUX_MOUNT_H 10#define _LINUX_MOUNT_H
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 0d8424f76899..7d8e0455ccac 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -78,6 +78,9 @@ extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group,
78 int echo); 78 int echo);
79extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags); 79extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
80 80
81extern void nfnl_lock(void);
82extern void nfnl_unlock(void);
83
81#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ 84#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
82 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) 85 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
83 86
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 78a5922a2f11..ac8d0233b05c 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -137,7 +137,7 @@ struct nfs_inode {
137 unsigned long attrtimeo_timestamp; 137 unsigned long attrtimeo_timestamp;
138 __u64 change_attr; /* v4 only */ 138 __u64 change_attr; /* v4 only */
139 139
140 unsigned long last_updated; 140 unsigned long attr_gencount;
141 /* "Generation counter" for the attribute cache. This is 141 /* "Generation counter" for the attribute cache. This is
142 * bumped whenever we update the metadata on the 142 * bumped whenever we update the metadata on the
143 * server. 143 * server.
@@ -200,11 +200,10 @@ struct nfs_inode {
200/* 200/*
201 * Bit offsets in flags field 201 * Bit offsets in flags field
202 */ 202 */
203#define NFS_INO_REVALIDATING (0) /* revalidating attrs */ 203#define NFS_INO_ADVISE_RDPLUS (0) /* advise readdirplus */
204#define NFS_INO_ADVISE_RDPLUS (1) /* advise readdirplus */ 204#define NFS_INO_STALE (1) /* possible stale inode */
205#define NFS_INO_STALE (2) /* possible stale inode */ 205#define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */
206#define NFS_INO_ACL_LRU_SET (3) /* Inode is on the LRU list */ 206#define NFS_INO_MOUNTPOINT (3) /* inode is remote mountpoint */
207#define NFS_INO_MOUNTPOINT (4) /* inode is remote mountpoint */
208 207
209static inline struct nfs_inode *NFS_I(const struct inode *inode) 208static inline struct nfs_inode *NFS_I(const struct inode *inode)
210{ 209{
@@ -345,15 +344,11 @@ extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ct
345extern void put_nfs_open_context(struct nfs_open_context *ctx); 344extern void put_nfs_open_context(struct nfs_open_context *ctx);
346extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); 345extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode);
347extern u64 nfs_compat_user_ino64(u64 fileid); 346extern u64 nfs_compat_user_ino64(u64 fileid);
347extern void nfs_fattr_init(struct nfs_fattr *fattr);
348 348
349/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ 349/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
350extern __be32 root_nfs_parse_addr(char *name); /*__init*/ 350extern __be32 root_nfs_parse_addr(char *name); /*__init*/
351 351extern unsigned long nfs_inc_attr_generation_counter(void);
352static inline void nfs_fattr_init(struct nfs_fattr *fattr)
353{
354 fattr->valid = 0;
355 fattr->time_start = jiffies;
356}
357 352
358/* 353/*
359 * linux/fs/nfs/file.c 354 * linux/fs/nfs/file.c
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index c9beacd16c00..4e477ae58699 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -119,7 +119,6 @@ struct nfs_server {
119 void (*destroy)(struct nfs_server *); 119 void (*destroy)(struct nfs_server *);
120 120
121 atomic_t active; /* Keep trace of any activity to this server */ 121 atomic_t active; /* Keep trace of any activity to this server */
122 wait_queue_head_t active_wq; /* Wait for any activity to stop */
123 122
124 /* mountd-related mount options */ 123 /* mountd-related mount options */
125 struct sockaddr_storage mountd_address; 124 struct sockaddr_storage mountd_address;
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index df7c6b7a7ebb..6549a06ac16e 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -65,4 +65,8 @@ struct nfs_mount_data {
65#define NFS_MOUNT_UNSHARED 0x8000 /* 5 */ 65#define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
66#define NFS_MOUNT_FLAGMASK 0xFFFF 66#define NFS_MOUNT_FLAGMASK 0xFFFF
67 67
68/* The following are for internal use only */
69#define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
70#define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000
71
68#endif 72#endif
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 8c77c11224d1..c1c31acb8a2b 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -36,6 +36,7 @@ struct nfs_fattr {
36 __u32 nlink; 36 __u32 nlink;
37 __u32 uid; 37 __u32 uid;
38 __u32 gid; 38 __u32 gid;
39 dev_t rdev;
39 __u64 size; 40 __u64 size;
40 union { 41 union {
41 struct { 42 struct {
@@ -46,7 +47,6 @@ struct nfs_fattr {
46 __u64 used; 47 __u64 used;
47 } nfs3; 48 } nfs3;
48 } du; 49 } du;
49 dev_t rdev;
50 struct nfs_fsid fsid; 50 struct nfs_fsid fsid;
51 __u64 fileid; 51 __u64 fileid;
52 struct timespec atime; 52 struct timespec atime;
@@ -56,6 +56,7 @@ struct nfs_fattr {
56 __u64 change_attr; /* NFSv4 change attribute */ 56 __u64 change_attr; /* NFSv4 change attribute */
57 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ 57 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
58 unsigned long time_start; 58 unsigned long time_start;
59 unsigned long gencount;
59}; 60};
60 61
61#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */ 62#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
@@ -672,16 +673,16 @@ struct nfs4_rename_res {
672 struct nfs_fattr * new_fattr; 673 struct nfs_fattr * new_fattr;
673}; 674};
674 675
675#define NFS4_SETCLIENTID_NAMELEN (56) 676#define NFS4_SETCLIENTID_NAMELEN (127)
676struct nfs4_setclientid { 677struct nfs4_setclientid {
677 const nfs4_verifier * sc_verifier; 678 const nfs4_verifier * sc_verifier;
678 unsigned int sc_name_len; 679 unsigned int sc_name_len;
679 char sc_name[NFS4_SETCLIENTID_NAMELEN]; 680 char sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
680 u32 sc_prog; 681 u32 sc_prog;
681 unsigned int sc_netid_len; 682 unsigned int sc_netid_len;
682 char sc_netid[RPCBIND_MAXNETIDLEN]; 683 char sc_netid[RPCBIND_MAXNETIDLEN + 1];
683 unsigned int sc_uaddr_len; 684 unsigned int sc_uaddr_len;
684 char sc_uaddr[RPCBIND_MAXUADDRLEN]; 685 char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
685 u32 sc_cb_ident; 686 u32 sc_cb_ident;
686}; 687};
687 688
diff --git a/include/linux/parport.h b/include/linux/parport.h
index 6a0d7cdb5774..e1f83c5065c5 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -1,5 +1,3 @@
1/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */
2
3/* 1/*
4 * Any part of this program may be used in documents licensed under 2 * Any part of this program may be used in documents licensed under
5 * the GNU Free Documentation License, Version 1.1 or any later version 3 * the GNU Free Documentation License, Version 1.1 or any later version
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 1176f1f177e2..8edddc240e4f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -587,6 +587,7 @@
587#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 587#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
588#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 588#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
589#define PCI_DEVICE_ID_MATROX_G400 0x0525 589#define PCI_DEVICE_ID_MATROX_G400 0x0525
590#define PCI_DEVICE_ID_MATROX_G200EV_PCI 0x0530
590#define PCI_DEVICE_ID_MATROX_G550 0x2527 591#define PCI_DEVICE_ID_MATROX_G550 0x2527
591#define PCI_DEVICE_ID_MATROX_VIA 0x4536 592#define PCI_DEVICE_ID_MATROX_VIA 0x4536
592 593
diff --git a/include/linux/pfn.h b/include/linux/pfn.h
index bb01f8b92b56..7646637221f3 100644
--- a/include/linux/pfn.h
+++ b/include/linux/pfn.h
@@ -1,9 +1,13 @@
1#ifndef _LINUX_PFN_H_ 1#ifndef _LINUX_PFN_H_
2#define _LINUX_PFN_H_ 2#define _LINUX_PFN_H_
3 3
4#ifndef __ASSEMBLY__
5#include <linux/types.h>
6#endif
7
4#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) 8#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
5#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) 9#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
6#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) 10#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
7#define PFN_PHYS(x) ((x) << PAGE_SHIFT) 11#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
8 12
9#endif 13#endif
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 1af82c4e17d4..d82fe825d62f 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -84,12 +84,6 @@ static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
84 return tsk->nsproxy->pid_ns; 84 return tsk->nsproxy->pid_ns;
85} 85}
86 86
87static inline struct task_struct *task_child_reaper(struct task_struct *tsk)
88{
89 BUG_ON(tsk != current);
90 return tsk->nsproxy->pid_ns->child_reaper;
91}
92
93void pidhash_init(void); 87void pidhash_init(void);
94void pidmap_init(void); 88void pidmap_init(void);
95 89
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 95ac21ab3a09..4b8cc6a32479 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -37,6 +37,8 @@ extern int platform_add_devices(struct platform_device **, int);
37 37
38extern struct platform_device *platform_device_register_simple(const char *, int id, 38extern struct platform_device *platform_device_register_simple(const char *, int id,
39 struct resource *, unsigned int); 39 struct resource *, unsigned int);
40extern struct platform_device *platform_device_register_data(struct device *,
41 const char *, int, const void *, size_t);
40 42
41extern struct platform_device *platform_device_alloc(const char *name, int id); 43extern struct platform_device *platform_device_alloc(const char *name, int id);
42extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 44extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 4dcce54b6d76..42de4003c4ee 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -419,7 +419,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
419 419
420#define suspend_report_result(fn, ret) \ 420#define suspend_report_result(fn, ret) \
421 do { \ 421 do { \
422 __suspend_report_result(__FUNCTION__, fn, ret); \ 422 __suspend_report_result(__func__, fn, ret); \
423 } while (0) 423 } while (0)
424 424
425#else /* !CONFIG_PM_SLEEP */ 425#else /* !CONFIG_PM_SLEEP */
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index be764e514e35..53b70fd1d9a5 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -22,9 +22,11 @@ struct pnp_dev;
22 * Resource Management 22 * Resource Management
23 */ 23 */
24#ifdef CONFIG_PNP 24#ifdef CONFIG_PNP
25struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); 25struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type,
26 unsigned int num);
26#else 27#else
27static inline struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned int type, unsigned int num) 28static inline struct resource *pnp_get_resource(struct pnp_dev *dev,
29 unsigned long type, unsigned int num)
28{ 30{
29 return NULL; 31 return NULL;
30} 32}
diff --git a/include/linux/profile.h b/include/linux/profile.h
index 7e7087239af5..570045053ce9 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -35,7 +35,9 @@ enum profile_type {
35extern int prof_on __read_mostly; 35extern int prof_on __read_mostly;
36 36
37/* init basic kernel profiler */ 37/* init basic kernel profiler */
38void __init profile_init(void); 38int profile_init(void);
39int profile_setup(char *str);
40int create_proc_profile(void);
39void profile_tick(int type); 41void profile_tick(int type);
40 42
41/* 43/*
@@ -84,9 +86,9 @@ struct pt_regs;
84 86
85#define prof_on 0 87#define prof_on 0
86 88
87static inline void profile_init(void) 89static inline int profile_init(void)
88{ 90{
89 return; 91 return 0;
90} 92}
91 93
92static inline void profile_tick(int type) 94static inline void profile_tick(int type)
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 376a05048bc5..40401b554484 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 *
32 * Version: $Id: quota.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
33 */ 31 */
34 32
35#ifndef _LINUX_QUOTA_ 33#ifndef _LINUX_QUOTA_
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index ca6b9b5c8d52..a558a4c1d35a 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -3,9 +3,6 @@
3 * macros expand to the right source-code. 3 * macros expand to the right source-code.
4 * 4 *
5 * Author: Marco van Wieringen <mvw@planets.elm.net> 5 * Author: Marco van Wieringen <mvw@planets.elm.net>
6 *
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
8 *
9 */ 6 */
10#ifndef _LINUX_QUOTAOPS_ 7#ifndef _LINUX_QUOTAOPS_
11#define _LINUX_QUOTAOPS_ 8#define _LINUX_QUOTAOPS_
diff --git a/include/linux/raid/linear.h b/include/linux/raid/linear.h
index 7e375111d007..f38b9c586afb 100644
--- a/include/linux/raid/linear.h
+++ b/include/linux/raid/linear.h
@@ -5,8 +5,8 @@
5 5
6struct dev_info { 6struct dev_info {
7 mdk_rdev_t *rdev; 7 mdk_rdev_t *rdev;
8 sector_t size; 8 sector_t num_sectors;
9 sector_t offset; 9 sector_t start_sector;
10}; 10};
11 11
12typedef struct dev_info dev_info_t; 12typedef struct dev_info dev_info_t;
@@ -15,9 +15,11 @@ struct linear_private_data
15{ 15{
16 struct linear_private_data *prev; /* earlier version */ 16 struct linear_private_data *prev; /* earlier version */
17 dev_info_t **hash_table; 17 dev_info_t **hash_table;
18 sector_t hash_spacing; 18 sector_t spacing;
19 sector_t array_sectors; 19 sector_t array_sectors;
20 int preshift; /* shift before dividing by hash_spacing */ 20 int sector_shift; /* shift before dividing
21 * by spacing
22 */
21 dev_info_t disks[0]; 23 dev_info_t disks[0];
22}; 24};
23 25
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
index dc0e3fcb9f28..82bea14cae1a 100644
--- a/include/linux/raid/md.h
+++ b/include/linux/raid/md.h
@@ -19,27 +19,7 @@
19#define _MD_H 19#define _MD_H
20 20
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/major.h>
23#include <linux/ioctl.h>
24#include <linux/types.h>
25#include <linux/bitops.h>
26#include <linux/module.h>
27#include <linux/hdreg.h>
28#include <linux/proc_fs.h>
29#include <linux/seq_file.h> 22#include <linux/seq_file.h>
30#include <linux/smp_lock.h>
31#include <linux/delay.h>
32#include <net/checksum.h>
33#include <linux/random.h>
34#include <linux/kernel_stat.h>
35#include <asm/io.h>
36#include <linux/completion.h>
37#include <linux/mempool.h>
38#include <linux/list.h>
39#include <linux/reboot.h>
40#include <linux/vmalloc.h>
41#include <linux/blkpg.h>
42#include <linux/bio.h>
43 23
44/* 24/*
45 * 'md_p.h' holds the 'physical' layout of RAID devices 25 * 'md_p.h' holds the 'physical' layout of RAID devices
@@ -74,19 +54,17 @@
74 54
75extern int mdp_major; 55extern int mdp_major;
76 56
77extern int register_md_personality (struct mdk_personality *p); 57extern int register_md_personality(struct mdk_personality *p);
78extern int unregister_md_personality (struct mdk_personality *p); 58extern int unregister_md_personality(struct mdk_personality *p);
79extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), 59extern mdk_thread_t * md_register_thread(void (*run) (mddev_t *mddev),
80 mddev_t *mddev, const char *name); 60 mddev_t *mddev, const char *name);
81extern void md_unregister_thread (mdk_thread_t *thread); 61extern void md_unregister_thread(mdk_thread_t *thread);
82extern void md_wakeup_thread(mdk_thread_t *thread); 62extern void md_wakeup_thread(mdk_thread_t *thread);
83extern void md_check_recovery(mddev_t *mddev); 63extern void md_check_recovery(mddev_t *mddev);
84extern void md_write_start(mddev_t *mddev, struct bio *bi); 64extern void md_write_start(mddev_t *mddev, struct bio *bi);
85extern void md_write_end(mddev_t *mddev); 65extern void md_write_end(mddev_t *mddev);
86extern void md_handle_safemode(mddev_t *mddev);
87extern void md_done_sync(mddev_t *mddev, int blocks, int ok); 66extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
88extern void md_error (mddev_t *mddev, mdk_rdev_t *rdev); 67extern void md_error(mddev_t *mddev, mdk_rdev_t *rdev);
89extern void md_unplug_mddev(mddev_t *mddev);
90 68
91extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev, 69extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
92 sector_t sector, int size, struct page *page); 70 sector_t sector, int size, struct page *page);
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index e9963af16cda..bc5114d35e99 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -87,7 +87,7 @@ void reiserfs_warning(struct super_block *s, const char *fmt, ...);
87if( !( cond ) ) \ 87if( !( cond ) ) \
88 reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at " \ 88 reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at " \
89 __FILE__ ":%i:%s: " format "\n", \ 89 __FILE__ ":%i:%s: " format "\n", \
90 in_interrupt() ? -1 : task_pid_nr(current), __LINE__ , __FUNCTION__ , ##args ) 90 in_interrupt() ? -1 : task_pid_nr(current), __LINE__ , __func__ , ##args )
91 91
92#define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args) 92#define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args)
93 93
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 382bb7951166..f19b00b7d530 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -54,7 +54,7 @@ struct hrtimer_sleeper;
54#ifdef CONFIG_DEBUG_RT_MUTEXES 54#ifdef CONFIG_DEBUG_RT_MUTEXES
55# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \ 55# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \
56 , .name = #mutexname, .file = __FILE__, .line = __LINE__ 56 , .name = #mutexname, .file = __FILE__, .line = __LINE__
57# define rt_mutex_init(mutex) __rt_mutex_init(mutex, __FUNCTION__) 57# define rt_mutex_init(mutex) __rt_mutex_init(mutex, __func__)
58 extern void rt_mutex_debug_task_free(struct task_struct *tsk); 58 extern void rt_mutex_debug_task_free(struct task_struct *tsk);
59#else 59#else
60# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) 60# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname)
diff --git a/include/linux/spi/orion_spi.h b/include/linux/spi/orion_spi.h
index b4d9fa6f797c..decf6d8c77b7 100644
--- a/include/linux/spi/orion_spi.h
+++ b/include/linux/spi/orion_spi.h
@@ -11,6 +11,7 @@
11 11
12struct orion_spi_info { 12struct orion_spi_info {
13 u32 tclk; /* no <linux/clk.h> support yet */ 13 u32 tclk; /* no <linux/clk.h> support yet */
14 u32 enable_clock_fix;
14}; 15};
15 16
16 17
diff --git a/include/linux/sunrpc/xprtrdma.h b/include/linux/sunrpc/xprtrdma.h
index 4de56b1d372b..54a379c9e8eb 100644
--- a/include/linux/sunrpc/xprtrdma.h
+++ b/include/linux/sunrpc/xprtrdma.h
@@ -66,9 +66,6 @@
66 66
67#define RPCRDMA_INLINE_PAD_THRESH (512)/* payload threshold to pad (bytes) */ 67#define RPCRDMA_INLINE_PAD_THRESH (512)/* payload threshold to pad (bytes) */
68 68
69#define RDMA_RESOLVE_TIMEOUT (5*HZ) /* TBD 5 seconds */
70#define RDMA_CONNECT_RETRY_MAX (2) /* retries if no listener backlog */
71
72/* memory registration strategies */ 69/* memory registration strategies */
73#define RPCRDMA_PERSISTENT_REGISTRATION (1) 70#define RPCRDMA_PERSISTENT_REGISTRATION (1)
74 71
@@ -78,6 +75,7 @@ enum rpcrdma_memreg {
78 RPCRDMA_MEMWINDOWS, 75 RPCRDMA_MEMWINDOWS,
79 RPCRDMA_MEMWINDOWS_ASYNC, 76 RPCRDMA_MEMWINDOWS_ASYNC,
80 RPCRDMA_MTHCAFMR, 77 RPCRDMA_MTHCAFMR,
78 RPCRDMA_FRMR,
81 RPCRDMA_ALLPHYSICAL, 79 RPCRDMA_ALLPHYSICAL,
82 RPCRDMA_LAST 80 RPCRDMA_LAST
83}; 81};
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
new file mode 100644
index 000000000000..b18ec5533e8c
--- /dev/null
+++ b/include/linux/swiotlb.h
@@ -0,0 +1,83 @@
1#ifndef __LINUX_SWIOTLB_H
2#define __LINUX_SWIOTLB_H
3
4#include <linux/types.h>
5
6struct device;
7struct dma_attrs;
8struct scatterlist;
9
10extern void
11swiotlb_init(void);
12
13extern void
14*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
15 dma_addr_t *dma_handle, gfp_t flags);
16
17extern void
18swiotlb_free_coherent(struct device *hwdev, size_t size,
19 void *vaddr, dma_addr_t dma_handle);
20
21extern dma_addr_t
22swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir);
23
24extern void
25swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
26 size_t size, int dir);
27
28extern dma_addr_t
29swiotlb_map_single_attrs(struct device *hwdev, void *ptr, size_t size,
30 int dir, struct dma_attrs *attrs);
31
32extern void
33swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr,
34 size_t size, int dir, struct dma_attrs *attrs);
35
36extern int
37swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
38 int direction);
39
40extern void
41swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
42 int direction);
43
44extern int
45swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
46 int dir, struct dma_attrs *attrs);
47
48extern void
49swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
50 int nelems, int dir, struct dma_attrs *attrs);
51
52extern void
53swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
54 size_t size, int dir);
55
56extern void
57swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
58 int nelems, int dir);
59
60extern void
61swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
62 size_t size, int dir);
63
64extern void
65swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
66 int nelems, int dir);
67
68extern void
69swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
70 unsigned long offset, size_t size, int dir);
71
72extern void
73swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
74 unsigned long offset, size_t size,
75 int dir);
76
77extern int
78swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
79
80extern int
81swiotlb_dma_supported(struct device *hwdev, u64 mask);
82
83#endif /* __LINUX_SWIOTLB_H */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index d0437f36921f..39d471d1163b 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -972,7 +972,7 @@ extern int sysctl_perm(struct ctl_table_root *root,
972 972
973typedef struct ctl_table ctl_table; 973typedef struct ctl_table ctl_table;
974 974
975typedef int ctl_handler (struct ctl_table *table, int __user *name, int nlen, 975typedef int ctl_handler (struct ctl_table *table,
976 void __user *oldval, size_t __user *oldlenp, 976 void __user *oldval, size_t __user *oldlenp,
977 void __user *newval, size_t newlen); 977 void __user *newval, size_t newlen);
978 978
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 37fa24152bd8..b330e289d71f 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -78,6 +78,8 @@ struct sysfs_ops {
78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
79}; 79};
80 80
81struct sysfs_dirent;
82
81#ifdef CONFIG_SYSFS 83#ifdef CONFIG_SYSFS
82 84
83int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), 85int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
@@ -117,9 +119,14 @@ int sysfs_add_file_to_group(struct kobject *kobj,
117void sysfs_remove_file_from_group(struct kobject *kobj, 119void sysfs_remove_file_from_group(struct kobject *kobj,
118 const struct attribute *attr, const char *group); 120 const struct attribute *attr, const char *group);
119 121
120void sysfs_notify(struct kobject *kobj, char *dir, char *attr); 122void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
121 123void sysfs_notify_dirent(struct sysfs_dirent *sd);
122extern int __must_check sysfs_init(void); 124struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
125 const unsigned char *name);
126struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
127void sysfs_put(struct sysfs_dirent *sd);
128void sysfs_printk_last_file(void);
129int __must_check sysfs_init(void);
123 130
124#else /* CONFIG_SYSFS */ 131#else /* CONFIG_SYSFS */
125 132
@@ -222,7 +229,24 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj,
222{ 229{
223} 230}
224 231
225static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) 232static inline void sysfs_notify(struct kobject *kobj, const char *dir,
233 const char *attr)
234{
235}
236static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
237{
238}
239static inline
240struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
241 const unsigned char *name)
242{
243 return NULL;
244}
245static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
246{
247 return NULL;
248}
249static inline void sysfs_put(struct sysfs_dirent *sd)
226{ 250{
227} 251}
228 252
@@ -231,6 +255,10 @@ static inline int __must_check sysfs_init(void)
231 return 0; 255 return 0;
232} 256}
233 257
258static inline void sysfs_printk_last_file(void)
259{
260}
261
234#endif /* CONFIG_SYSFS */ 262#endif /* CONFIG_SYSFS */
235 263
236#endif /* _SYSFS_H_ */ 264#endif /* _SYSFS_H_ */
diff --git a/include/linux/task_io_accounting.h b/include/linux/task_io_accounting.h
index 5e88afc9a2fb..bdf855c2856f 100644
--- a/include/linux/task_io_accounting.h
+++ b/include/linux/task_io_accounting.h
@@ -5,7 +5,7 @@
5 * Don't include this header file directly - it is designed to be dragged in via 5 * Don't include this header file directly - it is designed to be dragged in via
6 * sched.h. 6 * sched.h.
7 * 7 *
8 * Blame akpm@osdl.org for all this. 8 * Blame Andrew Morton for all this.
9 */ 9 */
10 10
11struct task_io_accounting { 11struct task_io_accounting {
diff --git a/include/linux/telephony.h b/include/linux/telephony.h
index 0d0cf2a1e7bc..5b2b6261f193 100644
--- a/include/linux/telephony.h
+++ b/include/linux/telephony.h
@@ -28,10 +28,6 @@
28 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION 28 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
29 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 29 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
30 * 30 *
31 * Version: $Revision: 4.2 $
32 *
33 * $Id: telephony.h,v 4.2 2001/08/06 07:09:43 craigs Exp $
34 *
35 *****************************************************************************/ 31 *****************************************************************************/
36 32
37#ifndef TELEPHONY_H 33#ifndef TELEPHONY_H
diff --git a/include/linux/time.h b/include/linux/time.h
index e15206a7e82e..51e883df0fa5 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -29,6 +29,8 @@ struct timezone {
29 29
30#ifdef __KERNEL__ 30#ifdef __KERNEL__
31 31
32extern struct timezone sys_tz;
33
32/* Parameters used to convert the timespec values: */ 34/* Parameters used to convert the timespec values: */
33#define MSEC_PER_SEC 1000L 35#define MSEC_PER_SEC 1000L
34#define USEC_PER_MSEC 1000L 36#define USEC_PER_MSEC 1000L
diff --git a/include/linux/types.h b/include/linux/types.h
index d4a9ce6e2760..f24f7beb47df 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -191,12 +191,14 @@ typedef __u32 __bitwise __wsum;
191#ifdef __KERNEL__ 191#ifdef __KERNEL__
192typedef unsigned __bitwise__ gfp_t; 192typedef unsigned __bitwise__ gfp_t;
193 193
194#ifdef CONFIG_RESOURCES_64BIT 194#ifdef CONFIG_PHYS_ADDR_T_64BIT
195typedef u64 resource_size_t; 195typedef u64 phys_addr_t;
196#else 196#else
197typedef u32 resource_size_t; 197typedef u32 phys_addr_t;
198#endif 198#endif
199 199
200typedef phys_addr_t resource_size_t;
201
200struct ustat { 202struct ustat {
201 __kernel_daddr_t f_tfree; 203 __kernel_daddr_t f_tfree;
202 __kernel_ino_t f_tinode; 204 __kernel_ino_t f_tinode;
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 0081147a9fe8..ef609f842fac 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -108,15 +108,6 @@ static inline int waitqueue_active(wait_queue_head_t *q)
108 return !list_empty(&q->task_list); 108 return !list_empty(&q->task_list);
109} 109}
110 110
111/*
112 * Used to distinguish between sync and async io wait context:
113 * sync i/o typically specifies a NULL wait queue entry or a wait
114 * queue entry bound to a task (current task) to wake up.
115 * aio specifies a wait queue entry with an async notification
116 * callback routine, not associated with any task.
117 */
118#define is_sync_wait(wait) (!(wait) || ((wait)->private))
119
120extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); 111extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
121extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait); 112extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait);
122extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); 113extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index 64a2ec746a3e..c5a6e22a4b37 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -24,7 +24,7 @@
24 24
25extern unsigned int saa7146_debug; 25extern unsigned int saa7146_debug;
26 26
27//#define DEBUG_PROLOG printk("(0x%08x)(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,RPS_ADDR0))),(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),KBUILD_MODNAME,__FUNCTION__) 27//#define DEBUG_PROLOG printk("(0x%08x)(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,RPS_ADDR0))),(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),KBUILD_MODNAME,__func__)
28 28
29#ifndef DEBUG_VARIABLE 29#ifndef DEBUG_VARIABLE
30 #define DEBUG_VARIABLE saa7146_debug 30 #define DEBUG_VARIABLE saa7146_debug
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index c3626c0ba9d3..fb163e2e0de6 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -61,7 +61,7 @@ extern unsigned int p9_debug_level;
61do { \ 61do { \
62 if ((p9_debug_level & level) == level) \ 62 if ((p9_debug_level & level) == level) \
63 printk(KERN_NOTICE "-- %s (%d): " \ 63 printk(KERN_NOTICE "-- %s (%d): " \
64 format , __FUNCTION__, task_pid_nr(current) , ## arg); \ 64 format , __func__, task_pid_nr(current) , ## arg); \
65} while (0) 65} while (0)
66 66
67#define PRINT_FCALL_ERROR(s, fcall) P9_DPRINTK(P9_DEBUG_ERROR, \ 67#define PRINT_FCALL_ERROR(s, fcall) P9_DPRINTK(P9_DEBUG_ERROR, \
@@ -76,7 +76,7 @@ do { \
76#define P9_EPRINTK(level, format, arg...) \ 76#define P9_EPRINTK(level, format, arg...) \
77do { \ 77do { \
78 printk(level "9p: %s (%d): " \ 78 printk(level "9p: %s (%d): " \
79 format , __FUNCTION__, task_pid_nr(current), ## arg); \ 79 format , __func__, task_pid_nr(current), ## arg); \
80} while (0) 80} while (0)
81 81
82/** 82/**
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 6f8418bf4241..996d12df7594 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -54,8 +54,8 @@
54#define SOL_RFCOMM 18 54#define SOL_RFCOMM 18
55 55
56#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg) 56#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
57#define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg) 57#define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __func__ , ## arg)
58#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg) 58#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
59 59
60/* Connection and socket states */ 60/* Connection and socket states */
61enum { 61enum {
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index 6048579d0b24..93a56de3594b 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -114,7 +114,7 @@ extern u32 ieee80211_debug_level;
114#define IEEE80211_DEBUG(level, fmt, args...) \ 114#define IEEE80211_DEBUG(level, fmt, args...) \
115do { if (ieee80211_debug_level & (level)) \ 115do { if (ieee80211_debug_level & (level)) \
116 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 116 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
117 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 117 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
118static inline bool ieee80211_ratelimit_debug(u32 level) 118static inline bool ieee80211_ratelimit_debug(u32 level)
119{ 119{
120 return (ieee80211_debug_level & level) && net_ratelimit(); 120 return (ieee80211_debug_level & level) && net_ratelimit();
diff --git a/include/net/ip.h b/include/net/ip.h
index 1cbccaf0de3f..bc026ecb513f 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -396,7 +396,7 @@ extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
396int ipv4_doint_and_flush(ctl_table *ctl, int write, 396int ipv4_doint_and_flush(ctl_table *ctl, int write,
397 struct file* filp, void __user *buffer, 397 struct file* filp, void __user *buffer,
398 size_t *lenp, loff_t *ppos); 398 size_t *lenp, loff_t *ppos);
399int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen, 399int ipv4_doint_and_flush_strategy(ctl_table *table,
400 void __user *oldval, size_t __user *oldlenp, 400 void __user *oldval, size_t __user *oldlenp,
401 void __user *newval, size_t newlen); 401 void __user *newval, size_t newlen);
402#ifdef CONFIG_PROC_FS 402#ifdef CONFIG_PROC_FS
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 0b2071d9326d..fe9fcf73c85e 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -165,13 +165,13 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
165 do { \ 165 do { \
166 if (level <= ip_vs_get_debug_level()) \ 166 if (level <= ip_vs_get_debug_level()) \
167 printk(KERN_DEBUG "Enter: %s, %s line %i\n", \ 167 printk(KERN_DEBUG "Enter: %s, %s line %i\n", \
168 __FUNCTION__, __FILE__, __LINE__); \ 168 __func__, __FILE__, __LINE__); \
169 } while (0) 169 } while (0)
170#define LeaveFunction(level) \ 170#define LeaveFunction(level) \
171 do { \ 171 do { \
172 if (level <= ip_vs_get_debug_level()) \ 172 if (level <= ip_vs_get_debug_level()) \
173 printk(KERN_DEBUG "Leave: %s, %s line %i\n", \ 173 printk(KERN_DEBUG "Leave: %s, %s line %i\n", \
174 __FUNCTION__, __FILE__, __LINE__); \ 174 __func__, __FILE__, __LINE__); \
175 } while (0) 175 } while (0)
176#else 176#else
177#define EnterFunction(level) do {} while (0) 177#define EnterFunction(level) do {} while (0)
diff --git a/include/net/irda/irda.h b/include/net/irda/irda.h
index 08387553b57e..7e582061b230 100644
--- a/include/net/irda/irda.h
+++ b/include/net/irda/irda.h
@@ -72,7 +72,7 @@ do { if (irda_debug >= (n)) \
72#define IRDA_ASSERT(expr, func) \ 72#define IRDA_ASSERT(expr, func) \
73do { if(!(expr)) { \ 73do { if(!(expr)) { \
74 printk( "Assertion failed! %s:%s:%d %s\n", \ 74 printk( "Assertion failed! %s:%s:%d %s\n", \
75 __FILE__,__FUNCTION__,__LINE__,(#expr) ); \ 75 __FILE__,__func__,__LINE__,(#expr) ); \
76 func } } while (0) 76 func } } while (0)
77#define IRDA_ASSERT_LABEL(label) label 77#define IRDA_ASSERT_LABEL(label) label
78#else 78#else
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5617a1613c91..d861197f83c7 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -645,7 +645,8 @@ enum ieee80211_key_flags {
645 * - Temporal Encryption Key (128 bits) 645 * - Temporal Encryption Key (128 bits)
646 * - Temporal Authenticator Tx MIC Key (64 bits) 646 * - Temporal Authenticator Tx MIC Key (64 bits)
647 * - Temporal Authenticator Rx MIC Key (64 bits) 647 * - Temporal Authenticator Rx MIC Key (64 bits)
648 * 648 * @icv_len: FIXME
649 * @iv_len: FIXME
649 */ 650 */
650struct ieee80211_key_conf { 651struct ieee80211_key_conf {
651 enum ieee80211_key_alg alg; 652 enum ieee80211_key_alg alg;
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index a01b7c4dc763..11dd0137c6a5 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -129,9 +129,8 @@ extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl,
129 void __user *buffer, 129 void __user *buffer,
130 size_t *lenp, 130 size_t *lenp,
131 loff_t *ppos); 131 loff_t *ppos);
132int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name, 132int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl,
133 int nlen, void __user *oldval, 133 void __user *oldval, size_t __user *oldlenp,
134 size_t __user *oldlenp,
135 void __user *newval, size_t newlen); 134 void __user *newval, size_t newlen);
136#endif 135#endif
137 136
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h
index f29eeb9777e0..58684066388c 100644
--- a/include/net/netfilter/nf_nat_core.h
+++ b/include/net/netfilter/nf_nat_core.h
@@ -25,4 +25,12 @@ static inline int nf_nat_initialized(struct nf_conn *ct,
25 else 25 else
26 return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status); 26 return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
27} 27}
28
29struct nlattr;
30
31extern int
32(*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct,
33 enum nf_nat_manip_type manip,
34 struct nlattr *attr);
35
28#endif /* _NF_NAT_CORE_H */ 36#endif /* _NF_NAT_CORE_H */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 703305d00365..ed71b110edf7 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -303,7 +303,7 @@ extern int sctp_debug_flag;
303#define SCTP_ASSERT(expr, str, func) \ 303#define SCTP_ASSERT(expr, str, func) \
304 if (!(expr)) { \ 304 if (!(expr)) { \
305 SCTP_DEBUG_PRINTK("Assertion Failed: %s(%s) at %s:%s:%d\n", \ 305 SCTP_DEBUG_PRINTK("Assertion Failed: %s(%s) at %s:%s:%d\n", \
306 str, (#expr), __FILE__, __FUNCTION__, __LINE__); \ 306 str, (#expr), __FILE__, __func__, __LINE__); \
307 func; \ 307 func; \
308 } 308 }
309 309
diff --git a/include/video/cyblafb.h b/include/video/cyblafb.h
index 717440575380..d3c1d4e2c8e3 100644
--- a/include/video/cyblafb.h
+++ b/include/video/cyblafb.h
@@ -4,7 +4,7 @@
4#endif 4#endif
5 5
6#if CYBLAFB_DEBUG 6#if CYBLAFB_DEBUG
7#define debug(f,a...) printk("%s:" f, __FUNCTION__ , ## a); 7#define debug(f,a...) printk("%s:" f, __func__ , ## a);
8#else 8#else
9#define debug(f,a...) 9#define debug(f,a...)
10#endif 10#endif
diff --git a/include/video/neomagic.h b/include/video/neomagic.h
index 38910da0ae59..08b663782956 100644
--- a/include/video/neomagic.h
+++ b/include/video/neomagic.h
@@ -123,7 +123,6 @@ typedef volatile struct {
123 123
124struct neofb_par { 124struct neofb_par {
125 struct vgastate state; 125 struct vgastate state;
126 struct mutex open_lock;
127 unsigned int ref_count; 126 unsigned int ref_count;
128 127
129 unsigned char MiscOutReg; /* Misc */ 128 unsigned char MiscOutReg; /* Misc */
diff --git a/include/video/radeon.h b/include/video/radeon.h
index 099ffa5e5bee..d5dcaf154ba4 100644
--- a/include/video/radeon.h
+++ b/include/video/radeon.h
@@ -386,7 +386,7 @@
386#define SC_BOTTOM_RIGHT 0x16F0 386#define SC_BOTTOM_RIGHT 0x16F0
387#define SRC_SC_BOTTOM_RIGHT 0x16F4 387#define SRC_SC_BOTTOM_RIGHT 0x16F4
388#define RB2D_DSTCACHE_MODE 0x3428 388#define RB2D_DSTCACHE_MODE 0x3428
389#define RB2D_DSTCACHE_CTLSTAT 0x342C 389#define RB2D_DSTCACHE_CTLSTAT_broken 0x342C /* do not use */
390#define LVDS_GEN_CNTL 0x02d0 390#define LVDS_GEN_CNTL 0x02d0
391#define LVDS_PLL_CNTL 0x02d4 391#define LVDS_PLL_CNTL 0x02d4
392#define FP2_GEN_CNTL 0x0288 392#define FP2_GEN_CNTL 0x0288
@@ -525,6 +525,9 @@
525#define CRTC_DISPLAY_DIS (1 << 10) 525#define CRTC_DISPLAY_DIS (1 << 10)
526#define CRTC_CRT_ON (1 << 15) 526#define CRTC_CRT_ON (1 << 15)
527 527
528/* DSTCACHE_MODE bits constants */
529#define RB2D_DC_AUTOFLUSH_ENABLE (1 << 8)
530#define RB2D_DC_DC_DISABLE_IGNORE_PE (1 << 17)
528 531
529/* DSTCACHE_CTLSTAT bit constants */ 532/* DSTCACHE_CTLSTAT bit constants */
530#define RB2D_DC_FLUSH_2D (1 << 0) 533#define RB2D_DC_FLUSH_2D (1 << 0)
@@ -532,6 +535,9 @@
532#define RB2D_DC_FLUSH_ALL (RB2D_DC_FLUSH_2D | RB2D_DC_FREE_2D) 535#define RB2D_DC_FLUSH_ALL (RB2D_DC_FLUSH_2D | RB2D_DC_FREE_2D)
533#define RB2D_DC_BUSY (1 << 31) 536#define RB2D_DC_BUSY (1 << 31)
534 537
538/* DSTCACHE_MODE bits constants */
539#define RB2D_DC_AUTOFLUSH_ENABLE (1 << 8)
540#define RB2D_DC_DC_DISABLE_IGNORE_PE (1 << 17)
535 541
536/* CRTC_GEN_CNTL bit constants */ 542/* CRTC_GEN_CNTL bit constants */
537#define CRTC_DBL_SCAN_EN 0x00000001 543#define CRTC_DBL_SCAN_EN 0x00000001
@@ -863,15 +869,10 @@
863#define GMC_DST_16BPP_YVYU422 0x00000c00 869#define GMC_DST_16BPP_YVYU422 0x00000c00
864#define GMC_DST_32BPP_AYUV444 0x00000e00 870#define GMC_DST_32BPP_AYUV444 0x00000e00
865#define GMC_DST_16BPP_ARGB4444 0x00000f00 871#define GMC_DST_16BPP_ARGB4444 0x00000f00
866#define GMC_SRC_MONO 0x00000000
867#define GMC_SRC_MONO_LBKGD 0x00001000
868#define GMC_SRC_DSTCOLOR 0x00003000
869#define GMC_BYTE_ORDER_MSB_TO_LSB 0x00000000 872#define GMC_BYTE_ORDER_MSB_TO_LSB 0x00000000
870#define GMC_BYTE_ORDER_LSB_TO_MSB 0x00004000 873#define GMC_BYTE_ORDER_LSB_TO_MSB 0x00004000
871#define GMC_DP_CONVERSION_TEMP_9300 0x00008000 874#define GMC_DP_CONVERSION_TEMP_9300 0x00008000
872#define GMC_DP_CONVERSION_TEMP_6500 0x00000000 875#define GMC_DP_CONVERSION_TEMP_6500 0x00000000
873#define GMC_DP_SRC_RECT 0x02000000
874#define GMC_DP_SRC_HOST 0x03000000
875#define GMC_DP_SRC_HOST_BYTEALIGN 0x04000000 876#define GMC_DP_SRC_HOST_BYTEALIGN 0x04000000
876#define GMC_3D_FCN_EN_CLR 0x00000000 877#define GMC_3D_FCN_EN_CLR 0x00000000
877#define GMC_3D_FCN_EN_SET 0x08000000 878#define GMC_3D_FCN_EN_SET 0x08000000
@@ -882,6 +883,9 @@
882#define GMC_WRITE_MASK_LEAVE 0x00000000 883#define GMC_WRITE_MASK_LEAVE 0x00000000
883#define GMC_WRITE_MASK_SET 0x40000000 884#define GMC_WRITE_MASK_SET 0x40000000
884#define GMC_CLR_CMP_CNTL_DIS (1 << 28) 885#define GMC_CLR_CMP_CNTL_DIS (1 << 28)
886#define GMC_SRC_DATATYPE_MASK (3 << 12)
887#define GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12)
888#define GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12)
885#define GMC_SRC_DATATYPE_COLOR (3 << 12) 889#define GMC_SRC_DATATYPE_COLOR (3 << 12)
886#define ROP3_S 0x00cc0000 890#define ROP3_S 0x00cc0000
887#define ROP3_SRCCOPY 0x00cc0000 891#define ROP3_SRCCOPY 0x00cc0000
@@ -890,6 +894,7 @@
890#define DP_SRC_SOURCE_MASK (7 << 24) 894#define DP_SRC_SOURCE_MASK (7 << 24)
891#define GMC_BRUSH_NONE (15 << 4) 895#define GMC_BRUSH_NONE (15 << 4)
892#define DP_SRC_SOURCE_MEMORY (2 << 24) 896#define DP_SRC_SOURCE_MEMORY (2 << 24)
897#define DP_SRC_SOURCE_HOST_DATA (3 << 24)
893#define GMC_BRUSH_SOLIDCOLOR 0x000000d0 898#define GMC_BRUSH_SOLIDCOLOR 0x000000d0
894 899
895/* DP_MIX bit constants */ 900/* DP_MIX bit constants */
@@ -975,6 +980,12 @@
975#define DISP_PWR_MAN_TV_ENABLE_RST (1 << 25) 980#define DISP_PWR_MAN_TV_ENABLE_RST (1 << 25)
976#define DISP_PWR_MAN_AUTO_PWRUP_EN (1 << 26) 981#define DISP_PWR_MAN_AUTO_PWRUP_EN (1 << 26)
977 982
983/* RBBM_GUICNTL constants */
984#define RBBM_GUICNTL_HOST_DATA_SWAP_NONE (0 << 0)
985#define RBBM_GUICNTL_HOST_DATA_SWAP_16BIT (1 << 0)
986#define RBBM_GUICNTL_HOST_DATA_SWAP_32BIT (2 << 0)
987#define RBBM_GUICNTL_HOST_DATA_SWAP_HDW (3 << 0)
988
978/* masks */ 989/* masks */
979 990
980#define CONFIG_MEMSIZE_MASK 0x1f000000 991#define CONFIG_MEMSIZE_MASK 0x1f000000
diff --git a/include/video/s1d13xxxfb.h b/include/video/s1d13xxxfb.h
index c99d261df8f7..fe41b8407946 100644
--- a/include/video/s1d13xxxfb.h
+++ b/include/video/s1d13xxxfb.h
@@ -14,7 +14,8 @@
14#define S1D13XXXFB_H 14#define S1D13XXXFB_H
15 15
16#define S1D_PALETTE_SIZE 256 16#define S1D_PALETTE_SIZE 256
17#define S1D_CHIP_REV 7 /* expected chip revision number for s1d13806 */ 17#define S1D13506_CHIP_REV 4 /* expected chip revision number for s1d13506 */
18#define S1D13806_CHIP_REV 7 /* expected chip revision number for s1d13806 */
18#define S1D_FBID "S1D13806" 19#define S1D_FBID "S1D13806"
19#define S1D_DEVICENAME "s1d13806fb" 20#define S1D_DEVICENAME "s1d13806fb"
20 21
diff --git a/init/Kconfig b/init/Kconfig
index 8a8e2d00c40e..5ceff3249a2d 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -713,6 +713,14 @@ config SHMEM
713 option replaces shmem and tmpfs with the much simpler ramfs code, 713 option replaces shmem and tmpfs with the much simpler ramfs code,
714 which may be appropriate on small systems without swap. 714 which may be appropriate on small systems without swap.
715 715
716config AIO
717 bool "Enable AIO support" if EMBEDDED
718 default y
719 help
720 This option enables POSIX asynchronous I/O which may by used
721 by some high performance threaded applications. Disabling
722 this option saves about 7k.
723
716config VM_EVENT_COUNTERS 724config VM_EVENT_COUNTERS
717 default y 725 default y
718 bool "Enable VM event counters for /proc/vmstat" if EMBEDDED 726 bool "Enable VM event counters for /proc/vmstat" if EMBEDDED
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index 48b3fadd83ed..4c87ee1fe5d3 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -1,5 +1,6 @@
1 1
2#include <linux/raid/md.h> 2#include <linux/raid/md.h>
3#include <linux/delay.h>
3 4
4#include "do_mounts.h" 5#include "do_mounts.h"
5 6
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index fedef93b586f..a7c748fa977a 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -71,7 +71,7 @@ identify_ramdisk_image(int fd, int start_block)
71 sys_read(fd, buf, size); 71 sys_read(fd, buf, size);
72 72
73 /* 73 /*
74 * If it matches the gzip magic numbers, return -1 74 * If it matches the gzip magic numbers, return 0
75 */ 75 */
76 if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) { 76 if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {
77 printk(KERN_NOTICE 77 printk(KERN_NOTICE
diff --git a/init/initramfs.c b/init/initramfs.c
index 644fc01ad5f0..4f5ba75aaa7c 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -6,6 +6,7 @@
6#include <linux/delay.h> 6#include <linux/delay.h>
7#include <linux/string.h> 7#include <linux/string.h>
8#include <linux/syscalls.h> 8#include <linux/syscalls.h>
9#include <linux/utime.h>
9 10
10static __initdata char *message; 11static __initdata char *message;
11static void __init error(char *x) 12static void __init error(char *x)
@@ -72,6 +73,49 @@ static void __init free_hash(void)
72 } 73 }
73} 74}
74 75
76static long __init do_utime(char __user *filename, time_t mtime)
77{
78 struct timespec t[2];
79
80 t[0].tv_sec = mtime;
81 t[0].tv_nsec = 0;
82 t[1].tv_sec = mtime;
83 t[1].tv_nsec = 0;
84
85 return do_utimes(AT_FDCWD, filename, t, AT_SYMLINK_NOFOLLOW);
86}
87
88static __initdata LIST_HEAD(dir_list);
89struct dir_entry {
90 struct list_head list;
91 char *name;
92 time_t mtime;
93};
94
95static void __init dir_add(const char *name, time_t mtime)
96{
97 struct dir_entry *de = kmalloc(sizeof(struct dir_entry), GFP_KERNEL);
98 if (!de)
99 panic("can't allocate dir_entry buffer");
100 INIT_LIST_HEAD(&de->list);
101 de->name = kstrdup(name, GFP_KERNEL);
102 de->mtime = mtime;
103 list_add(&de->list, &dir_list);
104}
105
106static void __init dir_utime(void)
107{
108 struct dir_entry *de, *tmp;
109 list_for_each_entry_safe(de, tmp, &dir_list, list) {
110 list_del(&de->list);
111 do_utime(de->name, de->mtime);
112 kfree(de->name);
113 kfree(de);
114 }
115}
116
117static __initdata time_t mtime;
118
75/* cpio header parsing */ 119/* cpio header parsing */
76 120
77static __initdata unsigned long ino, major, minor, nlink; 121static __initdata unsigned long ino, major, minor, nlink;
@@ -97,6 +141,7 @@ static void __init parse_header(char *s)
97 uid = parsed[2]; 141 uid = parsed[2];
98 gid = parsed[3]; 142 gid = parsed[3];
99 nlink = parsed[4]; 143 nlink = parsed[4];
144 mtime = parsed[5];
100 body_len = parsed[6]; 145 body_len = parsed[6];
101 major = parsed[7]; 146 major = parsed[7];
102 minor = parsed[8]; 147 minor = parsed[8];
@@ -130,6 +175,7 @@ static inline void __init eat(unsigned n)
130 count -= n; 175 count -= n;
131} 176}
132 177
178static __initdata char *vcollected;
133static __initdata char *collected; 179static __initdata char *collected;
134static __initdata int remains; 180static __initdata int remains;
135static __initdata char *collect; 181static __initdata char *collect;
@@ -271,6 +317,7 @@ static int __init do_name(void)
271 if (wfd >= 0) { 317 if (wfd >= 0) {
272 sys_fchown(wfd, uid, gid); 318 sys_fchown(wfd, uid, gid);
273 sys_fchmod(wfd, mode); 319 sys_fchmod(wfd, mode);
320 vcollected = kstrdup(collected, GFP_KERNEL);
274 state = CopyFile; 321 state = CopyFile;
275 } 322 }
276 } 323 }
@@ -278,12 +325,14 @@ static int __init do_name(void)
278 sys_mkdir(collected, mode); 325 sys_mkdir(collected, mode);
279 sys_chown(collected, uid, gid); 326 sys_chown(collected, uid, gid);
280 sys_chmod(collected, mode); 327 sys_chmod(collected, mode);
328 dir_add(collected, mtime);
281 } else if (S_ISBLK(mode) || S_ISCHR(mode) || 329 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
282 S_ISFIFO(mode) || S_ISSOCK(mode)) { 330 S_ISFIFO(mode) || S_ISSOCK(mode)) {
283 if (maybe_link() == 0) { 331 if (maybe_link() == 0) {
284 sys_mknod(collected, mode, rdev); 332 sys_mknod(collected, mode, rdev);
285 sys_chown(collected, uid, gid); 333 sys_chown(collected, uid, gid);
286 sys_chmod(collected, mode); 334 sys_chmod(collected, mode);
335 do_utime(collected, mtime);
287 } 336 }
288 } 337 }
289 return 0; 338 return 0;
@@ -294,6 +343,8 @@ static int __init do_copy(void)
294 if (count >= body_len) { 343 if (count >= body_len) {
295 sys_write(wfd, victim, body_len); 344 sys_write(wfd, victim, body_len);
296 sys_close(wfd); 345 sys_close(wfd);
346 do_utime(vcollected, mtime);
347 kfree(vcollected);
297 eat(body_len); 348 eat(body_len);
298 state = SkipIt; 349 state = SkipIt;
299 return 0; 350 return 0;
@@ -311,6 +362,7 @@ static int __init do_symlink(void)
311 clean_path(collected, 0); 362 clean_path(collected, 0);
312 sys_symlink(collected + N_ALIGN(name_len), collected); 363 sys_symlink(collected + N_ALIGN(name_len), collected);
313 sys_lchown(collected, uid, gid); 364 sys_lchown(collected, uid, gid);
365 do_utime(collected, mtime);
314 state = SkipIt; 366 state = SkipIt;
315 next_state = Reset; 367 next_state = Reset;
316 return 0; 368 return 0;
@@ -466,6 +518,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
466 buf += inptr; 518 buf += inptr;
467 len -= inptr; 519 len -= inptr;
468 } 520 }
521 dir_utime();
469 kfree(window); 522 kfree(window);
470 kfree(name_buf); 523 kfree(name_buf);
471 kfree(symlink_buf); 524 kfree(symlink_buf);
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index 69bc85978ba0..0dfebc509426 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -131,7 +131,7 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
131 131
132#ifdef CONFIG_SYSCTL_SYSCALL 132#ifdef CONFIG_SYSCTL_SYSCALL
133/* The generic sysctl ipc data routine. */ 133/* The generic sysctl ipc data routine. */
134static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen, 134static int sysctl_ipc_data(ctl_table *table,
135 void __user *oldval, size_t __user *oldlenp, 135 void __user *oldval, size_t __user *oldlenp,
136 void __user *newval, size_t newlen) 136 void __user *newval, size_t newlen)
137{ 137{
@@ -169,14 +169,13 @@ static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
169 return 1; 169 return 1;
170} 170}
171 171
172static int sysctl_ipc_registered_data(ctl_table *table, int __user *name, 172static int sysctl_ipc_registered_data(ctl_table *table,
173 int nlen, void __user *oldval, size_t __user *oldlenp, 173 void __user *oldval, size_t __user *oldlenp,
174 void __user *newval, size_t newlen) 174 void __user *newval, size_t newlen)
175{ 175{
176 int rc; 176 int rc;
177 177
178 rc = sysctl_ipc_data(table, name, nlen, oldval, oldlenp, newval, 178 rc = sysctl_ipc_data(table, oldval, oldlenp, newval, newlen);
179 newlen);
180 179
181 if (newval && newlen && rc > 0) 180 if (newval && newlen && rc > 0)
182 /* 181 /*
diff --git a/ipc/sem.c b/ipc/sem.c
index bf1bc36cb7ee..082122469b17 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -504,7 +504,7 @@ static int count_semzcnt (struct sem_array * sma, ushort semnum)
504 return semzcnt; 504 return semzcnt;
505} 505}
506 506
507void free_un(struct rcu_head *head) 507static void free_un(struct rcu_head *head)
508{ 508{
509 struct sem_undo *un = container_of(head, struct sem_undo, rcu); 509 struct sem_undo *un = container_of(head, struct sem_undo, rcu);
510 kfree(un); 510 kfree(un);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a0123d75ec9a..8c6e1c17e6d3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2735,6 +2735,8 @@ void cgroup_fork_callbacks(struct task_struct *child)
2735 * Called on every change to mm->owner. mm_init_owner() does not 2735 * Called on every change to mm->owner. mm_init_owner() does not
2736 * invoke this routine, since it assigns the mm->owner the first time 2736 * invoke this routine, since it assigns the mm->owner the first time
2737 * and does not change it. 2737 * and does not change it.
2738 *
2739 * The callbacks are invoked with mmap_sem held in read mode.
2738 */ 2740 */
2739void cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new) 2741void cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new)
2740{ 2742{
@@ -2750,7 +2752,7 @@ void cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new)
2750 if (oldcgrp == newcgrp) 2752 if (oldcgrp == newcgrp)
2751 continue; 2753 continue;
2752 if (ss->mm_owner_changed) 2754 if (ss->mm_owner_changed)
2753 ss->mm_owner_changed(ss, oldcgrp, newcgrp); 2755 ss->mm_owner_changed(ss, oldcgrp, newcgrp, new);
2754 } 2756 }
2755 } 2757 }
2756} 2758}
diff --git a/kernel/compat.c b/kernel/compat.c
index 32c254a8ab9a..143990e48cb9 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -26,6 +26,64 @@
26 26
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28 28
29/*
30 * Note that the native side is already converted to a timespec, because
31 * that's what we want anyway.
32 */
33static int compat_get_timeval(struct timespec *o,
34 struct compat_timeval __user *i)
35{
36 long usec;
37
38 if (get_user(o->tv_sec, &i->tv_sec) ||
39 get_user(usec, &i->tv_usec))
40 return -EFAULT;
41 o->tv_nsec = usec * 1000;
42 return 0;
43}
44
45static int compat_put_timeval(struct compat_timeval __user *o,
46 struct timeval *i)
47{
48 return (put_user(i->tv_sec, &o->tv_sec) ||
49 put_user(i->tv_usec, &o->tv_usec)) ? -EFAULT : 0;
50}
51
52asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
53 struct timezone __user *tz)
54{
55 if (tv) {
56 struct timeval ktv;
57 do_gettimeofday(&ktv);
58 if (compat_put_timeval(tv, &ktv))
59 return -EFAULT;
60 }
61 if (tz) {
62 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
63 return -EFAULT;
64 }
65
66 return 0;
67}
68
69asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
70 struct timezone __user *tz)
71{
72 struct timespec kts;
73 struct timezone ktz;
74
75 if (tv) {
76 if (compat_get_timeval(&kts, tv))
77 return -EFAULT;
78 }
79 if (tz) {
80 if (copy_from_user(&ktz, tz, sizeof(ktz)))
81 return -EFAULT;
82 }
83
84 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
85}
86
29int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) 87int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
30{ 88{
31 return (!access_ok(VERIFY_READ, cts, sizeof(*cts)) || 89 return (!access_ok(VERIFY_READ, cts, sizeof(*cts)) ||
diff --git a/kernel/dma.c b/kernel/dma.c
index d2c60a822790..f903189c5304 100644
--- a/kernel/dma.c
+++ b/kernel/dma.c
@@ -1,4 +1,4 @@
1/* $Id: dma.c,v 1.7 1994/12/28 03:35:33 root Exp root $ 1/*
2 * linux/kernel/dma.c: A DMA channel allocator. Inspired by linux/kernel/irq.c. 2 * linux/kernel/dma.c: A DMA channel allocator. Inspired by linux/kernel/irq.c.
3 * 3 *
4 * Written by Hennus Bergman, 1992. 4 * Written by Hennus Bergman, 1992.
diff --git a/kernel/exit.c b/kernel/exit.c
index 85a83c831856..0ef4673e351b 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -640,24 +640,23 @@ retry:
640assign_new_owner: 640assign_new_owner:
641 BUG_ON(c == p); 641 BUG_ON(c == p);
642 get_task_struct(c); 642 get_task_struct(c);
643 read_unlock(&tasklist_lock);
644 down_write(&mm->mmap_sem);
643 /* 645 /*
644 * The task_lock protects c->mm from changing. 646 * The task_lock protects c->mm from changing.
645 * We always want mm->owner->mm == mm 647 * We always want mm->owner->mm == mm
646 */ 648 */
647 task_lock(c); 649 task_lock(c);
648 /*
649 * Delay read_unlock() till we have the task_lock()
650 * to ensure that c does not slip away underneath us
651 */
652 read_unlock(&tasklist_lock);
653 if (c->mm != mm) { 650 if (c->mm != mm) {
654 task_unlock(c); 651 task_unlock(c);
652 up_write(&mm->mmap_sem);
655 put_task_struct(c); 653 put_task_struct(c);
656 goto retry; 654 goto retry;
657 } 655 }
658 cgroup_mm_owner_callbacks(mm->owner, c); 656 cgroup_mm_owner_callbacks(mm->owner, c);
659 mm->owner = c; 657 mm->owner = c;
660 task_unlock(c); 658 task_unlock(c);
659 up_write(&mm->mmap_sem);
661 put_task_struct(c); 660 put_task_struct(c);
662} 661}
663#endif /* CONFIG_MM_OWNER */ 662#endif /* CONFIG_MM_OWNER */
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 38fc10ac7541..5072cf1685a2 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -260,7 +260,6 @@ const char *kallsyms_lookup(unsigned long addr,
260 /* see if it's in a module */ 260 /* see if it's in a module */
261 return module_address_lookup(addr, symbolsize, offset, modname, 261 return module_address_lookup(addr, symbolsize, offset, modname,
262 namebuf); 262 namebuf);
263 return NULL;
264} 263}
265 264
266int lookup_symbol_name(unsigned long addr, char *symname) 265int lookup_symbol_name(unsigned long addr, char *symname)
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 2456d1a0befb..3d3c3ea3a023 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -113,7 +113,7 @@ int request_module(const char *fmt, ...)
113 return ret; 113 return ret;
114} 114}
115EXPORT_SYMBOL(request_module); 115EXPORT_SYMBOL(request_module);
116#endif /* CONFIG_KMOD */ 116#endif /* CONFIG_MODULES */
117 117
118struct subprocess_info { 118struct subprocess_info {
119 struct work_struct work; 119 struct work_struct work;
@@ -265,7 +265,7 @@ static void __call_usermodehelper(struct work_struct *work)
265 } 265 }
266} 266}
267 267
268#ifdef CONFIG_PM 268#ifdef CONFIG_PM_SLEEP
269/* 269/*
270 * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY 270 * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
271 * (used for preventing user land processes from being created after the user 271 * (used for preventing user land processes from being created after the user
@@ -288,39 +288,37 @@ static DECLARE_WAIT_QUEUE_HEAD(running_helpers_waitq);
288 */ 288 */
289#define RUNNING_HELPERS_TIMEOUT (5 * HZ) 289#define RUNNING_HELPERS_TIMEOUT (5 * HZ)
290 290
291static int usermodehelper_pm_callback(struct notifier_block *nfb, 291/**
292 unsigned long action, 292 * usermodehelper_disable - prevent new helpers from being started
293 void *ignored) 293 */
294int usermodehelper_disable(void)
294{ 295{
295 long retval; 296 long retval;
296 297
297 switch (action) { 298 usermodehelper_disabled = 1;
298 case PM_HIBERNATION_PREPARE: 299 smp_mb();
299 case PM_SUSPEND_PREPARE: 300 /*
300 usermodehelper_disabled = 1; 301 * From now on call_usermodehelper_exec() won't start any new
301 smp_mb(); 302 * helpers, so it is sufficient if running_helpers turns out to
302 /* 303 * be zero at one point (it may be increased later, but that
303 * From now on call_usermodehelper_exec() won't start any new 304 * doesn't matter).
304 * helpers, so it is sufficient if running_helpers turns out to 305 */
305 * be zero at one point (it may be increased later, but that 306 retval = wait_event_timeout(running_helpers_waitq,
306 * doesn't matter).
307 */
308 retval = wait_event_timeout(running_helpers_waitq,
309 atomic_read(&running_helpers) == 0, 307 atomic_read(&running_helpers) == 0,
310 RUNNING_HELPERS_TIMEOUT); 308 RUNNING_HELPERS_TIMEOUT);
311 if (retval) { 309 if (retval)
312 return NOTIFY_OK; 310 return 0;
313 } else {
314 usermodehelper_disabled = 0;
315 return NOTIFY_BAD;
316 }
317 case PM_POST_HIBERNATION:
318 case PM_POST_SUSPEND:
319 usermodehelper_disabled = 0;
320 return NOTIFY_OK;
321 }
322 311
323 return NOTIFY_DONE; 312 usermodehelper_disabled = 0;
313 return -EAGAIN;
314}
315
316/**
317 * usermodehelper_enable - allow new helpers to be started again
318 */
319void usermodehelper_enable(void)
320{
321 usermodehelper_disabled = 0;
324} 322}
325 323
326static void helper_lock(void) 324static void helper_lock(void)
@@ -334,18 +332,12 @@ static void helper_unlock(void)
334 if (atomic_dec_and_test(&running_helpers)) 332 if (atomic_dec_and_test(&running_helpers))
335 wake_up(&running_helpers_waitq); 333 wake_up(&running_helpers_waitq);
336} 334}
337 335#else /* CONFIG_PM_SLEEP */
338static void register_pm_notifier_callback(void)
339{
340 pm_notifier(usermodehelper_pm_callback, 0);
341}
342#else /* CONFIG_PM */
343#define usermodehelper_disabled 0 336#define usermodehelper_disabled 0
344 337
345static inline void helper_lock(void) {} 338static inline void helper_lock(void) {}
346static inline void helper_unlock(void) {} 339static inline void helper_unlock(void) {}
347static inline void register_pm_notifier_callback(void) {} 340#endif /* CONFIG_PM_SLEEP */
348#endif /* CONFIG_PM */
349 341
350/** 342/**
351 * call_usermodehelper_setup - prepare to call a usermode helper 343 * call_usermodehelper_setup - prepare to call a usermode helper
@@ -515,5 +507,4 @@ void __init usermodehelper_init(void)
515{ 507{
516 khelper_wq = create_singlethread_workqueue("khelper"); 508 khelper_wq = create_singlethread_workqueue("khelper");
517 BUG_ON(!khelper_wq); 509 BUG_ON(!khelper_wq);
518 register_pm_notifier_callback();
519} 510}
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 75bc2cd9ebc6..8b57a2597f21 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -404,7 +404,7 @@ void kretprobe_hash_lock(struct task_struct *tsk,
404 spin_lock_irqsave(hlist_lock, *flags); 404 spin_lock_irqsave(hlist_lock, *flags);
405} 405}
406 406
407void kretprobe_table_lock(unsigned long hash, unsigned long *flags) 407static void kretprobe_table_lock(unsigned long hash, unsigned long *flags)
408{ 408{
409 spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash); 409 spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
410 spin_lock_irqsave(hlist_lock, *flags); 410 spin_lock_irqsave(hlist_lock, *flags);
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index e53bc30e9ba5..08dd8ed86c77 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/kexec.h> 16#include <linux/kexec.h>
17#include <linux/profile.h>
17#include <linux/sched.h> 18#include <linux/sched.h>
18 19
19#define KERNEL_ATTR_RO(_name) \ 20#define KERNEL_ATTR_RO(_name) \
@@ -53,6 +54,37 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
53KERNEL_ATTR_RW(uevent_helper); 54KERNEL_ATTR_RW(uevent_helper);
54#endif 55#endif
55 56
57#ifdef CONFIG_PROFILING
58static ssize_t profiling_show(struct kobject *kobj,
59 struct kobj_attribute *attr, char *buf)
60{
61 return sprintf(buf, "%d\n", prof_on);
62}
63static ssize_t profiling_store(struct kobject *kobj,
64 struct kobj_attribute *attr,
65 const char *buf, size_t count)
66{
67 int ret;
68
69 if (prof_on)
70 return -EEXIST;
71 /*
72 * This eventually calls into get_option() which
73 * has a ton of callers and is not const. It is
74 * easiest to cast it away here.
75 */
76 profile_setup((char *)buf);
77 ret = profile_init();
78 if (ret)
79 return ret;
80 ret = create_proc_profile();
81 if (ret)
82 return ret;
83 return count;
84}
85KERNEL_ATTR_RW(profiling);
86#endif
87
56#ifdef CONFIG_KEXEC 88#ifdef CONFIG_KEXEC
57static ssize_t kexec_loaded_show(struct kobject *kobj, 89static ssize_t kexec_loaded_show(struct kobject *kobj,
58 struct kobj_attribute *attr, char *buf) 90 struct kobj_attribute *attr, char *buf)
@@ -109,6 +141,9 @@ static struct attribute * kernel_attrs[] = {
109 &uevent_seqnum_attr.attr, 141 &uevent_seqnum_attr.attr,
110 &uevent_helper_attr.attr, 142 &uevent_helper_attr.attr,
111#endif 143#endif
144#ifdef CONFIG_PROFILING
145 &profiling_attr.attr,
146#endif
112#ifdef CONFIG_KEXEC 147#ifdef CONFIG_KEXEC
113 &kexec_loaded_attr.attr, 148 &kexec_loaded_attr.attr,
114 &kexec_crash_loaded_attr.attr, 149 &kexec_crash_loaded_attr.attr,
diff --git a/kernel/module.c b/kernel/module.c
index 9db11911e04b..b7205f67cfaf 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -100,7 +100,7 @@ static inline int strong_try_module_get(struct module *mod)
100static inline void add_taint_module(struct module *mod, unsigned flag) 100static inline void add_taint_module(struct module *mod, unsigned flag)
101{ 101{
102 add_taint(flag); 102 add_taint(flag);
103 mod->taints |= flag; 103 mod->taints |= (1U << flag);
104} 104}
105 105
106/* 106/*
@@ -784,6 +784,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
784 mutex_lock(&module_mutex); 784 mutex_lock(&module_mutex);
785 /* Store the name of the last unloaded module for diagnostic purposes */ 785 /* Store the name of the last unloaded module for diagnostic purposes */
786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
787 unregister_dynamic_debug_module(mod->name);
787 free_module(mod); 788 free_module(mod);
788 789
789 out: 790 out:
@@ -923,7 +924,7 @@ static const char vermagic[] = VERMAGIC_STRING;
923static int try_to_force_load(struct module *mod, const char *symname) 924static int try_to_force_load(struct module *mod, const char *symname)
924{ 925{
925#ifdef CONFIG_MODULE_FORCE_LOAD 926#ifdef CONFIG_MODULE_FORCE_LOAD
926 if (!(tainted & TAINT_FORCED_MODULE)) 927 if (!test_taint(TAINT_FORCED_MODULE))
927 printk("%s: no version for \"%s\" found: kernel tainted.\n", 928 printk("%s: no version for \"%s\" found: kernel tainted.\n",
928 mod->name, symname); 929 mod->name, symname);
929 add_taint_module(mod, TAINT_FORCED_MODULE); 930 add_taint_module(mod, TAINT_FORCED_MODULE);
@@ -1033,7 +1034,7 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
1033 const unsigned long *crc; 1034 const unsigned long *crc;
1034 1035
1035 ret = find_symbol(name, &owner, &crc, 1036 ret = find_symbol(name, &owner, &crc,
1036 !(mod->taints & TAINT_PROPRIETARY_MODULE), true); 1037 !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
1037 if (!IS_ERR_VALUE(ret)) { 1038 if (!IS_ERR_VALUE(ret)) {
1038 /* use_module can fail due to OOM, 1039 /* use_module can fail due to OOM,
1039 or module initialization or unloading */ 1040 or module initialization or unloading */
@@ -1173,7 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
1173 while (i-- > 0) 1174 while (i-- > 0)
1174 sysfs_remove_bin_file(notes_attrs->dir, 1175 sysfs_remove_bin_file(notes_attrs->dir,
1175 &notes_attrs->attrs[i]); 1176 &notes_attrs->attrs[i]);
1176 kobject_del(notes_attrs->dir); 1177 kobject_put(notes_attrs->dir);
1177 } 1178 }
1178 kfree(notes_attrs); 1179 kfree(notes_attrs);
1179} 1180}
@@ -1634,7 +1635,7 @@ static void set_license(struct module *mod, const char *license)
1634 license = "unspecified"; 1635 license = "unspecified";
1635 1636
1636 if (!license_is_gpl_compatible(license)) { 1637 if (!license_is_gpl_compatible(license)) {
1637 if (!(tainted & TAINT_PROPRIETARY_MODULE)) 1638 if (!test_taint(TAINT_PROPRIETARY_MODULE))
1638 printk(KERN_WARNING "%s: module license '%s' taints " 1639 printk(KERN_WARNING "%s: module license '%s' taints "
1639 "kernel.\n", mod->name, license); 1640 "kernel.\n", mod->name, license);
1640 add_taint_module(mod, TAINT_PROPRIETARY_MODULE); 1641 add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
@@ -1783,6 +1784,33 @@ static inline void add_kallsyms(struct module *mod,
1783} 1784}
1784#endif /* CONFIG_KALLSYMS */ 1785#endif /* CONFIG_KALLSYMS */
1785 1786
1787#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
1788static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex)
1789{
1790 struct mod_debug *debug_info;
1791 unsigned long pos, end;
1792 unsigned int num_verbose;
1793
1794 pos = sechdrs[verboseindex].sh_addr;
1795 num_verbose = sechdrs[verboseindex].sh_size /
1796 sizeof(struct mod_debug);
1797 end = pos + (num_verbose * sizeof(struct mod_debug));
1798
1799 for (; pos < end; pos += sizeof(struct mod_debug)) {
1800 debug_info = (struct mod_debug *)pos;
1801 register_dynamic_debug_module(debug_info->modname,
1802 debug_info->type, debug_info->logical_modname,
1803 debug_info->flag_names, debug_info->hash,
1804 debug_info->hash2);
1805 }
1806}
1807#else
1808static inline void dynamic_printk_setup(Elf_Shdr *sechdrs,
1809 unsigned int verboseindex)
1810{
1811}
1812#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */
1813
1786static void *module_alloc_update_bounds(unsigned long size) 1814static void *module_alloc_update_bounds(unsigned long size)
1787{ 1815{
1788 void *ret = module_alloc(size); 1816 void *ret = module_alloc(size);
@@ -1831,6 +1859,7 @@ static noinline struct module *load_module(void __user *umod,
1831#endif 1859#endif
1832 unsigned int markersindex; 1860 unsigned int markersindex;
1833 unsigned int markersstringsindex; 1861 unsigned int markersstringsindex;
1862 unsigned int verboseindex;
1834 struct module *mod; 1863 struct module *mod;
1835 long err = 0; 1864 long err = 0;
1836 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1865 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -2117,6 +2146,7 @@ static noinline struct module *load_module(void __user *umod,
2117 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); 2146 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
2118 markersstringsindex = find_sec(hdr, sechdrs, secstrings, 2147 markersstringsindex = find_sec(hdr, sechdrs, secstrings,
2119 "__markers_strings"); 2148 "__markers_strings");
2149 verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose");
2120 2150
2121 /* Now do relocations. */ 2151 /* Now do relocations. */
2122 for (i = 1; i < hdr->e_shnum; i++) { 2152 for (i = 1; i < hdr->e_shnum; i++) {
@@ -2167,6 +2197,7 @@ static noinline struct module *load_module(void __user *umod,
2167 marker_update_probe_range(mod->markers, 2197 marker_update_probe_range(mod->markers,
2168 mod->markers + mod->num_markers); 2198 mod->markers + mod->num_markers);
2169#endif 2199#endif
2200 dynamic_printk_setup(sechdrs, verboseindex);
2170 err = module_finalize(hdr, sechdrs, mod); 2201 err = module_finalize(hdr, sechdrs, mod);
2171 if (err < 0) 2202 if (err < 0)
2172 goto cleanup; 2203 goto cleanup;
@@ -2552,9 +2583,9 @@ static char *module_flags(struct module *mod, char *buf)
2552 mod->state == MODULE_STATE_GOING || 2583 mod->state == MODULE_STATE_GOING ||
2553 mod->state == MODULE_STATE_COMING) { 2584 mod->state == MODULE_STATE_COMING) {
2554 buf[bx++] = '('; 2585 buf[bx++] = '(';
2555 if (mod->taints & TAINT_PROPRIETARY_MODULE) 2586 if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE))
2556 buf[bx++] = 'P'; 2587 buf[bx++] = 'P';
2557 if (mod->taints & TAINT_FORCED_MODULE) 2588 if (mod->taints & (1 << TAINT_FORCED_MODULE))
2558 buf[bx++] = 'F'; 2589 buf[bx++] = 'F';
2559 /* 2590 /*
2560 * TAINT_FORCED_RMMOD: could be added. 2591 * TAINT_FORCED_RMMOD: could be added.
diff --git a/kernel/panic.c b/kernel/panic.c
index 12c5a0a6c89b..f290e8e866f6 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -23,7 +23,7 @@
23#include <linux/kallsyms.h> 23#include <linux/kallsyms.h>
24 24
25int panic_on_oops; 25int panic_on_oops;
26int tainted; 26static unsigned long tainted_mask;
27static int pause_on_oops; 27static int pause_on_oops;
28static int pause_on_oops_flag; 28static int pause_on_oops_flag;
29static DEFINE_SPINLOCK(pause_on_oops_lock); 29static DEFINE_SPINLOCK(pause_on_oops_lock);
@@ -143,6 +143,26 @@ NORET_TYPE void panic(const char * fmt, ...)
143 143
144EXPORT_SYMBOL(panic); 144EXPORT_SYMBOL(panic);
145 145
146
147struct tnt {
148 u8 bit;
149 char true;
150 char false;
151};
152
153static const struct tnt tnts[] = {
154 { TAINT_PROPRIETARY_MODULE, 'P', 'G' },
155 { TAINT_FORCED_MODULE, 'F', ' ' },
156 { TAINT_UNSAFE_SMP, 'S', ' ' },
157 { TAINT_FORCED_RMMOD, 'R', ' ' },
158 { TAINT_MACHINE_CHECK, 'M', ' ' },
159 { TAINT_BAD_PAGE, 'B', ' ' },
160 { TAINT_USER, 'U', ' ' },
161 { TAINT_DIE, 'D', ' ' },
162 { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' },
163 { TAINT_WARN, 'W', ' ' },
164};
165
146/** 166/**
147 * print_tainted - return a string to represent the kernel taint state. 167 * print_tainted - return a string to represent the kernel taint state.
148 * 168 *
@@ -158,32 +178,41 @@ EXPORT_SYMBOL(panic);
158 * 178 *
159 * The string is overwritten by the next call to print_taint(). 179 * The string is overwritten by the next call to print_taint().
160 */ 180 */
161
162const char *print_tainted(void) 181const char *print_tainted(void)
163{ 182{
164 static char buf[20]; 183 static char buf[ARRAY_SIZE(tnts) + sizeof("Tainted: ") + 1];
165 if (tainted) { 184
166 snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c", 185 if (tainted_mask) {
167 tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G', 186 char *s;
168 tainted & TAINT_FORCED_MODULE ? 'F' : ' ', 187 int i;
169 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ', 188
170 tainted & TAINT_FORCED_RMMOD ? 'R' : ' ', 189 s = buf + sprintf(buf, "Tainted: ");
171 tainted & TAINT_MACHINE_CHECK ? 'M' : ' ', 190 for (i = 0; i < ARRAY_SIZE(tnts); i++) {
172 tainted & TAINT_BAD_PAGE ? 'B' : ' ', 191 const struct tnt *t = &tnts[i];
173 tainted & TAINT_USER ? 'U' : ' ', 192 *s++ = test_bit(t->bit, &tainted_mask) ?
174 tainted & TAINT_DIE ? 'D' : ' ', 193 t->true : t->false;
175 tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ', 194 }
176 tainted & TAINT_WARN ? 'W' : ' '); 195 *s = 0;
177 } 196 } else
178 else
179 snprintf(buf, sizeof(buf), "Not tainted"); 197 snprintf(buf, sizeof(buf), "Not tainted");
180 return(buf); 198 return(buf);
181} 199}
182 200
201int test_taint(unsigned flag)
202{
203 return test_bit(flag, &tainted_mask);
204}
205EXPORT_SYMBOL(test_taint);
206
207unsigned long get_taint(void)
208{
209 return tainted_mask;
210}
211
183void add_taint(unsigned flag) 212void add_taint(unsigned flag)
184{ 213{
185 debug_locks = 0; /* can't trust the integrity of the kernel anymore */ 214 debug_locks = 0; /* can't trust the integrity of the kernel anymore */
186 tainted |= flag; 215 set_bit(flag, &tainted_mask);
187} 216}
188EXPORT_SYMBOL(add_taint); 217EXPORT_SYMBOL(add_taint);
189 218
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index bbd85c60f741..331f9836383f 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -14,6 +14,7 @@
14#include <linux/reboot.h> 14#include <linux/reboot.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/kmod.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
18#include <linux/fs.h> 19#include <linux/fs.h>
19#include <linux/mount.h> 20#include <linux/mount.h>
@@ -520,6 +521,10 @@ int hibernate(void)
520 if (error) 521 if (error)
521 goto Exit; 522 goto Exit;
522 523
524 error = usermodehelper_disable();
525 if (error)
526 goto Exit;
527
523 /* Allocate memory management structures */ 528 /* Allocate memory management structures */
524 error = create_basic_memory_bitmaps(); 529 error = create_basic_memory_bitmaps();
525 if (error) 530 if (error)
@@ -558,6 +563,7 @@ int hibernate(void)
558 thaw_processes(); 563 thaw_processes();
559 Finish: 564 Finish:
560 free_basic_memory_bitmaps(); 565 free_basic_memory_bitmaps();
566 usermodehelper_enable();
561 Exit: 567 Exit:
562 pm_notifier_call_chain(PM_POST_HIBERNATION); 568 pm_notifier_call_chain(PM_POST_HIBERNATION);
563 pm_restore_console(); 569 pm_restore_console();
@@ -634,6 +640,10 @@ static int software_resume(void)
634 if (error) 640 if (error)
635 goto Finish; 641 goto Finish;
636 642
643 error = usermodehelper_disable();
644 if (error)
645 goto Finish;
646
637 error = create_basic_memory_bitmaps(); 647 error = create_basic_memory_bitmaps();
638 if (error) 648 if (error)
639 goto Finish; 649 goto Finish;
@@ -656,6 +666,7 @@ static int software_resume(void)
656 thaw_processes(); 666 thaw_processes();
657 Done: 667 Done:
658 free_basic_memory_bitmaps(); 668 free_basic_memory_bitmaps();
669 usermodehelper_enable();
659 Finish: 670 Finish:
660 pm_notifier_call_chain(PM_POST_RESTORE); 671 pm_notifier_call_chain(PM_POST_RESTORE);
661 pm_restore_console(); 672 pm_restore_console();
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 540b16b68565..19122cf6d827 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -14,6 +14,7 @@
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/kmod.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/console.h> 19#include <linux/console.h>
19#include <linux/cpu.h> 20#include <linux/cpu.h>
@@ -237,6 +238,10 @@ static int suspend_prepare(void)
237 if (error) 238 if (error)
238 goto Finish; 239 goto Finish;
239 240
241 error = usermodehelper_disable();
242 if (error)
243 goto Finish;
244
240 if (suspend_freeze_processes()) { 245 if (suspend_freeze_processes()) {
241 error = -EAGAIN; 246 error = -EAGAIN;
242 goto Thaw; 247 goto Thaw;
@@ -256,6 +261,7 @@ static int suspend_prepare(void)
256 261
257 Thaw: 262 Thaw:
258 suspend_thaw_processes(); 263 suspend_thaw_processes();
264 usermodehelper_enable();
259 Finish: 265 Finish:
260 pm_notifier_call_chain(PM_POST_SUSPEND); 266 pm_notifier_call_chain(PM_POST_SUSPEND);
261 pm_restore_console(); 267 pm_restore_console();
@@ -376,6 +382,7 @@ int suspend_devices_and_enter(suspend_state_t state)
376static void suspend_finish(void) 382static void suspend_finish(void)
377{ 383{
378 suspend_thaw_processes(); 384 suspend_thaw_processes();
385 usermodehelper_enable();
379 pm_notifier_call_chain(PM_POST_SUSPEND); 386 pm_notifier_call_chain(PM_POST_SUSPEND);
380 pm_restore_console(); 387 pm_restore_console();
381} 388}
diff --git a/kernel/power/user.c b/kernel/power/user.c
index a6332a313262..005b93d839ba 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -212,13 +212,20 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
212 case SNAPSHOT_FREEZE: 212 case SNAPSHOT_FREEZE:
213 if (data->frozen) 213 if (data->frozen)
214 break; 214 break;
215
215 printk("Syncing filesystems ... "); 216 printk("Syncing filesystems ... ");
216 sys_sync(); 217 sys_sync();
217 printk("done.\n"); 218 printk("done.\n");
218 219
219 error = freeze_processes(); 220 error = usermodehelper_disable();
220 if (error) 221 if (error)
222 break;
223
224 error = freeze_processes();
225 if (error) {
221 thaw_processes(); 226 thaw_processes();
227 usermodehelper_enable();
228 }
222 if (!error) 229 if (!error)
223 data->frozen = 1; 230 data->frozen = 1;
224 break; 231 break;
@@ -227,6 +234,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
227 if (!data->frozen || data->ready) 234 if (!data->frozen || data->ready)
228 break; 235 break;
229 thaw_processes(); 236 thaw_processes();
237 usermodehelper_enable();
230 data->frozen = 0; 238 data->frozen = 0;
231 break; 239 break;
232 240
diff --git a/kernel/printk.c b/kernel/printk.c
index a430fd04008b..6341af77eb65 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -13,7 +13,7 @@
13 * Fixed SMP synchronization, 08/08/99, Manfred Spraul 13 * Fixed SMP synchronization, 08/08/99, Manfred Spraul
14 * manfred@colorfullife.com 14 * manfred@colorfullife.com
15 * Rewrote bits to get rid of console_lock 15 * Rewrote bits to get rid of console_lock
16 * 01Mar01 Andrew Morton <andrewm@uow.edu.au> 16 * 01Mar01 Andrew Morton
17 */ 17 */
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -577,9 +577,6 @@ static int have_callable_console(void)
577 * @fmt: format string 577 * @fmt: format string
578 * 578 *
579 * This is printk(). It can be called from any context. We want it to work. 579 * This is printk(). It can be called from any context. We want it to work.
580 * Be aware of the fact that if oops_in_progress is not set, we might try to
581 * wake klogd up which could deadlock on runqueue lock if printk() is called
582 * from scheduler code.
583 * 580 *
584 * We try to grab the console_sem. If we succeed, it's easy - we log the output and 581 * We try to grab the console_sem. If we succeed, it's easy - we log the output and
585 * call the console drivers. If we fail to get the semaphore we place the output 582 * call the console drivers. If we fail to get the semaphore we place the output
@@ -593,6 +590,8 @@ static int have_callable_console(void)
593 * 590 *
594 * See also: 591 * See also:
595 * printf(3) 592 * printf(3)
593 *
594 * See the vsnprintf() documentation for format string extensions over C99.
596 */ 595 */
597 596
598asmlinkage int printk(const char *fmt, ...) 597asmlinkage int printk(const char *fmt, ...)
@@ -982,10 +981,25 @@ int is_console_locked(void)
982 return console_locked; 981 return console_locked;
983} 982}
984 983
985void wake_up_klogd(void) 984static DEFINE_PER_CPU(int, printk_pending);
985
986void printk_tick(void)
986{ 987{
987 if (!oops_in_progress && waitqueue_active(&log_wait)) 988 if (__get_cpu_var(printk_pending)) {
989 __get_cpu_var(printk_pending) = 0;
988 wake_up_interruptible(&log_wait); 990 wake_up_interruptible(&log_wait);
991 }
992}
993
994int printk_needs_cpu(int cpu)
995{
996 return per_cpu(printk_pending, cpu);
997}
998
999void wake_up_klogd(void)
1000{
1001 if (waitqueue_active(&log_wait))
1002 __raw_get_cpu_var(printk_pending) = 1;
989} 1003}
990 1004
991/** 1005/**
diff --git a/kernel/profile.c b/kernel/profile.c
index cd26bed4cc26..a9e422df6bf6 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -22,6 +22,8 @@
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <linux/highmem.h> 23#include <linux/highmem.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/slab.h>
26#include <linux/vmalloc.h>
25#include <asm/sections.h> 27#include <asm/sections.h>
26#include <asm/irq_regs.h> 28#include <asm/irq_regs.h>
27#include <asm/ptrace.h> 29#include <asm/ptrace.h>
@@ -50,11 +52,11 @@ static DEFINE_PER_CPU(int, cpu_profile_flip);
50static DEFINE_MUTEX(profile_flip_mutex); 52static DEFINE_MUTEX(profile_flip_mutex);
51#endif /* CONFIG_SMP */ 53#endif /* CONFIG_SMP */
52 54
53static int __init profile_setup(char *str) 55int profile_setup(char *str)
54{ 56{
55 static char __initdata schedstr[] = "schedule"; 57 static char schedstr[] = "schedule";
56 static char __initdata sleepstr[] = "sleep"; 58 static char sleepstr[] = "sleep";
57 static char __initdata kvmstr[] = "kvm"; 59 static char kvmstr[] = "kvm";
58 int par; 60 int par;
59 61
60 if (!strncmp(str, sleepstr, strlen(sleepstr))) { 62 if (!strncmp(str, sleepstr, strlen(sleepstr))) {
@@ -100,14 +102,33 @@ static int __init profile_setup(char *str)
100__setup("profile=", profile_setup); 102__setup("profile=", profile_setup);
101 103
102 104
103void __init profile_init(void) 105int profile_init(void)
104{ 106{
107 int buffer_bytes;
105 if (!prof_on) 108 if (!prof_on)
106 return; 109 return 0;
107 110
108 /* only text is profiled */ 111 /* only text is profiled */
109 prof_len = (_etext - _stext) >> prof_shift; 112 prof_len = (_etext - _stext) >> prof_shift;
110 prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t)); 113 buffer_bytes = prof_len*sizeof(atomic_t);
114 if (!slab_is_available()) {
115 prof_buffer = alloc_bootmem(buffer_bytes);
116 return 0;
117 }
118
119 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL);
120 if (prof_buffer)
121 return 0;
122
123 prof_buffer = alloc_pages_exact(buffer_bytes, GFP_KERNEL|__GFP_ZERO);
124 if (prof_buffer)
125 return 0;
126
127 prof_buffer = vmalloc(buffer_bytes);
128 if (prof_buffer)
129 return 0;
130
131 return -ENOMEM;
111} 132}
112 133
113/* Profile event notifications */ 134/* Profile event notifications */
@@ -527,7 +548,7 @@ static void __init profile_nop(void *unused)
527{ 548{
528} 549}
529 550
530static int __init create_hash_tables(void) 551static int create_hash_tables(void)
531{ 552{
532 int cpu; 553 int cpu;
533 554
@@ -575,14 +596,14 @@ out_cleanup:
575#define create_hash_tables() ({ 0; }) 596#define create_hash_tables() ({ 0; })
576#endif 597#endif
577 598
578static int __init create_proc_profile(void) 599int create_proc_profile(void)
579{ 600{
580 struct proc_dir_entry *entry; 601 struct proc_dir_entry *entry;
581 602
582 if (!prof_on) 603 if (!prof_on)
583 return 0; 604 return 0;
584 if (create_hash_tables()) 605 if (create_hash_tables())
585 return -1; 606 return -ENOMEM;
586 entry = proc_create("profile", S_IWUSR | S_IRUGO, 607 entry = proc_create("profile", S_IWUSR | S_IRUGO,
587 NULL, &proc_profile_operations); 608 NULL, &proc_profile_operations);
588 if (!entry) 609 if (!entry)
diff --git a/kernel/resource.c b/kernel/resource.c
index 414d6fc9131e..4089d12af6e0 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -38,10 +38,6 @@ EXPORT_SYMBOL(iomem_resource);
38 38
39static DEFINE_RWLOCK(resource_lock); 39static DEFINE_RWLOCK(resource_lock);
40 40
41#ifdef CONFIG_PROC_FS
42
43enum { MAX_IORES_LEVEL = 5 };
44
45static void *r_next(struct seq_file *m, void *v, loff_t *pos) 41static void *r_next(struct seq_file *m, void *v, loff_t *pos)
46{ 42{
47 struct resource *p = v; 43 struct resource *p = v;
@@ -53,6 +49,10 @@ static void *r_next(struct seq_file *m, void *v, loff_t *pos)
53 return p->sibling; 49 return p->sibling;
54} 50}
55 51
52#ifdef CONFIG_PROC_FS
53
54enum { MAX_IORES_LEVEL = 5 };
55
56static void *r_start(struct seq_file *m, loff_t *pos) 56static void *r_start(struct seq_file *m, loff_t *pos)
57 __acquires(resource_lock) 57 __acquires(resource_lock)
58{ 58{
@@ -549,13 +549,9 @@ static void __init __reserve_region_with_split(struct resource *root,
549 } 549 }
550 550
551 if (!res) { 551 if (!res) {
552 printk(KERN_DEBUG " __reserve_region_with_split: (%s) [%llx, %llx], res: (%s) [%llx, %llx]\n",
553 conflict->name, conflict->start, conflict->end,
554 name, start, end);
555
556 /* failed, split and try again */ 552 /* failed, split and try again */
557 553
558 /* conflict coverred whole area */ 554 /* conflict covered whole area */
559 if (conflict->start <= start && conflict->end >= end) 555 if (conflict->start <= start && conflict->end >= end)
560 return; 556 return;
561 557
@@ -630,33 +626,34 @@ struct resource * __request_region(struct resource *parent,
630{ 626{
631 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); 627 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
632 628
633 if (res) { 629 if (!res)
634 res->name = name; 630 return NULL;
635 res->start = start;
636 res->end = start + n - 1;
637 res->flags = IORESOURCE_BUSY;
638 631
639 write_lock(&resource_lock); 632 res->name = name;
633 res->start = start;
634 res->end = start + n - 1;
635 res->flags = IORESOURCE_BUSY;
640 636
641 for (;;) { 637 write_lock(&resource_lock);
642 struct resource *conflict;
643 638
644 conflict = __request_resource(parent, res); 639 for (;;) {
645 if (!conflict) 640 struct resource *conflict;
646 break;
647 if (conflict != parent) {
648 parent = conflict;
649 if (!(conflict->flags & IORESOURCE_BUSY))
650 continue;
651 }
652 641
653 /* Uhhuh, that didn't work out.. */ 642 conflict = __request_resource(parent, res);
654 kfree(res); 643 if (!conflict)
655 res = NULL;
656 break; 644 break;
645 if (conflict != parent) {
646 parent = conflict;
647 if (!(conflict->flags & IORESOURCE_BUSY))
648 continue;
657 } 649 }
658 write_unlock(&resource_lock); 650
651 /* Uhhuh, that didn't work out.. */
652 kfree(res);
653 res = NULL;
654 break;
659 } 655 }
656 write_unlock(&resource_lock);
660 return res; 657 return res;
661} 658}
662EXPORT_SYMBOL(__request_region); 659EXPORT_SYMBOL(__request_region);
@@ -831,3 +828,40 @@ static int __init reserve_setup(char *str)
831} 828}
832 829
833__setup("reserve=", reserve_setup); 830__setup("reserve=", reserve_setup);
831
832/*
833 * Check if the requested addr and size spans more than any slot in the
834 * iomem resource tree.
835 */
836int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
837{
838 struct resource *p = &iomem_resource;
839 int err = 0;
840 loff_t l;
841
842 read_lock(&resource_lock);
843 for (p = p->child; p ; p = r_next(NULL, p, &l)) {
844 /*
845 * We can probably skip the resources without
846 * IORESOURCE_IO attribute?
847 */
848 if (p->start >= addr + size)
849 continue;
850 if (p->end < addr)
851 continue;
852 if (p->start <= addr && (p->end >= addr + size - 1))
853 continue;
854 printk(KERN_WARNING "resource map sanity check conflict: "
855 "0x%llx 0x%llx 0x%llx 0x%llx %s\n",
856 (unsigned long long)addr,
857 (unsigned long long)(addr + size - 1),
858 (unsigned long long)p->start,
859 (unsigned long long)p->end,
860 p->name);
861 err = -1;
862 break;
863 }
864 read_unlock(&resource_lock);
865
866 return err;
867}
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index e8ab096ddfe3..81787248b60f 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -118,13 +118,13 @@ static u64 __update_sched_clock(struct sched_clock_data *scd, u64 now)
118 118
119 /* 119 /*
120 * scd->clock = clamp(scd->tick_gtod + delta, 120 * scd->clock = clamp(scd->tick_gtod + delta,
121 * max(scd->tick_gtod, scd->clock), 121 * max(scd->tick_gtod, scd->clock),
122 * scd->tick_gtod + TICK_NSEC); 122 * max(scd->clock, scd->tick_gtod + TICK_NSEC));
123 */ 123 */
124 124
125 clock = scd->tick_gtod + delta; 125 clock = scd->tick_gtod + delta;
126 min_clock = wrap_max(scd->tick_gtod, scd->clock); 126 min_clock = wrap_max(scd->tick_gtod, scd->clock);
127 max_clock = scd->tick_gtod + TICK_NSEC; 127 max_clock = wrap_max(scd->clock, scd->tick_gtod + TICK_NSEC);
128 128
129 clock = wrap_max(clock, min_clock); 129 clock = wrap_max(clock, min_clock);
130 clock = wrap_min(clock, max_clock); 130 clock = wrap_min(clock, max_clock);
diff --git a/kernel/softirq.c b/kernel/softirq.c
index c506f266a6b9..37d67aa2d56f 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -46,7 +46,7 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
46EXPORT_SYMBOL(irq_stat); 46EXPORT_SYMBOL(irq_stat);
47#endif 47#endif
48 48
49static struct softirq_action softirq_vec[32] __cacheline_aligned_in_smp; 49static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
50 50
51static DEFINE_PER_CPU(struct task_struct *, ksoftirqd); 51static DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
52 52
@@ -205,7 +205,18 @@ restart:
205 205
206 do { 206 do {
207 if (pending & 1) { 207 if (pending & 1) {
208 int prev_count = preempt_count();
209
208 h->action(h); 210 h->action(h);
211
212 if (unlikely(prev_count != preempt_count())) {
213 printk(KERN_ERR "huh, entered softirq %td %p"
214 "with preempt_count %08x,"
215 " exited with %08x?\n", h - softirq_vec,
216 h->action, prev_count, preempt_count());
217 preempt_count() = prev_count;
218 }
219
209 rcu_bh_qsctr_inc(cpu); 220 rcu_bh_qsctr_inc(cpu);
210 } 221 }
211 h++; 222 h++;
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index cb838ee93a82..3953e4aed733 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -226,7 +226,7 @@ static void check_hung_uninterruptible_tasks(int this_cpu)
226 * If the system crashed already then all bets are off, 226 * If the system crashed already then all bets are off,
227 * do not report extra hung tasks: 227 * do not report extra hung tasks:
228 */ 228 */
229 if ((tainted & TAINT_DIE) || did_panic) 229 if (test_taint(TAINT_DIE) || did_panic)
230 return; 230 return;
231 231
232 read_lock(&tasklist_lock); 232 read_lock(&tasklist_lock);
diff --git a/kernel/sys.c b/kernel/sys.c
index 234d9454294e..0bc8fa3c2288 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1349,8 +1349,10 @@ asmlinkage long sys_sethostname(char __user *name, int len)
1349 down_write(&uts_sem); 1349 down_write(&uts_sem);
1350 errno = -EFAULT; 1350 errno = -EFAULT;
1351 if (!copy_from_user(tmp, name, len)) { 1351 if (!copy_from_user(tmp, name, len)) {
1352 memcpy(utsname()->nodename, tmp, len); 1352 struct new_utsname *u = utsname();
1353 utsname()->nodename[len] = 0; 1353
1354 memcpy(u->nodename, tmp, len);
1355 memset(u->nodename + len, 0, sizeof(u->nodename) - len);
1354 errno = 0; 1356 errno = 0;
1355 } 1357 }
1356 up_write(&uts_sem); 1358 up_write(&uts_sem);
@@ -1362,15 +1364,17 @@ asmlinkage long sys_sethostname(char __user *name, int len)
1362asmlinkage long sys_gethostname(char __user *name, int len) 1364asmlinkage long sys_gethostname(char __user *name, int len)
1363{ 1365{
1364 int i, errno; 1366 int i, errno;
1367 struct new_utsname *u;
1365 1368
1366 if (len < 0) 1369 if (len < 0)
1367 return -EINVAL; 1370 return -EINVAL;
1368 down_read(&uts_sem); 1371 down_read(&uts_sem);
1369 i = 1 + strlen(utsname()->nodename); 1372 u = utsname();
1373 i = 1 + strlen(u->nodename);
1370 if (i > len) 1374 if (i > len)
1371 i = len; 1375 i = len;
1372 errno = 0; 1376 errno = 0;
1373 if (copy_to_user(name, utsname()->nodename, i)) 1377 if (copy_to_user(name, u->nodename, i))
1374 errno = -EFAULT; 1378 errno = -EFAULT;
1375 up_read(&uts_sem); 1379 up_read(&uts_sem);
1376 return errno; 1380 return errno;
@@ -1395,8 +1399,10 @@ asmlinkage long sys_setdomainname(char __user *name, int len)
1395 down_write(&uts_sem); 1399 down_write(&uts_sem);
1396 errno = -EFAULT; 1400 errno = -EFAULT;
1397 if (!copy_from_user(tmp, name, len)) { 1401 if (!copy_from_user(tmp, name, len)) {
1398 memcpy(utsname()->domainname, tmp, len); 1402 struct new_utsname *u = utsname();
1399 utsname()->domainname[len] = 0; 1403
1404 memcpy(u->domainname, tmp, len);
1405 memset(u->domainname + len, 0, sizeof(u->domainname) - len);
1400 errno = 0; 1406 errno = 0;
1401 } 1407 }
1402 up_write(&uts_sem); 1408 up_write(&uts_sem);
@@ -1450,14 +1456,22 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
1450 return -EINVAL; 1456 return -EINVAL;
1451 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim))) 1457 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
1452 return -EFAULT; 1458 return -EFAULT;
1453 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1454 return -EINVAL;
1455 old_rlim = current->signal->rlim + resource; 1459 old_rlim = current->signal->rlim + resource;
1456 if ((new_rlim.rlim_max > old_rlim->rlim_max) && 1460 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
1457 !capable(CAP_SYS_RESOURCE)) 1461 !capable(CAP_SYS_RESOURCE))
1458 return -EPERM; 1462 return -EPERM;
1459 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open) 1463
1460 return -EPERM; 1464 if (resource == RLIMIT_NOFILE) {
1465 if (new_rlim.rlim_max == RLIM_INFINITY)
1466 new_rlim.rlim_max = sysctl_nr_open;
1467 if (new_rlim.rlim_cur == RLIM_INFINITY)
1468 new_rlim.rlim_cur = sysctl_nr_open;
1469 if (new_rlim.rlim_max > sysctl_nr_open)
1470 return -EPERM;
1471 }
1472
1473 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1474 return -EINVAL;
1461 1475
1462 retval = security_task_setrlimit(resource, &new_rlim); 1476 retval = security_task_setrlimit(resource, &new_rlim);
1463 if (retval) 1477 if (retval)
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 503d8d4eb80a..a77b27b11b04 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -126,6 +126,11 @@ cond_syscall(sys_vm86);
126cond_syscall(compat_sys_ipc); 126cond_syscall(compat_sys_ipc);
127cond_syscall(compat_sys_sysctl); 127cond_syscall(compat_sys_sysctl);
128cond_syscall(sys_flock); 128cond_syscall(sys_flock);
129cond_syscall(sys_io_setup);
130cond_syscall(sys_io_destroy);
131cond_syscall(sys_io_submit);
132cond_syscall(sys_io_cancel);
133cond_syscall(sys_io_getevents);
129 134
130/* arch-specific weak syscall entries */ 135/* arch-specific weak syscall entries */
131cond_syscall(sys_pciconfig_read); 136cond_syscall(sys_pciconfig_read);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index cfc5295f1e82..617d41e4d6a0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -149,7 +149,7 @@ extern int max_lock_depth;
149#ifdef CONFIG_PROC_SYSCTL 149#ifdef CONFIG_PROC_SYSCTL
150static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 150static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
151 void __user *buffer, size_t *lenp, loff_t *ppos); 151 void __user *buffer, size_t *lenp, loff_t *ppos);
152static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, 152static int proc_taint(struct ctl_table *table, int write, struct file *filp,
153 void __user *buffer, size_t *lenp, loff_t *ppos); 153 void __user *buffer, size_t *lenp, loff_t *ppos);
154#endif 154#endif
155 155
@@ -379,10 +379,9 @@ static struct ctl_table kern_table[] = {
379#ifdef CONFIG_PROC_SYSCTL 379#ifdef CONFIG_PROC_SYSCTL
380 { 380 {
381 .procname = "tainted", 381 .procname = "tainted",
382 .data = &tainted, 382 .maxlen = sizeof(long),
383 .maxlen = sizeof(int),
384 .mode = 0644, 383 .mode = 0644,
385 .proc_handler = &proc_dointvec_taint, 384 .proc_handler = &proc_taint,
386 }, 385 },
387#endif 386#endif
388#ifdef CONFIG_LATENCYTOP 387#ifdef CONFIG_LATENCYTOP
@@ -1282,6 +1281,7 @@ static struct ctl_table fs_table[] = {
1282 .extra2 = &two, 1281 .extra2 = &two,
1283 }, 1282 },
1284#endif 1283#endif
1284#ifdef CONFIG_AIO
1285 { 1285 {
1286 .procname = "aio-nr", 1286 .procname = "aio-nr",
1287 .data = &aio_nr, 1287 .data = &aio_nr,
@@ -1296,6 +1296,7 @@ static struct ctl_table fs_table[] = {
1296 .mode = 0644, 1296 .mode = 0644,
1297 .proc_handler = &proc_doulongvec_minmax, 1297 .proc_handler = &proc_doulongvec_minmax,
1298 }, 1298 },
1299#endif /* CONFIG_AIO */
1299#ifdef CONFIG_INOTIFY_USER 1300#ifdef CONFIG_INOTIFY_USER
1300 { 1301 {
1301 .ctl_name = FS_INOTIFY, 1302 .ctl_name = FS_INOTIFY,
@@ -1501,7 +1502,6 @@ void register_sysctl_root(struct ctl_table_root *root)
1501/* Perform the actual read/write of a sysctl table entry. */ 1502/* Perform the actual read/write of a sysctl table entry. */
1502static int do_sysctl_strategy(struct ctl_table_root *root, 1503static int do_sysctl_strategy(struct ctl_table_root *root,
1503 struct ctl_table *table, 1504 struct ctl_table *table,
1504 int __user *name, int nlen,
1505 void __user *oldval, size_t __user *oldlenp, 1505 void __user *oldval, size_t __user *oldlenp,
1506 void __user *newval, size_t newlen) 1506 void __user *newval, size_t newlen)
1507{ 1507{
@@ -1515,8 +1515,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
1515 return -EPERM; 1515 return -EPERM;
1516 1516
1517 if (table->strategy) { 1517 if (table->strategy) {
1518 rc = table->strategy(table, name, nlen, oldval, oldlenp, 1518 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
1519 newval, newlen);
1520 if (rc < 0) 1519 if (rc < 0)
1521 return rc; 1520 return rc;
1522 if (rc > 0) 1521 if (rc > 0)
@@ -1526,8 +1525,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
1526 /* If there is no strategy routine, or if the strategy returns 1525 /* If there is no strategy routine, or if the strategy returns
1527 * zero, proceed with automatic r/w */ 1526 * zero, proceed with automatic r/w */
1528 if (table->data && table->maxlen) { 1527 if (table->data && table->maxlen) {
1529 rc = sysctl_data(table, name, nlen, oldval, oldlenp, 1528 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
1530 newval, newlen);
1531 if (rc < 0) 1529 if (rc < 0)
1532 return rc; 1530 return rc;
1533 } 1531 }
@@ -1559,7 +1557,7 @@ repeat:
1559 table = table->child; 1557 table = table->child;
1560 goto repeat; 1558 goto repeat;
1561 } 1559 }
1562 error = do_sysctl_strategy(root, table, name, nlen, 1560 error = do_sysctl_strategy(root, table,
1563 oldval, oldlenp, 1561 oldval, oldlenp,
1564 newval, newlen); 1562 newval, newlen);
1565 return error; 1563 return error;
@@ -2228,49 +2226,39 @@ int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2228 NULL,NULL); 2226 NULL,NULL);
2229} 2227}
2230 2228
2231#define OP_SET 0
2232#define OP_AND 1
2233#define OP_OR 2
2234
2235static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
2236 int *valp,
2237 int write, void *data)
2238{
2239 int op = *(int *)data;
2240 if (write) {
2241 int val = *negp ? -*lvalp : *lvalp;
2242 switch(op) {
2243 case OP_SET: *valp = val; break;
2244 case OP_AND: *valp &= val; break;
2245 case OP_OR: *valp |= val; break;
2246 }
2247 } else {
2248 int val = *valp;
2249 if (val < 0) {
2250 *negp = -1;
2251 *lvalp = (unsigned long)-val;
2252 } else {
2253 *negp = 0;
2254 *lvalp = (unsigned long)val;
2255 }
2256 }
2257 return 0;
2258}
2259
2260/* 2229/*
2261 * Taint values can only be increased 2230 * Taint values can only be increased
2231 * This means we can safely use a temporary.
2262 */ 2232 */
2263static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, 2233static int proc_taint(struct ctl_table *table, int write, struct file *filp,
2264 void __user *buffer, size_t *lenp, loff_t *ppos) 2234 void __user *buffer, size_t *lenp, loff_t *ppos)
2265{ 2235{
2266 int op; 2236 struct ctl_table t;
2237 unsigned long tmptaint = get_taint();
2238 int err;
2267 2239
2268 if (write && !capable(CAP_SYS_ADMIN)) 2240 if (write && !capable(CAP_SYS_ADMIN))
2269 return -EPERM; 2241 return -EPERM;
2270 2242
2271 op = OP_OR; 2243 t = *table;
2272 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 2244 t.data = &tmptaint;
2273 do_proc_dointvec_bset_conv,&op); 2245 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2246 if (err < 0)
2247 return err;
2248
2249 if (write) {
2250 /*
2251 * Poor man's atomic or. Not worth adding a primitive
2252 * to everyone's atomic.h for this
2253 */
2254 int i;
2255 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2256 if ((tmptaint >> i) & 1)
2257 add_taint(i);
2258 }
2259 }
2260
2261 return err;
2274} 2262}
2275 2263
2276struct do_proc_dointvec_minmax_conv_param { 2264struct do_proc_dointvec_minmax_conv_param {
@@ -2718,7 +2706,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2718 */ 2706 */
2719 2707
2720/* The generic sysctl data routine (used if no strategy routine supplied) */ 2708/* The generic sysctl data routine (used if no strategy routine supplied) */
2721int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 2709int sysctl_data(struct ctl_table *table,
2722 void __user *oldval, size_t __user *oldlenp, 2710 void __user *oldval, size_t __user *oldlenp,
2723 void __user *newval, size_t newlen) 2711 void __user *newval, size_t newlen)
2724{ 2712{
@@ -2752,7 +2740,7 @@ int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2752} 2740}
2753 2741
2754/* The generic string strategy routine: */ 2742/* The generic string strategy routine: */
2755int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 2743int sysctl_string(struct ctl_table *table,
2756 void __user *oldval, size_t __user *oldlenp, 2744 void __user *oldval, size_t __user *oldlenp,
2757 void __user *newval, size_t newlen) 2745 void __user *newval, size_t newlen)
2758{ 2746{
@@ -2798,7 +2786,7 @@ int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
2798 * are between the minimum and maximum values given in the arrays 2786 * are between the minimum and maximum values given in the arrays
2799 * table->extra1 and table->extra2, respectively. 2787 * table->extra1 and table->extra2, respectively.
2800 */ 2788 */
2801int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 2789int sysctl_intvec(struct ctl_table *table,
2802 void __user *oldval, size_t __user *oldlenp, 2790 void __user *oldval, size_t __user *oldlenp,
2803 void __user *newval, size_t newlen) 2791 void __user *newval, size_t newlen)
2804{ 2792{
@@ -2834,7 +2822,7 @@ int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
2834} 2822}
2835 2823
2836/* Strategy function to convert jiffies to seconds */ 2824/* Strategy function to convert jiffies to seconds */
2837int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 2825int sysctl_jiffies(struct ctl_table *table,
2838 void __user *oldval, size_t __user *oldlenp, 2826 void __user *oldval, size_t __user *oldlenp,
2839 void __user *newval, size_t newlen) 2827 void __user *newval, size_t newlen)
2840{ 2828{
@@ -2868,7 +2856,7 @@ int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
2868} 2856}
2869 2857
2870/* Strategy function to convert jiffies to seconds */ 2858/* Strategy function to convert jiffies to seconds */
2871int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 2859int sysctl_ms_jiffies(struct ctl_table *table,
2872 void __user *oldval, size_t __user *oldlenp, 2860 void __user *oldval, size_t __user *oldlenp,
2873 void __user *newval, size_t newlen) 2861 void __user *newval, size_t newlen)
2874{ 2862{
@@ -2923,35 +2911,35 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2923 return error; 2911 return error;
2924} 2912}
2925 2913
2926int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 2914int sysctl_data(struct ctl_table *table,
2927 void __user *oldval, size_t __user *oldlenp, 2915 void __user *oldval, size_t __user *oldlenp,
2928 void __user *newval, size_t newlen) 2916 void __user *newval, size_t newlen)
2929{ 2917{
2930 return -ENOSYS; 2918 return -ENOSYS;
2931} 2919}
2932 2920
2933int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 2921int sysctl_string(struct ctl_table *table,
2934 void __user *oldval, size_t __user *oldlenp, 2922 void __user *oldval, size_t __user *oldlenp,
2935 void __user *newval, size_t newlen) 2923 void __user *newval, size_t newlen)
2936{ 2924{
2937 return -ENOSYS; 2925 return -ENOSYS;
2938} 2926}
2939 2927
2940int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 2928int sysctl_intvec(struct ctl_table *table,
2941 void __user *oldval, size_t __user *oldlenp, 2929 void __user *oldval, size_t __user *oldlenp,
2942 void __user *newval, size_t newlen) 2930 void __user *newval, size_t newlen)
2943{ 2931{
2944 return -ENOSYS; 2932 return -ENOSYS;
2945} 2933}
2946 2934
2947int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 2935int sysctl_jiffies(struct ctl_table *table,
2948 void __user *oldval, size_t __user *oldlenp, 2936 void __user *oldval, size_t __user *oldlenp,
2949 void __user *newval, size_t newlen) 2937 void __user *newval, size_t newlen)
2950{ 2938{
2951 return -ENOSYS; 2939 return -ENOSYS;
2952} 2940}
2953 2941
2954int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 2942int sysctl_ms_jiffies(struct ctl_table *table,
2955 void __user *oldval, size_t __user *oldlenp, 2943 void __user *oldval, size_t __user *oldlenp,
2956 void __user *newval, size_t newlen) 2944 void __user *newval, size_t newlen)
2957{ 2945{
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
index 8d53106a0a92..95ed42951e0a 100644
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -3,7 +3,6 @@
3# 3#
4config TICK_ONESHOT 4config TICK_ONESHOT
5 bool 5 bool
6 default n
7 6
8config NO_HZ 7config NO_HZ
9 bool "Tickless System (Dynamic Ticks)" 8 bool "Tickless System (Dynamic Ticks)"
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index a4d219398167..b711ffcb106c 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -270,7 +270,7 @@ void tick_nohz_stop_sched_tick(int inidle)
270 next_jiffies = get_next_timer_interrupt(last_jiffies); 270 next_jiffies = get_next_timer_interrupt(last_jiffies);
271 delta_jiffies = next_jiffies - last_jiffies; 271 delta_jiffies = next_jiffies - last_jiffies;
272 272
273 if (rcu_needs_cpu(cpu)) 273 if (rcu_needs_cpu(cpu) || printk_needs_cpu(cpu))
274 delta_jiffies = 1; 274 delta_jiffies = 1;
275 /* 275 /*
276 * Do not stop the tick, if we are only one off 276 * Do not stop the tick, if we are only one off
diff --git a/kernel/timer.c b/kernel/timer.c
index 03bc7f1f1593..510fe69351ca 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -978,6 +978,7 @@ void update_process_times(int user_tick)
978 run_local_timers(); 978 run_local_timers();
979 if (rcu_pending(cpu)) 979 if (rcu_pending(cpu))
980 rcu_check_callbacks(cpu, user_tick); 980 rcu_check_callbacks(cpu, user_tick);
981 printk_tick();
981 scheduler_tick(); 982 scheduler_tick();
982 run_posix_cpu_timers(p); 983 run_posix_cpu_timers(p);
983} 984}
diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 4ab9659d269e..3b34b3545936 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -60,7 +60,7 @@ static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
60 60
61#ifdef CONFIG_SYSCTL_SYSCALL 61#ifdef CONFIG_SYSCTL_SYSCALL
62/* The generic string strategy routine: */ 62/* The generic string strategy routine: */
63static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen, 63static int sysctl_uts_string(ctl_table *table,
64 void __user *oldval, size_t __user *oldlenp, 64 void __user *oldval, size_t __user *oldlenp,
65 void __user *newval, size_t newlen) 65 void __user *newval, size_t newlen)
66{ 66{
@@ -69,8 +69,7 @@ static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
69 write = newval && newlen; 69 write = newval && newlen;
70 memcpy(&uts_table, table, sizeof(uts_table)); 70 memcpy(&uts_table, table, sizeof(uts_table));
71 uts_table.data = get_uts(table, write); 71 uts_table.data = get_uts(table, write);
72 r = sysctl_string(&uts_table, name, nlen, 72 r = sysctl_string(&uts_table, oldval, oldlenp, newval, newlen);
73 oldval, oldlenp, newval, newlen);
74 put_uts(table, write, uts_table.data); 73 put_uts(table, write, uts_table.data);
75 return r; 74 return r;
76} 75}
diff --git a/kernel/wait.c b/kernel/wait.c
index c275c56cf2d3..cd87131f2fc2 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -72,12 +72,7 @@ prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
72 spin_lock_irqsave(&q->lock, flags); 72 spin_lock_irqsave(&q->lock, flags);
73 if (list_empty(&wait->task_list)) 73 if (list_empty(&wait->task_list))
74 __add_wait_queue(q, wait); 74 __add_wait_queue(q, wait);
75 /* 75 set_current_state(state);
76 * don't alter the task state if this is just going to
77 * queue an async wait queue callback
78 */
79 if (is_sync_wait(wait))
80 set_current_state(state);
81 spin_unlock_irqrestore(&q->lock, flags); 76 spin_unlock_irqrestore(&q->lock, flags);
82} 77}
83EXPORT_SYMBOL(prepare_to_wait); 78EXPORT_SYMBOL(prepare_to_wait);
@@ -91,12 +86,7 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
91 spin_lock_irqsave(&q->lock, flags); 86 spin_lock_irqsave(&q->lock, flags);
92 if (list_empty(&wait->task_list)) 87 if (list_empty(&wait->task_list))
93 __add_wait_queue_tail(q, wait); 88 __add_wait_queue_tail(q, wait);
94 /* 89 set_current_state(state);
95 * don't alter the task state if this is just going to
96 * queue an async wait queue callback
97 */
98 if (is_sync_wait(wait))
99 set_current_state(state);
100 spin_unlock_irqrestore(&q->lock, flags); 90 spin_unlock_irqrestore(&q->lock, flags);
101} 91}
102EXPORT_SYMBOL(prepare_to_wait_exclusive); 92EXPORT_SYMBOL(prepare_to_wait_exclusive);
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 4048e92aa04f..714afad46539 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -9,7 +9,7 @@
9 * Derived from the taskqueue/keventd code by: 9 * Derived from the taskqueue/keventd code by:
10 * 10 *
11 * David Woodhouse <dwmw2@infradead.org> 11 * David Woodhouse <dwmw2@infradead.org>
12 * Andrew Morton <andrewm@uow.edu.au> 12 * Andrew Morton
13 * Kai Petzke <wpp@marie.physik.tu-berlin.de> 13 * Kai Petzke <wpp@marie.physik.tu-berlin.de>
14 * Theodore Ts'o <tytso@mit.edu> 14 * Theodore Ts'o <tytso@mit.edu>
15 * 15 *
diff --git a/lib/Kconfig b/lib/Kconfig
index c7ad7a5b3535..85cf7ea978aa 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -8,10 +8,10 @@ config BITREVERSE
8 tristate 8 tristate
9 9
10config GENERIC_FIND_FIRST_BIT 10config GENERIC_FIND_FIRST_BIT
11 def_bool n 11 bool
12 12
13config GENERIC_FIND_NEXT_BIT 13config GENERIC_FIND_NEXT_BIT
14 def_bool n 14 bool
15 15
16config CRC_CCITT 16config CRC_CCITT
17 tristate "CRC-CCITT functions" 17 tristate "CRC-CCITT functions"
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index aa81d2848448..31d784dd80d0 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -807,6 +807,61 @@ menuconfig BUILD_DOCSRC
807 807
808 Say N if you are unsure. 808 Say N if you are unsure.
809 809
810config DYNAMIC_PRINTK_DEBUG
811 bool "Enable dynamic printk() call support"
812 default n
813 depends on PRINTK
814 select PRINTK_DEBUG
815 help
816
817 Compiles debug level messages into the kernel, which would not
818 otherwise be available at runtime. These messages can then be
819 enabled/disabled on a per module basis. This mechanism implicitly
820 enables all pr_debug() and dev_dbg() calls. The impact of this
821 compile option is a larger kernel text size of about 2%.
822
823 Usage:
824
825 Dynamic debugging is controlled by the debugfs file,
826 dynamic_printk/modules. This file contains a list of the modules that
827 can be enabled. The format of the file is the module name, followed
828 by a set of flags that can be enabled. The first flag is always the
829 'enabled' flag. For example:
830
831 <module_name> <enabled=0/1>
832 .
833 .
834 .
835
836 <module_name> : Name of the module in which the debug call resides
837 <enabled=0/1> : whether the messages are enabled or not
838
839 From a live system:
840
841 snd_hda_intel enabled=0
842 fixup enabled=0
843 driver enabled=0
844
845 Enable a module:
846
847 $echo "set enabled=1 <module_name>" > dynamic_printk/modules
848
849 Disable a module:
850
851 $echo "set enabled=0 <module_name>" > dynamic_printk/modules
852
853 Enable all modules:
854
855 $echo "set enabled=1 all" > dynamic_printk/modules
856
857 Disable all modules:
858
859 $echo "set enabled=0 all" > dynamic_printk/modules
860
861 Finally, passing "dynamic_printk" at the command line enables
862 debugging for all modules. This mode can be turned off via the above
863 disable command.
864
810source "samples/Kconfig" 865source "samples/Kconfig"
811 866
812source "lib/Kconfig.kgdb" 867source "lib/Kconfig.kgdb"
diff --git a/lib/Makefile b/lib/Makefile
index 44001af76a7d..16feaab057b2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -81,6 +81,8 @@ obj-$(CONFIG_HAVE_LMB) += lmb.o
81 81
82obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o 82obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
83 83
84obj-$(CONFIG_DYNAMIC_PRINTK_DEBUG) += dynamic_printk.o
85
84hostprogs-y := gen_crc32table 86hostprogs-y := gen_crc32table
85clean-files := crc32table.h 87clean-files := crc32table.h
86 88
diff --git a/lib/dynamic_printk.c b/lib/dynamic_printk.c
new file mode 100644
index 000000000000..d640f87bdc9e
--- /dev/null
+++ b/lib/dynamic_printk.c
@@ -0,0 +1,418 @@
1/*
2 * lib/dynamic_printk.c
3 *
4 * make pr_debug()/dev_dbg() calls runtime configurable based upon their
5 * their source module.
6 *
7 * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com>
8 */
9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/uaccess.h>
13#include <linux/seq_file.h>
14#include <linux/debugfs.h>
15#include <linux/fs.h>
16
17extern struct mod_debug __start___verbose[];
18extern struct mod_debug __stop___verbose[];
19
20struct debug_name {
21 struct hlist_node hlist;
22 struct hlist_node hlist2;
23 int hash1;
24 int hash2;
25 char *name;
26 int enable;
27 int type;
28};
29
30static int nr_entries;
31static int num_enabled;
32int dynamic_enabled = DYNAMIC_ENABLED_NONE;
33static struct hlist_head module_table[DEBUG_HASH_TABLE_SIZE] =
34 { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
35static struct hlist_head module_table2[DEBUG_HASH_TABLE_SIZE] =
36 { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
37static DECLARE_MUTEX(debug_list_mutex);
38
39/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
40 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
41 * use independent hash functions, to reduce the chance of false positives.
42 */
43long long dynamic_printk_enabled;
44EXPORT_SYMBOL_GPL(dynamic_printk_enabled);
45long long dynamic_printk_enabled2;
46EXPORT_SYMBOL_GPL(dynamic_printk_enabled2);
47
48/* returns the debug module pointer. */
49static struct debug_name *find_debug_module(char *module_name)
50{
51 int i;
52 struct hlist_head *head;
53 struct hlist_node *node;
54 struct debug_name *element;
55
56 element = NULL;
57 for (i = 0; i < DEBUG_HASH_TABLE_SIZE; i++) {
58 head = &module_table[i];
59 hlist_for_each_entry_rcu(element, node, head, hlist)
60 if (!strcmp(element->name, module_name))
61 return element;
62 }
63 return NULL;
64}
65
66/* returns the debug module pointer. */
67static struct debug_name *find_debug_module_hash(char *module_name, int hash)
68{
69 struct hlist_head *head;
70 struct hlist_node *node;
71 struct debug_name *element;
72
73 element = NULL;
74 head = &module_table[hash];
75 hlist_for_each_entry_rcu(element, node, head, hlist)
76 if (!strcmp(element->name, module_name))
77 return element;
78 return NULL;
79}
80
81/* caller must hold mutex*/
82static int __add_debug_module(char *mod_name, int hash, int hash2)
83{
84 struct debug_name *new;
85 char *module_name;
86 int ret = 0;
87
88 if (find_debug_module(mod_name)) {
89 ret = -EINVAL;
90 goto out;
91 }
92 module_name = kmalloc(strlen(mod_name) + 1, GFP_KERNEL);
93 if (!module_name) {
94 ret = -ENOMEM;
95 goto out;
96 }
97 module_name = strcpy(module_name, mod_name);
98 module_name[strlen(mod_name)] = '\0';
99 new = kzalloc(sizeof(struct debug_name), GFP_KERNEL);
100 if (!new) {
101 kfree(module_name);
102 ret = -ENOMEM;
103 goto out;
104 }
105 INIT_HLIST_NODE(&new->hlist);
106 INIT_HLIST_NODE(&new->hlist2);
107 new->name = module_name;
108 new->hash1 = hash;
109 new->hash2 = hash2;
110 hlist_add_head_rcu(&new->hlist, &module_table[hash]);
111 hlist_add_head_rcu(&new->hlist2, &module_table2[hash2]);
112 nr_entries++;
113out:
114 return ret;
115}
116
117int unregister_dynamic_debug_module(char *mod_name)
118{
119 struct debug_name *element;
120 int ret = 0;
121
122 down(&debug_list_mutex);
123 element = find_debug_module(mod_name);
124 if (!element) {
125 ret = -EINVAL;
126 goto out;
127 }
128 hlist_del_rcu(&element->hlist);
129 hlist_del_rcu(&element->hlist2);
130 synchronize_rcu();
131 kfree(element->name);
132 if (element->enable)
133 num_enabled--;
134 kfree(element);
135 nr_entries--;
136out:
137 up(&debug_list_mutex);
138 return 0;
139}
140EXPORT_SYMBOL_GPL(unregister_dynamic_debug_module);
141
142int register_dynamic_debug_module(char *mod_name, int type, char *share_name,
143 char *flags, int hash, int hash2)
144{
145 struct debug_name *elem;
146 int ret = 0;
147
148 down(&debug_list_mutex);
149 elem = find_debug_module(mod_name);
150 if (!elem) {
151 if (__add_debug_module(mod_name, hash, hash2))
152 goto out;
153 elem = find_debug_module(mod_name);
154 if (dynamic_enabled == DYNAMIC_ENABLED_ALL &&
155 !strcmp(mod_name, share_name)) {
156 elem->enable = true;
157 num_enabled++;
158 }
159 }
160 elem->type |= type;
161out:
162 up(&debug_list_mutex);
163 return ret;
164}
165EXPORT_SYMBOL_GPL(register_dynamic_debug_module);
166
167int __dynamic_dbg_enabled_helper(char *mod_name, int type, int value, int hash)
168{
169 struct debug_name *elem;
170 int ret = 0;
171
172 if (dynamic_enabled == DYNAMIC_ENABLED_ALL)
173 return 1;
174 rcu_read_lock();
175 elem = find_debug_module_hash(mod_name, hash);
176 if (elem && elem->enable)
177 ret = 1;
178 rcu_read_unlock();
179 return ret;
180}
181EXPORT_SYMBOL_GPL(__dynamic_dbg_enabled_helper);
182
183static void set_all(bool enable)
184{
185 struct debug_name *e;
186 struct hlist_node *node;
187 int i;
188 long long enable_mask;
189
190 for (i = 0; i < DEBUG_HASH_TABLE_SIZE; i++) {
191 if (module_table[i].first != NULL) {
192 hlist_for_each_entry(e, node, &module_table[i], hlist) {
193 e->enable = enable;
194 }
195 }
196 }
197 if (enable)
198 enable_mask = ULLONG_MAX;
199 else
200 enable_mask = 0;
201 dynamic_printk_enabled = enable_mask;
202 dynamic_printk_enabled2 = enable_mask;
203}
204
205static int disabled_hash(int i, bool first_table)
206{
207 struct debug_name *e;
208 struct hlist_node *node;
209
210 if (first_table) {
211 hlist_for_each_entry(e, node, &module_table[i], hlist) {
212 if (e->enable)
213 return 0;
214 }
215 } else {
216 hlist_for_each_entry(e, node, &module_table2[i], hlist2) {
217 if (e->enable)
218 return 0;
219 }
220 }
221 return 1;
222}
223
224static ssize_t pr_debug_write(struct file *file, const char __user *buf,
225 size_t length, loff_t *ppos)
226{
227 char *buffer, *s, *value_str, *setting_str;
228 int err, value;
229 struct debug_name *elem = NULL;
230 int all = 0;
231
232 if (length > PAGE_SIZE || length < 0)
233 return -EINVAL;
234
235 buffer = (char *)__get_free_page(GFP_KERNEL);
236 if (!buffer)
237 return -ENOMEM;
238
239 err = -EFAULT;
240 if (copy_from_user(buffer, buf, length))
241 goto out;
242
243 err = -EINVAL;
244 if (length < PAGE_SIZE)
245 buffer[length] = '\0';
246 else if (buffer[PAGE_SIZE-1])
247 goto out;
248
249 err = -EINVAL;
250 down(&debug_list_mutex);
251
252 if (strncmp("set", buffer, 3))
253 goto out_up;
254 s = buffer + 3;
255 setting_str = strsep(&s, "=");
256 if (s == NULL)
257 goto out_up;
258 setting_str = strstrip(setting_str);
259 value_str = strsep(&s, " ");
260 if (s == NULL)
261 goto out_up;
262 s = strstrip(s);
263 if (!strncmp(s, "all", 3))
264 all = 1;
265 else
266 elem = find_debug_module(s);
267 if (!strncmp(setting_str, "enable", 6)) {
268 value = !!simple_strtol(value_str, NULL, 10);
269 if (all) {
270 if (value) {
271 set_all(true);
272 num_enabled = nr_entries;
273 dynamic_enabled = DYNAMIC_ENABLED_ALL;
274 } else {
275 set_all(false);
276 num_enabled = 0;
277 dynamic_enabled = DYNAMIC_ENABLED_NONE;
278 }
279 err = 0;
280 } else {
281 if (elem) {
282 if (value && (elem->enable == 0)) {
283 dynamic_printk_enabled |=
284 (1LL << elem->hash1);
285 dynamic_printk_enabled2 |=
286 (1LL << elem->hash2);
287 elem->enable = 1;
288 num_enabled++;
289 dynamic_enabled = DYNAMIC_ENABLED_SOME;
290 err = 0;
291 printk(KERN_DEBUG
292 "debugging enabled for module %s",
293 elem->name);
294 } else if (!value && (elem->enable == 1)) {
295 elem->enable = 0;
296 num_enabled--;
297 if (disabled_hash(elem->hash1, true))
298 dynamic_printk_enabled &=
299 ~(1LL << elem->hash1);
300 if (disabled_hash(elem->hash2, false))
301 dynamic_printk_enabled2 &=
302 ~(1LL << elem->hash2);
303 if (num_enabled)
304 dynamic_enabled =
305 DYNAMIC_ENABLED_SOME;
306 else
307 dynamic_enabled =
308 DYNAMIC_ENABLED_NONE;
309 err = 0;
310 printk(KERN_DEBUG
311 "debugging disabled for module "
312 "%s", elem->name);
313 }
314 }
315 }
316 }
317 if (!err)
318 err = length;
319out_up:
320 up(&debug_list_mutex);
321out:
322 free_page((unsigned long)buffer);
323 return err;
324}
325
326static void *pr_debug_seq_start(struct seq_file *f, loff_t *pos)
327{
328 return (*pos < DEBUG_HASH_TABLE_SIZE) ? pos : NULL;
329}
330
331static void *pr_debug_seq_next(struct seq_file *s, void *v, loff_t *pos)
332{
333 (*pos)++;
334 if (*pos >= DEBUG_HASH_TABLE_SIZE)
335 return NULL;
336 return pos;
337}
338
339static void pr_debug_seq_stop(struct seq_file *s, void *v)
340{
341 /* Nothing to do */
342}
343
344static int pr_debug_seq_show(struct seq_file *s, void *v)
345{
346 struct hlist_head *head;
347 struct hlist_node *node;
348 struct debug_name *elem;
349 unsigned int i = *(loff_t *) v;
350
351 rcu_read_lock();
352 head = &module_table[i];
353 hlist_for_each_entry_rcu(elem, node, head, hlist) {
354 seq_printf(s, "%s enabled=%d", elem->name, elem->enable);
355 seq_printf(s, "\n");
356 }
357 rcu_read_unlock();
358 return 0;
359}
360
361static struct seq_operations pr_debug_seq_ops = {
362 .start = pr_debug_seq_start,
363 .next = pr_debug_seq_next,
364 .stop = pr_debug_seq_stop,
365 .show = pr_debug_seq_show
366};
367
368static int pr_debug_open(struct inode *inode, struct file *filp)
369{
370 return seq_open(filp, &pr_debug_seq_ops);
371}
372
373static const struct file_operations pr_debug_operations = {
374 .open = pr_debug_open,
375 .read = seq_read,
376 .write = pr_debug_write,
377 .llseek = seq_lseek,
378 .release = seq_release,
379};
380
381static int __init dynamic_printk_init(void)
382{
383 struct dentry *dir, *file;
384 struct mod_debug *iter;
385 unsigned long value;
386
387 dir = debugfs_create_dir("dynamic_printk", NULL);
388 if (!dir)
389 return -ENOMEM;
390 file = debugfs_create_file("modules", 0644, dir, NULL,
391 &pr_debug_operations);
392 if (!file) {
393 debugfs_remove(dir);
394 return -ENOMEM;
395 }
396 for (value = (unsigned long)__start___verbose;
397 value < (unsigned long)__stop___verbose;
398 value += sizeof(struct mod_debug)) {
399 iter = (struct mod_debug *)value;
400 register_dynamic_debug_module(iter->modname,
401 iter->type,
402 iter->logical_modname,
403 iter->flag_names, iter->hash, iter->hash2);
404 }
405 return 0;
406}
407module_init(dynamic_printk_init);
408/* may want to move this earlier so we can get traces as early as possible */
409
410static int __init dynamic_printk_setup(char *str)
411{
412 if (str)
413 return -ENOENT;
414 set_all(true);
415 return 0;
416}
417/* Use early_param(), so we can get debug output as early as possible */
418early_param("dynamic_printk", dynamic_printk_setup);
diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c
index 5d90074dca75..75dbda03f4fb 100644
--- a/lib/iommu-helper.c
+++ b/lib/iommu-helper.c
@@ -79,3 +79,12 @@ void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr)
79 } 79 }
80} 80}
81EXPORT_SYMBOL(iommu_area_free); 81EXPORT_SYMBOL(iommu_area_free);
82
83unsigned long iommu_num_pages(unsigned long addr, unsigned long len,
84 unsigned long io_page_size)
85{
86 unsigned long size = (addr & (io_page_size - 1)) + len;
87
88 return DIV_ROUND_UP(size, io_page_size);
89}
90EXPORT_SYMBOL(iommu_num_pages);
diff --git a/lib/kobject.c b/lib/kobject.c
index fbf0ae282376..0487d1f64806 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -387,11 +387,17 @@ EXPORT_SYMBOL_GPL(kobject_init_and_add);
387 * kobject_rename - change the name of an object 387 * kobject_rename - change the name of an object
388 * @kobj: object in question. 388 * @kobj: object in question.
389 * @new_name: object's new name 389 * @new_name: object's new name
390 *
391 * It is the responsibility of the caller to provide mutual
392 * exclusion between two different calls of kobject_rename
393 * on the same kobject and to ensure that new_name is valid and
394 * won't conflict with other kobjects.
390 */ 395 */
391int kobject_rename(struct kobject *kobj, const char *new_name) 396int kobject_rename(struct kobject *kobj, const char *new_name)
392{ 397{
393 int error = 0; 398 int error = 0;
394 const char *devpath = NULL; 399 const char *devpath = NULL;
400 const char *dup_name = NULL, *name;
395 char *devpath_string = NULL; 401 char *devpath_string = NULL;
396 char *envp[2]; 402 char *envp[2];
397 403
@@ -401,19 +407,6 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
401 if (!kobj->parent) 407 if (!kobj->parent)
402 return -EINVAL; 408 return -EINVAL;
403 409
404 /* see if this name is already in use */
405 if (kobj->kset) {
406 struct kobject *temp_kobj;
407 temp_kobj = kset_find_obj(kobj->kset, new_name);
408 if (temp_kobj) {
409 printk(KERN_WARNING "kobject '%s' cannot be renamed "
410 "to '%s' as '%s' is already in existence.\n",
411 kobject_name(kobj), new_name, new_name);
412 kobject_put(temp_kobj);
413 return -EINVAL;
414 }
415 }
416
417 devpath = kobject_get_path(kobj, GFP_KERNEL); 410 devpath = kobject_get_path(kobj, GFP_KERNEL);
418 if (!devpath) { 411 if (!devpath) {
419 error = -ENOMEM; 412 error = -ENOMEM;
@@ -428,15 +421,27 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
428 envp[0] = devpath_string; 421 envp[0] = devpath_string;
429 envp[1] = NULL; 422 envp[1] = NULL;
430 423
424 name = dup_name = kstrdup(new_name, GFP_KERNEL);
425 if (!name) {
426 error = -ENOMEM;
427 goto out;
428 }
429
431 error = sysfs_rename_dir(kobj, new_name); 430 error = sysfs_rename_dir(kobj, new_name);
431 if (error)
432 goto out;
433
434 /* Install the new kobject name */
435 dup_name = kobj->name;
436 kobj->name = name;
432 437
433 /* This function is mostly/only used for network interface. 438 /* This function is mostly/only used for network interface.
434 * Some hotplug package track interfaces by their name and 439 * Some hotplug package track interfaces by their name and
435 * therefore want to know when the name is changed by the user. */ 440 * therefore want to know when the name is changed by the user. */
436 if (!error) 441 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
437 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
438 442
439out: 443out:
444 kfree(dup_name);
440 kfree(devpath_string); 445 kfree(devpath_string);
441 kfree(devpath); 446 kfree(devpath);
442 kobject_put(kobj); 447 kobject_put(kobj);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c399bc1093cb..cceecb6a963d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -32,40 +32,48 @@
32/* Works only for digits and letters, but small and fast */ 32/* Works only for digits and letters, but small and fast */
33#define TOLOWER(x) ((x) | 0x20) 33#define TOLOWER(x) ((x) | 0x20)
34 34
35static unsigned int simple_guess_base(const char *cp)
36{
37 if (cp[0] == '0') {
38 if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2]))
39 return 16;
40 else
41 return 8;
42 } else {
43 return 10;
44 }
45}
46
35/** 47/**
36 * simple_strtoul - convert a string to an unsigned long 48 * simple_strtoul - convert a string to an unsigned long
37 * @cp: The start of the string 49 * @cp: The start of the string
38 * @endp: A pointer to the end of the parsed string will be placed here 50 * @endp: A pointer to the end of the parsed string will be placed here
39 * @base: The number base to use 51 * @base: The number base to use
40 */ 52 */
41unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) 53unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
42{ 54{
43 unsigned long result = 0,value; 55 unsigned long result = 0;
44 56
45 if (!base) { 57 if (!base)
46 base = 10; 58 base = simple_guess_base(cp);
47 if (*cp == '0') { 59
48 base = 8; 60 if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x')
49 cp++; 61 cp += 2;
50 if ((TOLOWER(*cp) == 'x') && isxdigit(cp[1])) { 62
51 cp++; 63 while (isxdigit(*cp)) {
52 base = 16; 64 unsigned int value;
53 } 65
54 } 66 value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10;
55 } else if (base == 16) { 67 if (value >= base)
56 if (cp[0] == '0' && TOLOWER(cp[1]) == 'x') 68 break;
57 cp += 2; 69 result = result * base + value;
58 }
59 while (isxdigit(*cp) &&
60 (value = isdigit(*cp) ? *cp-'0' : TOLOWER(*cp)-'a'+10) < base) {
61 result = result*base + value;
62 cp++; 70 cp++;
63 } 71 }
72
64 if (endp) 73 if (endp)
65 *endp = (char *)cp; 74 *endp = (char *)cp;
66 return result; 75 return result;
67} 76}
68
69EXPORT_SYMBOL(simple_strtoul); 77EXPORT_SYMBOL(simple_strtoul);
70 78
71/** 79/**
@@ -74,13 +82,12 @@ EXPORT_SYMBOL(simple_strtoul);
74 * @endp: A pointer to the end of the parsed string will be placed here 82 * @endp: A pointer to the end of the parsed string will be placed here
75 * @base: The number base to use 83 * @base: The number base to use
76 */ 84 */
77long simple_strtol(const char *cp,char **endp,unsigned int base) 85long simple_strtol(const char *cp, char **endp, unsigned int base)
78{ 86{
79 if(*cp=='-') 87 if(*cp == '-')
80 return -simple_strtoul(cp+1,endp,base); 88 return -simple_strtoul(cp + 1, endp, base);
81 return simple_strtoul(cp,endp,base); 89 return simple_strtoul(cp, endp, base);
82} 90}
83
84EXPORT_SYMBOL(simple_strtol); 91EXPORT_SYMBOL(simple_strtol);
85 92
86/** 93/**
@@ -89,34 +96,30 @@ EXPORT_SYMBOL(simple_strtol);
89 * @endp: A pointer to the end of the parsed string will be placed here 96 * @endp: A pointer to the end of the parsed string will be placed here
90 * @base: The number base to use 97 * @base: The number base to use
91 */ 98 */
92unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base) 99unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
93{ 100{
94 unsigned long long result = 0,value; 101 unsigned long long result = 0;
95 102
96 if (!base) { 103 if (!base)
97 base = 10; 104 base = simple_guess_base(cp);
98 if (*cp == '0') { 105
99 base = 8; 106 if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x')
100 cp++; 107 cp += 2;
101 if ((TOLOWER(*cp) == 'x') && isxdigit(cp[1])) { 108
102 cp++; 109 while (isxdigit(*cp)) {
103 base = 16; 110 unsigned int value;
104 } 111
105 } 112 value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10;
106 } else if (base == 16) { 113 if (value >= base)
107 if (cp[0] == '0' && TOLOWER(cp[1]) == 'x') 114 break;
108 cp += 2; 115 result = result * base + value;
109 }
110 while (isxdigit(*cp)
111 && (value = isdigit(*cp) ? *cp-'0' : TOLOWER(*cp)-'a'+10) < base) {
112 result = result*base + value;
113 cp++; 116 cp++;
114 } 117 }
118
115 if (endp) 119 if (endp)
116 *endp = (char *)cp; 120 *endp = (char *)cp;
117 return result; 121 return result;
118} 122}
119
120EXPORT_SYMBOL(simple_strtoull); 123EXPORT_SYMBOL(simple_strtoull);
121 124
122/** 125/**
@@ -125,14 +128,13 @@ EXPORT_SYMBOL(simple_strtoull);
125 * @endp: A pointer to the end of the parsed string will be placed here 128 * @endp: A pointer to the end of the parsed string will be placed here
126 * @base: The number base to use 129 * @base: The number base to use
127 */ 130 */
128long long simple_strtoll(const char *cp,char **endp,unsigned int base) 131long long simple_strtoll(const char *cp, char **endp, unsigned int base)
129{ 132{
130 if(*cp=='-') 133 if(*cp=='-')
131 return -simple_strtoull(cp+1,endp,base); 134 return -simple_strtoull(cp + 1, endp, base);
132 return simple_strtoull(cp,endp,base); 135 return simple_strtoull(cp, endp, base);
133} 136}
134 137
135
136/** 138/**
137 * strict_strtoul - convert a string to an unsigned long strictly 139 * strict_strtoul - convert a string to an unsigned long strictly
138 * @cp: The string to be converted 140 * @cp: The string to be converted
@@ -155,7 +157,27 @@ long long simple_strtoll(const char *cp,char **endp,unsigned int base)
155 * simple_strtoul just ignores the successive invalid characters and 157 * simple_strtoul just ignores the successive invalid characters and
156 * return the converted value of prefix part of the string. 158 * return the converted value of prefix part of the string.
157 */ 159 */
158int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); 160int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
161{
162 char *tail;
163 unsigned long val;
164 size_t len;
165
166 *res = 0;
167 len = strlen(cp);
168 if (len == 0)
169 return -EINVAL;
170
171 val = simple_strtoul(cp, &tail, base);
172 if ((*tail == '\0') ||
173 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
174 *res = val;
175 return 0;
176 }
177
178 return -EINVAL;
179}
180EXPORT_SYMBOL(strict_strtoul);
159 181
160/** 182/**
161 * strict_strtol - convert a string to a long strictly 183 * strict_strtol - convert a string to a long strictly
@@ -169,7 +191,20 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
169 * It returns 0 if conversion is successful and *res is set to the converted 191 * It returns 0 if conversion is successful and *res is set to the converted
170 * value, otherwise it returns -EINVAL and *res is set to 0. 192 * value, otherwise it returns -EINVAL and *res is set to 0.
171 */ 193 */
172int strict_strtol(const char *cp, unsigned int base, long *res); 194int strict_strtol(const char *cp, unsigned int base, long *res)
195{
196 int ret;
197 if (*cp == '-') {
198 ret = strict_strtoul(cp + 1, base, (unsigned long *)res);
199 if (!ret)
200 *res = -(*res);
201 } else {
202 ret = strict_strtoul(cp, base, (unsigned long *)res);
203 }
204
205 return ret;
206}
207EXPORT_SYMBOL(strict_strtol);
173 208
174/** 209/**
175 * strict_strtoull - convert a string to an unsigned long long strictly 210 * strict_strtoull - convert a string to an unsigned long long strictly
@@ -193,7 +228,27 @@ int strict_strtol(const char *cp, unsigned int base, long *res);
193 * simple_strtoull just ignores the successive invalid characters and 228 * simple_strtoull just ignores the successive invalid characters and
194 * return the converted value of prefix part of the string. 229 * return the converted value of prefix part of the string.
195 */ 230 */
196int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res); 231int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res)
232{
233 char *tail;
234 unsigned long long val;
235 size_t len;
236
237 *res = 0;
238 len = strlen(cp);
239 if (len == 0)
240 return -EINVAL;
241
242 val = simple_strtoull(cp, &tail, base);
243 if ((*tail == '\0') ||
244 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
245 *res = val;
246 return 0;
247 }
248
249 return -EINVAL;
250}
251EXPORT_SYMBOL(strict_strtoull);
197 252
198/** 253/**
199 * strict_strtoll - convert a string to a long long strictly 254 * strict_strtoll - convert a string to a long long strictly
@@ -207,53 +262,20 @@ int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res);
207 * It returns 0 if conversion is successful and *res is set to the converted 262 * It returns 0 if conversion is successful and *res is set to the converted
208 * value, otherwise it returns -EINVAL and *res is set to 0. 263 * value, otherwise it returns -EINVAL and *res is set to 0.
209 */ 264 */
210int strict_strtoll(const char *cp, unsigned int base, long long *res); 265int strict_strtoll(const char *cp, unsigned int base, long long *res)
211 266{
212#define define_strict_strtoux(type, valtype) \ 267 int ret;
213int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\ 268 if (*cp == '-') {
214{ \ 269 ret = strict_strtoull(cp + 1, base, (unsigned long long *)res);
215 char *tail; \ 270 if (!ret)
216 valtype val; \ 271 *res = -(*res);
217 size_t len; \ 272 } else {
218 \ 273 ret = strict_strtoull(cp, base, (unsigned long long *)res);
219 *res = 0; \ 274 }
220 len = strlen(cp); \
221 if (len == 0) \
222 return -EINVAL; \
223 \
224 val = simple_strtou##type(cp, &tail, base); \
225 if ((*tail == '\0') || \
226 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\
227 *res = val; \
228 return 0; \
229 } \
230 \
231 return -EINVAL; \
232} \
233
234#define define_strict_strtox(type, valtype) \
235int strict_strto##type(const char *cp, unsigned int base, valtype *res) \
236{ \
237 int ret; \
238 if (*cp == '-') { \
239 ret = strict_strtou##type(cp+1, base, res); \
240 if (!ret) \
241 *res = -(*res); \
242 } else \
243 ret = strict_strtou##type(cp, base, res); \
244 \
245 return ret; \
246} \
247
248define_strict_strtoux(l, unsigned long)
249define_strict_strtox(l, long)
250define_strict_strtoux(ll, unsigned long long)
251define_strict_strtox(ll, long long)
252 275
253EXPORT_SYMBOL(strict_strtoul); 276 return ret;
254EXPORT_SYMBOL(strict_strtol); 277}
255EXPORT_SYMBOL(strict_strtoll); 278EXPORT_SYMBOL(strict_strtoll);
256EXPORT_SYMBOL(strict_strtoull);
257 279
258static int skip_atoi(const char **s) 280static int skip_atoi(const char **s)
259{ 281{
@@ -565,6 +587,10 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field
565 * @fmt: The format string to use 587 * @fmt: The format string to use
566 * @args: Arguments for the format string 588 * @args: Arguments for the format string
567 * 589 *
590 * This function follows C99 vsnprintf, but has some extensions:
591 * %pS output the name of a text symbol
592 * %pF output the name of a function pointer
593 *
568 * The return value is the number of characters which would 594 * The return value is the number of characters which would
569 * be generated for the given input, excluding the trailing 595 * be generated for the given input, excluding the trailing
570 * '\0', as per ISO C99. If you want to have the exact 596 * '\0', as per ISO C99. If you want to have the exact
@@ -790,7 +816,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
790 /* the trailing null byte doesn't count towards the total */ 816 /* the trailing null byte doesn't count towards the total */
791 return str-buf; 817 return str-buf;
792} 818}
793
794EXPORT_SYMBOL(vsnprintf); 819EXPORT_SYMBOL(vsnprintf);
795 820
796/** 821/**
@@ -806,6 +831,8 @@ EXPORT_SYMBOL(vsnprintf);
806 * 831 *
807 * Call this function if you are already dealing with a va_list. 832 * Call this function if you are already dealing with a va_list.
808 * You probably want scnprintf() instead. 833 * You probably want scnprintf() instead.
834 *
835 * See the vsnprintf() documentation for format string extensions over C99.
809 */ 836 */
810int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) 837int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
811{ 838{
@@ -814,7 +841,6 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
814 i=vsnprintf(buf,size,fmt,args); 841 i=vsnprintf(buf,size,fmt,args);
815 return (i >= size) ? (size - 1) : i; 842 return (i >= size) ? (size - 1) : i;
816} 843}
817
818EXPORT_SYMBOL(vscnprintf); 844EXPORT_SYMBOL(vscnprintf);
819 845
820/** 846/**
@@ -828,6 +854,8 @@ EXPORT_SYMBOL(vscnprintf);
828 * generated for the given input, excluding the trailing null, 854 * generated for the given input, excluding the trailing null,
829 * as per ISO C99. If the return is greater than or equal to 855 * as per ISO C99. If the return is greater than or equal to
830 * @size, the resulting string is truncated. 856 * @size, the resulting string is truncated.
857 *
858 * See the vsnprintf() documentation for format string extensions over C99.
831 */ 859 */
832int snprintf(char * buf, size_t size, const char *fmt, ...) 860int snprintf(char * buf, size_t size, const char *fmt, ...)
833{ 861{
@@ -839,7 +867,6 @@ int snprintf(char * buf, size_t size, const char *fmt, ...)
839 va_end(args); 867 va_end(args);
840 return i; 868 return i;
841} 869}
842
843EXPORT_SYMBOL(snprintf); 870EXPORT_SYMBOL(snprintf);
844 871
845/** 872/**
@@ -877,12 +904,13 @@ EXPORT_SYMBOL(scnprintf);
877 * 904 *
878 * Call this function if you are already dealing with a va_list. 905 * Call this function if you are already dealing with a va_list.
879 * You probably want sprintf() instead. 906 * You probably want sprintf() instead.
907 *
908 * See the vsnprintf() documentation for format string extensions over C99.
880 */ 909 */
881int vsprintf(char *buf, const char *fmt, va_list args) 910int vsprintf(char *buf, const char *fmt, va_list args)
882{ 911{
883 return vsnprintf(buf, INT_MAX, fmt, args); 912 return vsnprintf(buf, INT_MAX, fmt, args);
884} 913}
885
886EXPORT_SYMBOL(vsprintf); 914EXPORT_SYMBOL(vsprintf);
887 915
888/** 916/**
@@ -894,6 +922,8 @@ EXPORT_SYMBOL(vsprintf);
894 * The function returns the number of characters written 922 * The function returns the number of characters written
895 * into @buf. Use snprintf() or scnprintf() in order to avoid 923 * into @buf. Use snprintf() or scnprintf() in order to avoid
896 * buffer overflows. 924 * buffer overflows.
925 *
926 * See the vsnprintf() documentation for format string extensions over C99.
897 */ 927 */
898int sprintf(char * buf, const char *fmt, ...) 928int sprintf(char * buf, const char *fmt, ...)
899{ 929{
@@ -905,7 +935,6 @@ int sprintf(char * buf, const char *fmt, ...)
905 va_end(args); 935 va_end(args);
906 return i; 936 return i;
907} 937}
908
909EXPORT_SYMBOL(sprintf); 938EXPORT_SYMBOL(sprintf);
910 939
911/** 940/**
@@ -1134,7 +1163,6 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
1134 1163
1135 return num; 1164 return num;
1136} 1165}
1137
1138EXPORT_SYMBOL(vsscanf); 1166EXPORT_SYMBOL(vsscanf);
1139 1167
1140/** 1168/**
@@ -1153,5 +1181,4 @@ int sscanf(const char * buf, const char * fmt, ...)
1153 va_end(args); 1181 va_end(args);
1154 return i; 1182 return i;
1155} 1183}
1156
1157EXPORT_SYMBOL(sscanf); 1184EXPORT_SYMBOL(sscanf);
diff --git a/mm/Kconfig b/mm/Kconfig
index 0bd9c2dbb2a0..1a501a4de95c 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -101,7 +101,7 @@ config HAVE_MEMORY_PRESENT
101# with gcc 3.4 and later. 101# with gcc 3.4 and later.
102# 102#
103config SPARSEMEM_STATIC 103config SPARSEMEM_STATIC
104 def_bool n 104 bool
105 105
106# 106#
107# Architecture platforms which require a two level mem_section in SPARSEMEM 107# Architecture platforms which require a two level mem_section in SPARSEMEM
@@ -113,7 +113,7 @@ config SPARSEMEM_EXTREME
113 depends on SPARSEMEM && !SPARSEMEM_STATIC 113 depends on SPARSEMEM && !SPARSEMEM_STATIC
114 114
115config SPARSEMEM_VMEMMAP_ENABLE 115config SPARSEMEM_VMEMMAP_ENABLE
116 def_bool n 116 bool
117 117
118config SPARSEMEM_VMEMMAP 118config SPARSEMEM_VMEMMAP
119 bool "Sparse Memory virtual memmap" 119 bool "Sparse Memory virtual memmap"
@@ -187,6 +187,9 @@ config RESOURCES_64BIT
187 help 187 help
188 This option allows memory and IO resources to be 64 bit. 188 This option allows memory and IO resources to be 64 bit.
189 189
190config PHYS_ADDR_T_64BIT
191 def_bool 64BIT || ARCH_PHYS_ADDR_T_64BIT
192
190config ZONE_DMA_FLAG 193config ZONE_DMA_FLAG
191 int 194 int
192 default "0" if !ZONE_DMA 195 default "0" if !ZONE_DMA
diff --git a/mm/bootmem.c b/mm/bootmem.c
index ad8eec6e44a8..ac5a891f142a 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -48,7 +48,7 @@ early_param("bootmem_debug", bootmem_debug_setup);
48 if (unlikely(bootmem_debug)) \ 48 if (unlikely(bootmem_debug)) \
49 printk(KERN_INFO \ 49 printk(KERN_INFO \
50 "bootmem::%s " fmt, \ 50 "bootmem::%s " fmt, \
51 __FUNCTION__, ## args); \ 51 __func__, ## args); \
52}) 52})
53 53
54static unsigned long __init bootmap_bytes(unsigned long pages) 54static unsigned long __init bootmap_bytes(unsigned long pages)
diff --git a/mm/fadvise.c b/mm/fadvise.c
index 343cfdfebd9e..a1da969bd980 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002, Linus Torvalds 4 * Copyright (C) 2002, Linus Torvalds
5 * 5 *
6 * 11Jan2003 akpm@digeo.com 6 * 11Jan2003 Andrew Morton
7 * Initial version. 7 * Initial version.
8 */ 8 */
9 9
diff --git a/mm/filemap.c b/mm/filemap.c
index 876bc595d0f8..903bf316912a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1100,8 +1100,9 @@ page_ok:
1100 1100
1101page_not_up_to_date: 1101page_not_up_to_date:
1102 /* Get exclusive access to the page ... */ 1102 /* Get exclusive access to the page ... */
1103 if (lock_page_killable(page)) 1103 error = lock_page_killable(page);
1104 goto readpage_eio; 1104 if (unlikely(error))
1105 goto readpage_error;
1105 1106
1106page_not_up_to_date_locked: 1107page_not_up_to_date_locked:
1107 /* Did it get truncated before we got the lock? */ 1108 /* Did it get truncated before we got the lock? */
@@ -1130,8 +1131,9 @@ readpage:
1130 } 1131 }
1131 1132
1132 if (!PageUptodate(page)) { 1133 if (!PageUptodate(page)) {
1133 if (lock_page_killable(page)) 1134 error = lock_page_killable(page);
1134 goto readpage_eio; 1135 if (unlikely(error))
1136 goto readpage_error;
1135 if (!PageUptodate(page)) { 1137 if (!PageUptodate(page)) {
1136 if (page->mapping == NULL) { 1138 if (page->mapping == NULL) {
1137 /* 1139 /*
@@ -1143,15 +1145,14 @@ readpage:
1143 } 1145 }
1144 unlock_page(page); 1146 unlock_page(page);
1145 shrink_readahead_size_eio(filp, ra); 1147 shrink_readahead_size_eio(filp, ra);
1146 goto readpage_eio; 1148 error = -EIO;
1149 goto readpage_error;
1147 } 1150 }
1148 unlock_page(page); 1151 unlock_page(page);
1149 } 1152 }
1150 1153
1151 goto page_ok; 1154 goto page_ok;
1152 1155
1153readpage_eio:
1154 error = -EIO;
1155readpage_error: 1156readpage_error:
1156 /* UHHUH! A synchronous read error occurred. Report it */ 1157 /* UHHUH! A synchronous read error occurred. Report it */
1157 desc->error = error; 1158 desc->error = error;
@@ -1186,8 +1187,7 @@ out:
1186 ra->prev_pos |= prev_offset; 1187 ra->prev_pos |= prev_offset;
1187 1188
1188 *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset; 1189 *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset;
1189 if (filp) 1190 file_accessed(filp);
1190 file_accessed(filp);
1191} 1191}
1192 1192
1193int file_read_actor(read_descriptor_t *desc, struct page *page, 1193int file_read_actor(read_descriptor_t *desc, struct page *page,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 67a71191136e..38633864a93e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2008,7 +2008,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2008 entry = huge_ptep_get(ptep); 2008 entry = huge_ptep_get(ptep);
2009 if (huge_pte_none(entry)) { 2009 if (huge_pte_none(entry)) {
2010 ret = hugetlb_no_page(mm, vma, address, ptep, write_access); 2010 ret = hugetlb_no_page(mm, vma, address, ptep, write_access);
2011 goto out_unlock; 2011 goto out_mutex;
2012 } 2012 }
2013 2013
2014 ret = 0; 2014 ret = 0;
@@ -2024,7 +2024,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2024 if (write_access && !pte_write(entry)) { 2024 if (write_access && !pte_write(entry)) {
2025 if (vma_needs_reservation(h, vma, address) < 0) { 2025 if (vma_needs_reservation(h, vma, address) < 0) {
2026 ret = VM_FAULT_OOM; 2026 ret = VM_FAULT_OOM;
2027 goto out_unlock; 2027 goto out_mutex;
2028 } 2028 }
2029 2029
2030 if (!(vma->vm_flags & VM_SHARED)) 2030 if (!(vma->vm_flags & VM_SHARED))
@@ -2034,10 +2034,23 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2034 2034
2035 spin_lock(&mm->page_table_lock); 2035 spin_lock(&mm->page_table_lock);
2036 /* Check for a racing update before calling hugetlb_cow */ 2036 /* Check for a racing update before calling hugetlb_cow */
2037 if (likely(pte_same(entry, huge_ptep_get(ptep)))) 2037 if (unlikely(!pte_same(entry, huge_ptep_get(ptep))))
2038 if (write_access && !pte_write(entry)) 2038 goto out_page_table_lock;
2039
2040
2041 if (write_access) {
2042 if (!pte_write(entry)) {
2039 ret = hugetlb_cow(mm, vma, address, ptep, entry, 2043 ret = hugetlb_cow(mm, vma, address, ptep, entry,
2040 pagecache_page); 2044 pagecache_page);
2045 goto out_page_table_lock;
2046 }
2047 entry = pte_mkdirty(entry);
2048 }
2049 entry = pte_mkyoung(entry);
2050 if (huge_ptep_set_access_flags(vma, address, ptep, entry, write_access))
2051 update_mmu_cache(vma, address, entry);
2052
2053out_page_table_lock:
2041 spin_unlock(&mm->page_table_lock); 2054 spin_unlock(&mm->page_table_lock);
2042 2055
2043 if (pagecache_page) { 2056 if (pagecache_page) {
@@ -2045,7 +2058,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2045 put_page(pagecache_page); 2058 put_page(pagecache_page);
2046 } 2059 }
2047 2060
2048out_unlock: 2061out_mutex:
2049 mutex_unlock(&hugetlb_instantiation_mutex); 2062 mutex_unlock(&hugetlb_instantiation_mutex);
2050 2063
2051 return ret; 2064 return ret;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 24de8b65fdbd..c130a137c129 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -7,7 +7,7 @@
7 * Contains functions related to writing back dirty pages at the 7 * Contains functions related to writing back dirty pages at the
8 * address_space level. 8 * address_space level.
9 * 9 *
10 * 10Apr2002 akpm@zip.com.au 10 * 10Apr2002 Andrew Morton
11 * Initial version 11 * Initial version
12 */ 12 */
13 13
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 27b8681139fd..9eb9eb928285 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3952,7 +3952,7 @@ static void check_for_regular_memory(pg_data_t *pgdat)
3952void __init free_area_init_nodes(unsigned long *max_zone_pfn) 3952void __init free_area_init_nodes(unsigned long *max_zone_pfn)
3953{ 3953{
3954 unsigned long nid; 3954 unsigned long nid;
3955 enum zone_type i; 3955 int i;
3956 3956
3957 /* Sort early_node_map as initialisation assumes it is sorted */ 3957 /* Sort early_node_map as initialisation assumes it is sorted */
3958 sort_node_map(); 3958 sort_node_map();
diff --git a/mm/pdflush.c b/mm/pdflush.c
index 0cbe0c60c6bf..a0a14c4d5072 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002, Linus Torvalds. 4 * Copyright (C) 2002, Linus Torvalds.
5 * 5 *
6 * 09Apr2002 akpm@zip.com.au 6 * 09Apr2002 Andrew Morton
7 * Initial version 7 * Initial version
8 * 29Feb2004 kaos@sgi.com 8 * 29Feb2004 kaos@sgi.com
9 * Move worker thread creation to kthread to avoid chewing 9 * Move worker thread creation to kthread to avoid chewing
diff --git a/mm/readahead.c b/mm/readahead.c
index 77e8ddf945e9..6cbd9a72fde2 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002, Linus Torvalds 4 * Copyright (C) 2002, Linus Torvalds
5 * 5 *
6 * 09Apr2002 akpm@zip.com.au 6 * 09Apr2002 Andrew Morton
7 * Initial version. 7 * Initial version.
8 */ 8 */
9 9
diff --git a/mm/truncate.c b/mm/truncate.c
index 6650c1d878b4..e83e4b114ef1 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002, Linus Torvalds 4 * Copyright (C) 2002, Linus Torvalds
5 * 5 *
6 * 10Sep2002 akpm@zip.com.au 6 * 10Sep2002 Andrew Morton
7 * Initial version. 7 * Initial version.
8 */ 8 */
9 9
diff --git a/net/802/fc.c b/net/802/fc.c
index cb3475ea6fda..34cf1ee014b8 100644
--- a/net/802/fc.c
+++ b/net/802/fc.c
@@ -82,13 +82,13 @@ static int fc_header(struct sk_buff *skb, struct net_device *dev,
82 82
83static int fc_rebuild_header(struct sk_buff *skb) 83static int fc_rebuild_header(struct sk_buff *skb)
84{ 84{
85#ifdef CONFIG_INET
85 struct fch_hdr *fch=(struct fch_hdr *)skb->data; 86 struct fch_hdr *fch=(struct fch_hdr *)skb->data;
86 struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr)); 87 struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr));
87 if(fcllc->ethertype != htons(ETH_P_IP)) { 88 if(fcllc->ethertype != htons(ETH_P_IP)) {
88 printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(fcllc->ethertype)); 89 printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(fcllc->ethertype));
89 return 0; 90 return 0;
90 } 91 }
91#ifdef CONFIG_INET
92 return arp_find(fch->daddr, skb); 92 return arp_find(fch->daddr, skb);
93#else 93#else
94 return 0; 94 return 0;
diff --git a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
index 366d3e9d51f8..ba6f73eb06c6 100644
--- a/net/bridge/netfilter/Kconfig
+++ b/net/bridge/netfilter/Kconfig
@@ -4,6 +4,7 @@
4 4
5menuconfig BRIDGE_NF_EBTABLES 5menuconfig BRIDGE_NF_EBTABLES
6 tristate "Ethernet Bridge tables (ebtables) support" 6 tristate "Ethernet Bridge tables (ebtables) support"
7 depends on BRIDGE && BRIDGE_NETFILTER
7 select NETFILTER_XTABLES 8 select NETFILTER_XTABLES
8 help 9 help
9 ebtables is a general, extensible frame/packet identification 10 ebtables is a general, extensible frame/packet identification
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index b0dc818a91d7..f1d07b5c1e17 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -96,7 +96,7 @@ static void net_free(struct net *net)
96 return; 96 return;
97 } 97 }
98#endif 98#endif
99 99 kfree(net->gen);
100 kmem_cache_free(net_cachep, net); 100 kmem_cache_free(net_cachep, net);
101} 101}
102 102
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 2f0ac3c3eb71..8008c8613027 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -152,7 +152,7 @@ static struct dn_dev_parms dn_dev_list[] = {
152 152
153#define DN_DEV_LIST_SIZE ARRAY_SIZE(dn_dev_list) 153#define DN_DEV_LIST_SIZE ARRAY_SIZE(dn_dev_list)
154 154
155#define DN_DEV_PARMS_OFFSET(x) ((int) ((char *) &((struct dn_dev_parms *)0)->x)) 155#define DN_DEV_PARMS_OFFSET(x) offsetof(struct dn_dev_parms, x)
156 156
157#ifdef CONFIG_SYSCTL 157#ifdef CONFIG_SYSCTL
158 158
@@ -166,7 +166,7 @@ static int max_priority[] = { 127 }; /* From DECnet spec */
166 166
167static int dn_forwarding_proc(ctl_table *, int, struct file *, 167static int dn_forwarding_proc(ctl_table *, int, struct file *,
168 void __user *, size_t *, loff_t *); 168 void __user *, size_t *, loff_t *);
169static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen, 169static int dn_forwarding_sysctl(ctl_table *table,
170 void __user *oldval, size_t __user *oldlenp, 170 void __user *oldval, size_t __user *oldlenp,
171 void __user *newval, size_t newlen); 171 void __user *newval, size_t newlen);
172 172
@@ -318,7 +318,7 @@ static int dn_forwarding_proc(ctl_table *table, int write,
318#endif 318#endif
319} 319}
320 320
321static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen, 321static int dn_forwarding_sysctl(ctl_table *table,
322 void __user *oldval, size_t __user *oldlenp, 322 void __user *oldval, size_t __user *oldlenp,
323 void __user *newval, size_t newlen) 323 void __user *newval, size_t newlen)
324{ 324{
diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
index 228067c571ba..36400b266896 100644
--- a/net/decnet/sysctl_net_decnet.c
+++ b/net/decnet/sysctl_net_decnet.c
@@ -132,7 +132,7 @@ static int parse_addr(__le16 *addr, char *str)
132} 132}
133 133
134 134
135static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen, 135static int dn_node_address_strategy(ctl_table *table,
136 void __user *oldval, size_t __user *oldlenp, 136 void __user *oldval, size_t __user *oldlenp,
137 void __user *newval, size_t newlen) 137 void __user *newval, size_t newlen)
138{ 138{
@@ -217,7 +217,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
217} 217}
218 218
219 219
220static int dn_def_dev_strategy(ctl_table *table, int __user *name, int nlen, 220static int dn_def_dev_strategy(ctl_table *table,
221 void __user *oldval, size_t __user *oldlenp, 221 void __user *oldval, size_t __user *oldlenp,
222 void __user *newval, size_t newlen) 222 void __user *newval, size_t newlen)
223{ 223{
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index b12dae2b0b2d..5154e729cf16 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1283,7 +1283,7 @@ static int devinet_conf_proc(ctl_table *ctl, int write,
1283 return ret; 1283 return ret;
1284} 1284}
1285 1285
1286static int devinet_conf_sysctl(ctl_table *table, int __user *name, int nlen, 1286static int devinet_conf_sysctl(ctl_table *table,
1287 void __user *oldval, size_t __user *oldlenp, 1287 void __user *oldval, size_t __user *oldlenp,
1288 void __user *newval, size_t newlen) 1288 void __user *newval, size_t newlen)
1289{ 1289{
@@ -1379,12 +1379,11 @@ int ipv4_doint_and_flush(ctl_table *ctl, int write,
1379 return ret; 1379 return ret;
1380} 1380}
1381 1381
1382int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen, 1382int ipv4_doint_and_flush_strategy(ctl_table *table,
1383 void __user *oldval, size_t __user *oldlenp, 1383 void __user *oldval, size_t __user *oldlenp,
1384 void __user *newval, size_t newlen) 1384 void __user *newval, size_t newlen)
1385{ 1385{
1386 int ret = devinet_conf_sysctl(table, name, nlen, oldval, oldlenp, 1386 int ret = devinet_conf_sysctl(table, oldval, oldlenp, newval, newlen);
1387 newval, newlen);
1388 struct net *net = table->extra2; 1387 struct net *net = table->extra2;
1389 1388
1390 if (ret == 1) 1389 if (ret == 1)
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index aa2c50a180f7..fa2d6b6fc3e5 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -41,12 +41,13 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
41 int (*okfn)(struct sk_buff *)) 41 int (*okfn)(struct sk_buff *))
42{ 42{
43#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 43#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
44#if !defined(CONFIG_NF_NAT) && !defined(CONFIG_NF_NAT_MODULE)
44 /* Previously seen (loopback)? Ignore. Do this before 45 /* Previously seen (loopback)? Ignore. Do this before
45 fragment check. */ 46 fragment check. */
46 if (skb->nfct) 47 if (skb->nfct)
47 return NF_ACCEPT; 48 return NF_ACCEPT;
48#endif 49#endif
49 50#endif
50 /* Gather fragments. */ 51 /* Gather fragments. */
51 if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { 52 if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
52 if (nf_ct_ipv4_gather_frags(skb, 53 if (nf_ct_ipv4_gather_frags(skb,
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index 2ac9eaf1a8c9..a65cf692359f 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -584,6 +584,98 @@ static struct nf_ct_ext_type nat_extend __read_mostly = {
584 .flags = NF_CT_EXT_F_PREALLOC, 584 .flags = NF_CT_EXT_F_PREALLOC,
585}; 585};
586 586
587#if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
588
589#include <linux/netfilter/nfnetlink.h>
590#include <linux/netfilter/nfnetlink_conntrack.h>
591
592static const struct nla_policy protonat_nla_policy[CTA_PROTONAT_MAX+1] = {
593 [CTA_PROTONAT_PORT_MIN] = { .type = NLA_U16 },
594 [CTA_PROTONAT_PORT_MAX] = { .type = NLA_U16 },
595};
596
597static int nfnetlink_parse_nat_proto(struct nlattr *attr,
598 const struct nf_conn *ct,
599 struct nf_nat_range *range)
600{
601 struct nlattr *tb[CTA_PROTONAT_MAX+1];
602 const struct nf_nat_protocol *npt;
603 int err;
604
605 err = nla_parse_nested(tb, CTA_PROTONAT_MAX, attr, protonat_nla_policy);
606 if (err < 0)
607 return err;
608
609 npt = nf_nat_proto_find_get(nf_ct_protonum(ct));
610 if (npt->nlattr_to_range)
611 err = npt->nlattr_to_range(tb, range);
612 nf_nat_proto_put(npt);
613 return err;
614}
615
616static const struct nla_policy nat_nla_policy[CTA_NAT_MAX+1] = {
617 [CTA_NAT_MINIP] = { .type = NLA_U32 },
618 [CTA_NAT_MAXIP] = { .type = NLA_U32 },
619};
620
621static int
622nfnetlink_parse_nat(struct nlattr *nat,
623 const struct nf_conn *ct, struct nf_nat_range *range)
624{
625 struct nlattr *tb[CTA_NAT_MAX+1];
626 int err;
627
628 memset(range, 0, sizeof(*range));
629
630 err = nla_parse_nested(tb, CTA_NAT_MAX, nat, nat_nla_policy);
631 if (err < 0)
632 return err;
633
634 if (tb[CTA_NAT_MINIP])
635 range->min_ip = nla_get_be32(tb[CTA_NAT_MINIP]);
636
637 if (!tb[CTA_NAT_MAXIP])
638 range->max_ip = range->min_ip;
639 else
640 range->max_ip = nla_get_be32(tb[CTA_NAT_MAXIP]);
641
642 if (range->min_ip)
643 range->flags |= IP_NAT_RANGE_MAP_IPS;
644
645 if (!tb[CTA_NAT_PROTO])
646 return 0;
647
648 err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO], ct, range);
649 if (err < 0)
650 return err;
651
652 return 0;
653}
654
655static int
656nfnetlink_parse_nat_setup(struct nf_conn *ct,
657 enum nf_nat_manip_type manip,
658 struct nlattr *attr)
659{
660 struct nf_nat_range range;
661
662 if (nfnetlink_parse_nat(attr, ct, &range) < 0)
663 return -EINVAL;
664 if (nf_nat_initialized(ct, manip))
665 return -EEXIST;
666
667 return nf_nat_setup_info(ct, &range, manip);
668}
669#else
670static int
671nfnetlink_parse_nat_setup(struct nf_conn *ct,
672 enum nf_nat_manip_type manip,
673 struct nlattr *attr)
674{
675 return -EOPNOTSUPP;
676}
677#endif
678
587static int __net_init nf_nat_net_init(struct net *net) 679static int __net_init nf_nat_net_init(struct net *net)
588{ 680{
589 net->ipv4.nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size, 681 net->ipv4.nat_bysource = nf_ct_alloc_hashtable(&nf_nat_htable_size,
@@ -654,6 +746,9 @@ static int __init nf_nat_init(void)
654 746
655 BUG_ON(nf_nat_seq_adjust_hook != NULL); 747 BUG_ON(nf_nat_seq_adjust_hook != NULL);
656 rcu_assign_pointer(nf_nat_seq_adjust_hook, nf_nat_seq_adjust); 748 rcu_assign_pointer(nf_nat_seq_adjust_hook, nf_nat_seq_adjust);
749 BUG_ON(nfnetlink_parse_nat_setup_hook != NULL);
750 rcu_assign_pointer(nfnetlink_parse_nat_setup_hook,
751 nfnetlink_parse_nat_setup);
657 return 0; 752 return 0;
658 753
659 cleanup_extend: 754 cleanup_extend:
@@ -667,10 +762,12 @@ static void __exit nf_nat_cleanup(void)
667 nf_ct_l3proto_put(l3proto); 762 nf_ct_l3proto_put(l3proto);
668 nf_ct_extend_unregister(&nat_extend); 763 nf_ct_extend_unregister(&nat_extend);
669 rcu_assign_pointer(nf_nat_seq_adjust_hook, NULL); 764 rcu_assign_pointer(nf_nat_seq_adjust_hook, NULL);
765 rcu_assign_pointer(nfnetlink_parse_nat_setup_hook, NULL);
670 synchronize_net(); 766 synchronize_net();
671} 767}
672 768
673MODULE_LICENSE("GPL"); 769MODULE_LICENSE("GPL");
770MODULE_ALIAS("nf-nat-ipv4");
674 771
675module_init(nf_nat_init); 772module_init(nf_nat_init);
676module_exit(nf_nat_cleanup); 773module_exit(nf_nat_cleanup);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a6d7c584f53b..942be04e7955 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2908,8 +2908,6 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
2908} 2908}
2909 2909
2910static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table, 2910static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table,
2911 int __user *name,
2912 int nlen,
2913 void __user *oldval, 2911 void __user *oldval,
2914 size_t __user *oldlenp, 2912 size_t __user *oldlenp,
2915 void __user *newval, 2913 void __user *newval,
@@ -2972,16 +2970,13 @@ static int ipv4_sysctl_rt_secret_interval(ctl_table *ctl, int write,
2972} 2970}
2973 2971
2974static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table, 2972static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table,
2975 int __user *name,
2976 int nlen,
2977 void __user *oldval, 2973 void __user *oldval,
2978 size_t __user *oldlenp, 2974 size_t __user *oldlenp,
2979 void __user *newval, 2975 void __user *newval,
2980 size_t newlen) 2976 size_t newlen)
2981{ 2977{
2982 int old = ip_rt_secret_interval; 2978 int old = ip_rt_secret_interval;
2983 int ret = sysctl_jiffies(table, name, nlen, oldval, oldlenp, newval, 2979 int ret = sysctl_jiffies(table, oldval, oldlenp, newval, newlen);
2984 newlen);
2985 2980
2986 rt_secret_reschedule(old); 2981 rt_secret_reschedule(old);
2987 2982
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 276d047fb85a..1bb10df8ce7d 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -64,8 +64,8 @@ static int ipv4_local_port_range(ctl_table *table, int write, struct file *filp,
64} 64}
65 65
66/* Validate changes from sysctl interface. */ 66/* Validate changes from sysctl interface. */
67static int ipv4_sysctl_local_port_range(ctl_table *table, int __user *name, 67static int ipv4_sysctl_local_port_range(ctl_table *table,
68 int nlen, void __user *oldval, 68 void __user *oldval,
69 size_t __user *oldlenp, 69 size_t __user *oldlenp,
70 void __user *newval, size_t newlen) 70 void __user *newval, size_t newlen)
71{ 71{
@@ -80,7 +80,7 @@ static int ipv4_sysctl_local_port_range(ctl_table *table, int __user *name,
80 }; 80 };
81 81
82 inet_get_local_port_range(range, range + 1); 82 inet_get_local_port_range(range, range + 1);
83 ret = sysctl_intvec(&tmp, name, nlen, oldval, oldlenp, newval, newlen); 83 ret = sysctl_intvec(&tmp, oldval, oldlenp, newval, newlen);
84 if (ret == 0 && newval && newlen) { 84 if (ret == 0 && newval && newlen) {
85 if (range[1] < range[0]) 85 if (range[1] < range[0])
86 ret = -EINVAL; 86 ret = -EINVAL;
@@ -109,8 +109,8 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write, struct file *
109 return ret; 109 return ret;
110} 110}
111 111
112static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name, 112static int sysctl_tcp_congestion_control(ctl_table *table,
113 int nlen, void __user *oldval, 113 void __user *oldval,
114 size_t __user *oldlenp, 114 size_t __user *oldlenp,
115 void __user *newval, size_t newlen) 115 void __user *newval, size_t newlen)
116{ 116{
@@ -122,7 +122,7 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
122 int ret; 122 int ret;
123 123
124 tcp_get_default_congestion_control(val); 124 tcp_get_default_congestion_control(val);
125 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); 125 ret = sysctl_string(&tbl, oldval, oldlenp, newval, newlen);
126 if (ret == 1 && newval && newlen) 126 if (ret == 1 && newval && newlen)
127 ret = tcp_set_default_congestion_control(val); 127 ret = tcp_set_default_congestion_control(val);
128 return ret; 128 return ret;
@@ -165,8 +165,8 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
165 return ret; 165 return ret;
166} 166}
167 167
168static int strategy_allowed_congestion_control(ctl_table *table, int __user *name, 168static int strategy_allowed_congestion_control(ctl_table *table,
169 int nlen, void __user *oldval, 169 void __user *oldval,
170 size_t __user *oldlenp, 170 size_t __user *oldlenp,
171 void __user *newval, 171 void __user *newval,
172 size_t newlen) 172 size_t newlen)
@@ -179,7 +179,7 @@ static int strategy_allowed_congestion_control(ctl_table *table, int __user *nam
179 return -ENOMEM; 179 return -ENOMEM;
180 180
181 tcp_get_available_congestion_control(tbl.data, tbl.maxlen); 181 tcp_get_available_congestion_control(tbl.data, tbl.maxlen);
182 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); 182 ret = sysctl_string(&tbl, oldval, oldlenp, newval, newlen);
183 if (ret == 1 && newval && newlen) 183 if (ret == 1 && newval && newlen)
184 ret = tcp_set_allowed_congestion_control(tbl.data); 184 ret = tcp_set_allowed_congestion_control(tbl.data);
185 kfree(tbl.data); 185 kfree(tbl.data);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7b6a584b62dd..eea9542728ca 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3982,7 +3982,6 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
3982} 3982}
3983 3983
3984static int addrconf_sysctl_forward_strategy(ctl_table *table, 3984static int addrconf_sysctl_forward_strategy(ctl_table *table,
3985 int __user *name, int nlen,
3986 void __user *oldval, 3985 void __user *oldval,
3987 size_t __user *oldlenp, 3986 size_t __user *oldlenp,
3988 void __user *newval, size_t newlen) 3987 void __user *newval, size_t newlen)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 840b15780a36..172438320eec 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1199,7 +1199,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1199 } 1199 }
1200 neigh->flags |= NTF_ROUTER; 1200 neigh->flags |= NTF_ROUTER;
1201 } else if (rt) { 1201 } else if (rt) {
1202 rt->rt6i_flags |= (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); 1202 rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
1203 } 1203 }
1204 1204
1205 if (rt) 1205 if (rt)
@@ -1730,9 +1730,8 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, struct file * f
1730 return ret; 1730 return ret;
1731} 1731}
1732 1732
1733int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name, 1733int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl,
1734 int nlen, void __user *oldval, 1734 void __user *oldval, size_t __user *oldlenp,
1735 size_t __user *oldlenp,
1736 void __user *newval, size_t newlen) 1735 void __user *newval, size_t newlen)
1737{ 1736{
1738 struct net_device *dev = ctl->extra1; 1737 struct net_device *dev = ctl->extra1;
@@ -1745,13 +1744,11 @@ int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name,
1745 1744
1746 switch (ctl->ctl_name) { 1745 switch (ctl->ctl_name) {
1747 case NET_NEIGH_REACHABLE_TIME: 1746 case NET_NEIGH_REACHABLE_TIME:
1748 ret = sysctl_jiffies(ctl, name, nlen, 1747 ret = sysctl_jiffies(ctl, oldval, oldlenp, newval, newlen);
1749 oldval, oldlenp, newval, newlen);
1750 break; 1748 break;
1751 case NET_NEIGH_RETRANS_TIME_MS: 1749 case NET_NEIGH_RETRANS_TIME_MS:
1752 case NET_NEIGH_REACHABLE_TIME_MS: 1750 case NET_NEIGH_REACHABLE_TIME_MS:
1753 ret = sysctl_ms_jiffies(ctl, name, nlen, 1751 ret = sysctl_ms_jiffies(ctl, oldval, oldlenp, newval, newlen);
1754 oldval, oldlenp, newval, newlen);
1755 break; 1752 break;
1756 default: 1753 default:
1757 ret = 0; 1754 ret = 0;
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index 6b29b03925f1..fd5b3a4e3329 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -12,6 +12,7 @@
12 12
13int ip6_route_me_harder(struct sk_buff *skb) 13int ip6_route_me_harder(struct sk_buff *skb)
14{ 14{
15 struct net *net = dev_net(skb->dst->dev);
15 struct ipv6hdr *iph = ipv6_hdr(skb); 16 struct ipv6hdr *iph = ipv6_hdr(skb);
16 struct dst_entry *dst; 17 struct dst_entry *dst;
17 struct flowi fl = { 18 struct flowi fl = {
@@ -23,7 +24,7 @@ int ip6_route_me_harder(struct sk_buff *skb)
23 .saddr = iph->saddr, } }, 24 .saddr = iph->saddr, } },
24 }; 25 };
25 26
26 dst = ip6_route_output(dev_net(skb->dst->dev), skb->sk, &fl); 27 dst = ip6_route_output(net, skb->sk, &fl);
27 28
28#ifdef CONFIG_XFRM 29#ifdef CONFIG_XFRM
29 if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && 30 if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
@@ -33,8 +34,7 @@ int ip6_route_me_harder(struct sk_buff *skb)
33#endif 34#endif
34 35
35 if (dst->error) { 36 if (dst->error) {
36 IP6_INC_STATS(&init_net, ip6_dst_idev(dst), 37 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
37 IPSTATS_MIB_OUTNOROUTES);
38 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n"); 38 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n");
39 dst_release(dst); 39 dst_release(dst);
40 return -EINVAL; 40 return -EINVAL;
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 2a4515623776..2ad504fc3414 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -545,8 +545,12 @@ static int netdev_notify(struct notifier_block *nb,
545 545
546 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 546 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
547 547
548 sprintf(buf, "netdev:%s", dev->name);
549 dir = sdata->debugfsdir; 548 dir = sdata->debugfsdir;
549
550 if (!dir)
551 return 0;
552
553 sprintf(buf, "netdev:%s", dev->name);
550 if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf)) 554 if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
551 printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs " 555 printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
552 "dir to %s\n", buf); 556 "dir to %s\n", buf);
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index b9902e425f09..189d0bafa91a 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -249,11 +249,22 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
249 DECLARE_MAC_BUF(mbuf); 249 DECLARE_MAC_BUF(mbuf);
250 u8 *mac; 250 u8 *mac;
251 251
252 sta->debugfs.add_has_run = true;
253
252 if (!stations_dir) 254 if (!stations_dir)
253 return; 255 return;
254 256
255 mac = print_mac(mbuf, sta->sta.addr); 257 mac = print_mac(mbuf, sta->sta.addr);
256 258
259 /*
260 * This might fail due to a race condition:
261 * When mac80211 unlinks a station, the debugfs entries
262 * remain, but it is already possible to link a new
263 * station with the same address which triggers adding
264 * it to debugfs; therefore, if the old station isn't
265 * destroyed quickly enough the old station's debugfs
266 * dir might still be around.
267 */
257 sta->debugfs.dir = debugfs_create_dir(mac, stations_dir); 268 sta->debugfs.dir = debugfs_create_dir(mac, stations_dir);
258 if (!sta->debugfs.dir) 269 if (!sta->debugfs.dir)
259 return; 270 return;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 8025b294588b..156e42a003ae 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -816,8 +816,8 @@ struct ieee802_11_elems {
816 u8 *ext_supp_rates; 816 u8 *ext_supp_rates;
817 u8 *wmm_info; 817 u8 *wmm_info;
818 u8 *wmm_param; 818 u8 *wmm_param;
819 u8 *ht_cap_elem; 819 struct ieee80211_ht_cap *ht_cap_elem;
820 u8 *ht_info_elem; 820 struct ieee80211_ht_addt_info *ht_info_elem;
821 u8 *mesh_config; 821 u8 *mesh_config;
822 u8 *mesh_id; 822 u8 *mesh_id;
823 u8 *peer_link; 823 u8 *peer_link;
@@ -844,8 +844,6 @@ struct ieee802_11_elems {
844 u8 ext_supp_rates_len; 844 u8 ext_supp_rates_len;
845 u8 wmm_info_len; 845 u8 wmm_info_len;
846 u8 wmm_param_len; 846 u8 wmm_param_len;
847 u8 ht_cap_elem_len;
848 u8 ht_info_elem_len;
849 u8 mesh_config_len; 847 u8 mesh_config_len;
850 u8 mesh_id_len; 848 u8 mesh_id_len;
851 u8 peer_link_len; 849 u8 peer_link_len;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 49f86fa56bff..87665d7bb4f9 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1348,10 +1348,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1348 (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { 1348 (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) {
1349 struct ieee80211_ht_bss_info bss_info; 1349 struct ieee80211_ht_bss_info bss_info;
1350 ieee80211_ht_cap_ie_to_ht_info( 1350 ieee80211_ht_cap_ie_to_ht_info(
1351 (struct ieee80211_ht_cap *)
1352 elems.ht_cap_elem, &sta->sta.ht_info); 1351 elems.ht_cap_elem, &sta->sta.ht_info);
1353 ieee80211_ht_addt_info_ie_to_ht_bss_info( 1352 ieee80211_ht_addt_info_ie_to_ht_bss_info(
1354 (struct ieee80211_ht_addt_info *)
1355 elems.ht_info_elem, &bss_info); 1353 elems.ht_info_elem, &bss_info);
1356 ieee80211_handle_ht(local, 1, &sta->sta.ht_info, &bss_info); 1354 ieee80211_handle_ht(local, 1, &sta->sta.ht_info, &bss_info);
1357 } 1355 }
@@ -1709,7 +1707,6 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1709 struct ieee80211_ht_bss_info bss_info; 1707 struct ieee80211_ht_bss_info bss_info;
1710 1708
1711 ieee80211_ht_addt_info_ie_to_ht_bss_info( 1709 ieee80211_ht_addt_info_ie_to_ht_bss_info(
1712 (struct ieee80211_ht_addt_info *)
1713 elems.ht_info_elem, &bss_info); 1710 elems.ht_info_elem, &bss_info);
1714 changed |= ieee80211_handle_ht(local, 1, &conf->ht_conf, 1711 changed |= ieee80211_handle_ht(local, 1, &conf->ht_conf,
1715 &bss_info); 1712 &bss_info);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 8e6685e7ae85..416bb41099f3 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -388,7 +388,8 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
388 bss = ieee80211_bss_info_update(sdata->local, rx_status, 388 bss = ieee80211_bss_info_update(sdata->local, rx_status,
389 mgmt, skb->len, &elems, 389 mgmt, skb->len, &elems,
390 freq, beacon); 390 freq, beacon);
391 ieee80211_rx_bss_put(sdata->local, bss); 391 if (bss)
392 ieee80211_rx_bss_put(sdata->local, bss);
392 393
393 dev_kfree_skb(skb); 394 dev_kfree_skb(skb);
394 return RX_QUEUED; 395 return RX_QUEUED;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 9b72d15bc8dc..7fef8ea1f5ec 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -635,7 +635,12 @@ static void sta_info_debugfs_add_work(struct work_struct *work)
635 635
636 spin_lock_irqsave(&local->sta_lock, flags); 636 spin_lock_irqsave(&local->sta_lock, flags);
637 list_for_each_entry(tmp, &local->sta_list, list) { 637 list_for_each_entry(tmp, &local->sta_list, list) {
638 if (!tmp->debugfs.dir) { 638 /*
639 * debugfs.add_has_run will be set by
640 * ieee80211_sta_debugfs_add regardless
641 * of what else it does.
642 */
643 if (!tmp->debugfs.add_has_run) {
639 sta = tmp; 644 sta = tmp;
640 __sta_info_pin(sta); 645 __sta_info_pin(sta);
641 break; 646 break;
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index a6b51862a89d..168a39a298bd 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -300,6 +300,7 @@ struct sta_info {
300 struct dentry *inactive_ms; 300 struct dentry *inactive_ms;
301 struct dentry *last_seq_ctrl; 301 struct dentry *last_seq_ctrl;
302 struct dentry *agg_status; 302 struct dentry *agg_status;
303 bool add_has_run;
303 } debugfs; 304 } debugfs;
304#endif 305#endif
305 306
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index f32561ec224c..cee4884b9d06 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -529,12 +529,12 @@ void ieee802_11_parse_elems(u8 *start, size_t len,
529 elems->ext_supp_rates_len = elen; 529 elems->ext_supp_rates_len = elen;
530 break; 530 break;
531 case WLAN_EID_HT_CAPABILITY: 531 case WLAN_EID_HT_CAPABILITY:
532 elems->ht_cap_elem = pos; 532 if (elen >= sizeof(struct ieee80211_ht_cap))
533 elems->ht_cap_elem_len = elen; 533 elems->ht_cap_elem = (void *)pos;
534 break; 534 break;
535 case WLAN_EID_HT_EXTRA_INFO: 535 case WLAN_EID_HT_EXTRA_INFO:
536 elems->ht_info_elem = pos; 536 if (elen >= sizeof(struct ieee80211_ht_addt_info))
537 elems->ht_info_elem_len = elen; 537 elems->ht_info_elem = (void *)pos;
538 break; 538 break;
539 case WLAN_EID_MESH_ID: 539 case WLAN_EID_MESH_ID:
540 elems->mesh_id = pos; 540 elems->mesh_id = pos;
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index 7e0d53abde24..742f811ca416 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -775,7 +775,7 @@ static int ieee80211_ioctl_siwfrag(struct net_device *dev,
775 * configure it here */ 775 * configure it here */
776 776
777 if (local->ops->set_frag_threshold) 777 if (local->ops->set_frag_threshold)
778 local->ops->set_frag_threshold( 778 return local->ops->set_frag_threshold(
779 local_to_hw(local), 779 local_to_hw(local),
780 local->fragmentation_threshold); 780 local->fragmentation_threshold);
781 781
diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
index 03591d37b9cc..b92df5c1dfcf 100644
--- a/net/netfilter/nf_conntrack_acct.c
+++ b/net/netfilter/nf_conntrack_acct.c
@@ -115,7 +115,7 @@ int nf_conntrack_acct_init(struct net *net)
115 115
116 if (net_eq(net, &init_net)) { 116 if (net_eq(net, &init_net)) {
117#ifdef CONFIG_NF_CT_ACCT 117#ifdef CONFIG_NF_CT_ACCT
118 printk(KERN_WARNING "CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Plase use\n"); 118 printk(KERN_WARNING "CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Please use\n");
119 printk(KERN_WARNING "nf_conntrack.acct=1 kernel paramater, acct=1 nf_conntrack module option or\n"); 119 printk(KERN_WARNING "nf_conntrack.acct=1 kernel paramater, acct=1 nf_conntrack module option or\n");
120 printk(KERN_WARNING "sysctl net.netfilter.nf_conntrack_acct=1 to enable it.\n"); 120 printk(KERN_WARNING "sysctl net.netfilter.nf_conntrack_acct=1 to enable it.\n");
121#endif 121#endif
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 27de3c7b006e..622d7c671cb7 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -38,9 +38,16 @@
38#include <net/netfilter/nf_conntrack_core.h> 38#include <net/netfilter/nf_conntrack_core.h>
39#include <net/netfilter/nf_conntrack_extend.h> 39#include <net/netfilter/nf_conntrack_extend.h>
40#include <net/netfilter/nf_conntrack_acct.h> 40#include <net/netfilter/nf_conntrack_acct.h>
41#include <net/netfilter/nf_nat.h>
41 42
42#define NF_CONNTRACK_VERSION "0.5.0" 43#define NF_CONNTRACK_VERSION "0.5.0"
43 44
45unsigned int
46(*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct,
47 enum nf_nat_manip_type manip,
48 struct nlattr *attr) __read_mostly;
49EXPORT_SYMBOL_GPL(nfnetlink_parse_nat_setup_hook);
50
44DEFINE_SPINLOCK(nf_conntrack_lock); 51DEFINE_SPINLOCK(nf_conntrack_lock);
45EXPORT_SYMBOL_GPL(nf_conntrack_lock); 52EXPORT_SYMBOL_GPL(nf_conntrack_lock);
46 53
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index cadfd15b44f6..08e82d64eb6f 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -689,71 +689,6 @@ ctnetlink_parse_tuple(struct nlattr *cda[], struct nf_conntrack_tuple *tuple,
689 return 0; 689 return 0;
690} 690}
691 691
692#ifdef CONFIG_NF_NAT_NEEDED
693static const struct nla_policy protonat_nla_policy[CTA_PROTONAT_MAX+1] = {
694 [CTA_PROTONAT_PORT_MIN] = { .type = NLA_U16 },
695 [CTA_PROTONAT_PORT_MAX] = { .type = NLA_U16 },
696};
697
698static int nfnetlink_parse_nat_proto(struct nlattr *attr,
699 const struct nf_conn *ct,
700 struct nf_nat_range *range)
701{
702 struct nlattr *tb[CTA_PROTONAT_MAX+1];
703 const struct nf_nat_protocol *npt;
704 int err;
705
706 err = nla_parse_nested(tb, CTA_PROTONAT_MAX, attr, protonat_nla_policy);
707 if (err < 0)
708 return err;
709
710 npt = nf_nat_proto_find_get(nf_ct_protonum(ct));
711 if (npt->nlattr_to_range)
712 err = npt->nlattr_to_range(tb, range);
713 nf_nat_proto_put(npt);
714 return err;
715}
716
717static const struct nla_policy nat_nla_policy[CTA_NAT_MAX+1] = {
718 [CTA_NAT_MINIP] = { .type = NLA_U32 },
719 [CTA_NAT_MAXIP] = { .type = NLA_U32 },
720};
721
722static inline int
723nfnetlink_parse_nat(struct nlattr *nat,
724 const struct nf_conn *ct, struct nf_nat_range *range)
725{
726 struct nlattr *tb[CTA_NAT_MAX+1];
727 int err;
728
729 memset(range, 0, sizeof(*range));
730
731 err = nla_parse_nested(tb, CTA_NAT_MAX, nat, nat_nla_policy);
732 if (err < 0)
733 return err;
734
735 if (tb[CTA_NAT_MINIP])
736 range->min_ip = nla_get_be32(tb[CTA_NAT_MINIP]);
737
738 if (!tb[CTA_NAT_MAXIP])
739 range->max_ip = range->min_ip;
740 else
741 range->max_ip = nla_get_be32(tb[CTA_NAT_MAXIP]);
742
743 if (range->min_ip)
744 range->flags |= IP_NAT_RANGE_MAP_IPS;
745
746 if (!tb[CTA_NAT_PROTO])
747 return 0;
748
749 err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO], ct, range);
750 if (err < 0)
751 return err;
752
753 return 0;
754}
755#endif
756
757static inline int 692static inline int
758ctnetlink_parse_help(struct nlattr *attr, char **helper_name) 693ctnetlink_parse_help(struct nlattr *attr, char **helper_name)
759{ 694{
@@ -879,6 +814,34 @@ out:
879} 814}
880 815
881static int 816static int
817ctnetlink_parse_nat_setup(struct nf_conn *ct,
818 enum nf_nat_manip_type manip,
819 struct nlattr *attr)
820{
821 typeof(nfnetlink_parse_nat_setup_hook) parse_nat_setup;
822
823 parse_nat_setup = rcu_dereference(nfnetlink_parse_nat_setup_hook);
824 if (!parse_nat_setup) {
825#ifdef CONFIG_KMOD
826 rcu_read_unlock();
827 nfnl_unlock();
828 if (request_module("nf-nat-ipv4") < 0) {
829 nfnl_lock();
830 rcu_read_lock();
831 return -EOPNOTSUPP;
832 }
833 nfnl_lock();
834 rcu_read_lock();
835 if (nfnetlink_parse_nat_setup_hook)
836 return -EAGAIN;
837#endif
838 return -EOPNOTSUPP;
839 }
840
841 return parse_nat_setup(ct, manip, attr);
842}
843
844static int
882ctnetlink_change_status(struct nf_conn *ct, struct nlattr *cda[]) 845ctnetlink_change_status(struct nf_conn *ct, struct nlattr *cda[])
883{ 846{
884 unsigned long d; 847 unsigned long d;
@@ -897,31 +860,6 @@ ctnetlink_change_status(struct nf_conn *ct, struct nlattr *cda[])
897 /* ASSURED bit can only be set */ 860 /* ASSURED bit can only be set */
898 return -EBUSY; 861 return -EBUSY;
899 862
900 if (cda[CTA_NAT_SRC] || cda[CTA_NAT_DST]) {
901#ifndef CONFIG_NF_NAT_NEEDED
902 return -EOPNOTSUPP;
903#else
904 struct nf_nat_range range;
905
906 if (cda[CTA_NAT_DST]) {
907 if (nfnetlink_parse_nat(cda[CTA_NAT_DST], ct,
908 &range) < 0)
909 return -EINVAL;
910 if (nf_nat_initialized(ct, IP_NAT_MANIP_DST))
911 return -EEXIST;
912 nf_nat_setup_info(ct, &range, IP_NAT_MANIP_DST);
913 }
914 if (cda[CTA_NAT_SRC]) {
915 if (nfnetlink_parse_nat(cda[CTA_NAT_SRC], ct,
916 &range) < 0)
917 return -EINVAL;
918 if (nf_nat_initialized(ct, IP_NAT_MANIP_SRC))
919 return -EEXIST;
920 nf_nat_setup_info(ct, &range, IP_NAT_MANIP_SRC);
921 }
922#endif
923 }
924
925 /* Be careful here, modifying NAT bits can screw up things, 863 /* Be careful here, modifying NAT bits can screw up things,
926 * so don't let users modify them directly if they don't pass 864 * so don't let users modify them directly if they don't pass
927 * nf_nat_range. */ 865 * nf_nat_range. */
@@ -929,6 +867,31 @@ ctnetlink_change_status(struct nf_conn *ct, struct nlattr *cda[])
929 return 0; 867 return 0;
930} 868}
931 869
870static int
871ctnetlink_change_nat(struct nf_conn *ct, struct nlattr *cda[])
872{
873#ifdef CONFIG_NF_NAT_NEEDED
874 int ret;
875
876 if (cda[CTA_NAT_DST]) {
877 ret = ctnetlink_parse_nat_setup(ct,
878 IP_NAT_MANIP_DST,
879 cda[CTA_NAT_DST]);
880 if (ret < 0)
881 return ret;
882 }
883 if (cda[CTA_NAT_SRC]) {
884 ret = ctnetlink_parse_nat_setup(ct,
885 IP_NAT_MANIP_SRC,
886 cda[CTA_NAT_SRC]);
887 if (ret < 0)
888 return ret;
889 }
890 return 0;
891#else
892 return -EOPNOTSUPP;
893#endif
894}
932 895
933static inline int 896static inline int
934ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[]) 897ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[])
@@ -1157,6 +1120,14 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
1157 } 1120 }
1158 } 1121 }
1159 1122
1123 if (cda[CTA_NAT_SRC] || cda[CTA_NAT_DST]) {
1124 err = ctnetlink_change_nat(ct, cda);
1125 if (err < 0) {
1126 rcu_read_unlock();
1127 goto err;
1128 }
1129 }
1130
1160 if (cda[CTA_PROTOINFO]) { 1131 if (cda[CTA_PROTOINFO]) {
1161 err = ctnetlink_change_protoinfo(ct, cda); 1132 err = ctnetlink_change_protoinfo(ct, cda);
1162 if (err < 0) { 1133 if (err < 0) {
diff --git a/net/netfilter/nf_conntrack_pptp.c b/net/netfilter/nf_conntrack_pptp.c
index 373e51e91ce5..1bc3001d1827 100644
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -65,7 +65,7 @@ void
65 struct nf_conntrack_expect *exp) __read_mostly; 65 struct nf_conntrack_expect *exp) __read_mostly;
66EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn); 66EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
67 67
68#ifdef DEBUG 68#if defined(DEBUG) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
69/* PptpControlMessageType names */ 69/* PptpControlMessageType names */
70const char *const pptp_msg_name[] = { 70const char *const pptp_msg_name[] = {
71 "UNKNOWN_MESSAGE", 71 "UNKNOWN_MESSAGE",
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index b75c9c4a995d..4739f9f961d8 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -44,15 +44,17 @@ static struct sock *nfnl = NULL;
44static const struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT]; 44static const struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT];
45static DEFINE_MUTEX(nfnl_mutex); 45static DEFINE_MUTEX(nfnl_mutex);
46 46
47static inline void nfnl_lock(void) 47void nfnl_lock(void)
48{ 48{
49 mutex_lock(&nfnl_mutex); 49 mutex_lock(&nfnl_mutex);
50} 50}
51EXPORT_SYMBOL_GPL(nfnl_lock);
51 52
52static inline void nfnl_unlock(void) 53void nfnl_unlock(void)
53{ 54{
54 mutex_unlock(&nfnl_mutex); 55 mutex_unlock(&nfnl_mutex);
55} 56}
57EXPORT_SYMBOL_GPL(nfnl_unlock);
56 58
57int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n) 59int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n)
58{ 60{
@@ -132,6 +134,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
132 return 0; 134 return 0;
133 135
134 type = nlh->nlmsg_type; 136 type = nlh->nlmsg_type;
137replay:
135 ss = nfnetlink_get_subsys(type); 138 ss = nfnetlink_get_subsys(type);
136 if (!ss) { 139 if (!ss) {
137#ifdef CONFIG_KMOD 140#ifdef CONFIG_KMOD
@@ -165,7 +168,10 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
165 } else 168 } else
166 return -EINVAL; 169 return -EINVAL;
167 170
168 return nc->call(nfnl, skb, nlh, cda); 171 err = nc->call(nfnl, skb, nlh, cda);
172 if (err == -EAGAIN)
173 goto replay;
174 return err;
169 } 175 }
170} 176}
171 177
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index da0789fa1b88..4895c341e46d 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -213,10 +213,10 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
213 } 213 }
214 214
215 /* save the nodename */ 215 /* save the nodename */
216 clnt->cl_nodelen = strlen(utsname()->nodename); 216 clnt->cl_nodelen = strlen(init_utsname()->nodename);
217 if (clnt->cl_nodelen > UNX_MAXNODENAME) 217 if (clnt->cl_nodelen > UNX_MAXNODENAME)
218 clnt->cl_nodelen = UNX_MAXNODENAME; 218 clnt->cl_nodelen = UNX_MAXNODENAME;
219 memcpy(clnt->cl_nodename, utsname()->nodename, clnt->cl_nodelen); 219 memcpy(clnt->cl_nodename, init_utsname()->nodename, clnt->cl_nodelen);
220 rpc_register_client(clnt); 220 rpc_register_client(clnt);
221 return clnt; 221 return clnt;
222 222
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 34abc91058d8..41013dd66ac3 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -460,6 +460,28 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
460 return rpc_run_task(&task_setup_data); 460 return rpc_run_task(&task_setup_data);
461} 461}
462 462
463/*
464 * In the case where rpc clients have been cloned, we want to make
465 * sure that we use the program number/version etc of the actual
466 * owner of the xprt. To do so, we walk back up the tree of parents
467 * to find whoever created the transport and/or whoever has the
468 * autobind flag set.
469 */
470static struct rpc_clnt *rpcb_find_transport_owner(struct rpc_clnt *clnt)
471{
472 struct rpc_clnt *parent = clnt->cl_parent;
473
474 while (parent != clnt) {
475 if (parent->cl_xprt != clnt->cl_xprt)
476 break;
477 if (clnt->cl_autobind)
478 break;
479 clnt = parent;
480 parent = parent->cl_parent;
481 }
482 return clnt;
483}
484
463/** 485/**
464 * rpcb_getport_async - obtain the port for a given RPC service on a given host 486 * rpcb_getport_async - obtain the port for a given RPC service on a given host
465 * @task: task that is waiting for portmapper request 487 * @task: task that is waiting for portmapper request
@@ -469,10 +491,10 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
469 */ 491 */
470void rpcb_getport_async(struct rpc_task *task) 492void rpcb_getport_async(struct rpc_task *task)
471{ 493{
472 struct rpc_clnt *clnt = task->tk_client; 494 struct rpc_clnt *clnt;
473 struct rpc_procinfo *proc; 495 struct rpc_procinfo *proc;
474 u32 bind_version; 496 u32 bind_version;
475 struct rpc_xprt *xprt = task->tk_xprt; 497 struct rpc_xprt *xprt;
476 struct rpc_clnt *rpcb_clnt; 498 struct rpc_clnt *rpcb_clnt;
477 static struct rpcbind_args *map; 499 static struct rpcbind_args *map;
478 struct rpc_task *child; 500 struct rpc_task *child;
@@ -481,13 +503,13 @@ void rpcb_getport_async(struct rpc_task *task)
481 size_t salen; 503 size_t salen;
482 int status; 504 int status;
483 505
506 clnt = rpcb_find_transport_owner(task->tk_client);
507 xprt = clnt->cl_xprt;
508
484 dprintk("RPC: %5u %s(%s, %u, %u, %d)\n", 509 dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
485 task->tk_pid, __func__, 510 task->tk_pid, __func__,
486 clnt->cl_server, clnt->cl_prog, clnt->cl_vers, xprt->prot); 511 clnt->cl_server, clnt->cl_prog, clnt->cl_vers, xprt->prot);
487 512
488 /* Autobind on cloned rpc clients is discouraged */
489 BUG_ON(clnt->cl_parent != clnt);
490
491 /* Put self on the wait queue to ensure we get notified if 513 /* Put self on the wait queue to ensure we get notified if
492 * some other task is already attempting to bind the port */ 514 * some other task is already attempting to bind the port */
493 rpc_sleep_on(&xprt->binding, task, NULL); 515 rpc_sleep_on(&xprt->binding, task, NULL);
@@ -549,7 +571,7 @@ void rpcb_getport_async(struct rpc_task *task)
549 status = -ENOMEM; 571 status = -ENOMEM;
550 dprintk("RPC: %5u %s: no memory available\n", 572 dprintk("RPC: %5u %s: no memory available\n",
551 task->tk_pid, __func__); 573 task->tk_pid, __func__);
552 goto bailout_nofree; 574 goto bailout_release_client;
553 } 575 }
554 map->r_prog = clnt->cl_prog; 576 map->r_prog = clnt->cl_prog;
555 map->r_vers = clnt->cl_vers; 577 map->r_vers = clnt->cl_vers;
@@ -569,11 +591,13 @@ void rpcb_getport_async(struct rpc_task *task)
569 task->tk_pid, __func__); 591 task->tk_pid, __func__);
570 return; 592 return;
571 } 593 }
572 rpc_put_task(child);
573 594
574 task->tk_xprt->stat.bind_count++; 595 xprt->stat.bind_count++;
596 rpc_put_task(child);
575 return; 597 return;
576 598
599bailout_release_client:
600 rpc_release_client(rpcb_clnt);
577bailout_nofree: 601bailout_nofree:
578 rpcb_wake_rpcbind_waiters(xprt, status); 602 rpcb_wake_rpcbind_waiters(xprt, status);
579 task->tk_status = status; 603 task->tk_status = status;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 99a52aabe332..29e401bb612e 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -108,13 +108,10 @@ int xprt_register_transport(struct xprt_class *transport)
108 goto out; 108 goto out;
109 } 109 }
110 110
111 result = -EINVAL; 111 list_add_tail(&transport->list, &xprt_list);
112 if (try_module_get(THIS_MODULE)) { 112 printk(KERN_INFO "RPC: Registered %s transport module.\n",
113 list_add_tail(&transport->list, &xprt_list); 113 transport->name);
114 printk(KERN_INFO "RPC: Registered %s transport module.\n", 114 result = 0;
115 transport->name);
116 result = 0;
117 }
118 115
119out: 116out:
120 spin_unlock(&xprt_list_lock); 117 spin_unlock(&xprt_list_lock);
@@ -143,7 +140,6 @@ int xprt_unregister_transport(struct xprt_class *transport)
143 "RPC: Unregistered %s transport module.\n", 140 "RPC: Unregistered %s transport module.\n",
144 transport->name); 141 transport->name);
145 list_del_init(&transport->list); 142 list_del_init(&transport->list);
146 module_put(THIS_MODULE);
147 goto out; 143 goto out;
148 } 144 }
149 } 145 }
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index 5c1954d28d09..14106d26bb95 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -118,6 +118,10 @@ rpcrdma_convert_iovs(struct xdr_buf *xdrbuf, unsigned int pos,
118 } 118 }
119 119
120 if (xdrbuf->tail[0].iov_len) { 120 if (xdrbuf->tail[0].iov_len) {
121 /* the rpcrdma protocol allows us to omit any trailing
122 * xdr pad bytes, saving the server an RDMA operation. */
123 if (xdrbuf->tail[0].iov_len < 4 && xprt_rdma_pad_optimize)
124 return n;
121 if (n == nsegs) 125 if (n == nsegs)
122 return 0; 126 return 0;
123 seg[n].mr_page = NULL; 127 seg[n].mr_page = NULL;
@@ -508,8 +512,8 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst)
508 if (hdrlen == 0) 512 if (hdrlen == 0)
509 return -1; 513 return -1;
510 514
511 dprintk("RPC: %s: %s: hdrlen %zd rpclen %zd padlen %zd\n" 515 dprintk("RPC: %s: %s: hdrlen %zd rpclen %zd padlen %zd"
512 " headerp 0x%p base 0x%p lkey 0x%x\n", 516 " headerp 0x%p base 0x%p lkey 0x%x\n",
513 __func__, transfertypes[wtype], hdrlen, rpclen, padlen, 517 __func__, transfertypes[wtype], hdrlen, rpclen, padlen,
514 headerp, base, req->rl_iov.lkey); 518 headerp, base, req->rl_iov.lkey);
515 519
@@ -594,7 +598,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, unsigned int max, int wrchunk, __b
594 * Scatter inline received data back into provided iov's. 598 * Scatter inline received data back into provided iov's.
595 */ 599 */
596static void 600static void
597rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len) 601rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
598{ 602{
599 int i, npages, curlen, olen; 603 int i, npages, curlen, olen;
600 char *destp; 604 char *destp;
@@ -660,6 +664,13 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len)
660 } else 664 } else
661 rqst->rq_rcv_buf.tail[0].iov_len = 0; 665 rqst->rq_rcv_buf.tail[0].iov_len = 0;
662 666
667 if (pad) {
668 /* implicit padding on terminal chunk */
669 unsigned char *p = rqst->rq_rcv_buf.tail[0].iov_base;
670 while (pad--)
671 p[rqst->rq_rcv_buf.tail[0].iov_len++] = 0;
672 }
673
663 if (copy_len) 674 if (copy_len)
664 dprintk("RPC: %s: %d bytes in" 675 dprintk("RPC: %s: %d bytes in"
665 " %d extra segments (%d lost)\n", 676 " %d extra segments (%d lost)\n",
@@ -681,12 +692,14 @@ rpcrdma_conn_func(struct rpcrdma_ep *ep)
681 struct rpc_xprt *xprt = ep->rep_xprt; 692 struct rpc_xprt *xprt = ep->rep_xprt;
682 693
683 spin_lock_bh(&xprt->transport_lock); 694 spin_lock_bh(&xprt->transport_lock);
695 if (++xprt->connect_cookie == 0) /* maintain a reserved value */
696 ++xprt->connect_cookie;
684 if (ep->rep_connected > 0) { 697 if (ep->rep_connected > 0) {
685 if (!xprt_test_and_set_connected(xprt)) 698 if (!xprt_test_and_set_connected(xprt))
686 xprt_wake_pending_tasks(xprt, 0); 699 xprt_wake_pending_tasks(xprt, 0);
687 } else { 700 } else {
688 if (xprt_test_and_clear_connected(xprt)) 701 if (xprt_test_and_clear_connected(xprt))
689 xprt_wake_pending_tasks(xprt, ep->rep_connected); 702 xprt_wake_pending_tasks(xprt, -ENOTCONN);
690 } 703 }
691 spin_unlock_bh(&xprt->transport_lock); 704 spin_unlock_bh(&xprt->transport_lock);
692} 705}
@@ -792,14 +805,20 @@ repost:
792 ((unsigned char *)iptr - (unsigned char *)headerp); 805 ((unsigned char *)iptr - (unsigned char *)headerp);
793 status = rep->rr_len + rdmalen; 806 status = rep->rr_len + rdmalen;
794 r_xprt->rx_stats.total_rdma_reply += rdmalen; 807 r_xprt->rx_stats.total_rdma_reply += rdmalen;
808 /* special case - last chunk may omit padding */
809 if (rdmalen &= 3) {
810 rdmalen = 4 - rdmalen;
811 status += rdmalen;
812 }
795 } else { 813 } else {
796 /* else ordinary inline */ 814 /* else ordinary inline */
815 rdmalen = 0;
797 iptr = (__be32 *)((unsigned char *)headerp + 28); 816 iptr = (__be32 *)((unsigned char *)headerp + 28);
798 rep->rr_len -= 28; /*sizeof *headerp;*/ 817 rep->rr_len -= 28; /*sizeof *headerp;*/
799 status = rep->rr_len; 818 status = rep->rr_len;
800 } 819 }
801 /* Fix up the rpc results for upper layer */ 820 /* Fix up the rpc results for upper layer */
802 rpcrdma_inline_fixup(rqst, (char *)iptr, rep->rr_len); 821 rpcrdma_inline_fixup(rqst, (char *)iptr, rep->rr_len, rdmalen);
803 break; 822 break;
804 823
805 case htonl(RDMA_NOMSG): 824 case htonl(RDMA_NOMSG):
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index a564c1a39ec5..9839c3d94145 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -70,11 +70,8 @@ static unsigned int xprt_rdma_slot_table_entries = RPCRDMA_DEF_SLOT_TABLE;
70static unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE; 70static unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE;
71static unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE; 71static unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE;
72static unsigned int xprt_rdma_inline_write_padding; 72static unsigned int xprt_rdma_inline_write_padding;
73#if !RPCRDMA_PERSISTENT_REGISTRATION 73static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRMR;
74static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_REGISTER; /* FMR? */ 74 int xprt_rdma_pad_optimize = 0;
75#else
76static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_ALLPHYSICAL;
77#endif
78 75
79#ifdef RPC_DEBUG 76#ifdef RPC_DEBUG
80 77
@@ -140,6 +137,14 @@ static ctl_table xr_tunables_table[] = {
140 .extra2 = &max_memreg, 137 .extra2 = &max_memreg,
141 }, 138 },
142 { 139 {
140 .ctl_name = CTL_UNNUMBERED,
141 .procname = "rdma_pad_optimize",
142 .data = &xprt_rdma_pad_optimize,
143 .maxlen = sizeof(unsigned int),
144 .mode = 0644,
145 .proc_handler = &proc_dointvec,
146 },
147 {
143 .ctl_name = 0, 148 .ctl_name = 0,
144 }, 149 },
145}; 150};
@@ -458,6 +463,8 @@ xprt_rdma_close(struct rpc_xprt *xprt)
458 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 463 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
459 464
460 dprintk("RPC: %s: closing\n", __func__); 465 dprintk("RPC: %s: closing\n", __func__);
466 if (r_xprt->rx_ep.rep_connected > 0)
467 xprt->reestablish_timeout = 0;
461 xprt_disconnect_done(xprt); 468 xprt_disconnect_done(xprt);
462 (void) rpcrdma_ep_disconnect(&r_xprt->rx_ep, &r_xprt->rx_ia); 469 (void) rpcrdma_ep_disconnect(&r_xprt->rx_ep, &r_xprt->rx_ia);
463} 470}
@@ -485,6 +492,11 @@ xprt_rdma_connect(struct rpc_task *task)
485 /* Reconnect */ 492 /* Reconnect */
486 schedule_delayed_work(&r_xprt->rdma_connect, 493 schedule_delayed_work(&r_xprt->rdma_connect,
487 xprt->reestablish_timeout); 494 xprt->reestablish_timeout);
495 xprt->reestablish_timeout <<= 1;
496 if (xprt->reestablish_timeout > (30 * HZ))
497 xprt->reestablish_timeout = (30 * HZ);
498 else if (xprt->reestablish_timeout < (5 * HZ))
499 xprt->reestablish_timeout = (5 * HZ);
488 } else { 500 } else {
489 schedule_delayed_work(&r_xprt->rdma_connect, 0); 501 schedule_delayed_work(&r_xprt->rdma_connect, 0);
490 if (!RPC_IS_ASYNC(task)) 502 if (!RPC_IS_ASYNC(task))
@@ -591,6 +603,7 @@ xprt_rdma_allocate(struct rpc_task *task, size_t size)
591 } 603 }
592 dprintk("RPC: %s: size %zd, request 0x%p\n", __func__, size, req); 604 dprintk("RPC: %s: size %zd, request 0x%p\n", __func__, size, req);
593out: 605out:
606 req->rl_connect_cookie = 0; /* our reserved value */
594 return req->rl_xdr_buf; 607 return req->rl_xdr_buf;
595 608
596outfail: 609outfail:
@@ -694,13 +707,21 @@ xprt_rdma_send_request(struct rpc_task *task)
694 req->rl_reply->rr_xprt = xprt; 707 req->rl_reply->rr_xprt = xprt;
695 } 708 }
696 709
697 if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req)) { 710 /* Must suppress retransmit to maintain credits */
698 xprt_disconnect_done(xprt); 711 if (req->rl_connect_cookie == xprt->connect_cookie)
699 return -ENOTCONN; /* implies disconnect */ 712 goto drop_connection;
700 } 713 req->rl_connect_cookie = xprt->connect_cookie;
714
715 if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req))
716 goto drop_connection;
701 717
718 task->tk_bytes_sent += rqst->rq_snd_buf.len;
702 rqst->rq_bytes_sent = 0; 719 rqst->rq_bytes_sent = 0;
703 return 0; 720 return 0;
721
722drop_connection:
723 xprt_disconnect_done(xprt);
724 return -ENOTCONN; /* implies disconnect */
704} 725}
705 726
706static void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) 727static void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
@@ -770,7 +791,7 @@ static void __exit xprt_rdma_cleanup(void)
770{ 791{
771 int rc; 792 int rc;
772 793
773 dprintk("RPCRDMA Module Removed, deregister RPC RDMA transport\n"); 794 dprintk(KERN_INFO "RPCRDMA Module Removed, deregister RPC RDMA transport\n");
774#ifdef RPC_DEBUG 795#ifdef RPC_DEBUG
775 if (sunrpc_table_header) { 796 if (sunrpc_table_header) {
776 unregister_sysctl_table(sunrpc_table_header); 797 unregister_sysctl_table(sunrpc_table_header);
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 8ea283ecc522..a5fef5e6c323 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -284,6 +284,7 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
284 switch (event->event) { 284 switch (event->event) {
285 case RDMA_CM_EVENT_ADDR_RESOLVED: 285 case RDMA_CM_EVENT_ADDR_RESOLVED:
286 case RDMA_CM_EVENT_ROUTE_RESOLVED: 286 case RDMA_CM_EVENT_ROUTE_RESOLVED:
287 ia->ri_async_rc = 0;
287 complete(&ia->ri_done); 288 complete(&ia->ri_done);
288 break; 289 break;
289 case RDMA_CM_EVENT_ADDR_ERROR: 290 case RDMA_CM_EVENT_ADDR_ERROR:
@@ -338,13 +339,32 @@ connected:
338 wake_up_all(&ep->rep_connect_wait); 339 wake_up_all(&ep->rep_connect_wait);
339 break; 340 break;
340 default: 341 default:
341 ia->ri_async_rc = -EINVAL; 342 dprintk("RPC: %s: unexpected CM event %d\n",
342 dprintk("RPC: %s: unexpected CM event %X\n",
343 __func__, event->event); 343 __func__, event->event);
344 complete(&ia->ri_done);
345 break; 344 break;
346 } 345 }
347 346
347#ifdef RPC_DEBUG
348 if (connstate == 1) {
349 int ird = attr.max_dest_rd_atomic;
350 int tird = ep->rep_remote_cma.responder_resources;
351 printk(KERN_INFO "rpcrdma: connection to %u.%u.%u.%u:%u "
352 "on %s, memreg %d slots %d ird %d%s\n",
353 NIPQUAD(addr->sin_addr.s_addr),
354 ntohs(addr->sin_port),
355 ia->ri_id->device->name,
356 ia->ri_memreg_strategy,
357 xprt->rx_buf.rb_max_requests,
358 ird, ird < 4 && ird < tird / 2 ? " (low!)" : "");
359 } else if (connstate < 0) {
360 printk(KERN_INFO "rpcrdma: connection to %u.%u.%u.%u:%u "
361 "closed (%d)\n",
362 NIPQUAD(addr->sin_addr.s_addr),
363 ntohs(addr->sin_port),
364 connstate);
365 }
366#endif
367
348 return 0; 368 return 0;
349} 369}
350 370
@@ -355,6 +375,8 @@ rpcrdma_create_id(struct rpcrdma_xprt *xprt,
355 struct rdma_cm_id *id; 375 struct rdma_cm_id *id;
356 int rc; 376 int rc;
357 377
378 init_completion(&ia->ri_done);
379
358 id = rdma_create_id(rpcrdma_conn_upcall, xprt, RDMA_PS_TCP); 380 id = rdma_create_id(rpcrdma_conn_upcall, xprt, RDMA_PS_TCP);
359 if (IS_ERR(id)) { 381 if (IS_ERR(id)) {
360 rc = PTR_ERR(id); 382 rc = PTR_ERR(id);
@@ -363,26 +385,28 @@ rpcrdma_create_id(struct rpcrdma_xprt *xprt,
363 return id; 385 return id;
364 } 386 }
365 387
366 ia->ri_async_rc = 0; 388 ia->ri_async_rc = -ETIMEDOUT;
367 rc = rdma_resolve_addr(id, NULL, addr, RDMA_RESOLVE_TIMEOUT); 389 rc = rdma_resolve_addr(id, NULL, addr, RDMA_RESOLVE_TIMEOUT);
368 if (rc) { 390 if (rc) {
369 dprintk("RPC: %s: rdma_resolve_addr() failed %i\n", 391 dprintk("RPC: %s: rdma_resolve_addr() failed %i\n",
370 __func__, rc); 392 __func__, rc);
371 goto out; 393 goto out;
372 } 394 }
373 wait_for_completion(&ia->ri_done); 395 wait_for_completion_interruptible_timeout(&ia->ri_done,
396 msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT) + 1);
374 rc = ia->ri_async_rc; 397 rc = ia->ri_async_rc;
375 if (rc) 398 if (rc)
376 goto out; 399 goto out;
377 400
378 ia->ri_async_rc = 0; 401 ia->ri_async_rc = -ETIMEDOUT;
379 rc = rdma_resolve_route(id, RDMA_RESOLVE_TIMEOUT); 402 rc = rdma_resolve_route(id, RDMA_RESOLVE_TIMEOUT);
380 if (rc) { 403 if (rc) {
381 dprintk("RPC: %s: rdma_resolve_route() failed %i\n", 404 dprintk("RPC: %s: rdma_resolve_route() failed %i\n",
382 __func__, rc); 405 __func__, rc);
383 goto out; 406 goto out;
384 } 407 }
385 wait_for_completion(&ia->ri_done); 408 wait_for_completion_interruptible_timeout(&ia->ri_done,
409 msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT) + 1);
386 rc = ia->ri_async_rc; 410 rc = ia->ri_async_rc;
387 if (rc) 411 if (rc)
388 goto out; 412 goto out;
@@ -423,11 +447,10 @@ rpcrdma_clean_cq(struct ib_cq *cq)
423int 447int
424rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg) 448rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
425{ 449{
426 int rc; 450 int rc, mem_priv;
451 struct ib_device_attr devattr;
427 struct rpcrdma_ia *ia = &xprt->rx_ia; 452 struct rpcrdma_ia *ia = &xprt->rx_ia;
428 453
429 init_completion(&ia->ri_done);
430
431 ia->ri_id = rpcrdma_create_id(xprt, ia, addr); 454 ia->ri_id = rpcrdma_create_id(xprt, ia, addr);
432 if (IS_ERR(ia->ri_id)) { 455 if (IS_ERR(ia->ri_id)) {
433 rc = PTR_ERR(ia->ri_id); 456 rc = PTR_ERR(ia->ri_id);
@@ -443,6 +466,73 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
443 } 466 }
444 467
445 /* 468 /*
469 * Query the device to determine if the requested memory
470 * registration strategy is supported. If it isn't, set the
471 * strategy to a globally supported model.
472 */
473 rc = ib_query_device(ia->ri_id->device, &devattr);
474 if (rc) {
475 dprintk("RPC: %s: ib_query_device failed %d\n",
476 __func__, rc);
477 goto out2;
478 }
479
480 if (devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
481 ia->ri_have_dma_lkey = 1;
482 ia->ri_dma_lkey = ia->ri_id->device->local_dma_lkey;
483 }
484
485 switch (memreg) {
486 case RPCRDMA_MEMWINDOWS:
487 case RPCRDMA_MEMWINDOWS_ASYNC:
488 if (!(devattr.device_cap_flags & IB_DEVICE_MEM_WINDOW)) {
489 dprintk("RPC: %s: MEMWINDOWS registration "
490 "specified but not supported by adapter, "
491 "using slower RPCRDMA_REGISTER\n",
492 __func__);
493 memreg = RPCRDMA_REGISTER;
494 }
495 break;
496 case RPCRDMA_MTHCAFMR:
497 if (!ia->ri_id->device->alloc_fmr) {
498#if RPCRDMA_PERSISTENT_REGISTRATION
499 dprintk("RPC: %s: MTHCAFMR registration "
500 "specified but not supported by adapter, "
501 "using riskier RPCRDMA_ALLPHYSICAL\n",
502 __func__);
503 memreg = RPCRDMA_ALLPHYSICAL;
504#else
505 dprintk("RPC: %s: MTHCAFMR registration "
506 "specified but not supported by adapter, "
507 "using slower RPCRDMA_REGISTER\n",
508 __func__);
509 memreg = RPCRDMA_REGISTER;
510#endif
511 }
512 break;
513 case RPCRDMA_FRMR:
514 /* Requires both frmr reg and local dma lkey */
515 if ((devattr.device_cap_flags &
516 (IB_DEVICE_MEM_MGT_EXTENSIONS|IB_DEVICE_LOCAL_DMA_LKEY)) !=
517 (IB_DEVICE_MEM_MGT_EXTENSIONS|IB_DEVICE_LOCAL_DMA_LKEY)) {
518#if RPCRDMA_PERSISTENT_REGISTRATION
519 dprintk("RPC: %s: FRMR registration "
520 "specified but not supported by adapter, "
521 "using riskier RPCRDMA_ALLPHYSICAL\n",
522 __func__);
523 memreg = RPCRDMA_ALLPHYSICAL;
524#else
525 dprintk("RPC: %s: FRMR registration "
526 "specified but not supported by adapter, "
527 "using slower RPCRDMA_REGISTER\n",
528 __func__);
529 memreg = RPCRDMA_REGISTER;
530#endif
531 }
532 break;
533 }
534
535 /*
446 * Optionally obtain an underlying physical identity mapping in 536 * Optionally obtain an underlying physical identity mapping in
447 * order to do a memory window-based bind. This base registration 537 * order to do a memory window-based bind. This base registration
448 * is protected from remote access - that is enabled only by binding 538 * is protected from remote access - that is enabled only by binding
@@ -450,22 +540,28 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
450 * revoked after the corresponding completion similar to a storage 540 * revoked after the corresponding completion similar to a storage
451 * adapter. 541 * adapter.
452 */ 542 */
453 if (memreg > RPCRDMA_REGISTER) { 543 switch (memreg) {
454 int mem_priv = IB_ACCESS_LOCAL_WRITE; 544 case RPCRDMA_BOUNCEBUFFERS:
455 switch (memreg) { 545 case RPCRDMA_REGISTER:
546 case RPCRDMA_FRMR:
547 break;
456#if RPCRDMA_PERSISTENT_REGISTRATION 548#if RPCRDMA_PERSISTENT_REGISTRATION
457 case RPCRDMA_ALLPHYSICAL: 549 case RPCRDMA_ALLPHYSICAL:
458 mem_priv |= IB_ACCESS_REMOTE_WRITE; 550 mem_priv = IB_ACCESS_LOCAL_WRITE |
459 mem_priv |= IB_ACCESS_REMOTE_READ; 551 IB_ACCESS_REMOTE_WRITE |
460 break; 552 IB_ACCESS_REMOTE_READ;
553 goto register_setup;
461#endif 554#endif
462 case RPCRDMA_MEMWINDOWS_ASYNC: 555 case RPCRDMA_MEMWINDOWS_ASYNC:
463 case RPCRDMA_MEMWINDOWS: 556 case RPCRDMA_MEMWINDOWS:
464 mem_priv |= IB_ACCESS_MW_BIND; 557 mem_priv = IB_ACCESS_LOCAL_WRITE |
465 break; 558 IB_ACCESS_MW_BIND;
466 default: 559 goto register_setup;
560 case RPCRDMA_MTHCAFMR:
561 if (ia->ri_have_dma_lkey)
467 break; 562 break;
468 } 563 mem_priv = IB_ACCESS_LOCAL_WRITE;
564 register_setup:
469 ia->ri_bind_mem = ib_get_dma_mr(ia->ri_pd, mem_priv); 565 ia->ri_bind_mem = ib_get_dma_mr(ia->ri_pd, mem_priv);
470 if (IS_ERR(ia->ri_bind_mem)) { 566 if (IS_ERR(ia->ri_bind_mem)) {
471 printk(KERN_ALERT "%s: ib_get_dma_mr for " 567 printk(KERN_ALERT "%s: ib_get_dma_mr for "
@@ -475,7 +571,15 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
475 memreg = RPCRDMA_REGISTER; 571 memreg = RPCRDMA_REGISTER;
476 ia->ri_bind_mem = NULL; 572 ia->ri_bind_mem = NULL;
477 } 573 }
574 break;
575 default:
576 printk(KERN_ERR "%s: invalid memory registration mode %d\n",
577 __func__, memreg);
578 rc = -EINVAL;
579 goto out2;
478 } 580 }
581 dprintk("RPC: %s: memory registration strategy is %d\n",
582 __func__, memreg);
479 583
480 /* Else will do memory reg/dereg for each chunk */ 584 /* Else will do memory reg/dereg for each chunk */
481 ia->ri_memreg_strategy = memreg; 585 ia->ri_memreg_strategy = memreg;
@@ -483,6 +587,7 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
483 return 0; 587 return 0;
484out2: 588out2:
485 rdma_destroy_id(ia->ri_id); 589 rdma_destroy_id(ia->ri_id);
590 ia->ri_id = NULL;
486out1: 591out1:
487 return rc; 592 return rc;
488} 593}
@@ -503,15 +608,17 @@ rpcrdma_ia_close(struct rpcrdma_ia *ia)
503 dprintk("RPC: %s: ib_dereg_mr returned %i\n", 608 dprintk("RPC: %s: ib_dereg_mr returned %i\n",
504 __func__, rc); 609 __func__, rc);
505 } 610 }
506 if (ia->ri_id != NULL && !IS_ERR(ia->ri_id) && ia->ri_id->qp) 611 if (ia->ri_id != NULL && !IS_ERR(ia->ri_id)) {
507 rdma_destroy_qp(ia->ri_id); 612 if (ia->ri_id->qp)
613 rdma_destroy_qp(ia->ri_id);
614 rdma_destroy_id(ia->ri_id);
615 ia->ri_id = NULL;
616 }
508 if (ia->ri_pd != NULL && !IS_ERR(ia->ri_pd)) { 617 if (ia->ri_pd != NULL && !IS_ERR(ia->ri_pd)) {
509 rc = ib_dealloc_pd(ia->ri_pd); 618 rc = ib_dealloc_pd(ia->ri_pd);
510 dprintk("RPC: %s: ib_dealloc_pd returned %i\n", 619 dprintk("RPC: %s: ib_dealloc_pd returned %i\n",
511 __func__, rc); 620 __func__, rc);
512 } 621 }
513 if (ia->ri_id != NULL && !IS_ERR(ia->ri_id))
514 rdma_destroy_id(ia->ri_id);
515} 622}
516 623
517/* 624/*
@@ -541,6 +648,12 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
541 ep->rep_attr.srq = NULL; 648 ep->rep_attr.srq = NULL;
542 ep->rep_attr.cap.max_send_wr = cdata->max_requests; 649 ep->rep_attr.cap.max_send_wr = cdata->max_requests;
543 switch (ia->ri_memreg_strategy) { 650 switch (ia->ri_memreg_strategy) {
651 case RPCRDMA_FRMR:
652 /* Add room for frmr register and invalidate WRs */
653 ep->rep_attr.cap.max_send_wr *= 3;
654 if (ep->rep_attr.cap.max_send_wr > devattr.max_qp_wr)
655 return -EINVAL;
656 break;
544 case RPCRDMA_MEMWINDOWS_ASYNC: 657 case RPCRDMA_MEMWINDOWS_ASYNC:
545 case RPCRDMA_MEMWINDOWS: 658 case RPCRDMA_MEMWINDOWS:
546 /* Add room for mw_binds+unbinds - overkill! */ 659 /* Add room for mw_binds+unbinds - overkill! */
@@ -617,29 +730,13 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
617 ep->rep_remote_cma.private_data_len = 0; 730 ep->rep_remote_cma.private_data_len = 0;
618 731
619 /* Client offers RDMA Read but does not initiate */ 732 /* Client offers RDMA Read but does not initiate */
620 switch (ia->ri_memreg_strategy) { 733 ep->rep_remote_cma.initiator_depth = 0;
621 case RPCRDMA_BOUNCEBUFFERS: 734 if (ia->ri_memreg_strategy == RPCRDMA_BOUNCEBUFFERS)
622 ep->rep_remote_cma.responder_resources = 0; 735 ep->rep_remote_cma.responder_resources = 0;
623 break; 736 else if (devattr.max_qp_rd_atom > 32) /* arbitrary but <= 255 */
624 case RPCRDMA_MTHCAFMR: 737 ep->rep_remote_cma.responder_resources = 32;
625 case RPCRDMA_REGISTER: 738 else
626 ep->rep_remote_cma.responder_resources = cdata->max_requests *
627 (RPCRDMA_MAX_DATA_SEGS / 8);
628 break;
629 case RPCRDMA_MEMWINDOWS:
630 case RPCRDMA_MEMWINDOWS_ASYNC:
631#if RPCRDMA_PERSISTENT_REGISTRATION
632 case RPCRDMA_ALLPHYSICAL:
633#endif
634 ep->rep_remote_cma.responder_resources = cdata->max_requests *
635 (RPCRDMA_MAX_DATA_SEGS / 2);
636 break;
637 default:
638 break;
639 }
640 if (ep->rep_remote_cma.responder_resources > devattr.max_qp_rd_atom)
641 ep->rep_remote_cma.responder_resources = devattr.max_qp_rd_atom; 739 ep->rep_remote_cma.responder_resources = devattr.max_qp_rd_atom;
642 ep->rep_remote_cma.initiator_depth = 0;
643 740
644 ep->rep_remote_cma.retry_count = 7; 741 ep->rep_remote_cma.retry_count = 7;
645 ep->rep_remote_cma.flow_control = 0; 742 ep->rep_remote_cma.flow_control = 0;
@@ -679,21 +776,16 @@ rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
679 if (rc) 776 if (rc)
680 dprintk("RPC: %s: rpcrdma_ep_disconnect" 777 dprintk("RPC: %s: rpcrdma_ep_disconnect"
681 " returned %i\n", __func__, rc); 778 " returned %i\n", __func__, rc);
779 rdma_destroy_qp(ia->ri_id);
780 ia->ri_id->qp = NULL;
682 } 781 }
683 782
684 ep->rep_func = NULL;
685
686 /* padding - could be done in rpcrdma_buffer_destroy... */ 783 /* padding - could be done in rpcrdma_buffer_destroy... */
687 if (ep->rep_pad_mr) { 784 if (ep->rep_pad_mr) {
688 rpcrdma_deregister_internal(ia, ep->rep_pad_mr, &ep->rep_pad); 785 rpcrdma_deregister_internal(ia, ep->rep_pad_mr, &ep->rep_pad);
689 ep->rep_pad_mr = NULL; 786 ep->rep_pad_mr = NULL;
690 } 787 }
691 788
692 if (ia->ri_id->qp) {
693 rdma_destroy_qp(ia->ri_id);
694 ia->ri_id->qp = NULL;
695 }
696
697 rpcrdma_clean_cq(ep->rep_cq); 789 rpcrdma_clean_cq(ep->rep_cq);
698 rc = ib_destroy_cq(ep->rep_cq); 790 rc = ib_destroy_cq(ep->rep_cq);
699 if (rc) 791 if (rc)
@@ -712,9 +804,8 @@ rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
712 struct rdma_cm_id *id; 804 struct rdma_cm_id *id;
713 int rc = 0; 805 int rc = 0;
714 int retry_count = 0; 806 int retry_count = 0;
715 int reconnect = (ep->rep_connected != 0);
716 807
717 if (reconnect) { 808 if (ep->rep_connected != 0) {
718 struct rpcrdma_xprt *xprt; 809 struct rpcrdma_xprt *xprt;
719retry: 810retry:
720 rc = rpcrdma_ep_disconnect(ep, ia); 811 rc = rpcrdma_ep_disconnect(ep, ia);
@@ -745,6 +836,7 @@ retry:
745 goto out; 836 goto out;
746 } 837 }
747 /* END TEMP */ 838 /* END TEMP */
839 rdma_destroy_qp(ia->ri_id);
748 rdma_destroy_id(ia->ri_id); 840 rdma_destroy_id(ia->ri_id);
749 ia->ri_id = id; 841 ia->ri_id = id;
750 } 842 }
@@ -769,14 +861,6 @@ if (strnicmp(ia->ri_id->device->dma_device->bus->name, "pci", 3) == 0) {
769 } 861 }
770} 862}
771 863
772 /* Theoretically a client initiator_depth > 0 is not needed,
773 * but many peers fail to complete the connection unless they
774 * == responder_resources! */
775 if (ep->rep_remote_cma.initiator_depth !=
776 ep->rep_remote_cma.responder_resources)
777 ep->rep_remote_cma.initiator_depth =
778 ep->rep_remote_cma.responder_resources;
779
780 ep->rep_connected = 0; 864 ep->rep_connected = 0;
781 865
782 rc = rdma_connect(ia->ri_id, &ep->rep_remote_cma); 866 rc = rdma_connect(ia->ri_id, &ep->rep_remote_cma);
@@ -786,9 +870,6 @@ if (strnicmp(ia->ri_id->device->dma_device->bus->name, "pci", 3) == 0) {
786 goto out; 870 goto out;
787 } 871 }
788 872
789 if (reconnect)
790 return 0;
791
792 wait_event_interruptible(ep->rep_connect_wait, ep->rep_connected != 0); 873 wait_event_interruptible(ep->rep_connect_wait, ep->rep_connected != 0);
793 874
794 /* 875 /*
@@ -805,14 +886,16 @@ if (strnicmp(ia->ri_id->device->dma_device->bus->name, "pci", 3) == 0) {
805 if (ep->rep_connected <= 0) { 886 if (ep->rep_connected <= 0) {
806 /* Sometimes, the only way to reliably connect to remote 887 /* Sometimes, the only way to reliably connect to remote
807 * CMs is to use same nonzero values for ORD and IRD. */ 888 * CMs is to use same nonzero values for ORD and IRD. */
808 ep->rep_remote_cma.initiator_depth = 889 if (retry_count++ <= RDMA_CONNECT_RETRY_MAX + 1 &&
809 ep->rep_remote_cma.responder_resources; 890 (ep->rep_remote_cma.responder_resources == 0 ||
810 if (ep->rep_remote_cma.initiator_depth == 0) 891 ep->rep_remote_cma.initiator_depth !=
811 ++ep->rep_remote_cma.initiator_depth; 892 ep->rep_remote_cma.responder_resources)) {
812 if (ep->rep_remote_cma.responder_resources == 0) 893 if (ep->rep_remote_cma.responder_resources == 0)
813 ++ep->rep_remote_cma.responder_resources; 894 ep->rep_remote_cma.responder_resources = 1;
814 if (retry_count++ == 0) 895 ep->rep_remote_cma.initiator_depth =
896 ep->rep_remote_cma.responder_resources;
815 goto retry; 897 goto retry;
898 }
816 rc = ep->rep_connected; 899 rc = ep->rep_connected;
817 } else { 900 } else {
818 dprintk("RPC: %s: connected\n", __func__); 901 dprintk("RPC: %s: connected\n", __func__);
@@ -863,6 +946,7 @@ rpcrdma_buffer_create(struct rpcrdma_buffer *buf, struct rpcrdma_ep *ep,
863 char *p; 946 char *p;
864 size_t len; 947 size_t len;
865 int i, rc; 948 int i, rc;
949 struct rpcrdma_mw *r;
866 950
867 buf->rb_max_requests = cdata->max_requests; 951 buf->rb_max_requests = cdata->max_requests;
868 spin_lock_init(&buf->rb_lock); 952 spin_lock_init(&buf->rb_lock);
@@ -873,7 +957,7 @@ rpcrdma_buffer_create(struct rpcrdma_buffer *buf, struct rpcrdma_ep *ep,
873 * 2. arrays of struct rpcrdma_req to fill in pointers 957 * 2. arrays of struct rpcrdma_req to fill in pointers
874 * 3. array of struct rpcrdma_rep for replies 958 * 3. array of struct rpcrdma_rep for replies
875 * 4. padding, if any 959 * 4. padding, if any
876 * 5. mw's, if any 960 * 5. mw's, fmr's or frmr's, if any
877 * Send/recv buffers in req/rep need to be registered 961 * Send/recv buffers in req/rep need to be registered
878 */ 962 */
879 963
@@ -881,6 +965,10 @@ rpcrdma_buffer_create(struct rpcrdma_buffer *buf, struct rpcrdma_ep *ep,
881 (sizeof(struct rpcrdma_req *) + sizeof(struct rpcrdma_rep *)); 965 (sizeof(struct rpcrdma_req *) + sizeof(struct rpcrdma_rep *));
882 len += cdata->padding; 966 len += cdata->padding;
883 switch (ia->ri_memreg_strategy) { 967 switch (ia->ri_memreg_strategy) {
968 case RPCRDMA_FRMR:
969 len += buf->rb_max_requests * RPCRDMA_MAX_SEGS *
970 sizeof(struct rpcrdma_mw);
971 break;
884 case RPCRDMA_MTHCAFMR: 972 case RPCRDMA_MTHCAFMR:
885 /* TBD we are perhaps overallocating here */ 973 /* TBD we are perhaps overallocating here */
886 len += (buf->rb_max_requests + 1) * RPCRDMA_MAX_SEGS * 974 len += (buf->rb_max_requests + 1) * RPCRDMA_MAX_SEGS *
@@ -927,15 +1015,37 @@ rpcrdma_buffer_create(struct rpcrdma_buffer *buf, struct rpcrdma_ep *ep,
927 * and also reduce unbind-to-bind collision. 1015 * and also reduce unbind-to-bind collision.
928 */ 1016 */
929 INIT_LIST_HEAD(&buf->rb_mws); 1017 INIT_LIST_HEAD(&buf->rb_mws);
1018 r = (struct rpcrdma_mw *)p;
930 switch (ia->ri_memreg_strategy) { 1019 switch (ia->ri_memreg_strategy) {
1020 case RPCRDMA_FRMR:
1021 for (i = buf->rb_max_requests * RPCRDMA_MAX_SEGS; i; i--) {
1022 r->r.frmr.fr_mr = ib_alloc_fast_reg_mr(ia->ri_pd,
1023 RPCRDMA_MAX_SEGS);
1024 if (IS_ERR(r->r.frmr.fr_mr)) {
1025 rc = PTR_ERR(r->r.frmr.fr_mr);
1026 dprintk("RPC: %s: ib_alloc_fast_reg_mr"
1027 " failed %i\n", __func__, rc);
1028 goto out;
1029 }
1030 r->r.frmr.fr_pgl =
1031 ib_alloc_fast_reg_page_list(ia->ri_id->device,
1032 RPCRDMA_MAX_SEGS);
1033 if (IS_ERR(r->r.frmr.fr_pgl)) {
1034 rc = PTR_ERR(r->r.frmr.fr_pgl);
1035 dprintk("RPC: %s: "
1036 "ib_alloc_fast_reg_page_list "
1037 "failed %i\n", __func__, rc);
1038 goto out;
1039 }
1040 list_add(&r->mw_list, &buf->rb_mws);
1041 ++r;
1042 }
1043 break;
931 case RPCRDMA_MTHCAFMR: 1044 case RPCRDMA_MTHCAFMR:
932 {
933 struct rpcrdma_mw *r = (struct rpcrdma_mw *)p;
934 struct ib_fmr_attr fa = {
935 RPCRDMA_MAX_DATA_SEGS, 1, PAGE_SHIFT
936 };
937 /* TBD we are perhaps overallocating here */ 1045 /* TBD we are perhaps overallocating here */
938 for (i = (buf->rb_max_requests+1) * RPCRDMA_MAX_SEGS; i; i--) { 1046 for (i = (buf->rb_max_requests+1) * RPCRDMA_MAX_SEGS; i; i--) {
1047 static struct ib_fmr_attr fa =
1048 { RPCRDMA_MAX_DATA_SEGS, 1, PAGE_SHIFT };
939 r->r.fmr = ib_alloc_fmr(ia->ri_pd, 1049 r->r.fmr = ib_alloc_fmr(ia->ri_pd,
940 IB_ACCESS_REMOTE_WRITE | IB_ACCESS_REMOTE_READ, 1050 IB_ACCESS_REMOTE_WRITE | IB_ACCESS_REMOTE_READ,
941 &fa); 1051 &fa);
@@ -948,12 +1058,9 @@ rpcrdma_buffer_create(struct rpcrdma_buffer *buf, struct rpcrdma_ep *ep,
948 list_add(&r->mw_list, &buf->rb_mws); 1058 list_add(&r->mw_list, &buf->rb_mws);
949 ++r; 1059 ++r;
950 } 1060 }
951 }
952 break; 1061 break;
953 case RPCRDMA_MEMWINDOWS_ASYNC: 1062 case RPCRDMA_MEMWINDOWS_ASYNC:
954 case RPCRDMA_MEMWINDOWS: 1063 case RPCRDMA_MEMWINDOWS:
955 {
956 struct rpcrdma_mw *r = (struct rpcrdma_mw *)p;
957 /* Allocate one extra request's worth, for full cycling */ 1064 /* Allocate one extra request's worth, for full cycling */
958 for (i = (buf->rb_max_requests+1) * RPCRDMA_MAX_SEGS; i; i--) { 1065 for (i = (buf->rb_max_requests+1) * RPCRDMA_MAX_SEGS; i; i--) {
959 r->r.mw = ib_alloc_mw(ia->ri_pd); 1066 r->r.mw = ib_alloc_mw(ia->ri_pd);
@@ -966,7 +1073,6 @@ rpcrdma_buffer_create(struct rpcrdma_buffer *buf, struct rpcrdma_ep *ep,
966 list_add(&r->mw_list, &buf->rb_mws); 1073 list_add(&r->mw_list, &buf->rb_mws);
967 ++r; 1074 ++r;
968 } 1075 }
969 }
970 break; 1076 break;
971 default: 1077 default:
972 break; 1078 break;
@@ -1046,6 +1152,7 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
1046{ 1152{
1047 int rc, i; 1153 int rc, i;
1048 struct rpcrdma_ia *ia = rdmab_to_ia(buf); 1154 struct rpcrdma_ia *ia = rdmab_to_ia(buf);
1155 struct rpcrdma_mw *r;
1049 1156
1050 /* clean up in reverse order from create 1157 /* clean up in reverse order from create
1051 * 1. recv mr memory (mr free, then kfree) 1158 * 1. recv mr memory (mr free, then kfree)
@@ -1065,11 +1172,19 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
1065 } 1172 }
1066 if (buf->rb_send_bufs && buf->rb_send_bufs[i]) { 1173 if (buf->rb_send_bufs && buf->rb_send_bufs[i]) {
1067 while (!list_empty(&buf->rb_mws)) { 1174 while (!list_empty(&buf->rb_mws)) {
1068 struct rpcrdma_mw *r;
1069 r = list_entry(buf->rb_mws.next, 1175 r = list_entry(buf->rb_mws.next,
1070 struct rpcrdma_mw, mw_list); 1176 struct rpcrdma_mw, mw_list);
1071 list_del(&r->mw_list); 1177 list_del(&r->mw_list);
1072 switch (ia->ri_memreg_strategy) { 1178 switch (ia->ri_memreg_strategy) {
1179 case RPCRDMA_FRMR:
1180 rc = ib_dereg_mr(r->r.frmr.fr_mr);
1181 if (rc)
1182 dprintk("RPC: %s:"
1183 " ib_dereg_mr"
1184 " failed %i\n",
1185 __func__, rc);
1186 ib_free_fast_reg_page_list(r->r.frmr.fr_pgl);
1187 break;
1073 case RPCRDMA_MTHCAFMR: 1188 case RPCRDMA_MTHCAFMR:
1074 rc = ib_dealloc_fmr(r->r.fmr); 1189 rc = ib_dealloc_fmr(r->r.fmr);
1075 if (rc) 1190 if (rc)
@@ -1115,6 +1230,8 @@ rpcrdma_buffer_get(struct rpcrdma_buffer *buffers)
1115{ 1230{
1116 struct rpcrdma_req *req; 1231 struct rpcrdma_req *req;
1117 unsigned long flags; 1232 unsigned long flags;
1233 int i;
1234 struct rpcrdma_mw *r;
1118 1235
1119 spin_lock_irqsave(&buffers->rb_lock, flags); 1236 spin_lock_irqsave(&buffers->rb_lock, flags);
1120 if (buffers->rb_send_index == buffers->rb_max_requests) { 1237 if (buffers->rb_send_index == buffers->rb_max_requests) {
@@ -1135,9 +1252,8 @@ rpcrdma_buffer_get(struct rpcrdma_buffer *buffers)
1135 } 1252 }
1136 buffers->rb_send_bufs[buffers->rb_send_index++] = NULL; 1253 buffers->rb_send_bufs[buffers->rb_send_index++] = NULL;
1137 if (!list_empty(&buffers->rb_mws)) { 1254 if (!list_empty(&buffers->rb_mws)) {
1138 int i = RPCRDMA_MAX_SEGS - 1; 1255 i = RPCRDMA_MAX_SEGS - 1;
1139 do { 1256 do {
1140 struct rpcrdma_mw *r;
1141 r = list_entry(buffers->rb_mws.next, 1257 r = list_entry(buffers->rb_mws.next,
1142 struct rpcrdma_mw, mw_list); 1258 struct rpcrdma_mw, mw_list);
1143 list_del(&r->mw_list); 1259 list_del(&r->mw_list);
@@ -1171,6 +1287,7 @@ rpcrdma_buffer_put(struct rpcrdma_req *req)
1171 req->rl_reply = NULL; 1287 req->rl_reply = NULL;
1172 } 1288 }
1173 switch (ia->ri_memreg_strategy) { 1289 switch (ia->ri_memreg_strategy) {
1290 case RPCRDMA_FRMR:
1174 case RPCRDMA_MTHCAFMR: 1291 case RPCRDMA_MTHCAFMR:
1175 case RPCRDMA_MEMWINDOWS_ASYNC: 1292 case RPCRDMA_MEMWINDOWS_ASYNC:
1176 case RPCRDMA_MEMWINDOWS: 1293 case RPCRDMA_MEMWINDOWS:
@@ -1252,7 +1369,11 @@ rpcrdma_register_internal(struct rpcrdma_ia *ia, void *va, int len,
1252 va, len, DMA_BIDIRECTIONAL); 1369 va, len, DMA_BIDIRECTIONAL);
1253 iov->length = len; 1370 iov->length = len;
1254 1371
1255 if (ia->ri_bind_mem != NULL) { 1372 if (ia->ri_have_dma_lkey) {
1373 *mrp = NULL;
1374 iov->lkey = ia->ri_dma_lkey;
1375 return 0;
1376 } else if (ia->ri_bind_mem != NULL) {
1256 *mrp = NULL; 1377 *mrp = NULL;
1257 iov->lkey = ia->ri_bind_mem->lkey; 1378 iov->lkey = ia->ri_bind_mem->lkey;
1258 return 0; 1379 return 0;
@@ -1329,15 +1450,292 @@ rpcrdma_unmap_one(struct rpcrdma_ia *ia, struct rpcrdma_mr_seg *seg)
1329 seg->mr_dma, seg->mr_dmalen, seg->mr_dir); 1450 seg->mr_dma, seg->mr_dmalen, seg->mr_dir);
1330} 1451}
1331 1452
1453static int
1454rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg,
1455 int *nsegs, int writing, struct rpcrdma_ia *ia,
1456 struct rpcrdma_xprt *r_xprt)
1457{
1458 struct rpcrdma_mr_seg *seg1 = seg;
1459 struct ib_send_wr frmr_wr, *bad_wr;
1460 u8 key;
1461 int len, pageoff;
1462 int i, rc;
1463
1464 pageoff = offset_in_page(seg1->mr_offset);
1465 seg1->mr_offset -= pageoff; /* start of page */
1466 seg1->mr_len += pageoff;
1467 len = -pageoff;
1468 if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
1469 *nsegs = RPCRDMA_MAX_DATA_SEGS;
1470 for (i = 0; i < *nsegs;) {
1471 rpcrdma_map_one(ia, seg, writing);
1472 seg1->mr_chunk.rl_mw->r.frmr.fr_pgl->page_list[i] = seg->mr_dma;
1473 len += seg->mr_len;
1474 ++seg;
1475 ++i;
1476 /* Check for holes */
1477 if ((i < *nsegs && offset_in_page(seg->mr_offset)) ||
1478 offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len))
1479 break;
1480 }
1481 dprintk("RPC: %s: Using frmr %p to map %d segments\n",
1482 __func__, seg1->mr_chunk.rl_mw, i);
1483
1484 /* Bump the key */
1485 key = (u8)(seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey & 0x000000FF);
1486 ib_update_fast_reg_key(seg1->mr_chunk.rl_mw->r.frmr.fr_mr, ++key);
1487
1488 /* Prepare FRMR WR */
1489 memset(&frmr_wr, 0, sizeof frmr_wr);
1490 frmr_wr.opcode = IB_WR_FAST_REG_MR;
1491 frmr_wr.send_flags = 0; /* unsignaled */
1492 frmr_wr.wr.fast_reg.iova_start = (unsigned long)seg1->mr_dma;
1493 frmr_wr.wr.fast_reg.page_list = seg1->mr_chunk.rl_mw->r.frmr.fr_pgl;
1494 frmr_wr.wr.fast_reg.page_list_len = i;
1495 frmr_wr.wr.fast_reg.page_shift = PAGE_SHIFT;
1496 frmr_wr.wr.fast_reg.length = i << PAGE_SHIFT;
1497 frmr_wr.wr.fast_reg.access_flags = (writing ?
1498 IB_ACCESS_REMOTE_WRITE : IB_ACCESS_REMOTE_READ);
1499 frmr_wr.wr.fast_reg.rkey = seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey;
1500 DECR_CQCOUNT(&r_xprt->rx_ep);
1501
1502 rc = ib_post_send(ia->ri_id->qp, &frmr_wr, &bad_wr);
1503
1504 if (rc) {
1505 dprintk("RPC: %s: failed ib_post_send for register,"
1506 " status %i\n", __func__, rc);
1507 while (i--)
1508 rpcrdma_unmap_one(ia, --seg);
1509 } else {
1510 seg1->mr_rkey = seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey;
1511 seg1->mr_base = seg1->mr_dma + pageoff;
1512 seg1->mr_nsegs = i;
1513 seg1->mr_len = len;
1514 }
1515 *nsegs = i;
1516 return rc;
1517}
1518
1519static int
1520rpcrdma_deregister_frmr_external(struct rpcrdma_mr_seg *seg,
1521 struct rpcrdma_ia *ia, struct rpcrdma_xprt *r_xprt)
1522{
1523 struct rpcrdma_mr_seg *seg1 = seg;
1524 struct ib_send_wr invalidate_wr, *bad_wr;
1525 int rc;
1526
1527 while (seg1->mr_nsegs--)
1528 rpcrdma_unmap_one(ia, seg++);
1529
1530 memset(&invalidate_wr, 0, sizeof invalidate_wr);
1531 invalidate_wr.opcode = IB_WR_LOCAL_INV;
1532 invalidate_wr.send_flags = 0; /* unsignaled */
1533 invalidate_wr.ex.invalidate_rkey = seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey;
1534 DECR_CQCOUNT(&r_xprt->rx_ep);
1535
1536 rc = ib_post_send(ia->ri_id->qp, &invalidate_wr, &bad_wr);
1537 if (rc)
1538 dprintk("RPC: %s: failed ib_post_send for invalidate,"
1539 " status %i\n", __func__, rc);
1540 return rc;
1541}
1542
1543static int
1544rpcrdma_register_fmr_external(struct rpcrdma_mr_seg *seg,
1545 int *nsegs, int writing, struct rpcrdma_ia *ia)
1546{
1547 struct rpcrdma_mr_seg *seg1 = seg;
1548 u64 physaddrs[RPCRDMA_MAX_DATA_SEGS];
1549 int len, pageoff, i, rc;
1550
1551 pageoff = offset_in_page(seg1->mr_offset);
1552 seg1->mr_offset -= pageoff; /* start of page */
1553 seg1->mr_len += pageoff;
1554 len = -pageoff;
1555 if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
1556 *nsegs = RPCRDMA_MAX_DATA_SEGS;
1557 for (i = 0; i < *nsegs;) {
1558 rpcrdma_map_one(ia, seg, writing);
1559 physaddrs[i] = seg->mr_dma;
1560 len += seg->mr_len;
1561 ++seg;
1562 ++i;
1563 /* Check for holes */
1564 if ((i < *nsegs && offset_in_page(seg->mr_offset)) ||
1565 offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len))
1566 break;
1567 }
1568 rc = ib_map_phys_fmr(seg1->mr_chunk.rl_mw->r.fmr,
1569 physaddrs, i, seg1->mr_dma);
1570 if (rc) {
1571 dprintk("RPC: %s: failed ib_map_phys_fmr "
1572 "%u@0x%llx+%i (%d)... status %i\n", __func__,
1573 len, (unsigned long long)seg1->mr_dma,
1574 pageoff, i, rc);
1575 while (i--)
1576 rpcrdma_unmap_one(ia, --seg);
1577 } else {
1578 seg1->mr_rkey = seg1->mr_chunk.rl_mw->r.fmr->rkey;
1579 seg1->mr_base = seg1->mr_dma + pageoff;
1580 seg1->mr_nsegs = i;
1581 seg1->mr_len = len;
1582 }
1583 *nsegs = i;
1584 return rc;
1585}
1586
1587static int
1588rpcrdma_deregister_fmr_external(struct rpcrdma_mr_seg *seg,
1589 struct rpcrdma_ia *ia)
1590{
1591 struct rpcrdma_mr_seg *seg1 = seg;
1592 LIST_HEAD(l);
1593 int rc;
1594
1595 list_add(&seg1->mr_chunk.rl_mw->r.fmr->list, &l);
1596 rc = ib_unmap_fmr(&l);
1597 while (seg1->mr_nsegs--)
1598 rpcrdma_unmap_one(ia, seg++);
1599 if (rc)
1600 dprintk("RPC: %s: failed ib_unmap_fmr,"
1601 " status %i\n", __func__, rc);
1602 return rc;
1603}
1604
1605static int
1606rpcrdma_register_memwin_external(struct rpcrdma_mr_seg *seg,
1607 int *nsegs, int writing, struct rpcrdma_ia *ia,
1608 struct rpcrdma_xprt *r_xprt)
1609{
1610 int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
1611 IB_ACCESS_REMOTE_READ);
1612 struct ib_mw_bind param;
1613 int rc;
1614
1615 *nsegs = 1;
1616 rpcrdma_map_one(ia, seg, writing);
1617 param.mr = ia->ri_bind_mem;
1618 param.wr_id = 0ULL; /* no send cookie */
1619 param.addr = seg->mr_dma;
1620 param.length = seg->mr_len;
1621 param.send_flags = 0;
1622 param.mw_access_flags = mem_priv;
1623
1624 DECR_CQCOUNT(&r_xprt->rx_ep);
1625 rc = ib_bind_mw(ia->ri_id->qp, seg->mr_chunk.rl_mw->r.mw, &param);
1626 if (rc) {
1627 dprintk("RPC: %s: failed ib_bind_mw "
1628 "%u@0x%llx status %i\n",
1629 __func__, seg->mr_len,
1630 (unsigned long long)seg->mr_dma, rc);
1631 rpcrdma_unmap_one(ia, seg);
1632 } else {
1633 seg->mr_rkey = seg->mr_chunk.rl_mw->r.mw->rkey;
1634 seg->mr_base = param.addr;
1635 seg->mr_nsegs = 1;
1636 }
1637 return rc;
1638}
1639
1640static int
1641rpcrdma_deregister_memwin_external(struct rpcrdma_mr_seg *seg,
1642 struct rpcrdma_ia *ia,
1643 struct rpcrdma_xprt *r_xprt, void **r)
1644{
1645 struct ib_mw_bind param;
1646 LIST_HEAD(l);
1647 int rc;
1648
1649 BUG_ON(seg->mr_nsegs != 1);
1650 param.mr = ia->ri_bind_mem;
1651 param.addr = 0ULL; /* unbind */
1652 param.length = 0;
1653 param.mw_access_flags = 0;
1654 if (*r) {
1655 param.wr_id = (u64) (unsigned long) *r;
1656 param.send_flags = IB_SEND_SIGNALED;
1657 INIT_CQCOUNT(&r_xprt->rx_ep);
1658 } else {
1659 param.wr_id = 0ULL;
1660 param.send_flags = 0;
1661 DECR_CQCOUNT(&r_xprt->rx_ep);
1662 }
1663 rc = ib_bind_mw(ia->ri_id->qp, seg->mr_chunk.rl_mw->r.mw, &param);
1664 rpcrdma_unmap_one(ia, seg);
1665 if (rc)
1666 dprintk("RPC: %s: failed ib_(un)bind_mw,"
1667 " status %i\n", __func__, rc);
1668 else
1669 *r = NULL; /* will upcall on completion */
1670 return rc;
1671}
1672
1673static int
1674rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
1675 int *nsegs, int writing, struct rpcrdma_ia *ia)
1676{
1677 int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
1678 IB_ACCESS_REMOTE_READ);
1679 struct rpcrdma_mr_seg *seg1 = seg;
1680 struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS];
1681 int len, i, rc = 0;
1682
1683 if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
1684 *nsegs = RPCRDMA_MAX_DATA_SEGS;
1685 for (len = 0, i = 0; i < *nsegs;) {
1686 rpcrdma_map_one(ia, seg, writing);
1687 ipb[i].addr = seg->mr_dma;
1688 ipb[i].size = seg->mr_len;
1689 len += seg->mr_len;
1690 ++seg;
1691 ++i;
1692 /* Check for holes */
1693 if ((i < *nsegs && offset_in_page(seg->mr_offset)) ||
1694 offset_in_page((seg-1)->mr_offset+(seg-1)->mr_len))
1695 break;
1696 }
1697 seg1->mr_base = seg1->mr_dma;
1698 seg1->mr_chunk.rl_mr = ib_reg_phys_mr(ia->ri_pd,
1699 ipb, i, mem_priv, &seg1->mr_base);
1700 if (IS_ERR(seg1->mr_chunk.rl_mr)) {
1701 rc = PTR_ERR(seg1->mr_chunk.rl_mr);
1702 dprintk("RPC: %s: failed ib_reg_phys_mr "
1703 "%u@0x%llx (%d)... status %i\n",
1704 __func__, len,
1705 (unsigned long long)seg1->mr_dma, i, rc);
1706 while (i--)
1707 rpcrdma_unmap_one(ia, --seg);
1708 } else {
1709 seg1->mr_rkey = seg1->mr_chunk.rl_mr->rkey;
1710 seg1->mr_nsegs = i;
1711 seg1->mr_len = len;
1712 }
1713 *nsegs = i;
1714 return rc;
1715}
1716
1717static int
1718rpcrdma_deregister_default_external(struct rpcrdma_mr_seg *seg,
1719 struct rpcrdma_ia *ia)
1720{
1721 struct rpcrdma_mr_seg *seg1 = seg;
1722 int rc;
1723
1724 rc = ib_dereg_mr(seg1->mr_chunk.rl_mr);
1725 seg1->mr_chunk.rl_mr = NULL;
1726 while (seg1->mr_nsegs--)
1727 rpcrdma_unmap_one(ia, seg++);
1728 if (rc)
1729 dprintk("RPC: %s: failed ib_dereg_mr,"
1730 " status %i\n", __func__, rc);
1731 return rc;
1732}
1733
1332int 1734int
1333rpcrdma_register_external(struct rpcrdma_mr_seg *seg, 1735rpcrdma_register_external(struct rpcrdma_mr_seg *seg,
1334 int nsegs, int writing, struct rpcrdma_xprt *r_xprt) 1736 int nsegs, int writing, struct rpcrdma_xprt *r_xprt)
1335{ 1737{
1336 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 1738 struct rpcrdma_ia *ia = &r_xprt->rx_ia;
1337 int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
1338 IB_ACCESS_REMOTE_READ);
1339 struct rpcrdma_mr_seg *seg1 = seg;
1340 int i;
1341 int rc = 0; 1739 int rc = 0;
1342 1740
1343 switch (ia->ri_memreg_strategy) { 1741 switch (ia->ri_memreg_strategy) {
@@ -1352,114 +1750,25 @@ rpcrdma_register_external(struct rpcrdma_mr_seg *seg,
1352 break; 1750 break;
1353#endif 1751#endif
1354 1752
1355 /* Registration using fast memory registration */ 1753 /* Registration using frmr registration */
1754 case RPCRDMA_FRMR:
1755 rc = rpcrdma_register_frmr_external(seg, &nsegs, writing, ia, r_xprt);
1756 break;
1757
1758 /* Registration using fmr memory registration */
1356 case RPCRDMA_MTHCAFMR: 1759 case RPCRDMA_MTHCAFMR:
1357 { 1760 rc = rpcrdma_register_fmr_external(seg, &nsegs, writing, ia);
1358 u64 physaddrs[RPCRDMA_MAX_DATA_SEGS];
1359 int len, pageoff = offset_in_page(seg->mr_offset);
1360 seg1->mr_offset -= pageoff; /* start of page */
1361 seg1->mr_len += pageoff;
1362 len = -pageoff;
1363 if (nsegs > RPCRDMA_MAX_DATA_SEGS)
1364 nsegs = RPCRDMA_MAX_DATA_SEGS;
1365 for (i = 0; i < nsegs;) {
1366 rpcrdma_map_one(ia, seg, writing);
1367 physaddrs[i] = seg->mr_dma;
1368 len += seg->mr_len;
1369 ++seg;
1370 ++i;
1371 /* Check for holes */
1372 if ((i < nsegs && offset_in_page(seg->mr_offset)) ||
1373 offset_in_page((seg-1)->mr_offset+(seg-1)->mr_len))
1374 break;
1375 }
1376 nsegs = i;
1377 rc = ib_map_phys_fmr(seg1->mr_chunk.rl_mw->r.fmr,
1378 physaddrs, nsegs, seg1->mr_dma);
1379 if (rc) {
1380 dprintk("RPC: %s: failed ib_map_phys_fmr "
1381 "%u@0x%llx+%i (%d)... status %i\n", __func__,
1382 len, (unsigned long long)seg1->mr_dma,
1383 pageoff, nsegs, rc);
1384 while (nsegs--)
1385 rpcrdma_unmap_one(ia, --seg);
1386 } else {
1387 seg1->mr_rkey = seg1->mr_chunk.rl_mw->r.fmr->rkey;
1388 seg1->mr_base = seg1->mr_dma + pageoff;
1389 seg1->mr_nsegs = nsegs;
1390 seg1->mr_len = len;
1391 }
1392 }
1393 break; 1761 break;
1394 1762
1395 /* Registration using memory windows */ 1763 /* Registration using memory windows */
1396 case RPCRDMA_MEMWINDOWS_ASYNC: 1764 case RPCRDMA_MEMWINDOWS_ASYNC:
1397 case RPCRDMA_MEMWINDOWS: 1765 case RPCRDMA_MEMWINDOWS:
1398 { 1766 rc = rpcrdma_register_memwin_external(seg, &nsegs, writing, ia, r_xprt);
1399 struct ib_mw_bind param;
1400 rpcrdma_map_one(ia, seg, writing);
1401 param.mr = ia->ri_bind_mem;
1402 param.wr_id = 0ULL; /* no send cookie */
1403 param.addr = seg->mr_dma;
1404 param.length = seg->mr_len;
1405 param.send_flags = 0;
1406 param.mw_access_flags = mem_priv;
1407
1408 DECR_CQCOUNT(&r_xprt->rx_ep);
1409 rc = ib_bind_mw(ia->ri_id->qp,
1410 seg->mr_chunk.rl_mw->r.mw, &param);
1411 if (rc) {
1412 dprintk("RPC: %s: failed ib_bind_mw "
1413 "%u@0x%llx status %i\n",
1414 __func__, seg->mr_len,
1415 (unsigned long long)seg->mr_dma, rc);
1416 rpcrdma_unmap_one(ia, seg);
1417 } else {
1418 seg->mr_rkey = seg->mr_chunk.rl_mw->r.mw->rkey;
1419 seg->mr_base = param.addr;
1420 seg->mr_nsegs = 1;
1421 nsegs = 1;
1422 }
1423 }
1424 break; 1767 break;
1425 1768
1426 /* Default registration each time */ 1769 /* Default registration each time */
1427 default: 1770 default:
1428 { 1771 rc = rpcrdma_register_default_external(seg, &nsegs, writing, ia);
1429 struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS];
1430 int len = 0;
1431 if (nsegs > RPCRDMA_MAX_DATA_SEGS)
1432 nsegs = RPCRDMA_MAX_DATA_SEGS;
1433 for (i = 0; i < nsegs;) {
1434 rpcrdma_map_one(ia, seg, writing);
1435 ipb[i].addr = seg->mr_dma;
1436 ipb[i].size = seg->mr_len;
1437 len += seg->mr_len;
1438 ++seg;
1439 ++i;
1440 /* Check for holes */
1441 if ((i < nsegs && offset_in_page(seg->mr_offset)) ||
1442 offset_in_page((seg-1)->mr_offset+(seg-1)->mr_len))
1443 break;
1444 }
1445 nsegs = i;
1446 seg1->mr_base = seg1->mr_dma;
1447 seg1->mr_chunk.rl_mr = ib_reg_phys_mr(ia->ri_pd,
1448 ipb, nsegs, mem_priv, &seg1->mr_base);
1449 if (IS_ERR(seg1->mr_chunk.rl_mr)) {
1450 rc = PTR_ERR(seg1->mr_chunk.rl_mr);
1451 dprintk("RPC: %s: failed ib_reg_phys_mr "
1452 "%u@0x%llx (%d)... status %i\n",
1453 __func__, len,
1454 (unsigned long long)seg1->mr_dma, nsegs, rc);
1455 while (nsegs--)
1456 rpcrdma_unmap_one(ia, --seg);
1457 } else {
1458 seg1->mr_rkey = seg1->mr_chunk.rl_mr->rkey;
1459 seg1->mr_nsegs = nsegs;
1460 seg1->mr_len = len;
1461 }
1462 }
1463 break; 1772 break;
1464 } 1773 }
1465 if (rc) 1774 if (rc)
@@ -1473,7 +1782,6 @@ rpcrdma_deregister_external(struct rpcrdma_mr_seg *seg,
1473 struct rpcrdma_xprt *r_xprt, void *r) 1782 struct rpcrdma_xprt *r_xprt, void *r)
1474{ 1783{
1475 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 1784 struct rpcrdma_ia *ia = &r_xprt->rx_ia;
1476 struct rpcrdma_mr_seg *seg1 = seg;
1477 int nsegs = seg->mr_nsegs, rc; 1785 int nsegs = seg->mr_nsegs, rc;
1478 1786
1479 switch (ia->ri_memreg_strategy) { 1787 switch (ia->ri_memreg_strategy) {
@@ -1486,56 +1794,21 @@ rpcrdma_deregister_external(struct rpcrdma_mr_seg *seg,
1486 break; 1794 break;
1487#endif 1795#endif
1488 1796
1797 case RPCRDMA_FRMR:
1798 rc = rpcrdma_deregister_frmr_external(seg, ia, r_xprt);
1799 break;
1800
1489 case RPCRDMA_MTHCAFMR: 1801 case RPCRDMA_MTHCAFMR:
1490 { 1802 rc = rpcrdma_deregister_fmr_external(seg, ia);
1491 LIST_HEAD(l);
1492 list_add(&seg->mr_chunk.rl_mw->r.fmr->list, &l);
1493 rc = ib_unmap_fmr(&l);
1494 while (seg1->mr_nsegs--)
1495 rpcrdma_unmap_one(ia, seg++);
1496 }
1497 if (rc)
1498 dprintk("RPC: %s: failed ib_unmap_fmr,"
1499 " status %i\n", __func__, rc);
1500 break; 1803 break;
1501 1804
1502 case RPCRDMA_MEMWINDOWS_ASYNC: 1805 case RPCRDMA_MEMWINDOWS_ASYNC:
1503 case RPCRDMA_MEMWINDOWS: 1806 case RPCRDMA_MEMWINDOWS:
1504 { 1807 rc = rpcrdma_deregister_memwin_external(seg, ia, r_xprt, &r);
1505 struct ib_mw_bind param;
1506 BUG_ON(nsegs != 1);
1507 param.mr = ia->ri_bind_mem;
1508 param.addr = 0ULL; /* unbind */
1509 param.length = 0;
1510 param.mw_access_flags = 0;
1511 if (r) {
1512 param.wr_id = (u64) (unsigned long) r;
1513 param.send_flags = IB_SEND_SIGNALED;
1514 INIT_CQCOUNT(&r_xprt->rx_ep);
1515 } else {
1516 param.wr_id = 0ULL;
1517 param.send_flags = 0;
1518 DECR_CQCOUNT(&r_xprt->rx_ep);
1519 }
1520 rc = ib_bind_mw(ia->ri_id->qp,
1521 seg->mr_chunk.rl_mw->r.mw, &param);
1522 rpcrdma_unmap_one(ia, seg);
1523 }
1524 if (rc)
1525 dprintk("RPC: %s: failed ib_(un)bind_mw,"
1526 " status %i\n", __func__, rc);
1527 else
1528 r = NULL; /* will upcall on completion */
1529 break; 1808 break;
1530 1809
1531 default: 1810 default:
1532 rc = ib_dereg_mr(seg1->mr_chunk.rl_mr); 1811 rc = rpcrdma_deregister_default_external(seg, ia);
1533 seg1->mr_chunk.rl_mr = NULL;
1534 while (seg1->mr_nsegs--)
1535 rpcrdma_unmap_one(ia, seg++);
1536 if (rc)
1537 dprintk("RPC: %s: failed ib_dereg_mr,"
1538 " status %i\n", __func__, rc);
1539 break; 1812 break;
1540 } 1813 }
1541 if (r) { 1814 if (r) {
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index 2427822f8bd4..c7a7eba991bc 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -51,6 +51,9 @@
51#include <linux/sunrpc/rpc_rdma.h> /* RPC/RDMA protocol */ 51#include <linux/sunrpc/rpc_rdma.h> /* RPC/RDMA protocol */
52#include <linux/sunrpc/xprtrdma.h> /* xprt parameters */ 52#include <linux/sunrpc/xprtrdma.h> /* xprt parameters */
53 53
54#define RDMA_RESOLVE_TIMEOUT (5000) /* 5 seconds */
55#define RDMA_CONNECT_RETRY_MAX (2) /* retries if no listener backlog */
56
54/* 57/*
55 * Interface Adapter -- one per transport instance 58 * Interface Adapter -- one per transport instance
56 */ 59 */
@@ -58,6 +61,8 @@ struct rpcrdma_ia {
58 struct rdma_cm_id *ri_id; 61 struct rdma_cm_id *ri_id;
59 struct ib_pd *ri_pd; 62 struct ib_pd *ri_pd;
60 struct ib_mr *ri_bind_mem; 63 struct ib_mr *ri_bind_mem;
64 u32 ri_dma_lkey;
65 int ri_have_dma_lkey;
61 struct completion ri_done; 66 struct completion ri_done;
62 int ri_async_rc; 67 int ri_async_rc;
63 enum rpcrdma_memreg ri_memreg_strategy; 68 enum rpcrdma_memreg ri_memreg_strategy;
@@ -156,6 +161,10 @@ struct rpcrdma_mr_seg { /* chunk descriptors */
156 union { 161 union {
157 struct ib_mw *mw; 162 struct ib_mw *mw;
158 struct ib_fmr *fmr; 163 struct ib_fmr *fmr;
164 struct {
165 struct ib_fast_reg_page_list *fr_pgl;
166 struct ib_mr *fr_mr;
167 } frmr;
159 } r; 168 } r;
160 struct list_head mw_list; 169 struct list_head mw_list;
161 } *rl_mw; 170 } *rl_mw;
@@ -175,6 +184,7 @@ struct rpcrdma_req {
175 size_t rl_size; /* actual length of buffer */ 184 size_t rl_size; /* actual length of buffer */
176 unsigned int rl_niovs; /* 0, 2 or 4 */ 185 unsigned int rl_niovs; /* 0, 2 or 4 */
177 unsigned int rl_nchunks; /* non-zero if chunks */ 186 unsigned int rl_nchunks; /* non-zero if chunks */
187 unsigned int rl_connect_cookie; /* retry detection */
178 struct rpcrdma_buffer *rl_buffer; /* home base for this structure */ 188 struct rpcrdma_buffer *rl_buffer; /* home base for this structure */
179 struct rpcrdma_rep *rl_reply;/* holder for reply buffer */ 189 struct rpcrdma_rep *rl_reply;/* holder for reply buffer */
180 struct rpcrdma_mr_seg rl_segments[RPCRDMA_MAX_SEGS];/* chunk segments */ 190 struct rpcrdma_mr_seg rl_segments[RPCRDMA_MAX_SEGS];/* chunk segments */
@@ -198,7 +208,7 @@ struct rpcrdma_buffer {
198 atomic_t rb_credits; /* most recent server credits */ 208 atomic_t rb_credits; /* most recent server credits */
199 unsigned long rb_cwndscale; /* cached framework rpc_cwndscale */ 209 unsigned long rb_cwndscale; /* cached framework rpc_cwndscale */
200 int rb_max_requests;/* client max requests */ 210 int rb_max_requests;/* client max requests */
201 struct list_head rb_mws; /* optional memory windows/fmrs */ 211 struct list_head rb_mws; /* optional memory windows/fmrs/frmrs */
202 int rb_send_index; 212 int rb_send_index;
203 struct rpcrdma_req **rb_send_bufs; 213 struct rpcrdma_req **rb_send_bufs;
204 int rb_recv_index; 214 int rb_recv_index;
@@ -273,6 +283,11 @@ struct rpcrdma_xprt {
273#define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, xprt) 283#define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, xprt)
274#define rpcx_to_rdmad(x) (rpcx_to_rdmax(x)->rx_data) 284#define rpcx_to_rdmad(x) (rpcx_to_rdmax(x)->rx_data)
275 285
286/* Setting this to 0 ensures interoperability with early servers.
287 * Setting this to 1 enhances certain unaligned read/write performance.
288 * Default is 0, see sysctl entry and rpc_rdma.c rpcrdma_convert_iovs() */
289extern int xprt_rdma_pad_optimize;
290
276/* 291/*
277 * Interface Adapter calls - xprtrdma/verbs.c 292 * Interface Adapter calls - xprtrdma/verbs.c
278 */ 293 */
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 24fdd4cd22cb..5031db7b275b 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -184,7 +184,8 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
184 if (result) 184 if (result)
185 goto out_unlock; 185 goto out_unlock;
186 186
187 if (!debugfs_rename(rdev->wiphy.debugfsdir->d_parent, 187 if (rdev->wiphy.debugfsdir &&
188 !debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
188 rdev->wiphy.debugfsdir, 189 rdev->wiphy.debugfsdir,
189 rdev->wiphy.debugfsdir->d_parent, 190 rdev->wiphy.debugfsdir->d_parent,
190 newname)) 191 newname))
@@ -317,6 +318,8 @@ int wiphy_register(struct wiphy *wiphy)
317 drv->wiphy.debugfsdir = 318 drv->wiphy.debugfsdir =
318 debugfs_create_dir(wiphy_name(&drv->wiphy), 319 debugfs_create_dir(wiphy_name(&drv->wiphy),
319 ieee80211_debugfs_dir); 320 ieee80211_debugfs_dir);
321 if (IS_ERR(drv->wiphy.debugfsdir))
322 drv->wiphy.debugfsdir = NULL;
320 323
321 res = 0; 324 res = 0;
322out_unlock: 325out_unlock:
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ea48b82a3707..b4ca38a21158 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -96,6 +96,14 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
96modname_flags = $(if $(filter 1,$(words $(modname))),\ 96modname_flags = $(if $(filter 1,$(words $(modname))),\
97 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 97 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
98 98
99#hash values
100ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
101debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\
102 -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))"
103else
104debug_flags =
105endif
106
99orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o) 107orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
100_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 108_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
101_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o) 109_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
@@ -121,7 +129,8 @@ endif
121 129
122c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 130c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
123 $(__c_flags) $(modkern_cflags) \ 131 $(__c_flags) $(modkern_cflags) \
124 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) 132 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \
133 $(debug_flags)
125 134
126a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 135a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
127 $(__a_flags) $(modkern_aflags) 136 $(__a_flags) $(modkern_aflags)
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index 4c324a1f1e0e..09559951df12 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -9,7 +9,7 @@
9# fixdep: Used to generate dependency information during build process 9# fixdep: Used to generate dependency information during build process
10# docproc: Used in Documentation/DocBook 10# docproc: Used in Documentation/DocBook
11 11
12hostprogs-y := fixdep docproc 12hostprogs-y := fixdep docproc hash
13always := $(hostprogs-y) 13always := $(hostprogs-y)
14 14
15# fixdep is needed to compile other host programs 15# fixdep is needed to compile other host programs
diff --git a/scripts/basic/hash.c b/scripts/basic/hash.c
new file mode 100644
index 000000000000..3299ad7fc8c0
--- /dev/null
+++ b/scripts/basic/hash.c
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com>
3 *
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9
10#define DYNAMIC_DEBUG_HASH_BITS 6
11
12static const char *program;
13
14static void usage(void)
15{
16 printf("Usage: %s <djb2|r5> <modname>\n", program);
17 exit(1);
18}
19
20/* djb2 hashing algorithm by Dan Bernstein. From:
21 * http://www.cse.yorku.ca/~oz/hash.html
22 */
23
24unsigned int djb2_hash(char *str)
25{
26 unsigned long hash = 5381;
27 int c;
28
29 c = *str;
30 while (c) {
31 hash = ((hash << 5) + hash) + c;
32 c = *++str;
33 }
34 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
35}
36
37unsigned int r5_hash(char *str)
38{
39 unsigned long hash = 0;
40 int c;
41
42 c = *str;
43 while (c) {
44 hash = (hash + (c << 4) + (c >> 4)) * 11;
45 c = *++str;
46 }
47 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
48}
49
50int main(int argc, char *argv[])
51{
52 program = argv[0];
53
54 if (argc != 3)
55 usage();
56 if (!strcmp(argv[1], "djb2"))
57 printf("%d\n", djb2_hash(argv[2]));
58 else if (!strcmp(argv[1], "r5"))
59 printf("%d\n", r5_hash(argv[2]));
60 else
61 usage();
62 exit(0);
63}
64
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bc6779398229..e30bac141b21 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,7 +9,7 @@ use strict;
9my $P = $0; 9my $P = $0;
10$P =~ s@.*/@@g; 10$P =~ s@.*/@@g;
11 11
12my $V = '0.21'; 12my $V = '0.24';
13 13
14use Getopt::Long qw(:config no_auto_abbrev); 14use Getopt::Long qw(:config no_auto_abbrev);
15 15
@@ -66,6 +66,7 @@ if ($#ARGV < 0) {
66my $dbg_values = 0; 66my $dbg_values = 0;
67my $dbg_possible = 0; 67my $dbg_possible = 0;
68my $dbg_type = 0; 68my $dbg_type = 0;
69my $dbg_attr = 0;
69for my $key (keys %debug) { 70for my $key (keys %debug) {
70 eval "\${dbg_$key} = '$debug{$key}';" 71 eval "\${dbg_$key} = '$debug{$key}';"
71} 72}
@@ -112,7 +113,10 @@ our $Attribute = qr{
112 const| 113 const|
113 __read_mostly| 114 __read_mostly|
114 __kprobes| 115 __kprobes|
115 __(?:mem|cpu|dev|)(?:initdata|init) 116 __(?:mem|cpu|dev|)(?:initdata|init)|
117 ____cacheline_aligned|
118 ____cacheline_aligned_in_smp|
119 ____cacheline_internodealigned_in_smp
116 }x; 120 }x;
117our $Modifier; 121our $Modifier;
118our $Inline = qr{inline|__always_inline|noinline}; 122our $Inline = qr{inline|__always_inline|noinline};
@@ -142,6 +146,11 @@ our $UTF8 = qr {
142 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 146 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
143}x; 147}x;
144 148
149our $typeTypedefs = qr{(?x:
150 (?:__)?(?:u|s|be|le)(?:\d|\d\d)|
151 atomic_t
152)};
153
145our @typeList = ( 154our @typeList = (
146 qr{void}, 155 qr{void},
147 qr{(?:unsigned\s+)?char}, 156 qr{(?:unsigned\s+)?char},
@@ -155,7 +164,6 @@ our @typeList = (
155 qr{float}, 164 qr{float},
156 qr{double}, 165 qr{double},
157 qr{bool}, 166 qr{bool},
158 qr{(?:__)?(?:u|s|be|le)(?:8|16|32|64)},
159 qr{struct\s+$Ident}, 167 qr{struct\s+$Ident},
160 qr{union\s+$Ident}, 168 qr{union\s+$Ident},
161 qr{enum\s+$Ident}, 169 qr{enum\s+$Ident},
@@ -175,6 +183,7 @@ sub build_types {
175 (?:$Modifier\s+|const\s+)* 183 (?:$Modifier\s+|const\s+)*
176 (?: 184 (?:
177 (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| 185 (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)|
186 (?:$typeTypedefs\b)|
178 (?:${all}\b) 187 (?:${all}\b)
179 ) 188 )
180 (?:\s+$Modifier|\s+const)* 189 (?:\s+$Modifier|\s+const)*
@@ -331,7 +340,7 @@ sub sanitise_line {
331 $off++; 340 $off++;
332 next; 341 next;
333 } 342 }
334 if (substr($line, $off, 2) eq '*/') { 343 if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
335 $sanitise_quote = ''; 344 $sanitise_quote = '';
336 substr($res, $off, 2, "$;$;"); 345 substr($res, $off, 2, "$;$;");
337 $off++; 346 $off++;
@@ -404,6 +413,7 @@ sub ctx_statement_block {
404 # context. 413 # context.
405 if ($off >= $len) { 414 if ($off >= $len) {
406 for (; $remain > 0; $line++) { 415 for (; $remain > 0; $line++) {
416 last if (!defined $lines[$line]);
407 next if ($lines[$line] =~ /^-/); 417 next if ($lines[$line] =~ /^-/);
408 $remain--; 418 $remain--;
409 $loff = $len; 419 $loff = $len;
@@ -669,6 +679,22 @@ sub ctx_has_comment {
669 return ($cmt ne ''); 679 return ($cmt ne '');
670} 680}
671 681
682sub raw_line {
683 my ($linenr, $cnt) = @_;
684
685 my $offset = $linenr - 1;
686 $cnt++;
687
688 my $line;
689 while ($cnt) {
690 $line = $rawlines[$offset++];
691 next if (defined($line) && $line =~ /^-/);
692 $cnt--;
693 }
694
695 return $line;
696}
697
672sub cat_vet { 698sub cat_vet {
673 my ($vet) = @_; 699 my ($vet) = @_;
674 my ($res, $coded); 700 my ($res, $coded);
@@ -782,9 +808,9 @@ sub annotate_values {
782 } 808 }
783 $type = 'N'; 809 $type = 'N';
784 810
785 } elsif ($cur =~ /^(if|while|typeof|__typeof__|for)\b/o) { 811 } elsif ($cur =~ /^(if|while|for)\b/o) {
786 print "COND($1)\n" if ($dbg_values > 1); 812 print "COND($1)\n" if ($dbg_values > 1);
787 $av_pending = 'N'; 813 $av_pending = 'E';
788 $type = 'N'; 814 $type = 'N';
789 815
790 } elsif ($cur =~/^(case)/o) { 816 } elsif ($cur =~/^(case)/o) {
@@ -792,7 +818,7 @@ sub annotate_values {
792 $av_pend_colon = 'C'; 818 $av_pend_colon = 'C';
793 $type = 'N'; 819 $type = 'N';
794 820
795 } elsif ($cur =~/^(return|else|goto)/o) { 821 } elsif ($cur =~/^(return|else|goto|typeof|__typeof__)\b/o) {
796 print "KEYWORD($1)\n" if ($dbg_values > 1); 822 print "KEYWORD($1)\n" if ($dbg_values > 1);
797 $type = 'N'; 823 $type = 'N';
798 824
@@ -858,7 +884,7 @@ sub annotate_values {
858 print "CLOSE($1)\n" if ($dbg_values > 1); 884 print "CLOSE($1)\n" if ($dbg_values > 1);
859 $type = 'N'; 885 $type = 'N';
860 886
861 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&(?!\&))/o) { 887 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
862 my $variant; 888 my $variant;
863 889
864 print "OPV($1)\n" if ($dbg_values > 1); 890 print "OPV($1)\n" if ($dbg_values > 1);
@@ -892,12 +918,22 @@ sub annotate_values {
892sub possible { 918sub possible {
893 my ($possible, $line) = @_; 919 my ($possible, $line) = @_;
894 920
895 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 1); 921 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
896 if ($possible !~ /^(?:$Modifier|$Storage|$Type|DEFINE_\S+)$/ && 922 if ($possible !~ /(?:
897 $possible ne 'goto' && $possible ne 'return' && 923 ^(?:
898 $possible ne 'case' && $possible ne 'else' && 924 $Modifier|
899 $possible ne 'asm' && $possible ne '__asm__' && 925 $Storage|
900 $possible !~ /^(typedef|struct|enum)\b/) { 926 $Type|
927 DEFINE_\S+|
928 goto|
929 return|
930 case|
931 else|
932 asm|__asm__|
933 do
934 )$|
935 ^(?:typedef|struct|enum)\b
936 )/x) {
901 # Check for modifiers. 937 # Check for modifiers.
902 $possible =~ s/\s*$Storage\s*//g; 938 $possible =~ s/\s*$Storage\s*//g;
903 $possible =~ s/\s*$Sparse\s*//g; 939 $possible =~ s/\s*$Sparse\s*//g;
@@ -915,6 +951,8 @@ sub possible {
915 push(@typeList, $possible); 951 push(@typeList, $possible);
916 } 952 }
917 build_types(); 953 build_types();
954 } else {
955 warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);
918 } 956 }
919} 957}
920 958
@@ -954,6 +992,33 @@ sub CHK {
954 } 992 }
955} 993}
956 994
995sub check_absolute_file {
996 my ($absolute, $herecurr) = @_;
997 my $file = $absolute;
998
999 ##print "absolute<$absolute>\n";
1000
1001 # See if any suffix of this path is a path within the tree.
1002 while ($file =~ s@^[^/]*/@@) {
1003 if (-f "$root/$file") {
1004 ##print "file<$file>\n";
1005 last;
1006 }
1007 }
1008 if (! -f _) {
1009 return 0;
1010 }
1011
1012 # It is, so see if the prefix is acceptable.
1013 my $prefix = $absolute;
1014 substr($prefix, -length($file)) = '';
1015
1016 ##print "prefix<$prefix>\n";
1017 if ($prefix ne ".../") {
1018 WARN("use relative pathname instead of absolute in changelog text\n" . $herecurr);
1019 }
1020}
1021
957sub process { 1022sub process {
958 my $filename = shift; 1023 my $filename = shift;
959 1024
@@ -991,6 +1056,7 @@ sub process {
991 1056
992 # suppression flags 1057 # suppression flags
993 my %suppress_ifbraces; 1058 my %suppress_ifbraces;
1059 my %suppress_whiletrailers;
994 1060
995 # Pre-scan the patch sanitizing the lines. 1061 # Pre-scan the patch sanitizing the lines.
996 # Pre-scan the patch looking for any __setup documentation. 1062 # Pre-scan the patch looking for any __setup documentation.
@@ -1025,9 +1091,14 @@ sub process {
1025 # edge is a close comment then we must be in a comment 1091 # edge is a close comment then we must be in a comment
1026 # at context start. 1092 # at context start.
1027 my $edge; 1093 my $edge;
1028 for (my $ln = $linenr + 1; $ln < ($linenr + $realcnt); $ln++) { 1094 my $cnt = $realcnt;
1029 next if ($line =~ /^-/); 1095 for (my $ln = $linenr + 1; $cnt > 0; $ln++) {
1030 ($edge) = ($rawlines[$ln - 1] =~ m@(/\*|\*/)@); 1096 next if (defined $rawlines[$ln - 1] &&
1097 $rawlines[$ln - 1] =~ /^-/);
1098 $cnt--;
1099 #print "RAW<$rawlines[$ln - 1]>\n";
1100 ($edge) = (defined $rawlines[$ln - 1] &&
1101 $rawlines[$ln - 1] =~ m@(/\*|\*/)@);
1031 last if (defined $edge); 1102 last if (defined $edge);
1032 } 1103 }
1033 if (defined $edge && $edge eq '*/') { 1104 if (defined $edge && $edge eq '*/') {
@@ -1075,6 +1146,7 @@ sub process {
1075 $linenr++; 1146 $linenr++;
1076 1147
1077 my $rawline = $rawlines[$linenr - 1]; 1148 my $rawline = $rawlines[$linenr - 1];
1149 my $hunk_line = ($realcnt != 0);
1078 1150
1079#extract the line range in the file after the patch is applied 1151#extract the line range in the file after the patch is applied
1080 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { 1152 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
@@ -1090,6 +1162,7 @@ sub process {
1090 $prev_values = 'E'; 1162 $prev_values = 'E';
1091 1163
1092 %suppress_ifbraces = (); 1164 %suppress_ifbraces = ();
1165 %suppress_whiletrailers = ();
1093 next; 1166 next;
1094 1167
1095# track the line number as we move through the hunk, note that 1168# track the line number as we move through the hunk, note that
@@ -1125,7 +1198,7 @@ sub process {
1125 $realfile = $1; 1198 $realfile = $1;
1126 $realfile =~ s@^[^/]*/@@; 1199 $realfile =~ s@^[^/]*/@@;
1127 1200
1128 if ($realfile =~ m@include/asm/@) { 1201 if ($realfile =~ m@^include/asm/@) {
1129 ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); 1202 ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
1130 } 1203 }
1131 next; 1204 next;
@@ -1159,6 +1232,20 @@ sub process {
1159 $herecurr) if (!$emitted_corrupt++); 1232 $herecurr) if (!$emitted_corrupt++);
1160 } 1233 }
1161 1234
1235# Check for absolute kernel paths.
1236 if ($tree) {
1237 while ($line =~ m{(?:^|\s)(/\S*)}g) {
1238 my $file = $1;
1239
1240 if ($file =~ m{^(.*?)(?::\d+)+:?$} &&
1241 check_absolute_file($1, $herecurr)) {
1242 #
1243 } else {
1244 check_absolute_file($file, $herecurr);
1245 }
1246 }
1247 }
1248
1162# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php 1249# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
1163 if (($realfile =~ /^$/ || $line =~ /^\+/) && 1250 if (($realfile =~ /^$/ || $line =~ /^\+/) &&
1164 $rawline !~ m/^$UTF8*$/) { 1251 $rawline !~ m/^$UTF8*$/) {
@@ -1171,11 +1258,8 @@ sub process {
1171 ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); 1258 ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
1172 } 1259 }
1173 1260
1174#ignore lines being removed 1261# ignore non-hunk lines and lines being removed
1175 if ($line=~/^-/) {next;} 1262 next if (!$hunk_line || $line =~ /^-/);
1176
1177# check we are in a valid source file if not then ignore this hunk
1178 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1179 1263
1180#trailing whitespace 1264#trailing whitespace
1181 if ($line =~ /^\+.*\015/) { 1265 if ($line =~ /^\+.*\015/) {
@@ -1186,6 +1270,10 @@ sub process {
1186 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 1270 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1187 ERROR("trailing whitespace\n" . $herevet); 1271 ERROR("trailing whitespace\n" . $herevet);
1188 } 1272 }
1273
1274# check we are in a valid source file if not then ignore this hunk
1275 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1276
1189#80 column limit 1277#80 column limit
1190 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1278 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1191 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1279 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
@@ -1200,8 +1288,8 @@ sub process {
1200 WARN("adding a line without newline at end of file\n" . $herecurr); 1288 WARN("adding a line without newline at end of file\n" . $herecurr);
1201 } 1289 }
1202 1290
1203# check we are in a valid source file *.[hc] if not then ignore this hunk 1291# check we are in a valid source file C or perl if not then ignore this hunk
1204 next if ($realfile !~ /\.[hc]$/); 1292 next if ($realfile !~ /\.(h|c|pl)$/);
1205 1293
1206# at the beginning of a line any tabs must come first and anything 1294# at the beginning of a line any tabs must come first and anything
1207# more than 8 must use tabs. 1295# more than 8 must use tabs.
@@ -1211,15 +1299,18 @@ sub process {
1211 ERROR("code indent should use tabs where possible\n" . $herevet); 1299 ERROR("code indent should use tabs where possible\n" . $herevet);
1212 } 1300 }
1213 1301
1302# check we are in a valid C source file if not then ignore this hunk
1303 next if ($realfile !~ /\.(h|c)$/);
1304
1214# check for RCS/CVS revision markers 1305# check for RCS/CVS revision markers
1215 if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { 1306 if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
1216 WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr); 1307 WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr);
1217 } 1308 }
1218 1309
1219# Check for potential 'bare' types 1310# Check for potential 'bare' types
1220 my ($stat, $cond, $line_nr_next, $remain_next); 1311 my ($stat, $cond, $line_nr_next, $remain_next, $off_next);
1221 if ($realcnt && $line =~ /.\s*\S/) { 1312 if ($realcnt && $line =~ /.\s*\S/) {
1222 ($stat, $cond, $line_nr_next, $remain_next) = 1313 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
1223 ctx_statement_block($linenr, $realcnt, 0); 1314 ctx_statement_block($linenr, $realcnt, 0);
1224 $stat =~ s/\n./\n /g; 1315 $stat =~ s/\n./\n /g;
1225 $cond =~ s/\n./\n /g; 1316 $cond =~ s/\n./\n /g;
@@ -1240,7 +1331,7 @@ sub process {
1240 possible($type, "A:" . $s); 1331 possible($type, "A:" . $s);
1241 1332
1242 # definitions in global scope can only start with types 1333 # definitions in global scope can only start with types
1243 } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b/s) { 1334 } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b\s*(?!:)/s) {
1244 possible($1, "B:" . $s); 1335 possible($1, "B:" . $s);
1245 } 1336 }
1246 1337
@@ -1294,10 +1385,6 @@ sub process {
1294 ERROR("switch and case should be at the same indent\n$hereline$err"); 1385 ERROR("switch and case should be at the same indent\n$hereline$err");
1295 } 1386 }
1296 } 1387 }
1297 if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
1298 $line !~ /\G(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$/g) {
1299 ERROR("trailing statements should be on next line\n" . $herecurr);
1300 }
1301 1388
1302# if/while/etc brace do not go on next line, unless defining a do while loop, 1389# if/while/etc brace do not go on next line, unless defining a do while loop,
1303# or if that brace on the next line is for something else 1390# or if that brace on the next line is for something else
@@ -1338,6 +1425,91 @@ sub process {
1338 } 1425 }
1339 } 1426 }
1340 1427
1428# Check relative indent for conditionals and blocks.
1429 if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
1430 my ($s, $c) = ($stat, $cond);
1431
1432 substr($s, 0, length($c), '');
1433
1434 # Make sure we remove the line prefixes as we have
1435 # none on the first line, and are going to readd them
1436 # where necessary.
1437 $s =~ s/\n./\n/gs;
1438
1439 # Find out how long the conditional actually is.
1440 my @newlines = ($c =~ /\n/gs);
1441 my $cond_lines = 1 + $#newlines;
1442
1443 # We want to check the first line inside the block
1444 # starting at the end of the conditional, so remove:
1445 # 1) any blank line termination
1446 # 2) any opening brace { on end of the line
1447 # 3) any do (...) {
1448 my $continuation = 0;
1449 my $check = 0;
1450 $s =~ s/^.*\bdo\b//;
1451 $s =~ s/^\s*{//;
1452 if ($s =~ s/^\s*\\//) {
1453 $continuation = 1;
1454 }
1455 if ($s =~ s/^\s*?\n//) {
1456 $check = 1;
1457 $cond_lines++;
1458 }
1459
1460 # Also ignore a loop construct at the end of a
1461 # preprocessor statement.
1462 if (($prevline =~ /^.\s*#\s*define\s/ ||
1463 $prevline =~ /\\\s*$/) && $continuation == 0) {
1464 $check = 0;
1465 }
1466
1467 my $cond_ptr = -1;
1468 $continuation = 0;
1469 while ($cond_ptr != $cond_lines) {
1470 $cond_ptr = $cond_lines;
1471
1472 # If we see an #else/#elif then the code
1473 # is not linear.
1474 if ($s =~ /^\s*\#\s*(?:else|elif)/) {
1475 $check = 0;
1476 }
1477
1478 # Ignore:
1479 # 1) blank lines, they should be at 0,
1480 # 2) preprocessor lines, and
1481 # 3) labels.
1482 if ($continuation ||
1483 $s =~ /^\s*?\n/ ||
1484 $s =~ /^\s*#\s*?/ ||
1485 $s =~ /^\s*$Ident\s*:/) {
1486 $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0;
1487 $s =~ s/^.*?\n//;
1488 $cond_lines++;
1489 }
1490 }
1491
1492 my (undef, $sindent) = line_stats("+" . $s);
1493 my $stat_real = raw_line($linenr, $cond_lines);
1494
1495 # Check if either of these lines are modified, else
1496 # this is not this patch's fault.
1497 if (!defined($stat_real) ||
1498 $stat !~ /^\+/ && $stat_real !~ /^\+/) {
1499 $check = 0;
1500 }
1501 if (defined($stat_real) && $cond_lines > 1) {
1502 $stat_real = "[...]\n$stat_real";
1503 }
1504
1505 #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
1506
1507 if ($check && (($sindent % 8) != 0 ||
1508 ($sindent <= $indent && $s ne ''))) {
1509 WARN("suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
1510 }
1511 }
1512
1341 # Track the 'values' across context and added lines. 1513 # Track the 'values' across context and added lines.
1342 my $opline = $line; $opline =~ s/^./ /; 1514 my $opline = $line; $opline =~ s/^./ /;
1343 my ($curr_values, $curr_vars) = 1515 my ($curr_values, $curr_vars) =
@@ -1363,6 +1535,15 @@ sub process {
1363 } 1535 }
1364 next; 1536 next;
1365 } 1537 }
1538# TEST: allow direct testing of the attribute matcher.
1539 if ($dbg_attr) {
1540 if ($line =~ /^.\s*$Attribute\s*$/) {
1541 ERROR("TEST: is attr\n" . $herecurr);
1542 } elsif ($dbg_attr > 1 && $line =~ /^.+($Attribute)/) {
1543 ERROR("TEST: is not attr ($1 is)\n". $herecurr);
1544 }
1545 next;
1546 }
1366 1547
1367# check for initialisation to aggregates open brace on the next line 1548# check for initialisation to aggregates open brace on the next line
1368 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ && 1549 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ &&
@@ -1395,13 +1576,14 @@ sub process {
1395 if (($line =~ /EXPORT_SYMBOL.*\((.*)\)/) || 1576 if (($line =~ /EXPORT_SYMBOL.*\((.*)\)/) ||
1396 ($line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) { 1577 ($line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
1397 my $name = $1; 1578 my $name = $1;
1398 if (($prevline !~ /^}/) && 1579 if ($prevline !~ /(?:
1399 ($prevline !~ /^\+}/) && 1580 ^.}|
1400 ($prevline !~ /^ }/) && 1581 ^.DEFINE_$Ident\(\Q$name\E\)|
1401 ($prevline !~ /^.DECLARE_$Ident\(\Q$name\E\)/) && 1582 ^.DECLARE_$Ident\(\Q$name\E\)|
1402 ($prevline !~ /^.LIST_HEAD\(\Q$name\E\)/) && 1583 ^.LIST_HEAD\(\Q$name\E\)|
1403 ($prevline !~ /^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(/) && 1584 ^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
1404 ($prevline !~ /\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[)/)) { 1585 \b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[)
1586 )/x) {
1405 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); 1587 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
1406 } 1588 }
1407 } 1589 }
@@ -1422,6 +1604,7 @@ sub process {
1422 if ($line =~ /\btypedef\s/ && 1604 if ($line =~ /\btypedef\s/ &&
1423 $line !~ /\btypedef\s+$Type\s+\(\s*\*?$Ident\s*\)\s*\(/ && 1605 $line !~ /\btypedef\s+$Type\s+\(\s*\*?$Ident\s*\)\s*\(/ &&
1424 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && 1606 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
1607 $line !~ /\b$typeTypedefs\b/ &&
1425 $line !~ /\b__bitwise(?:__|)\b/) { 1608 $line !~ /\b__bitwise(?:__|)\b/) {
1426 WARN("do not add new typedefs\n" . $herecurr); 1609 WARN("do not add new typedefs\n" . $herecurr);
1427 } 1610 }
@@ -1493,11 +1676,13 @@ sub process {
1493 1676
1494# check for spacing round square brackets; allowed: 1677# check for spacing round square brackets; allowed:
1495# 1. with a type on the left -- int [] a; 1678# 1. with a type on the left -- int [] a;
1496# 2. at the beginning of a line for slice initialisers -- [0..10] = 5, 1679# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
1680# 3. inside a curly brace -- = { [0...10] = 5 }
1497 while ($line =~ /(.*?\s)\[/g) { 1681 while ($line =~ /(.*?\s)\[/g) {
1498 my ($where, $prefix) = ($-[1], $1); 1682 my ($where, $prefix) = ($-[1], $1);
1499 if ($prefix !~ /$Type\s+$/ && 1683 if ($prefix !~ /$Type\s+$/ &&
1500 ($where != 0 || $prefix !~ /^.\s+$/)) { 1684 ($where != 0 || $prefix !~ /^.\s+$/) &&
1685 $prefix !~ /{\s+$/) {
1501 ERROR("space prohibited before open square bracket '['\n" . $herecurr); 1686 ERROR("space prohibited before open square bracket '['\n" . $herecurr);
1502 } 1687 }
1503 } 1688 }
@@ -1632,7 +1817,7 @@ sub process {
1632 # unary operator, or a cast 1817 # unary operator, or a cast
1633 } elsif ($op eq '!' || $op eq '~' || 1818 } elsif ($op eq '!' || $op eq '~' ||
1634 $opv eq '*U' || $opv eq '-U' || 1819 $opv eq '*U' || $opv eq '-U' ||
1635 $opv eq '&U') { 1820 $opv eq '&U' || $opv eq '&&U') {
1636 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { 1821 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
1637 ERROR("space required before that '$op' $at\n" . $hereptr); 1822 ERROR("space required before that '$op' $at\n" . $hereptr);
1638 } 1823 }
@@ -1785,7 +1970,26 @@ sub process {
1785 1970
1786# Check for illegal assignment in if conditional -- and check for trailing 1971# Check for illegal assignment in if conditional -- and check for trailing
1787# statements after the conditional. 1972# statements after the conditional.
1788 if ($line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) { 1973 if ($line =~ /do\s*(?!{)/) {
1974 my ($stat_next) = ctx_statement_block($line_nr_next,
1975 $remain_next, $off_next);
1976 $stat_next =~ s/\n./\n /g;
1977 ##print "stat<$stat> stat_next<$stat_next>\n";
1978
1979 if ($stat_next =~ /^\s*while\b/) {
1980 # If the statement carries leading newlines,
1981 # then count those as offsets.
1982 my ($whitespace) =
1983 ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
1984 my $offset =
1985 statement_rawlines($whitespace) - 1;
1986
1987 $suppress_whiletrailers{$line_nr_next +
1988 $offset} = 1;
1989 }
1990 }
1991 if (!defined $suppress_whiletrailers{$linenr} &&
1992 $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
1789 my ($s, $c) = ($stat, $cond); 1993 my ($s, $c) = ($stat, $cond);
1790 1994
1791 if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { 1995 if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) {
@@ -1800,57 +2004,16 @@ sub process {
1800 if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ && 2004 if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
1801 $c !~ /}\s*while\s*/) 2005 $c !~ /}\s*while\s*/)
1802 { 2006 {
1803 ERROR("trailing statements should be on next line\n" . $herecurr); 2007 # Find out how long the conditional actually is.
1804 } 2008 my @newlines = ($c =~ /\n/gs);
1805 } 2009 my $cond_lines = 1 + $#newlines;
1806
1807# Check relative indent for conditionals and blocks.
1808 if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
1809 my ($s, $c) = ($stat, $cond);
1810
1811 substr($s, 0, length($c), '');
1812 2010
1813 # Make sure we remove the line prefixes as we have 2011 my $stat_real = raw_line($linenr, $cond_lines);
1814 # none on the first line, and are going to readd them 2012 if (defined($stat_real) && $cond_lines > 1) {
1815 # where necessary. 2013 $stat_real = "[...]\n$stat_real";
1816 $s =~ s/\n./\n/gs; 2014 }
1817
1818 # We want to check the first line inside the block
1819 # starting at the end of the conditional, so remove:
1820 # 1) any blank line termination
1821 # 2) any opening brace { on end of the line
1822 # 3) any do (...) {
1823 my $continuation = 0;
1824 my $check = 0;
1825 $s =~ s/^.*\bdo\b//;
1826 $s =~ s/^\s*{//;
1827 if ($s =~ s/^\s*\\//) {
1828 $continuation = 1;
1829 }
1830 if ($s =~ s/^\s*\n//) {
1831 $check = 1;
1832 }
1833
1834 # Also ignore a loop construct at the end of a
1835 # preprocessor statement.
1836 if (($prevline =~ /^.\s*#\s*define\s/ ||
1837 $prevline =~ /\\\s*$/) && $continuation == 0) {
1838 $check = 0;
1839 }
1840
1841 # Ignore the current line if its is a preprocessor
1842 # line.
1843 if ($s =~ /^\s*#\s*/) {
1844 $check = 0;
1845 }
1846
1847 my (undef, $sindent) = line_stats("+" . $s);
1848
1849 ##print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s>\n";
1850 2015
1851 if ($check && (($sindent % 8) != 0 || 2016 ERROR("trailing statements should be on next line\n" . $herecurr . $stat_real);
1852 ($sindent <= $indent && $s ne ''))) {
1853 WARN("suspect code indent for conditional statements\n" . $herecurr);
1854 } 2017 }
1855 } 2018 }
1856 2019
@@ -1877,6 +2040,15 @@ sub process {
1877 ERROR("trailing statements should be on next line\n" . $herecurr); 2040 ERROR("trailing statements should be on next line\n" . $herecurr);
1878 } 2041 }
1879 } 2042 }
2043# case and default should not have general statements after them
2044 if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
2045 $line !~ /\G(?:
2046 (?:\s*$;*)(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
2047 \s*return\s+
2048 )/xg)
2049 {
2050 ERROR("trailing statements should be on next line\n" . $herecurr);
2051 }
1880 2052
1881 # Check for }<nl>else {, these must be at the same 2053 # Check for }<nl>else {, these must be at the same
1882 # indent level to be relevant to each other. 2054 # indent level to be relevant to each other.
@@ -1913,12 +2085,17 @@ sub process {
1913 2085
1914#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) 2086#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
1915 if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) { 2087 if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
1916 my $checkfile = "include/linux/$1.h"; 2088 my $file = "$1.h";
1917 if (-f "$root/$checkfile" && $realfile ne $checkfile && 2089 my $checkfile = "include/linux/$file";
2090 if (-f "$root/$checkfile" &&
2091 $realfile ne $checkfile &&
1918 $1 ne 'irq') 2092 $1 ne 'irq')
1919 { 2093 {
1920 WARN("Use #include <linux/$1.h> instead of <asm/$1.h>\n" . 2094 if ($realfile =~ m{^arch/}) {
1921 $herecurr); 2095 CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
2096 } else {
2097 WARN("Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
2098 }
1922 } 2099 }
1923 } 2100 }
1924 2101
@@ -1953,8 +2130,8 @@ sub process {
1953 # Extract the remainder of the define (if any) and 2130 # Extract the remainder of the define (if any) and
1954 # rip off surrounding spaces, and trailing \'s. 2131 # rip off surrounding spaces, and trailing \'s.
1955 $rest = ''; 2132 $rest = '';
1956 while ($off != 0 || ($cnt > 0 && $rest =~ /(?:^|\\)\s*$/)) { 2133 while ($off != 0 || ($cnt > 0 && $rest =~ /\\\s*$/)) {
1957 #print "ADDING $off <" . substr($lines[$ln - 1], $off) . ">\n"; 2134 #print "ADDING cnt<$cnt> $off <" . substr($lines[$ln - 1], $off) . "> rest<$rest>\n";
1958 if ($off != 0 || $lines[$ln - 1] !~ /^-/) { 2135 if ($off != 0 || $lines[$ln - 1] !~ /^-/) {
1959 $rest .= substr($lines[$ln - 1], $off) . "\n"; 2136 $rest .= substr($lines[$ln - 1], $off) . "\n";
1960 $cnt--; 2137 $cnt--;
@@ -1978,9 +2155,10 @@ sub process {
1978 $dstat =~ s/\s*$//s; 2155 $dstat =~ s/\s*$//s;
1979 2156
1980 # Flatten any parentheses and braces 2157 # Flatten any parentheses and braces
1981 while ($dstat =~ s/\([^\(\)]*\)/1/) { 2158 while ($dstat =~ s/\([^\(\)]*\)/1/ ||
1982 } 2159 $dstat =~ s/\{[^\{\}]*\}/1/ ||
1983 while ($dstat =~ s/\{[^\{\}]*\}/1/) { 2160 $dstat =~ s/\[[^\{\}]*\]/1/)
2161 {
1984 } 2162 }
1985 2163
1986 my $exceptions = qr{ 2164 my $exceptions = qr{
@@ -2003,6 +2181,7 @@ sub process {
2003 if ($dstat ne '' && 2181 if ($dstat ne '' &&
2004 $dstat !~ /^(?:$Ident|-?$Constant)$/ && 2182 $dstat !~ /^(?:$Ident|-?$Constant)$/ &&
2005 $dstat !~ /$exceptions/ && 2183 $dstat !~ /$exceptions/ &&
2184 $dstat !~ /^\.$Ident\s*=/ &&
2006 $dstat =~ /$Operators/) 2185 $dstat =~ /$Operators/)
2007 { 2186 {
2008 ERROR("Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n"); 2187 ERROR("Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n");
@@ -2103,10 +2282,10 @@ sub process {
2103 } 2282 }
2104 if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { 2283 if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) {
2105 my $herectx = $here . "\n";; 2284 my $herectx = $here . "\n";;
2106 my $end = $linenr + statement_rawlines($block) - 1; 2285 my $cnt = statement_rawlines($block);
2107 2286
2108 for (my $ln = $linenr - 1; $ln < $end; $ln++) { 2287 for (my $n = 0; $n < $cnt; $n++) {
2109 $herectx .= $rawlines[$ln] . "\n";; 2288 $herectx .= raw_line($linenr, $n) . "\n";;
2110 } 2289 }
2111 2290
2112 WARN("braces {} are not necessary for single statement blocks\n" . $herectx); 2291 WARN("braces {} are not necessary for single statement blocks\n" . $herectx);
@@ -2281,6 +2460,7 @@ sub process {
2281 my $string; 2460 my $string;
2282 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { 2461 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
2283 $string = substr($rawline, $-[1], $+[1] - $-[1]); 2462 $string = substr($rawline, $-[1], $+[1] - $-[1]);
2463 $string =~ s/%%/__/g;
2284 if ($string =~ /(?<!%)%L[udi]/) { 2464 if ($string =~ /(?<!%)%L[udi]/) {
2285 WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr); 2465 WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
2286 last; 2466 last;
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
index 99026dfb81ea..34c1d94f921e 100644
--- a/sound/arm/pxa2xx-ac97-lib.c
+++ b/sound/arm/pxa2xx-ac97-lib.c
@@ -50,7 +50,7 @@ unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
50 mutex_lock(&car_mutex); 50 mutex_lock(&car_mutex);
51 51
52 /* set up primary or secondary codec space */ 52 /* set up primary or secondary codec space */
53 if ((cpu_is_pxa21x() || cpu_is_pxa25x()) && reg == AC97_GPIO_STATUS) 53 if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
54 reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE; 54 reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
55 else 55 else
56 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; 56 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
@@ -90,7 +90,7 @@ void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
90 mutex_lock(&car_mutex); 90 mutex_lock(&car_mutex);
91 91
92 /* set up primary or secondary codec space */ 92 /* set up primary or secondary codec space */
93 if ((cpu_is_pxa21x() || cpu_is_pxa25x()) && reg == AC97_GPIO_STATUS) 93 if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
94 reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE; 94 reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
95 else 95 else
96 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; 96 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
@@ -200,7 +200,7 @@ static inline void pxa_ac97_cold_pxa3xx(void)
200bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) 200bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
201{ 201{
202#ifdef CONFIG_PXA25x 202#ifdef CONFIG_PXA25x
203 if (cpu_is_pxa21x() || cpu_is_pxa25x()) 203 if (cpu_is_pxa25x())
204 pxa_ac97_warm_pxa25x(); 204 pxa_ac97_warm_pxa25x();
205 else 205 else
206#endif 206#endif
@@ -230,7 +230,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset);
230bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) 230bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
231{ 231{
232#ifdef CONFIG_PXA25x 232#ifdef CONFIG_PXA25x
233 if (cpu_is_pxa21x() || cpu_is_pxa25x()) 233 if (cpu_is_pxa25x())
234 pxa_ac97_cold_pxa25x(); 234 pxa_ac97_cold_pxa25x();
235 else 235 else
236#endif 236#endif
@@ -301,7 +301,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_suspend);
301 301
302int pxa2xx_ac97_hw_resume(void) 302int pxa2xx_ac97_hw_resume(void)
303{ 303{
304 if (cpu_is_pxa21x() || cpu_is_pxa25x() || cpu_is_pxa27x()) { 304 if (cpu_is_pxa25x() || cpu_is_pxa27x()) {
305 pxa_gpio_mode(GPIO31_SYNC_AC97_MD); 305 pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
306 pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD); 306 pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
307 pxa_gpio_mode(GPIO28_BITCLK_AC97_MD); 307 pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
@@ -325,7 +325,7 @@ int __devinit pxa2xx_ac97_hw_probe(struct platform_device *dev)
325 if (ret < 0) 325 if (ret < 0)
326 goto err; 326 goto err;
327 327
328 if (cpu_is_pxa21x() || cpu_is_pxa25x() || cpu_is_pxa27x()) { 328 if (cpu_is_pxa25x() || cpu_is_pxa27x()) {
329 pxa_gpio_mode(GPIO31_SYNC_AC97_MD); 329 pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
330 pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD); 330 pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
331 pxa_gpio_mode(GPIO28_BITCLK_AC97_MD); 331 pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
diff --git a/sound/core/init.c b/sound/core/init.c
index 8af467df9245..ef2352c2e451 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -549,9 +549,9 @@ int snd_card_register(struct snd_card *card)
549 return -EINVAL; 549 return -EINVAL;
550#ifndef CONFIG_SYSFS_DEPRECATED 550#ifndef CONFIG_SYSFS_DEPRECATED
551 if (!card->card_dev) { 551 if (!card->card_dev) {
552 card->card_dev = device_create_drvdata(sound_class, card->dev, 552 card->card_dev = device_create(sound_class, card->dev,
553 MKDEV(0, 0), NULL, 553 MKDEV(0, 0), NULL,
554 "card%i", card->number); 554 "card%i", card->number);
555 if (IS_ERR(card->card_dev)) 555 if (IS_ERR(card->card_dev))
556 card->card_dev = NULL; 556 card->card_dev = NULL;
557 } 557 }
diff --git a/sound/core/sound.c b/sound/core/sound.c
index c0685e2f0afa..44a69bb8d4f0 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -274,9 +274,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
274 return minor; 274 return minor;
275 } 275 }
276 snd_minors[minor] = preg; 276 snd_minors[minor] = preg;
277 preg->dev = device_create_drvdata(sound_class, device, 277 preg->dev = device_create(sound_class, device, MKDEV(major, minor),
278 MKDEV(major, minor), 278 private_data, "%s", name);
279 private_data, "%s", name);
280 if (IS_ERR(preg->dev)) { 279 if (IS_ERR(preg->dev)) {
281 snd_minors[minor] = NULL; 280 snd_minors[minor] = NULL;
282 mutex_unlock(&sound_mutex); 281 mutex_unlock(&sound_mutex);
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 7d89c081a086..61aaedae6b7e 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -560,19 +560,18 @@ static int __init oss_init(void)
560 sound_dmap_flag = (dmabuf > 0 ? 1 : 0); 560 sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
561 561
562 for (i = 0; i < ARRAY_SIZE(dev_list); i++) { 562 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
563 device_create_drvdata(sound_class, NULL, 563 device_create(sound_class, NULL,
564 MKDEV(SOUND_MAJOR, dev_list[i].minor), 564 MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL,
565 NULL, "%s", dev_list[i].name); 565 "%s", dev_list[i].name);
566 566
567 if (!dev_list[i].num) 567 if (!dev_list[i].num)
568 continue; 568 continue;
569 569
570 for (j = 1; j < *dev_list[i].num; j++) 570 for (j = 1; j < *dev_list[i].num; j++)
571 device_create_drvdata(sound_class, NULL, 571 device_create(sound_class, NULL,
572 MKDEV(SOUND_MAJOR, 572 MKDEV(SOUND_MAJOR,
573 dev_list[i].minor + (j*0x10)), 573 dev_list[i].minor + (j*0x10)),
574 NULL, 574 NULL, "%s%d", dev_list[i].name, j);
575 "%s%d", dev_list[i].name, j);
576 } 575 }
577 576
578 if (sound_nblocks >= 1024) 577 if (sound_nblocks >= 1024)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0b6e682c46d0..e72707cb60a3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -822,6 +822,27 @@ static void alc_sku_automute(struct hda_codec *codec)
822 spec->jack_present ? 0 : PIN_OUT); 822 spec->jack_present ? 0 : PIN_OUT);
823} 823}
824 824
825static void alc_mic_automute(struct hda_codec *codec)
826{
827 struct alc_spec *spec = codec->spec;
828 unsigned int present;
829 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
830 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
831 unsigned int mix_nid = spec->capsrc_nids[0];
832 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
833
834 capsrc_idx_mic = mic_nid - 0x18;
835 capsrc_idx_fmic = fmic_nid - 0x18;
836 present = snd_hda_codec_read(codec, mic_nid, 0,
837 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
838 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
839 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
840 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
841 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
842 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
843 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
844}
845
825/* unsolicited event for HP jack sensing */ 846/* unsolicited event for HP jack sensing */
826static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 847static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
827{ 848{
@@ -829,10 +850,17 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
829 res >>= 28; 850 res >>= 28;
830 else 851 else
831 res >>= 26; 852 res >>= 26;
832 if (res != ALC880_HP_EVENT) 853 if (res == ALC880_HP_EVENT)
833 return; 854 alc_sku_automute(codec);
855
856 if (res == ALC880_MIC_EVENT)
857 alc_mic_automute(codec);
858}
834 859
860static void alc_inithook(struct hda_codec *codec)
861{
835 alc_sku_automute(codec); 862 alc_sku_automute(codec);
863 alc_mic_automute(codec);
836} 864}
837 865
838/* additional initialization for ALC888 variants */ 866/* additional initialization for ALC888 variants */
@@ -1018,10 +1046,17 @@ do_sku:
1018 else 1046 else
1019 return; 1047 return;
1020 } 1048 }
1049 if (spec->autocfg.hp_pins[0])
1050 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1051 AC_VERB_SET_UNSOLICITED_ENABLE,
1052 AC_USRSP_EN | ALC880_HP_EVENT);
1021 1053
1022 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, 1054 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1023 AC_VERB_SET_UNSOLICITED_ENABLE, 1055 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1024 AC_USRSP_EN | ALC880_HP_EVENT); 1056 snd_hda_codec_write(codec,
1057 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1058 AC_VERB_SET_UNSOLICITED_ENABLE,
1059 AC_USRSP_EN | ALC880_MIC_EVENT);
1025 1060
1026 spec->unsol_event = alc_sku_unsol_event; 1061 spec->unsol_event = alc_sku_unsol_event;
1027} 1062}
@@ -3808,7 +3843,7 @@ static void alc880_auto_init(struct hda_codec *codec)
3808 alc880_auto_init_extra_out(codec); 3843 alc880_auto_init_extra_out(codec);
3809 alc880_auto_init_analog_input(codec); 3844 alc880_auto_init_analog_input(codec);
3810 if (spec->unsol_event) 3845 if (spec->unsol_event)
3811 alc_sku_automute(codec); 3846 alc_inithook(codec);
3812} 3847}
3813 3848
3814/* 3849/*
@@ -5219,7 +5254,7 @@ static void alc260_auto_init(struct hda_codec *codec)
5219 alc260_auto_init_multi_out(codec); 5254 alc260_auto_init_multi_out(codec);
5220 alc260_auto_init_analog_input(codec); 5255 alc260_auto_init_analog_input(codec);
5221 if (spec->unsol_event) 5256 if (spec->unsol_event)
5222 alc_sku_automute(codec); 5257 alc_inithook(codec);
5223} 5258}
5224 5259
5225#ifdef CONFIG_SND_HDA_POWER_SAVE 5260#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -6629,7 +6664,7 @@ static void alc882_auto_init(struct hda_codec *codec)
6629 alc882_auto_init_analog_input(codec); 6664 alc882_auto_init_analog_input(codec);
6630 alc882_auto_init_input_src(codec); 6665 alc882_auto_init_input_src(codec);
6631 if (spec->unsol_event) 6666 if (spec->unsol_event)
6632 alc_sku_automute(codec); 6667 alc_inithook(codec);
6633} 6668}
6634 6669
6635static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ 6670static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
@@ -8306,8 +8341,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8306 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8341 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8307 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8342 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8308 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8343 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8344 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8309 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8345 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8310 SND_PCI_QUIRK(0x1043, 0x8317, "Asus M90V", ALC888_ASUS_M90V),
8311 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8346 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8312 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8347 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8313 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8348 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
@@ -8758,7 +8793,7 @@ static void alc883_auto_init(struct hda_codec *codec)
8758 alc883_auto_init_analog_input(codec); 8793 alc883_auto_init_analog_input(codec);
8759 alc883_auto_init_input_src(codec); 8794 alc883_auto_init_input_src(codec);
8760 if (spec->unsol_event) 8795 if (spec->unsol_event)
8761 alc_sku_automute(codec); 8796 alc_inithook(codec);
8762} 8797}
8763 8798
8764static int patch_alc883(struct hda_codec *codec) 8799static int patch_alc883(struct hda_codec *codec)
@@ -8802,8 +8837,13 @@ static int patch_alc883(struct hda_codec *codec)
8802 8837
8803 switch (codec->vendor_id) { 8838 switch (codec->vendor_id) {
8804 case 0x10ec0888: 8839 case 0x10ec0888:
8805 spec->stream_name_analog = "ALC888 Analog"; 8840 if (codec->revision_id == 0x100101) {
8806 spec->stream_name_digital = "ALC888 Digital"; 8841 spec->stream_name_analog = "ALC1200 Analog";
8842 spec->stream_name_digital = "ALC1200 Digital";
8843 } else {
8844 spec->stream_name_analog = "ALC888 Analog";
8845 spec->stream_name_digital = "ALC888 Digital";
8846 }
8807 break; 8847 break;
8808 case 0x10ec0889: 8848 case 0x10ec0889:
8809 spec->stream_name_analog = "ALC889 Analog"; 8849 spec->stream_name_analog = "ALC889 Analog";
@@ -10285,7 +10325,7 @@ static void alc262_auto_init(struct hda_codec *codec)
10285 alc262_auto_init_analog_input(codec); 10325 alc262_auto_init_analog_input(codec);
10286 alc262_auto_init_input_src(codec); 10326 alc262_auto_init_input_src(codec);
10287 if (spec->unsol_event) 10327 if (spec->unsol_event)
10288 alc_sku_automute(codec); 10328 alc_inithook(codec);
10289} 10329}
10290 10330
10291/* 10331/*
@@ -10343,7 +10383,7 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
10343 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 10383 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
10344 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 10384 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10345 ALC262_TOSHIBA_RX1), 10385 ALC262_TOSHIBA_RX1),
10346 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06), 10386 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
10347 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 10387 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
10348 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 10388 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
10349 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 10389 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
@@ -11417,7 +11457,7 @@ static void alc268_auto_init(struct hda_codec *codec)
11417 alc268_auto_init_mono_speaker_out(codec); 11457 alc268_auto_init_mono_speaker_out(codec);
11418 alc268_auto_init_analog_input(codec); 11458 alc268_auto_init_analog_input(codec);
11419 if (spec->unsol_event) 11459 if (spec->unsol_event)
11420 alc_sku_automute(codec); 11460 alc_inithook(codec);
11421} 11461}
11422 11462
11423/* 11463/*
@@ -12200,7 +12240,7 @@ static void alc269_auto_init(struct hda_codec *codec)
12200 alc269_auto_init_hp_out(codec); 12240 alc269_auto_init_hp_out(codec);
12201 alc269_auto_init_analog_input(codec); 12241 alc269_auto_init_analog_input(codec);
12202 if (spec->unsol_event) 12242 if (spec->unsol_event)
12203 alc_sku_automute(codec); 12243 alc_inithook(codec);
12204} 12244}
12205 12245
12206/* 12246/*
@@ -13281,7 +13321,7 @@ static void alc861_auto_init(struct hda_codec *codec)
13281 alc861_auto_init_hp_out(codec); 13321 alc861_auto_init_hp_out(codec);
13282 alc861_auto_init_analog_input(codec); 13322 alc861_auto_init_analog_input(codec);
13283 if (spec->unsol_event) 13323 if (spec->unsol_event)
13284 alc_sku_automute(codec); 13324 alc_inithook(codec);
13285} 13325}
13286 13326
13287#ifdef CONFIG_SND_HDA_POWER_SAVE 13327#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -14393,7 +14433,7 @@ static void alc861vd_auto_init(struct hda_codec *codec)
14393 alc861vd_auto_init_analog_input(codec); 14433 alc861vd_auto_init_analog_input(codec);
14394 alc861vd_auto_init_input_src(codec); 14434 alc861vd_auto_init_input_src(codec);
14395 if (spec->unsol_event) 14435 if (spec->unsol_event)
14396 alc_sku_automute(codec); 14436 alc_inithook(codec);
14397} 14437}
14398 14438
14399static int patch_alc861vd(struct hda_codec *codec) 14439static int patch_alc861vd(struct hda_codec *codec)
@@ -15667,7 +15707,7 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
15667 15707
15668static struct snd_pci_quirk alc662_cfg_tbl[] = { 15708static struct snd_pci_quirk alc662_cfg_tbl[] = {
15669 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), 15709 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
15670 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V), 15710 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
15671 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), 15711 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
15672 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 15712 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
15673 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), 15713 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
@@ -15680,6 +15720,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
15680 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), 15720 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15681 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), 15721 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15682 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), 15722 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
15723 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
15683 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), 15724 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15684 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), 15725 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15685 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), 15726 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
@@ -16223,7 +16264,7 @@ static void alc662_auto_init(struct hda_codec *codec)
16223 alc662_auto_init_analog_input(codec); 16264 alc662_auto_init_analog_input(codec);
16224 alc662_auto_init_input_src(codec); 16265 alc662_auto_init_input_src(codec);
16225 if (spec->unsol_event) 16266 if (spec->unsol_event)
16226 alc_sku_automute(codec); 16267 alc_inithook(codec);
16227} 16268}
16228 16269
16229static int patch_alc662(struct hda_codec *codec) 16270static int patch_alc662(struct hda_codec *codec)
@@ -16268,6 +16309,9 @@ static int patch_alc662(struct hda_codec *codec)
16268 if (codec->vendor_id == 0x10ec0663) { 16309 if (codec->vendor_id == 0x10ec0663) {
16269 spec->stream_name_analog = "ALC663 Analog"; 16310 spec->stream_name_analog = "ALC663 Analog";
16270 spec->stream_name_digital = "ALC663 Digital"; 16311 spec->stream_name_digital = "ALC663 Digital";
16312 } else if (codec->vendor_id == 0x10ec0272) {
16313 spec->stream_name_analog = "ALC272 Analog";
16314 spec->stream_name_digital = "ALC272 Digital";
16271 } else { 16315 } else {
16272 spec->stream_name_analog = "ALC662 Analog"; 16316 spec->stream_name_analog = "ALC662 Analog";
16273 spec->stream_name_digital = "ALC662 Digital"; 16317 spec->stream_name_digital = "ALC662 Digital";
@@ -16305,6 +16349,7 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
16305 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 16349 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
16306 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 16350 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
16307 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, 16351 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
16352 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
16308 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 16353 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
16309 .patch = patch_alc861 }, 16354 .patch = patch_alc861 },
16310 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 16355 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
@@ -16323,7 +16368,10 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
16323 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 16368 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
16324 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 16369 .patch = patch_alc882 }, /* should be patch_alc883() in future */
16325 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 16370 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
16371 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
16326 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 16372 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
16373 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16374 .patch = patch_alc883 },
16327 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 16375 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
16328 {} /* terminator */ 16376 {} /* terminator */
16329}; 16377};
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index c59065513118..a2ac7205d45d 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -2816,7 +2816,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2816 static const char *chname[4] = { 2816 static const char *chname[4] = {
2817 "Front", "Surround", NULL /*CLFE*/, "Side" 2817 "Front", "Surround", NULL /*CLFE*/, "Side"
2818 }; 2818 };
2819 hda_nid_t nid; 2819 hda_nid_t nid = 0;
2820 int i, err; 2820 int i, err;
2821 2821
2822 struct sigmatel_spec *spec = codec->spec; 2822 struct sigmatel_spec *spec = codec->spec;
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 4975d8573e4f..38a0e3b620a7 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -68,7 +68,7 @@ config SND_SOC_TLV320AIC23
68 depends on I2C 68 depends on I2C
69 69
70config SND_SOC_TLV320AIC26 70config SND_SOC_TLV320AIC26
71 tristate "TI TLV320AIC26 Codec support" 71 tristate "TI TLV320AIC26 Codec support" if SND_SOC_OF_SIMPLE
72 depends on SPI 72 depends on SPI
73 73
74config SND_SOC_TLV320AIC3X 74config SND_SOC_TLV320AIC3X
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index bac7815e00fb..44308dac9e18 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -84,7 +84,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg,
84 unsigned int value) 84 unsigned int value)
85{ 85{
86 86
87 u8 data; 87 u8 data[2];
88 88
89 /* TLV320AIC23 has 7 bit address and 9 bits of data 89 /* TLV320AIC23 has 7 bit address and 9 bits of data
90 * so we need to switch one data bit into reg and rest 90 * so we need to switch one data bit into reg and rest
@@ -96,12 +96,12 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg,
96 return -1; 96 return -1;
97 } 97 }
98 98
99 data = (reg << 1) | (value >> 8 & 0x01); 99 data[0] = (reg << 1) | (value >> 8 & 0x01);
100 data[1] = value & 0xff;
100 101
101 tlv320aic23_write_reg_cache(codec, reg, value); 102 tlv320aic23_write_reg_cache(codec, reg, value);
102 103
103 if (codec->hw_write(codec->control_data, data, 104 if (codec->hw_write(codec->control_data, data, 2) == 2)
104 (value & 0xff)) == 0)
105 return 0; 105 return 0;
106 106
107 printk(KERN_ERR "%s cannot write %03x to register R%d\n", __func__, 107 printk(KERN_ERR "%s cannot write %03x to register R%d\n", __func__,
@@ -674,7 +674,7 @@ static int tlv320aic23_probe(struct platform_device *pdev)
674 674
675 tlv320aic23_socdev = socdev; 675 tlv320aic23_socdev = socdev;
676#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 676#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
677 codec->hw_write = (hw_write_t) i2c_smbus_write_byte_data; 677 codec->hw_write = (hw_write_t) i2c_master_send;
678 codec->hw_read = NULL; 678 codec->hw_read = NULL;
679 ret = i2c_add_driver(&tlv320aic23_i2c_driver); 679 ret = i2c_add_driver(&tlv320aic23_i2c_driver);
680 if (ret != 0) 680 if (ret != 0)
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 4ae07e236b36..faef87a9bc3f 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -220,9 +220,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
220 else 220 else
221 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); 221 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
222 222
223 device_create_drvdata(sound_class, dev, 223 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
224 MKDEV(SOUND_MAJOR, s->unit_minor), 224 NULL, s->name+6);
225 NULL, s->name+6);
226 return r; 225 return r;
227 226
228 fail: 227 fail:
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index b441fe2cd190..c2515b680f9f 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -118,12 +118,11 @@ static int usb_stream_hwdep_vm_fault(struct vm_area_struct *area,
118 void *vaddr; 118 void *vaddr;
119 struct us122l *us122l = area->vm_private_data; 119 struct us122l *us122l = area->vm_private_data;
120 struct usb_stream *s; 120 struct usb_stream *s;
121 int vm_f = VM_FAULT_SIGBUS;
122 121
123 mutex_lock(&us122l->mutex); 122 mutex_lock(&us122l->mutex);
124 s = us122l->sk.s; 123 s = us122l->sk.s;
125 if (!s) 124 if (!s)
126 goto out; 125 goto unlock;
127 126
128 offset = vmf->pgoff << PAGE_SHIFT; 127 offset = vmf->pgoff << PAGE_SHIFT;
129 if (offset < PAGE_ALIGN(s->read_size)) 128 if (offset < PAGE_ALIGN(s->read_size))
@@ -131,7 +130,7 @@ static int usb_stream_hwdep_vm_fault(struct vm_area_struct *area,
131 else { 130 else {
132 offset -= PAGE_ALIGN(s->read_size); 131 offset -= PAGE_ALIGN(s->read_size);
133 if (offset >= PAGE_ALIGN(s->write_size)) 132 if (offset >= PAGE_ALIGN(s->write_size))
134 goto out; 133 goto unlock;
135 134
136 vaddr = us122l->sk.write_page + offset; 135 vaddr = us122l->sk.write_page + offset;
137 } 136 }
@@ -141,9 +140,11 @@ static int usb_stream_hwdep_vm_fault(struct vm_area_struct *area,
141 mutex_unlock(&us122l->mutex); 140 mutex_unlock(&us122l->mutex);
142 141
143 vmf->page = page; 142 vmf->page = page;
144 vm_f = 0; 143
145out: 144 return 0;
146 return vm_f; 145unlock:
146 mutex_unlock(&us122l->mutex);
147 return VM_FAULT_SIGBUS;
147} 148}
148 149
149static void usb_stream_hwdep_vm_close(struct vm_area_struct *area) 150static void usb_stream_hwdep_vm_close(struct vm_area_struct *area)
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index c0d22870ee9c..53772bb46320 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -39,6 +39,7 @@
39 39
40#include "ioapic.h" 40#include "ioapic.h"
41#include "lapic.h" 41#include "lapic.h"
42#include "irq.h"
42 43
43#if 0 44#if 0
44#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) 45#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
@@ -285,26 +286,31 @@ void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level)
285 } 286 }
286} 287}
287 288
288static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int gsi) 289static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int gsi,
290 int trigger_mode)
289{ 291{
290 union ioapic_redir_entry *ent; 292 union ioapic_redir_entry *ent;
291 293
292 ent = &ioapic->redirtbl[gsi]; 294 ent = &ioapic->redirtbl[gsi];
293 ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
294 295
295 ent->fields.remote_irr = 0; 296 kvm_notify_acked_irq(ioapic->kvm, gsi);
296 if (!ent->fields.mask && (ioapic->irr & (1 << gsi))) 297
297 ioapic_service(ioapic, gsi); 298 if (trigger_mode == IOAPIC_LEVEL_TRIG) {
299 ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
300 ent->fields.remote_irr = 0;
301 if (!ent->fields.mask && (ioapic->irr & (1 << gsi)))
302 ioapic_service(ioapic, gsi);
303 }
298} 304}
299 305
300void kvm_ioapic_update_eoi(struct kvm *kvm, int vector) 306void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode)
301{ 307{
302 struct kvm_ioapic *ioapic = kvm->arch.vioapic; 308 struct kvm_ioapic *ioapic = kvm->arch.vioapic;
303 int i; 309 int i;
304 310
305 for (i = 0; i < IOAPIC_NUM_PINS; i++) 311 for (i = 0; i < IOAPIC_NUM_PINS; i++)
306 if (ioapic->redirtbl[i].fields.vector == vector) 312 if (ioapic->redirtbl[i].fields.vector == vector)
307 __kvm_ioapic_update_eoi(ioapic, i); 313 __kvm_ioapic_update_eoi(ioapic, i, trigger_mode);
308} 314}
309 315
310static int ioapic_in_range(struct kvm_io_device *this, gpa_t addr, 316static int ioapic_in_range(struct kvm_io_device *this, gpa_t addr,
@@ -380,7 +386,7 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
380 break; 386 break;
381#ifdef CONFIG_IA64 387#ifdef CONFIG_IA64
382 case IOAPIC_REG_EOI: 388 case IOAPIC_REG_EOI:
383 kvm_ioapic_update_eoi(ioapic->kvm, data); 389 kvm_ioapic_update_eoi(ioapic->kvm, data, IOAPIC_LEVEL_TRIG);
384 break; 390 break;
385#endif 391#endif
386 392
diff --git a/virt/kvm/ioapic.h b/virt/kvm/ioapic.h
index 7f16675fe783..cd7ae7691c9d 100644
--- a/virt/kvm/ioapic.h
+++ b/virt/kvm/ioapic.h
@@ -58,6 +58,7 @@ struct kvm_ioapic {
58 } redirtbl[IOAPIC_NUM_PINS]; 58 } redirtbl[IOAPIC_NUM_PINS];
59 struct kvm_io_device dev; 59 struct kvm_io_device dev;
60 struct kvm *kvm; 60 struct kvm *kvm;
61 void (*ack_notifier)(void *opaque, int irq);
61}; 62};
62 63
63#ifdef DEBUG 64#ifdef DEBUG
@@ -78,16 +79,9 @@ static inline struct kvm_ioapic *ioapic_irqchip(struct kvm *kvm)
78 return kvm->arch.vioapic; 79 return kvm->arch.vioapic;
79} 80}
80 81
81#ifdef CONFIG_IA64
82static inline int irqchip_in_kernel(struct kvm *kvm)
83{
84 return 1;
85}
86#endif
87
88struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector, 82struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
89 unsigned long bitmap); 83 unsigned long bitmap);
90void kvm_ioapic_update_eoi(struct kvm *kvm, int vector); 84void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode);
91int kvm_ioapic_init(struct kvm *kvm); 85int kvm_ioapic_init(struct kvm *kvm);
92void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level); 86void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
93void kvm_ioapic_reset(struct kvm_ioapic *ioapic); 87void kvm_ioapic_reset(struct kvm_ioapic *ioapic);
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
new file mode 100644
index 000000000000..d0169f5e6047
--- /dev/null
+++ b/virt/kvm/irq_comm.c
@@ -0,0 +1,60 @@
1/*
2 * irq_comm.c: Common API for in kernel interrupt controller
3 * Copyright (c) 2007, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as 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 for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 * Authors:
18 * Yaozu (Eddie) Dong <Eddie.dong@intel.com>
19 *
20 */
21
22#include <linux/kvm_host.h>
23#include "irq.h"
24
25#include "ioapic.h"
26
27/* This should be called with the kvm->lock mutex held */
28void kvm_set_irq(struct kvm *kvm, int irq, int level)
29{
30 /* Not possible to detect if the guest uses the PIC or the
31 * IOAPIC. So set the bit in both. The guest will ignore
32 * writes to the unused one.
33 */
34 kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
35#ifdef CONFIG_X86
36 kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
37#endif
38}
39
40void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
41{
42 struct kvm_irq_ack_notifier *kian;
43 struct hlist_node *n;
44
45 hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link)
46 if (kian->gsi == gsi)
47 kian->irq_acked(kian);
48}
49
50void kvm_register_irq_ack_notifier(struct kvm *kvm,
51 struct kvm_irq_ack_notifier *kian)
52{
53 hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
54}
55
56void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
57 struct kvm_irq_ack_notifier *kian)
58{
59 hlist_del(&kian->link);
60}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7dd9b0b85e4e..cf0ab8ed3845 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -51,6 +51,12 @@
51#include "coalesced_mmio.h" 51#include "coalesced_mmio.h"
52#endif 52#endif
53 53
54#ifdef KVM_CAP_DEVICE_ASSIGNMENT
55#include <linux/pci.h>
56#include <linux/interrupt.h>
57#include "irq.h"
58#endif
59
54MODULE_AUTHOR("Qumranet"); 60MODULE_AUTHOR("Qumranet");
55MODULE_LICENSE("GPL"); 61MODULE_LICENSE("GPL");
56 62
@@ -71,11 +77,253 @@ static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
71 77
72bool kvm_rebooting; 78bool kvm_rebooting;
73 79
80#ifdef KVM_CAP_DEVICE_ASSIGNMENT
81static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head,
82 int assigned_dev_id)
83{
84 struct list_head *ptr;
85 struct kvm_assigned_dev_kernel *match;
86
87 list_for_each(ptr, head) {
88 match = list_entry(ptr, struct kvm_assigned_dev_kernel, list);
89 if (match->assigned_dev_id == assigned_dev_id)
90 return match;
91 }
92 return NULL;
93}
94
95static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
96{
97 struct kvm_assigned_dev_kernel *assigned_dev;
98
99 assigned_dev = container_of(work, struct kvm_assigned_dev_kernel,
100 interrupt_work);
101
102 /* This is taken to safely inject irq inside the guest. When
103 * the interrupt injection (or the ioapic code) uses a
104 * finer-grained lock, update this
105 */
106 mutex_lock(&assigned_dev->kvm->lock);
107 kvm_set_irq(assigned_dev->kvm,
108 assigned_dev->guest_irq, 1);
109 mutex_unlock(&assigned_dev->kvm->lock);
110 kvm_put_kvm(assigned_dev->kvm);
111}
112
113/* FIXME: Implement the OR logic needed to make shared interrupts on
114 * this line behave properly
115 */
116static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id)
117{
118 struct kvm_assigned_dev_kernel *assigned_dev =
119 (struct kvm_assigned_dev_kernel *) dev_id;
120
121 kvm_get_kvm(assigned_dev->kvm);
122 schedule_work(&assigned_dev->interrupt_work);
123 disable_irq_nosync(irq);
124 return IRQ_HANDLED;
125}
126
127/* Ack the irq line for an assigned device */
128static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
129{
130 struct kvm_assigned_dev_kernel *dev;
131
132 if (kian->gsi == -1)
133 return;
134
135 dev = container_of(kian, struct kvm_assigned_dev_kernel,
136 ack_notifier);
137 kvm_set_irq(dev->kvm, dev->guest_irq, 0);
138 enable_irq(dev->host_irq);
139}
140
141static void kvm_free_assigned_device(struct kvm *kvm,
142 struct kvm_assigned_dev_kernel
143 *assigned_dev)
144{
145 if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested)
146 free_irq(assigned_dev->host_irq, (void *)assigned_dev);
147
148 kvm_unregister_irq_ack_notifier(kvm, &assigned_dev->ack_notifier);
149
150 if (cancel_work_sync(&assigned_dev->interrupt_work))
151 /* We had pending work. That means we will have to take
152 * care of kvm_put_kvm.
153 */
154 kvm_put_kvm(kvm);
155
156 pci_release_regions(assigned_dev->dev);
157 pci_disable_device(assigned_dev->dev);
158 pci_dev_put(assigned_dev->dev);
159
160 list_del(&assigned_dev->list);
161 kfree(assigned_dev);
162}
163
164void kvm_free_all_assigned_devices(struct kvm *kvm)
165{
166 struct list_head *ptr, *ptr2;
167 struct kvm_assigned_dev_kernel *assigned_dev;
168
169 list_for_each_safe(ptr, ptr2, &kvm->arch.assigned_dev_head) {
170 assigned_dev = list_entry(ptr,
171 struct kvm_assigned_dev_kernel,
172 list);
173
174 kvm_free_assigned_device(kvm, assigned_dev);
175 }
176}
177
178static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
179 struct kvm_assigned_irq
180 *assigned_irq)
181{
182 int r = 0;
183 struct kvm_assigned_dev_kernel *match;
184
185 mutex_lock(&kvm->lock);
186
187 match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head,
188 assigned_irq->assigned_dev_id);
189 if (!match) {
190 mutex_unlock(&kvm->lock);
191 return -EINVAL;
192 }
193
194 if (match->irq_requested) {
195 match->guest_irq = assigned_irq->guest_irq;
196 match->ack_notifier.gsi = assigned_irq->guest_irq;
197 mutex_unlock(&kvm->lock);
198 return 0;
199 }
200
201 INIT_WORK(&match->interrupt_work,
202 kvm_assigned_dev_interrupt_work_handler);
203
204 if (irqchip_in_kernel(kvm)) {
205 if (!capable(CAP_SYS_RAWIO)) {
206 r = -EPERM;
207 goto out_release;
208 }
209
210 if (assigned_irq->host_irq)
211 match->host_irq = assigned_irq->host_irq;
212 else
213 match->host_irq = match->dev->irq;
214 match->guest_irq = assigned_irq->guest_irq;
215 match->ack_notifier.gsi = assigned_irq->guest_irq;
216 match->ack_notifier.irq_acked = kvm_assigned_dev_ack_irq;
217 kvm_register_irq_ack_notifier(kvm, &match->ack_notifier);
218
219 /* Even though this is PCI, we don't want to use shared
220 * interrupts. Sharing host devices with guest-assigned devices
221 * on the same interrupt line is not a happy situation: there
222 * are going to be long delays in accepting, acking, etc.
223 */
224 if (request_irq(match->host_irq, kvm_assigned_dev_intr, 0,
225 "kvm_assigned_device", (void *)match)) {
226 r = -EIO;
227 goto out_release;
228 }
229 }
230
231 match->irq_requested = true;
232 mutex_unlock(&kvm->lock);
233 return r;
234out_release:
235 mutex_unlock(&kvm->lock);
236 kvm_free_assigned_device(kvm, match);
237 return r;
238}
239
240static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
241 struct kvm_assigned_pci_dev *assigned_dev)
242{
243 int r = 0;
244 struct kvm_assigned_dev_kernel *match;
245 struct pci_dev *dev;
246
247 mutex_lock(&kvm->lock);
248
249 match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head,
250 assigned_dev->assigned_dev_id);
251 if (match) {
252 /* device already assigned */
253 r = -EINVAL;
254 goto out;
255 }
256
257 match = kzalloc(sizeof(struct kvm_assigned_dev_kernel), GFP_KERNEL);
258 if (match == NULL) {
259 printk(KERN_INFO "%s: Couldn't allocate memory\n",
260 __func__);
261 r = -ENOMEM;
262 goto out;
263 }
264 dev = pci_get_bus_and_slot(assigned_dev->busnr,
265 assigned_dev->devfn);
266 if (!dev) {
267 printk(KERN_INFO "%s: host device not found\n", __func__);
268 r = -EINVAL;
269 goto out_free;
270 }
271 if (pci_enable_device(dev)) {
272 printk(KERN_INFO "%s: Could not enable PCI device\n", __func__);
273 r = -EBUSY;
274 goto out_put;
275 }
276 r = pci_request_regions(dev, "kvm_assigned_device");
277 if (r) {
278 printk(KERN_INFO "%s: Could not get access to device regions\n",
279 __func__);
280 goto out_disable;
281 }
282 match->assigned_dev_id = assigned_dev->assigned_dev_id;
283 match->host_busnr = assigned_dev->busnr;
284 match->host_devfn = assigned_dev->devfn;
285 match->dev = dev;
286
287 match->kvm = kvm;
288
289 list_add(&match->list, &kvm->arch.assigned_dev_head);
290
291 if (assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU) {
292 r = kvm_iommu_map_guest(kvm, match);
293 if (r)
294 goto out_list_del;
295 }
296
297out:
298 mutex_unlock(&kvm->lock);
299 return r;
300out_list_del:
301 list_del(&match->list);
302 pci_release_regions(dev);
303out_disable:
304 pci_disable_device(dev);
305out_put:
306 pci_dev_put(dev);
307out_free:
308 kfree(match);
309 mutex_unlock(&kvm->lock);
310 return r;
311}
312#endif
313
74static inline int valid_vcpu(int n) 314static inline int valid_vcpu(int n)
75{ 315{
76 return likely(n >= 0 && n < KVM_MAX_VCPUS); 316 return likely(n >= 0 && n < KVM_MAX_VCPUS);
77} 317}
78 318
319inline int kvm_is_mmio_pfn(pfn_t pfn)
320{
321 if (pfn_valid(pfn))
322 return PageReserved(pfn_to_page(pfn));
323
324 return true;
325}
326
79/* 327/*
80 * Switches to specified vcpu, until a matching vcpu_put() 328 * Switches to specified vcpu, until a matching vcpu_put()
81 */ 329 */
@@ -570,6 +818,12 @@ int __kvm_set_memory_region(struct kvm *kvm,
570 } 818 }
571 819
572 kvm_free_physmem_slot(&old, &new); 820 kvm_free_physmem_slot(&old, &new);
821#ifdef CONFIG_DMAR
822 /* map the pages in iommu page table */
823 r = kvm_iommu_map_pages(kvm, base_gfn, npages);
824 if (r)
825 goto out;
826#endif
573 return 0; 827 return 0;
574 828
575out_free: 829out_free:
@@ -708,9 +962,6 @@ unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn)
708} 962}
709EXPORT_SYMBOL_GPL(gfn_to_hva); 963EXPORT_SYMBOL_GPL(gfn_to_hva);
710 964
711/*
712 * Requires current->mm->mmap_sem to be held
713 */
714pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn) 965pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn)
715{ 966{
716 struct page *page[1]; 967 struct page *page[1];
@@ -726,21 +977,24 @@ pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn)
726 return page_to_pfn(bad_page); 977 return page_to_pfn(bad_page);
727 } 978 }
728 979
729 npages = get_user_pages(current, current->mm, addr, 1, 1, 1, page, 980 npages = get_user_pages_fast(addr, 1, 1, page);
730 NULL);
731 981
732 if (unlikely(npages != 1)) { 982 if (unlikely(npages != 1)) {
733 struct vm_area_struct *vma; 983 struct vm_area_struct *vma;
734 984
985 down_read(&current->mm->mmap_sem);
735 vma = find_vma(current->mm, addr); 986 vma = find_vma(current->mm, addr);
987
736 if (vma == NULL || addr < vma->vm_start || 988 if (vma == NULL || addr < vma->vm_start ||
737 !(vma->vm_flags & VM_PFNMAP)) { 989 !(vma->vm_flags & VM_PFNMAP)) {
990 up_read(&current->mm->mmap_sem);
738 get_page(bad_page); 991 get_page(bad_page);
739 return page_to_pfn(bad_page); 992 return page_to_pfn(bad_page);
740 } 993 }
741 994
742 pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; 995 pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
743 BUG_ON(pfn_valid(pfn)); 996 up_read(&current->mm->mmap_sem);
997 BUG_ON(!kvm_is_mmio_pfn(pfn));
744 } else 998 } else
745 pfn = page_to_pfn(page[0]); 999 pfn = page_to_pfn(page[0]);
746 1000
@@ -754,10 +1008,10 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn)
754 pfn_t pfn; 1008 pfn_t pfn;
755 1009
756 pfn = gfn_to_pfn(kvm, gfn); 1010 pfn = gfn_to_pfn(kvm, gfn);
757 if (pfn_valid(pfn)) 1011 if (!kvm_is_mmio_pfn(pfn))
758 return pfn_to_page(pfn); 1012 return pfn_to_page(pfn);
759 1013
760 WARN_ON(!pfn_valid(pfn)); 1014 WARN_ON(kvm_is_mmio_pfn(pfn));
761 1015
762 get_page(bad_page); 1016 get_page(bad_page);
763 return bad_page; 1017 return bad_page;
@@ -773,7 +1027,7 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean);
773 1027
774void kvm_release_pfn_clean(pfn_t pfn) 1028void kvm_release_pfn_clean(pfn_t pfn)
775{ 1029{
776 if (pfn_valid(pfn)) 1030 if (!kvm_is_mmio_pfn(pfn))
777 put_page(pfn_to_page(pfn)); 1031 put_page(pfn_to_page(pfn));
778} 1032}
779EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); 1033EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);
@@ -799,7 +1053,7 @@ EXPORT_SYMBOL_GPL(kvm_set_page_dirty);
799 1053
800void kvm_set_pfn_dirty(pfn_t pfn) 1054void kvm_set_pfn_dirty(pfn_t pfn)
801{ 1055{
802 if (pfn_valid(pfn)) { 1056 if (!kvm_is_mmio_pfn(pfn)) {
803 struct page *page = pfn_to_page(pfn); 1057 struct page *page = pfn_to_page(pfn);
804 if (!PageReserved(page)) 1058 if (!PageReserved(page))
805 SetPageDirty(page); 1059 SetPageDirty(page);
@@ -809,14 +1063,14 @@ EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty);
809 1063
810void kvm_set_pfn_accessed(pfn_t pfn) 1064void kvm_set_pfn_accessed(pfn_t pfn)
811{ 1065{
812 if (pfn_valid(pfn)) 1066 if (!kvm_is_mmio_pfn(pfn))
813 mark_page_accessed(pfn_to_page(pfn)); 1067 mark_page_accessed(pfn_to_page(pfn));
814} 1068}
815EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed); 1069EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed);
816 1070
817void kvm_get_pfn(pfn_t pfn) 1071void kvm_get_pfn(pfn_t pfn)
818{ 1072{
819 if (pfn_valid(pfn)) 1073 if (!kvm_is_mmio_pfn(pfn))
820 get_page(pfn_to_page(pfn)); 1074 get_page(pfn_to_page(pfn));
821} 1075}
822EXPORT_SYMBOL_GPL(kvm_get_pfn); 1076EXPORT_SYMBOL_GPL(kvm_get_pfn);
@@ -972,12 +1226,12 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
972 for (;;) { 1226 for (;;) {
973 prepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE); 1227 prepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE);
974 1228
975 if (kvm_cpu_has_interrupt(vcpu)) 1229 if (kvm_cpu_has_interrupt(vcpu) ||
976 break; 1230 kvm_cpu_has_pending_timer(vcpu) ||
977 if (kvm_cpu_has_pending_timer(vcpu)) 1231 kvm_arch_vcpu_runnable(vcpu)) {
978 break; 1232 set_bit(KVM_REQ_UNHALT, &vcpu->requests);
979 if (kvm_arch_vcpu_runnable(vcpu))
980 break; 1233 break;
1234 }
981 if (signal_pending(current)) 1235 if (signal_pending(current))
982 break; 1236 break;
983 1237
@@ -1074,12 +1328,11 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
1074 1328
1075 r = kvm_arch_vcpu_setup(vcpu); 1329 r = kvm_arch_vcpu_setup(vcpu);
1076 if (r) 1330 if (r)
1077 goto vcpu_destroy; 1331 return r;
1078 1332
1079 mutex_lock(&kvm->lock); 1333 mutex_lock(&kvm->lock);
1080 if (kvm->vcpus[n]) { 1334 if (kvm->vcpus[n]) {
1081 r = -EEXIST; 1335 r = -EEXIST;
1082 mutex_unlock(&kvm->lock);
1083 goto vcpu_destroy; 1336 goto vcpu_destroy;
1084 } 1337 }
1085 kvm->vcpus[n] = vcpu; 1338 kvm->vcpus[n] = vcpu;
@@ -1095,8 +1348,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
1095unlink: 1348unlink:
1096 mutex_lock(&kvm->lock); 1349 mutex_lock(&kvm->lock);
1097 kvm->vcpus[n] = NULL; 1350 kvm->vcpus[n] = NULL;
1098 mutex_unlock(&kvm->lock);
1099vcpu_destroy: 1351vcpu_destroy:
1352 mutex_unlock(&kvm->lock);
1100 kvm_arch_vcpu_destroy(vcpu); 1353 kvm_arch_vcpu_destroy(vcpu);
1101 return r; 1354 return r;
1102} 1355}
@@ -1118,6 +1371,8 @@ static long kvm_vcpu_ioctl(struct file *filp,
1118 struct kvm_vcpu *vcpu = filp->private_data; 1371 struct kvm_vcpu *vcpu = filp->private_data;
1119 void __user *argp = (void __user *)arg; 1372 void __user *argp = (void __user *)arg;
1120 int r; 1373 int r;
1374 struct kvm_fpu *fpu = NULL;
1375 struct kvm_sregs *kvm_sregs = NULL;
1121 1376
1122 if (vcpu->kvm->mm != current->mm) 1377 if (vcpu->kvm->mm != current->mm)
1123 return -EIO; 1378 return -EIO;
@@ -1165,25 +1420,28 @@ out_free2:
1165 break; 1420 break;
1166 } 1421 }
1167 case KVM_GET_SREGS: { 1422 case KVM_GET_SREGS: {
1168 struct kvm_sregs kvm_sregs; 1423 kvm_sregs = kzalloc(sizeof(struct kvm_sregs), GFP_KERNEL);
1169 1424 r = -ENOMEM;
1170 memset(&kvm_sregs, 0, sizeof kvm_sregs); 1425 if (!kvm_sregs)
1171 r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, &kvm_sregs); 1426 goto out;
1427 r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, kvm_sregs);
1172 if (r) 1428 if (r)
1173 goto out; 1429 goto out;
1174 r = -EFAULT; 1430 r = -EFAULT;
1175 if (copy_to_user(argp, &kvm_sregs, sizeof kvm_sregs)) 1431 if (copy_to_user(argp, kvm_sregs, sizeof(struct kvm_sregs)))
1176 goto out; 1432 goto out;
1177 r = 0; 1433 r = 0;
1178 break; 1434 break;
1179 } 1435 }
1180 case KVM_SET_SREGS: { 1436 case KVM_SET_SREGS: {
1181 struct kvm_sregs kvm_sregs; 1437 kvm_sregs = kmalloc(sizeof(struct kvm_sregs), GFP_KERNEL);
1182 1438 r = -ENOMEM;
1439 if (!kvm_sregs)
1440 goto out;
1183 r = -EFAULT; 1441 r = -EFAULT;
1184 if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs)) 1442 if (copy_from_user(kvm_sregs, argp, sizeof(struct kvm_sregs)))
1185 goto out; 1443 goto out;
1186 r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, &kvm_sregs); 1444 r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs);
1187 if (r) 1445 if (r)
1188 goto out; 1446 goto out;
1189 r = 0; 1447 r = 0;
@@ -1264,25 +1522,28 @@ out_free2:
1264 break; 1522 break;
1265 } 1523 }
1266 case KVM_GET_FPU: { 1524 case KVM_GET_FPU: {
1267 struct kvm_fpu fpu; 1525 fpu = kzalloc(sizeof(struct kvm_fpu), GFP_KERNEL);
1268 1526 r = -ENOMEM;
1269 memset(&fpu, 0, sizeof fpu); 1527 if (!fpu)
1270 r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, &fpu); 1528 goto out;
1529 r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, fpu);
1271 if (r) 1530 if (r)
1272 goto out; 1531 goto out;
1273 r = -EFAULT; 1532 r = -EFAULT;
1274 if (copy_to_user(argp, &fpu, sizeof fpu)) 1533 if (copy_to_user(argp, fpu, sizeof(struct kvm_fpu)))
1275 goto out; 1534 goto out;
1276 r = 0; 1535 r = 0;
1277 break; 1536 break;
1278 } 1537 }
1279 case KVM_SET_FPU: { 1538 case KVM_SET_FPU: {
1280 struct kvm_fpu fpu; 1539 fpu = kmalloc(sizeof(struct kvm_fpu), GFP_KERNEL);
1281 1540 r = -ENOMEM;
1541 if (!fpu)
1542 goto out;
1282 r = -EFAULT; 1543 r = -EFAULT;
1283 if (copy_from_user(&fpu, argp, sizeof fpu)) 1544 if (copy_from_user(fpu, argp, sizeof(struct kvm_fpu)))
1284 goto out; 1545 goto out;
1285 r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, &fpu); 1546 r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu);
1286 if (r) 1547 if (r)
1287 goto out; 1548 goto out;
1288 r = 0; 1549 r = 0;
@@ -1292,6 +1553,8 @@ out_free2:
1292 r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); 1553 r = kvm_arch_vcpu_ioctl(filp, ioctl, arg);
1293 } 1554 }
1294out: 1555out:
1556 kfree(fpu);
1557 kfree(kvm_sregs);
1295 return r; 1558 return r;
1296} 1559}
1297 1560
@@ -1360,6 +1623,30 @@ static long kvm_vm_ioctl(struct file *filp,
1360 break; 1623 break;
1361 } 1624 }
1362#endif 1625#endif
1626#ifdef KVM_CAP_DEVICE_ASSIGNMENT
1627 case KVM_ASSIGN_PCI_DEVICE: {
1628 struct kvm_assigned_pci_dev assigned_dev;
1629
1630 r = -EFAULT;
1631 if (copy_from_user(&assigned_dev, argp, sizeof assigned_dev))
1632 goto out;
1633 r = kvm_vm_ioctl_assign_device(kvm, &assigned_dev);
1634 if (r)
1635 goto out;
1636 break;
1637 }
1638 case KVM_ASSIGN_IRQ: {
1639 struct kvm_assigned_irq assigned_irq;
1640
1641 r = -EFAULT;
1642 if (copy_from_user(&assigned_irq, argp, sizeof assigned_irq))
1643 goto out;
1644 r = kvm_vm_ioctl_assign_irq(kvm, &assigned_irq);
1645 if (r)
1646 goto out;
1647 break;
1648 }
1649#endif
1363 default: 1650 default:
1364 r = kvm_arch_vm_ioctl(filp, ioctl, arg); 1651 r = kvm_arch_vm_ioctl(filp, ioctl, arg);
1365 } 1652 }
@@ -1369,17 +1656,22 @@ out:
1369 1656
1370static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 1657static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1371{ 1658{
1659 struct page *page[1];
1660 unsigned long addr;
1661 int npages;
1662 gfn_t gfn = vmf->pgoff;
1372 struct kvm *kvm = vma->vm_file->private_data; 1663 struct kvm *kvm = vma->vm_file->private_data;
1373 struct page *page;
1374 1664
1375 if (!kvm_is_visible_gfn(kvm, vmf->pgoff)) 1665 addr = gfn_to_hva(kvm, gfn);
1666 if (kvm_is_error_hva(addr))
1376 return VM_FAULT_SIGBUS; 1667 return VM_FAULT_SIGBUS;
1377 page = gfn_to_page(kvm, vmf->pgoff); 1668
1378 if (is_error_page(page)) { 1669 npages = get_user_pages(current, current->mm, addr, 1, 1, 0, page,
1379 kvm_release_page_clean(page); 1670 NULL);
1671 if (unlikely(npages != 1))
1380 return VM_FAULT_SIGBUS; 1672 return VM_FAULT_SIGBUS;
1381 } 1673
1382 vmf->page = page; 1674 vmf->page = page[0];
1383 return 0; 1675 return 0;
1384} 1676}
1385 1677
diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
index 58141f31ea8f..41dcc845f78c 100644
--- a/virt/kvm/kvm_trace.c
+++ b/virt/kvm/kvm_trace.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/relay.h> 18#include <linux/relay.h>
19#include <linux/debugfs.h> 19#include <linux/debugfs.h>
20#include <linux/ktime.h>
20 21
21#include <linux/kvm_host.h> 22#include <linux/kvm_host.h>
22 23
@@ -35,16 +36,16 @@ static struct kvm_trace *kvm_trace;
35struct kvm_trace_probe { 36struct kvm_trace_probe {
36 const char *name; 37 const char *name;
37 const char *format; 38 const char *format;
38 u32 cycle_in; 39 u32 timestamp_in;
39 marker_probe_func *probe_func; 40 marker_probe_func *probe_func;
40}; 41};
41 42
42static inline int calc_rec_size(int cycle, int extra) 43static inline int calc_rec_size(int timestamp, int extra)
43{ 44{
44 int rec_size = KVM_TRC_HEAD_SIZE; 45 int rec_size = KVM_TRC_HEAD_SIZE;
45 46
46 rec_size += extra; 47 rec_size += extra;
47 return cycle ? rec_size += KVM_TRC_CYCLE_SIZE : rec_size; 48 return timestamp ? rec_size += KVM_TRC_CYCLE_SIZE : rec_size;
48} 49}
49 50
50static void kvm_add_trace(void *probe_private, void *call_data, 51static void kvm_add_trace(void *probe_private, void *call_data,
@@ -54,12 +55,13 @@ static void kvm_add_trace(void *probe_private, void *call_data,
54 struct kvm_trace *kt = kvm_trace; 55 struct kvm_trace *kt = kvm_trace;
55 struct kvm_trace_rec rec; 56 struct kvm_trace_rec rec;
56 struct kvm_vcpu *vcpu; 57 struct kvm_vcpu *vcpu;
57 int i, extra, size; 58 int i, size;
59 u32 extra;
58 60
59 if (unlikely(kt->trace_state != KVM_TRACE_STATE_RUNNING)) 61 if (unlikely(kt->trace_state != KVM_TRACE_STATE_RUNNING))
60 return; 62 return;
61 63
62 rec.event = va_arg(*args, u32); 64 rec.rec_val = TRACE_REC_EVENT_ID(va_arg(*args, u32));
63 vcpu = va_arg(*args, struct kvm_vcpu *); 65 vcpu = va_arg(*args, struct kvm_vcpu *);
64 rec.pid = current->tgid; 66 rec.pid = current->tgid;
65 rec.vcpu_id = vcpu->vcpu_id; 67 rec.vcpu_id = vcpu->vcpu_id;
@@ -67,21 +69,21 @@ static void kvm_add_trace(void *probe_private, void *call_data,
67 extra = va_arg(*args, u32); 69 extra = va_arg(*args, u32);
68 WARN_ON(!(extra <= KVM_TRC_EXTRA_MAX)); 70 WARN_ON(!(extra <= KVM_TRC_EXTRA_MAX));
69 extra = min_t(u32, extra, KVM_TRC_EXTRA_MAX); 71 extra = min_t(u32, extra, KVM_TRC_EXTRA_MAX);
70 rec.extra_u32 = extra;
71 72
72 rec.cycle_in = p->cycle_in; 73 rec.rec_val |= TRACE_REC_TCS(p->timestamp_in)
74 | TRACE_REC_NUM_DATA_ARGS(extra);
73 75
74 if (rec.cycle_in) { 76 if (p->timestamp_in) {
75 rec.u.cycle.cycle_u64 = get_cycles(); 77 rec.u.timestamp.timestamp = ktime_to_ns(ktime_get());
76 78
77 for (i = 0; i < rec.extra_u32; i++) 79 for (i = 0; i < extra; i++)
78 rec.u.cycle.extra_u32[i] = va_arg(*args, u32); 80 rec.u.timestamp.extra_u32[i] = va_arg(*args, u32);
79 } else { 81 } else {
80 for (i = 0; i < rec.extra_u32; i++) 82 for (i = 0; i < extra; i++)
81 rec.u.nocycle.extra_u32[i] = va_arg(*args, u32); 83 rec.u.notimestamp.extra_u32[i] = va_arg(*args, u32);
82 } 84 }
83 85
84 size = calc_rec_size(rec.cycle_in, rec.extra_u32 * sizeof(u32)); 86 size = calc_rec_size(p->timestamp_in, extra * sizeof(u32));
85 relay_write(kt->rchan, &rec, size); 87 relay_write(kt->rchan, &rec, size);
86} 88}
87 89
diff --git a/virt/kvm/vtd.c b/virt/kvm/vtd.c
new file mode 100644
index 000000000000..a770874f3a3a
--- /dev/null
+++ b/virt/kvm/vtd.c
@@ -0,0 +1,191 @@
1/*
2 * Copyright (c) 2006, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as 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 for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Copyright (C) 2006-2008 Intel Corporation
18 * Copyright IBM Corporation, 2008
19 * Author: Allen M. Kay <allen.m.kay@intel.com>
20 * Author: Weidong Han <weidong.han@intel.com>
21 * Author: Ben-Ami Yassour <benami@il.ibm.com>
22 */
23
24#include <linux/list.h>
25#include <linux/kvm_host.h>
26#include <linux/pci.h>
27#include <linux/dmar.h>
28#include <linux/intel-iommu.h>
29
30static int kvm_iommu_unmap_memslots(struct kvm *kvm);
31static void kvm_iommu_put_pages(struct kvm *kvm,
32 gfn_t base_gfn, unsigned long npages);
33
34int kvm_iommu_map_pages(struct kvm *kvm,
35 gfn_t base_gfn, unsigned long npages)
36{
37 gfn_t gfn = base_gfn;
38 pfn_t pfn;
39 int i, r = 0;
40 struct dmar_domain *domain = kvm->arch.intel_iommu_domain;
41
42 /* check if iommu exists and in use */
43 if (!domain)
44 return 0;
45
46 for (i = 0; i < npages; i++) {
47 /* check if already mapped */
48 pfn = (pfn_t)intel_iommu_iova_to_pfn(domain,
49 gfn_to_gpa(gfn));
50 if (pfn)
51 continue;
52
53 pfn = gfn_to_pfn(kvm, gfn);
54 r = intel_iommu_page_mapping(domain,
55 gfn_to_gpa(gfn),
56 pfn_to_hpa(pfn),
57 PAGE_SIZE,
58 DMA_PTE_READ |
59 DMA_PTE_WRITE);
60 if (r) {
61 printk(KERN_ERR "kvm_iommu_map_pages:"
62 "iommu failed to map pfn=%lx\n", pfn);
63 goto unmap_pages;
64 }
65 gfn++;
66 }
67 return 0;
68
69unmap_pages:
70 kvm_iommu_put_pages(kvm, base_gfn, i);
71 return r;
72}
73
74static int kvm_iommu_map_memslots(struct kvm *kvm)
75{
76 int i, r;
77
78 down_read(&kvm->slots_lock);
79 for (i = 0; i < kvm->nmemslots; i++) {
80 r = kvm_iommu_map_pages(kvm, kvm->memslots[i].base_gfn,
81 kvm->memslots[i].npages);
82 if (r)
83 break;
84 }
85 up_read(&kvm->slots_lock);
86 return r;
87}
88
89int kvm_iommu_map_guest(struct kvm *kvm,
90 struct kvm_assigned_dev_kernel *assigned_dev)
91{
92 struct pci_dev *pdev = NULL;
93 int r;
94
95 if (!intel_iommu_found()) {
96 printk(KERN_ERR "%s: intel iommu not found\n", __func__);
97 return -ENODEV;
98 }
99
100 printk(KERN_DEBUG "VT-d direct map: host bdf = %x:%x:%x\n",
101 assigned_dev->host_busnr,
102 PCI_SLOT(assigned_dev->host_devfn),
103 PCI_FUNC(assigned_dev->host_devfn));
104
105 pdev = assigned_dev->dev;
106
107 if (pdev == NULL) {
108 if (kvm->arch.intel_iommu_domain) {
109 intel_iommu_domain_exit(kvm->arch.intel_iommu_domain);
110 kvm->arch.intel_iommu_domain = NULL;
111 }
112 return -ENODEV;
113 }
114
115 kvm->arch.intel_iommu_domain = intel_iommu_domain_alloc(pdev);
116 if (!kvm->arch.intel_iommu_domain)
117 return -ENODEV;
118
119 r = kvm_iommu_map_memslots(kvm);
120 if (r)
121 goto out_unmap;
122
123 intel_iommu_detach_dev(kvm->arch.intel_iommu_domain,
124 pdev->bus->number, pdev->devfn);
125
126 r = intel_iommu_context_mapping(kvm->arch.intel_iommu_domain,
127 pdev);
128 if (r) {
129 printk(KERN_ERR "Domain context map for %s failed",
130 pci_name(pdev));
131 goto out_unmap;
132 }
133 return 0;
134
135out_unmap:
136 kvm_iommu_unmap_memslots(kvm);
137 return r;
138}
139
140static void kvm_iommu_put_pages(struct kvm *kvm,
141 gfn_t base_gfn, unsigned long npages)
142{
143 gfn_t gfn = base_gfn;
144 pfn_t pfn;
145 struct dmar_domain *domain = kvm->arch.intel_iommu_domain;
146 int i;
147
148 for (i = 0; i < npages; i++) {
149 pfn = (pfn_t)intel_iommu_iova_to_pfn(domain,
150 gfn_to_gpa(gfn));
151 kvm_release_pfn_clean(pfn);
152 gfn++;
153 }
154}
155
156static int kvm_iommu_unmap_memslots(struct kvm *kvm)
157{
158 int i;
159 down_read(&kvm->slots_lock);
160 for (i = 0; i < kvm->nmemslots; i++) {
161 kvm_iommu_put_pages(kvm, kvm->memslots[i].base_gfn,
162 kvm->memslots[i].npages);
163 }
164 up_read(&kvm->slots_lock);
165
166 return 0;
167}
168
169int kvm_iommu_unmap_guest(struct kvm *kvm)
170{
171 struct kvm_assigned_dev_kernel *entry;
172 struct dmar_domain *domain = kvm->arch.intel_iommu_domain;
173
174 /* check if iommu exists and in use */
175 if (!domain)
176 return 0;
177
178 list_for_each_entry(entry, &kvm->arch.assigned_dev_head, list) {
179 printk(KERN_DEBUG "VT-d unmap: host bdf = %x:%x:%x\n",
180 entry->host_busnr,
181 PCI_SLOT(entry->host_devfn),
182 PCI_FUNC(entry->host_devfn));
183
184 /* detach kvm dmar domain */
185 intel_iommu_detach_dev(domain, entry->host_busnr,
186 entry->host_devfn);
187 }
188 kvm_iommu_unmap_memslots(kvm);
189 intel_iommu_domain_exit(domain);
190 return 0;
191}